Notification : ps

This commit is contained in:
VE10-Sanjeev 2024-04-10 10:34:25 +00:00
parent a797c3eb6f
commit 3e17f60ed8
5 changed files with 398 additions and 375 deletions

View File

@ -151,8 +151,9 @@ $routes->match(['get','post'],'/book_publishwise_Report','Invoice::book_publishw
$routes->get("getExpCustomerDetail/(:num)",'Notifications::getExpCustomerDetail/$1'); $routes->get("getExpCustomerDetail/(:num)",'Notifications::getExpCustomerDetail/$1');
$routes->get('send_whatsapp_message/', 'Notifications::send_whatsapp_message'); $routes->get('send_whatsapp_message/', 'Notifications::send_whatsapp_message');
$routes->post('whatsapp_custom_notifications/', 'Notifications::whatsapp_custom_notifications'); // $routes->post('whatsapp_custom_notifications/', 'Notifications::whatsapp_custom_notifications');
$routes->match(['post', 'get'], 'mail_custom_notifications', 'Notifications::mail_custom_notifications'); // $routes->match(['post', 'get'], 'mail_custom_notifications', 'Notifications::mail_custom_notifications');
$routes->match(['post', 'get'], 'custom_notifications', 'Notifications::custom_notifications');
$routes->get('due_date_notifications', 'Notifications::due_date_notifications'); $routes->get('due_date_notifications', 'Notifications::due_date_notifications');
$routes->get('template_creation/', 'Notifications::template_creation'); $routes->get('template_creation/', 'Notifications::template_creation');
$routes->get('template_creation_form/(:any)', 'Notifications::template_creation_form/$1'); $routes->get('template_creation_form/(:any)', 'Notifications::template_creation_form/$1');

View File

@ -9,58 +9,50 @@ class Notifications extends BaseController
{ {
################################################################ ################################################################
# Custom Email Notification # Custom Notification
################################################################ ################################################################
public function mail_custom_notifications() public function custom_notifications(){
{
if ($this->request->is('post')) { if ($this->request->is('post')) {
$records = $this->request->getVar(); $records = $this->request->getVar();
helper('notification'); if($records['mode'] == 'Email'){
$notification = new NotificationHelper(); helper('notification');
$data = $notification->sendEmail($records); $notification = new NotificationHelper();
$parents_status = 0; $data = $notification->sendEmail($records);
$receiving_status = 0; $parents_status = 0;
if (isset($data['error'])) { $receiving_status = 0;
session()->setFlashdata('error', 'Message: ' . $data['error']); if (isset($data['error'])) {
$history_msg = $data; session()->setFlashdata('error', 'Message: ' . $data['error']);
} $history_msg = $data;
if (isset($data['success'])) { }
session()->setFlashdata('success', 'Message: ' . $data['success']); if (isset($data['success'])) {
$parents_status = 1; session()->setFlashdata('success', 'Message: ' . $data['success']);
$receiving_status = 1; $parents_status = 1;
$history_msg = 'Email sent successfully'; $receiving_status = 1;
} $history_msg = 'Email sent successfully';
$history_msg = (strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)) ; }
$NotificationModel = new NotificationModel(); $history_msg = (strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)) ;
$history_parents_data = ['campaign_id' => 0,'status' => $parents_status]; $NotificationModel = new NotificationModel();
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data); $history_parents_data = ['campaign_id' => 0,'status' => $parents_status];
$history_child_data = [ 'fkid' => $history_parent_id, $history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
'customer_id' => 0, $history_child_data = [ 'fkid' => $history_parent_id,
'receiving_entity' => $records['recipient_email'], 'customer_id' => 0,
'receiving_status' => $receiving_status, 'receiving_entity' => $records['recipient_email'],
'message' => $records['description'], 'receiving_status' => $receiving_status,
'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)]; 'message' => $records['description'],
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data); 'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)];
$this->logger->info('Custom Notifications Email : historychildid = '.$history_child_id); $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
} $this->logger->info('Custom Notifications Email : historychildid = '.$history_child_id);
$records = [];
$data['page_name'] = 'Custom Notifications'; }else{
$this->render_page('notifications_form', $data); $records = $this->request->getVar();
} $params = (object) Null;
# mail custom notifications closed $parents_status = 0;
$receiving_status = 0;
################################################################ $doc_details = $this->request->getFile('media_doc');
# Custom Whatsapp Notification $doc_path = APPPATH . '../public/uploads/';
################################################################ $doc_name = '';
public function whatsapp_custom_notifications() $this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
{ try {
if ($this->request->is('post')) {
$records = $this->request->getVar();
$params = (object) Null;
$parents_status = 0;
$receiving_status = 0;
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
try {
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') { if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
if ($records['group_id'] != "") { if ($records['group_id'] != "") {
$params->group_id = $records['group_id']; $params->group_id = $records['group_id'];
@ -75,6 +67,7 @@ class Notifications extends BaseController
} else if ($records['categories'] == 'SEND_WAAI_URL') { } else if ($records['categories'] == 'SEND_WAAI_URL') {
if ($records['mobile'] != "") { if ($records['mobile'] != "") {
$params->number = (int)'91' . $records['mobile']; $params->number = (int)'91' . $records['mobile'];
} else { } else {
throw new \Exception("Mobile Number Missing Please Try again.."); throw new \Exception("Mobile Number Missing Please Try again..");
} }
@ -84,13 +77,35 @@ class Notifications extends BaseController
if ($records['type'] == 'media') { if ($records['type'] == 'media') {
if ($records['media_url'] != "") { if ($records['media_url'] != "") {
$params->media_url = $records['media_url']; $params->media_url = $records['media_url'];
$params->type = "media";
} else { } else {
throw new \Exception("Media Url Missing Please Try again.."); throw new \Exception("Media Url Missing Please Try again..");
} }
} }
else if ($records['type'] == 'document') {
$doc_name = $doc_details->getName();
if($doc_name == ''){
$this->logger->error("Err on upload name not Founded ".$records['media_doc']);
throw new \Exception("Media Document Missing Please Try again..");
}else{
if ($doc_details->isValid()) {
$doc_details->move($doc_path, $doc_name);
$this->logger->info("Name After Upload".$doc_name);
$params->filename = $doc_name;
$params->media_url = base_url().'public/uploads/'.$doc_name;
$params->type = "media";
}else{
$params->filename = $doc_name;
$params->media_url = base_url().'public/uploads/'.$doc_name;
$params->type = "media";
}
}
}else{
$params->type = "text" ;
}
$url = constant($records['categories']); $url = constant($records['categories']);
$params->type = $records['type'] == "" ? "text" : $records['type'];
$params->instance_id = $_ENV['WAAI_INSTANCE']; $params->instance_id = $_ENV['WAAI_INSTANCE'];
$params->access_token = $_ENV['WAAI_TOKEN']; $params->access_token = $_ENV['WAAI_TOKEN'];
$params->message = strip_tags(ltrim($records['description'])); $params->message = strip_tags(ltrim($records['description']));
@ -120,14 +135,14 @@ class Notifications extends BaseController
'message' => $records['description'], 'message' => $records['description'],
'result'=>$history_msg]; 'result'=>$history_msg];
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data); $history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
$this->logger->info('Custom Notifications Whatsapp : historychildid = '.$history_child_id);
}
} }
$records = []; $records = [];
$data['page_name'] = 'Custom Notifications'; $data['page_name'] = 'Custom Notifications';
$this->render_page('notifications_form', $data); $this->render_page('notifications_form', $data);
$this->logger->info('Custom Notifications Whatsapp : historychildid = '.$history_child_id);
} }
# whatsapp custom notifications closed
public function due_date_notifications() public function due_date_notifications()
{ {
$date = $this->request->getGet('date'); $date = $this->request->getGet('date');

View File

@ -129,9 +129,7 @@ class NotificationHelper
if ($result->status === "success") { if ($result->status === "success") {
$final_result['message'] = isset($result->message) ? ( $final_result['message'] = isset($result->message) ? (
(strtolower(gettype($result->message)) === 'string') ? (strtolower(gettype($result->message)) === 'string') ? $result->message : "Sent Success") : " Not Sent.";
$result->message : "Sended Success"
) : " Message Not Sent. ";
$final_result['receiving_status'] = isset($result->message) ? ((strtolower(gettype($result->message)) === 'string') ? 0 : 1 ) : 0 ; $final_result['receiving_status'] = isset($result->message) ? ((strtolower(gettype($result->message)) === 'string') ? 0 : 1 ) : 0 ;
} }
} else { } else {

View File

@ -1,342 +1,300 @@
<style> <style>
/* Show the form section by default */ /* Show the form section by default */
#mailFormDiv { display: none; } #mailSection { display: none; }
#whatsappFormDiv { display: none; } #whatsappSection { display: none; }
img { #buttonSection { display: none; }
max-width: 20px; /* Adjust as needed */
max-height: 20px; /* Adjust as needed */
}
</style> </style>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col">
<input type="radio" name="notificationType" id="showMailLink" value="mail" >
<label for="mailRadio">
<img src="<?= base_url() . "public/assets/images/brands/gmail.png" ?>" alt="mail">
<span>Mail Custom Notification</span>
</label>
</div>
<div class="col">
<input type="radio" name="notificationType" id="showWhatsappLink" value="whatsapp">
<label for="whatsappRadio">
<img src="<?= base_url() . "public/assets/images/brands/whatsapp.png" ?>" alt="whatsapp">
<span>Whatsapp Custom Notification</span>
</label>
</div>
<!-- <div class="col">
<a class="dropdown-icon-item" href="<?= base_url()."send_whatsapp_message"; ?>">
<img src="<?= base_url() . "public/assets/images/brands/whatsapp.png" ?>" alt="whatsapp">
<span>Whatsapp Static Notification</span>
</a>
</div> -->
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-lg-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
<h4 class="header-title"><?= $page_name; ?></h4> <div class="row">
</br> <div class="col-lg-6">
<h4 class="header-title"><?= $page_name; ?></h4>
</div>
</div>
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?> <?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
<?php if (session()->getFlashdata('success')) : ?> <?php if (session()->getFlashdata('success')) : ?>
<div class="alert alert-success alert-dismissible fade show" role="alert"> <div class="alert alert-success alert-dismissible fade show" role="alert">
<?= session('success') ?> <?= session('success') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> <button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<?php unset($_SESSION['success']);unset($_SESSION['error']); endif; ?> <?php endif; ?>
<?php if (session()->getFlashdata('error')) : ?> <?php if (session()->getFlashdata('error')) : ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert"> <div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= session('error') ?> <?= session('error') ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> <button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<?php unset($_SESSION['success']);unset($_SESSION['error']); endif; ?> <?php endif; ?>
<?php <?php endif; ?>
unset($_SESSION['success']);unset($_SESSION['error']); <br>
endif; ?> <form role="form" class="parsley-examples" method="POST" enctype="multipart/form-data" action="<?= base_url() . "custom_notifications"; ?>" id="notifyCustomForm">
<div class="form-group row">
<label class="col-3 col-form-label" for="mode">Mode</label>
<div class="col-9">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" value="Email" onchange="get_notify_mode(this.value);">
<span class="form-check-label">Mail</span>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="mode" value="Whatsapp" onchange="get_notify_mode(this.value);">
<span class="form-check-label">Whatsapp</span>
</div>
</div>
</div>
<span id="mailSection">
<div class="form-group row">
<label for="recipient" class="col-3 col-form-label" >Recipient Email<span class="text-danger"> *</span></label>
<div class="col-9">
<input type="email" placeholder="Recipient Email" class="form-control" id="recipient" name="recipient_email" parsley-type="email" onkeyup="validateEmail(this.value)">
<span id="emailValidationMessage"></span>
</div>
</div>
<div class="form-group row">
<label for="CC" class="col-3 col-form-label">CC</label>
<div class="col-9">
<input type="text" placeholder="Enter multiple email addresses separated by commas" class="form-control" id="CC" name="carboncopy">
</div>
</div>
<div class="form-group row">
<label for="BCC" class="col-3 col-form-label">BCC</label>
<div class="col-9">
<input type="text" placeholder="Enter multiple email addresses separated by commas" class="form-control" id="BCC" name="blindcarboncopy">
</div>
</div>
<div class="form-group row">
<label for="subject" class="col-3 col-form-label">Subject<span class="text-danger"> *</span></label>
<div class="col-9">
<input type="text" placeholder="Subject" class="form-control" id="subject" name="subject">
</div>
</div>
<div class="form-group row">
<label for="body" class="col-3 col-form-label">Body<span class="text-danger"> *</span></label>
<div class="col-9">
<textarea id="summernote-basic" name="description" class="form-control" rows="7">
<h5>Hello {USER_NAME}, </h5>
<p>We create simple, flat & responsive custom mail template.</p>
<p>Please, write text here!</p>
</textarea>
</div>
</div>
</span>
<span id="whatsappSection">
<!-- <div class="form-group row">
<label for="group_id" class="col-3 col-form-label">Categories</label>
<div class="col-9">
<select class="form-control" id="categories" name="categories">
<option value="">Choose your Category Type</option>
<option value="SEND_WAAI_URL">Individual</option>
<option value="SEND_WAAI_GROUP_URL">Group</option>
</select>
</div>
</div> -->
<input type="hidden" id="categories" name="categories" value="SEND_WAAI_URL" />
<div id="fields-for-groupid" style="display: none;">
<div class="form-group row">
<label for="group_id" class="col-3 col-form-label">Group Id</label>
<div class="col-9">
<input type="text" placeholder="Group ID" class="form-control" id="group_id" name="group_id">
</div>
</div>
</div>
<div id="fields-for-mobile">
<div class="form-group row">
<label for="mobile" class="col-3 col-form-label">Mobile Number<span class="text-danger"> *</span></label>
<div class="col-9">
<!-- <input type="number" placeholder="Mobile Number" class="form-control" id="mobile" name="mobile"> -->
<!-- <input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile Number" data-toggle="input-mask" data-mask-format="0000000000" <input type="text" class="form-control" id="cmobile" name="cmobile" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required maxlength="10" onkeypress="return restriction(event)" /> -->
<!-- <input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile Number" data-toggle="input-mask" data-mask-format="0000000000"> -->
<!-- Modified input with validation -->
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile Number" maxlength="10" onkeypress="return restrictNonNumeric(event)">
<span id="mobileValidationMessage"></span>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-3 col-form-label">Message Type</label>
<div class="col-9">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="text" onchange="change_fields(this.value);" checked>
<span class="form-check-label">Text</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="media" onchange="change_fields(this.value);">
<span class="form-check-label">Media URL</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" value="document" onchange="change_fields(this.value);">
<span class="form-check-label">Document File</label>
</div>
</div>
</div>
<div id="fields-for-mediaurl" style="display: none;">
<div class="form-group row">
<label for="media_url" class="col-3 col-form-label">Media Link</label>
<div class="col-9">
<input type="text" placeholder="Media Link" class="form-control" id="media_url" name="media_url">
</div>
</div>
</div>
<div id="fields-for-doc" style="display: none;">
<div class="form-group row">
<label for="media_doc" class="col-3 col-form-label">Document</label>
<div class="col-9">
<input type="file" id="media_doc" name="media_doc" />
</div>
</div>
</div>
<div class="form-group row">
<label for="message" class="col-3 col-form-label">Message <span class="text-danger"> *</span></label>
<div class="col-9">
<textarea id="message" name="description" class="form-control" rows="5">Message text here</textarea>
</div>
</div>
</span>
<span id="buttonSection">
<div class="form-group text-right m-b-0 ">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="submitBtn">
Send
</button>
</div>
</span>
</form>
<div id="textDiv"> <div id="textDiv">
<span class="widget-simple text-center"> <span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title"> <div class="media-body align-self-center font-24 avatar-title">
<p style="color: #0a0a0a!important;" class="mt-0" style><?= "Please Choose Message Mode....."; ?></p> <!-- <p style="color: #0a0a0a!important;" class="mt-0" style><?= "Please Choose Message Mode....."; ?></p> -->
</div> </div>
</span> </span>
</div> </div>
<!-- <div id="textDiv"> </div>
<span class="widget-simple text-center">
<div class="media-body align-self-center font-24 avatar-title">
<?php if (isset($validationErrors)) { ?>
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<?= $validationErrors ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } elseif (isset($successMessage)) { ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<?= $successMessage ?>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<?php } ?>
<p style="color: #0a0a0a!important;" class="mt-0" style><?= "Please Choose Your Choice....."; ?></p>
</div>
</span>
</div> -->
<div id="mailFormDiv">
<form role="form" class="parsley-examples" method="POST" enctype="multipart/form-data" action="<?= base_url() . "mail_custom_notifications"; ?>" id="myForm1">
<div class="form-group row">
<label for="recipient" class="col-4 col-form-label" >Recipient Email<span class="text-danger"> *</span></label>
<div class="col-7">
<input type="email" placeholder="Recipient Email" class="form-control" id="recipient" name="recipient_email" parsley-type="email" onkeyup="validateEmail(this.value)">
<span id="emailValidationMessage"></span>
</div>
</div>
<div class="form-group row">
<label for="CC" class="col-4 col-form-label">CC</label>
<div class="col-7">
<input type="text" placeholder="Enter multiple email addresses separated by commas" class="form-control" id="CC" name="carboncopy">
</div>
</div>
<div class="form-group row">
<label for="BCC" class="col-4 col-form-label">BCC</label>
<div class="col-7">
<input type="text" placeholder="Enter multiple email addresses separated by commas" class="form-control" id="BCC" name="blindcarboncopy">
</div>
</div>
<div class="form-group row">
<label for="subject" class="col-4 col-form-label">Subject<span class="text-danger"> *</span></label>
<div class="col-7">
<input type="text" placeholder="Subject" class="form-control" id="subject" name="subject">
</div>
</div>
<div class="form-group row">
<label for="body" class="col-4 col-form-label">Body<span class="text-danger"> *</span></label>
<div class="col-7">
<textarea id="summernote-basic" name="description" class="form-control" rows="7">
<h5>Hello {USER_NAME}, </h5>
<p>We create simple, flat & responsive custom mail template.</p>
<p>Please, write text here!</p>
</textarea>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="submitBtn1">
Send
</button>
</div>
</form>
</div>
<div id="whatsappFormDiv">
<form role="form" class="parsley-examples" method="POST" enctype="multipart/form-data" action="<?= base_url() . "whatsapp_custom_notifications"; ?>" id="myForm2">
<!-- <div class="form-group row">
<label for="group_id" class="col-4 col-form-label">Categories</label>
<div class="col-7">
<select class="form-control" id="categories" name="categories">
<option value="">Choose your Category Type</option>
<option value="SEND_WAAI_URL">Individual</option>
<option value="SEND_WAAI_GROUP_URL">Group</option>
</select>
</div>
</div> -->
<input type="hidden" id="categories" name="categories" value="SEND_WAAI_URL" />
<div id="fields-for-groupid" style="display: none;">
<div class="form-group row">
<label for="group_id" class="col-4 col-form-label">Group Id</label>
<div class="col-7">
<input type="text" placeholder="Group ID" class="form-control" id="group_id" name="group_id">
</div>
</div>
</div>
<div id="fields-for-mobile">
<div class="form-group row">
<label for="mobile" class="col-4 col-form-label">Mobile Number<span class="text-danger"> *</span></label>
<div class="col-7">
<!-- <input type="number" placeholder="Mobile Number" class="form-control" id="mobile" name="mobile"> -->
<!-- <input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile Number" data-toggle="input-mask" data-mask-format="0000000000" <input type="text" class="form-control" id="cmobile" name="cmobile" value="<?= isset($customer['mobile_no']) ? $customer['mobile_no'] : '' ?>" placeholder="Mobile Number (Enter only numbers)" required maxlength="10" onkeypress="return restriction(event)" /> -->
<!-- <input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile Number" data-toggle="input-mask" data-mask-format="0000000000"> -->
<!-- Modified input with validation -->
<input type="text" class="form-control" id="mobile" name="mobile" placeholder="Mobile Number" maxlength="10" onkeypress="return restrictNonNumeric(event)">
<span id="mobileValidationMessage"></span>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-4 col-form-label">Message Type</label>
<div class="col-7">
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" id="textType" value="text" checked>
<label class="form-check-label" for="textType">Text</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="type" id="mediaType" value="media">
<label class="form-check-label" for="mediaType">Media</label>
</div> </div>
</div> </div>
</div> </div>
<div id="fields-for-mediaurl" style="display: none;">
<div class="form-group row">
<label for="media_url" class="col-4 col-form-label">Media Link</label>
<div class="col-7">
<input type="text" placeholder="Media Link" class="form-control" id="media_url" name="media_url">
</div>
</div>
</div>
<div class="form-group row">
<label for="message" class="col-4 col-form-label">Message <span class="text-danger"> *</span></label>
<div class="col-7">
<textarea id="message" name="description" class="form-control" rows="5">Message text here</textarea>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="submitBtn2">
Send
</button>
</div>
</form>
</div>
</div> <!-- end card-body-->
</div> <!-- end card-->
</div><!-- end col -->
</div><!-- end row -->
<script> <script>
const textDiv = document.getElementById('textDiv'); const textDiv = document.getElementById('textDiv');
const mailSection = document.getElementById('mailSection');
const showMailLink = document.getElementById('showMailLink'); const whatsappSection = document.getElementById('whatsappSection');
const mailFormDiv = document.getElementById('mailFormDiv'); const buttonSection = document.getElementById('buttonSection');
const showWhatsappLink = document.getElementById('showWhatsappLink');
const whatsappFormDiv = document.getElementById('whatsappFormDiv');
// Add a click event listener to the link
showMailLink.addEventListener('click', function() {
// Toggle the display of the div
// mailFormDiv.style.display = (mailFormDiv.style.display === 'none') ? 'block' : 'none';
mailFormDiv.style.display = 'block';
whatsappFormDiv.style.display = 'none';
textDiv.style.display = 'none';
const elements = document.getElementsByClassName("header-title");
for (let i = 0; i < elements.length; i++) {
elements[i].textContent = "Mail Custom Notification";
}
document.getElementById("recipient").required = true;
document.getElementById("subject").required = true;
document.getElementById("summernote-basic").required = true;
document.getElementById("mobile").required = false;
document.getElementById("message").required = false;
});
// Add a click event listener to the link
showWhatsappLink.addEventListener('click', function() {
// Toggle the display of the div
mailFormDiv.style.display = 'none';
textDiv.style.display = 'none';
// whatsappFormDiv.style.display = (whatsappFormDiv.style.display === 'none') ? 'block' : 'none';
whatsappFormDiv.style.display = 'block';
const elements = document.getElementsByClassName("header-title");
for (let i = 0; i < elements.length; i++) {
elements[i].textContent = "Whatsapp Custom Notification";
}
document.getElementById("recipient").required = false;
document.getElementById("subject").required = false;
document.getElementById("summernote-basic").required = false;
document.getElementById("mobile").required = true;
document.getElementById("message").required = true;
});
// Get references to the dropdown and field divs
const radioTextType = document.getElementById("textType");
const radioMediaType = document.getElementById("mediaType");
const fieldsForMediaURL = document.getElementById("fields-for-mediaurl");
// Add change event listeners to the radio buttons
radioTextType.addEventListener("change", function () {
// If "Text" is selected, hide the media URL field
fieldsForMediaURL.style.display = "none";
document.getElementById("media_url").value = "";
});
radioMediaType.addEventListener("change", function () {
// If "Media" is selected, show the media URL field
fieldsForMediaURL.style.display = "block";
});
const categories = document.getElementById("categories");
const fieldsForGroupID = document.getElementById("fields-for-groupid");
const fieldsForMobile = document.getElementById("fields-for-mobile");
// Add a change event listener to the dropdown
categories.addEventListener("change", function () {
// Determine which option is selected and show the corresponding fields
const selectedCategories = categories.value;
if (selectedCategories === "SEND_WAAI_GROUP_URL") {
fieldsForGroupID.style.display = "block"; function get_notify_mode(option) {
fieldsForMobile.style.display = "none"; if (option == 'Email') {
mailSection.style.display = 'block';
whatsappSection.style.display = 'none';
textDiv.style.display = 'none';
buttonSection.style.display = 'block';
document.getElementById("mobile").required = false;
document.getElementById("mobile").value = ""; document.getElementById("mobile").value = "";
} else if (selectedCategories === "SEND_WAAI_URL") {
fieldsForMobile.style.display = "block"; document.getElementById("message").required = false;
fieldsForGroupID.style.display = "none"; document.getElementById("message").value="";
document.getElementById("group_id").value = "";
document.getElementById("recipient").required = true;
document.getElementById("subject").required = true;
document.getElementById("summernote-basic").required = true;
} else { } else {
fieldsForMobile.style.display = "none"; whatsappSection.style.display = 'block';
fieldsForGroupID.style.display = "none"; mailSection.style.display = 'none';
document.getElementById("mobile").value = ""; textDiv.style.display = 'none';
document.getElementById("group_id").value = ""; buttonSection.style.display = 'block';
// whatsappSection.style.display = (whatsappSection.style.display === 'none') ? 'block' : 'none';
document.getElementById("recipient").required = false;
document.getElementById("subject").required = false;
document.getElementById("mobile").required = true;
document.getElementById("summernote-basic").required = true;
// document.getElementById("summernote-basic").value = "Hello {USER_NAME}, \n" +
// " We create simple, flat & responsive custom mail template\n" +
// " Please, write text here!";
// makeFormEmpty();
} }
}); }
// Get references to the dropdown and field divs
const fieldsForMediaURL = document.getElementById("fields-for-mediaurl");
const fieldsForDoc = document.getElementById("fields-for-doc");
function change_fields(option) {
if (option == 'document'){
fieldsForDoc.style.display = "block";
fieldsForMediaURL.style.display = "none";
document.getElementById("media_url").value = "";
}
if (option == 'media') {
fieldsForDoc.style.display = "none";
fieldsForMediaURL.style.display = "block";
document.getElementById("media_doc").value = "";
}
if (option == 'text') {
fieldsForDoc.style.display = "none";
fieldsForMediaURL.style.display = "none";
document.getElementById("media_url").value = "";
document.getElementById("media_doc").value = "";
}
}
const categories = document.getElementById("categories");
const fieldsForGroupID = document.getElementById("fields-for-groupid");
const fieldsForMobile = document.getElementById("fields-for-mobile");
// Add a change event listener to the dropdown
categories.addEventListener("change", function () {
// Determine which option is selected and show the corresponding fields
const selectedCategories = categories.value;
if (selectedCategories === "SEND_WAAI_GROUP_URL") {
fieldsForGroupID.style.display = "block";
fieldsForMobile.style.display = "none";
document.getElementById("mobile").value = "";
} else if (selectedCategories === "SEND_WAAI_URL") {
fieldsForMobile.style.display = "block";
fieldsForGroupID.style.display = "none";
document.getElementById("group_id").value = "";
} else {
fieldsForMobile.style.display = "none";
fieldsForGroupID.style.display = "none";
document.getElementById("mobile").value = "";
document.getElementById("group_id").value = "";
}
});
</script> </script>
<script> <script>
document.getElementById('myForm1').addEventListener('submit', function(event) { // Get the rich text field element
var form = event.target; var summernote = document.getElementById("summernote-basic");
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn1').prop('disabled', false);
} else {
$('#submitBtn1').prop('disabled', true);
}
});
document.getElementById('myForm2').addEventListener('submit', function(event) {
var form = event.target;
// Get the mobile input value // Add an event listener for the input event
var mobileInput = document.getElementById('mobile'); summernote.addEventListener("input", function() {
var mobileValue = mobileInput.value; // This function will be called whenever the content of the rich text field changes
// You can perform your desired actions here
console.log("Content changed:", summernote.value);
// Call your onchange function here
yourOnChangeFunction();
});
// Check the validity of the mobile number // Define your onchange function
var isMobileValid = /^[0-9]{10}$/.test(mobileValue); function yourOnChangeFunction() {
// alert(isMobileValid); // Your logic here
if (!isMobileValid) { console.log("Rich text field content changed!");
// alert(isMobileValid); }
if (form.checkValidity() === false || !isMobileValid) {
// alert("if-if");
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn2').prop('disabled', false);
} else {
// alert("if-else");
$('#submitBtn2').prop('disabled', true);
}
}else{
// alert("else");
$('#submitBtn2').prop('disabled', true);
}
});
</script> </script>
<script> <script>
function validateEmail(email) { function validateEmail(email) {
@ -356,6 +314,45 @@ radioMediaType.addEventListener("change", function () {
} }
} }
</script> </script>
<script>
document.getElementById('notifyCustomForm').addEventListener('submit', function(event) {
var form = event.target;
var mode = document.getElementById('mode').value;
if(mode == 'Email'){
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
$('#submitBtn').prop('disabled', true);
}
}else{
// Get the mobile input value
var mobileInput = document.getElementById('mobile');
var mobileValue = mobileInput.value;
// Check the validity of the mobile number
var isMobileValid = /^[0-9]{10}$/.test(mobileValue);
// alert(isMobileValid);
if (!isMobileValid) {
// alert(isMobileValid);
if (form.checkValidity() === false || !isMobileValid) {
// alert("if-if");
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
// alert("if-else");
$('#submitBtn').prop('disabled', true);
}
}else{
// alert("else");
$('#submitBtn').prop('disabled', true);
}
}
});
</script>
<script> <script>
function restrictNonNumeric(event) { function restrictNonNumeric(event) {
var keyCode = event.which ? event.which : event.keyCode; var keyCode = event.which ? event.which : event.keyCode;
@ -380,4 +377,16 @@ radioMediaType.addEventListener("change", function () {
validationMessage.style.color = "red"; validationMessage.style.color = "red";
} }
}); });
</script> </script>
<script>
function makeFormEmpty() {
var form = document.getElementById('notifyCustomForm');
var inputs = form.querySelectorAll('input, textarea'); // Include textarea fields as well
inputs.forEach(function(input) {
input.value = ''; // Clear the value of each input field
});
return true; // Form is now empty
}
</script>

View File

@ -253,8 +253,8 @@
<a href="<?= base_url()."template_creation"; ?>">Templates</a> <a href="<?= base_url()."template_creation"; ?>">Templates</a>
</li> </li>
<li> <li>
<a href="<?= base_url()."customer_group"; ?>">Customer Group</a> <a href="<?= base_url()."customer_group"; ?>">Customer Group</a>
</li> </li>
<li> <li>
<a href="<?= base_url()."campaign_creation"; ?>">Campaign</a> <a href="<?= base_url()."campaign_creation"; ?>">Campaign</a>
</li> </li>
@ -262,7 +262,7 @@
<a href="<?= base_url()."acknowlegdement"; ?>">Campaign Status</a> <a href="<?= base_url()."acknowlegdement"; ?>">Campaign Status</a>
</li> </li>
<li> <li>
<a href="<?= base_url()."mail_custom_notifications"; ?>">Ad-hoc Messages</a> <a href="<?= base_url()."custom_notifications"; ?>">Ad-hoc Messages</a>
</li> </li>
</ul> </ul>
</div> </div>