Notification : ps
This commit is contained in:
parent
a797c3eb6f
commit
3e17f60ed8
@ -151,8 +151,9 @@ $routes->match(['get','post'],'/book_publishwise_Report','Invoice::book_publishw
|
||||
|
||||
$routes->get("getExpCustomerDetail/(:num)",'Notifications::getExpCustomerDetail/$1');
|
||||
$routes->get('send_whatsapp_message/', 'Notifications::send_whatsapp_message');
|
||||
$routes->post('whatsapp_custom_notifications/', 'Notifications::whatsapp_custom_notifications');
|
||||
$routes->match(['post', 'get'], 'mail_custom_notifications', 'Notifications::mail_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'], 'custom_notifications', 'Notifications::custom_notifications');
|
||||
$routes->get('due_date_notifications', 'Notifications::due_date_notifications');
|
||||
$routes->get('template_creation/', 'Notifications::template_creation');
|
||||
$routes->get('template_creation_form/(:any)', 'Notifications::template_creation_form/$1');
|
||||
|
||||
@ -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')) {
|
||||
$records = $this->request->getVar();
|
||||
helper('notification');
|
||||
$notification = new NotificationHelper();
|
||||
$data = $notification->sendEmail($records);
|
||||
$parents_status = 0;
|
||||
$receiving_status = 0;
|
||||
if (isset($data['error'])) {
|
||||
session()->setFlashdata('error', 'Message: ' . $data['error']);
|
||||
$history_msg = $data;
|
||||
}
|
||||
if (isset($data['success'])) {
|
||||
session()->setFlashdata('success', 'Message: ' . $data['success']);
|
||||
$parents_status = 1;
|
||||
$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_parents_data = ['campaign_id' => 0,'status' => $parents_status];
|
||||
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
|
||||
$history_child_data = [ 'fkid' => $history_parent_id,
|
||||
'customer_id' => 0,
|
||||
'receiving_entity' => $records['recipient_email'],
|
||||
'receiving_status' => $receiving_status,
|
||||
'message' => $records['description'],
|
||||
'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)];
|
||||
$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';
|
||||
$this->render_page('notifications_form', $data);
|
||||
}
|
||||
# mail custom notifications closed
|
||||
|
||||
################################################################
|
||||
# Custom Whatsapp Notification
|
||||
################################################################
|
||||
public function whatsapp_custom_notifications()
|
||||
{
|
||||
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['mode'] == 'Email'){
|
||||
helper('notification');
|
||||
$notification = new NotificationHelper();
|
||||
$data = $notification->sendEmail($records);
|
||||
$parents_status = 0;
|
||||
$receiving_status = 0;
|
||||
if (isset($data['error'])) {
|
||||
session()->setFlashdata('error', 'Message: ' . $data['error']);
|
||||
$history_msg = $data;
|
||||
}
|
||||
if (isset($data['success'])) {
|
||||
session()->setFlashdata('success', 'Message: ' . $data['success']);
|
||||
$parents_status = 1;
|
||||
$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_parents_data = ['campaign_id' => 0,'status' => $parents_status];
|
||||
$history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data);
|
||||
$history_child_data = [ 'fkid' => $history_parent_id,
|
||||
'customer_id' => 0,
|
||||
'receiving_entity' => $records['recipient_email'],
|
||||
'receiving_status' => $receiving_status,
|
||||
'message' => $records['description'],
|
||||
'result'=>strtolower(gettype($history_msg)) == "string" ? $history_msg : json_encode($history_msg)];
|
||||
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
|
||||
$this->logger->info('Custom Notifications Email : historychildid = '.$history_child_id);
|
||||
|
||||
}else{
|
||||
$records = $this->request->getVar();
|
||||
$params = (object) Null;
|
||||
$parents_status = 0;
|
||||
$receiving_status = 0;
|
||||
$doc_details = $this->request->getFile('media_doc');
|
||||
$doc_path = APPPATH . '../public/uploads/';
|
||||
$doc_name = '';
|
||||
$this->logger->info("Whatsapp : sending message instance id = " . $_ENV['WAAI_INSTANCE'] . " - " . $_ENV['WAAI_TOKEN']);
|
||||
try {
|
||||
if ($records['categories'] == 'SEND_WAAI_GROUP_URL') {
|
||||
if ($records['group_id'] != "") {
|
||||
$params->group_id = $records['group_id'];
|
||||
@ -75,6 +67,7 @@ class Notifications extends BaseController
|
||||
} else if ($records['categories'] == 'SEND_WAAI_URL') {
|
||||
if ($records['mobile'] != "") {
|
||||
$params->number = (int)'91' . $records['mobile'];
|
||||
|
||||
} else {
|
||||
throw new \Exception("Mobile Number Missing Please Try again..");
|
||||
}
|
||||
@ -84,13 +77,35 @@ class Notifications extends BaseController
|
||||
if ($records['type'] == 'media') {
|
||||
if ($records['media_url'] != "") {
|
||||
$params->media_url = $records['media_url'];
|
||||
$params->type = "media";
|
||||
} else {
|
||||
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']);
|
||||
$params->type = $records['type'] == "" ? "text" : $records['type'];
|
||||
$params->instance_id = $_ENV['WAAI_INSTANCE'];
|
||||
$params->access_token = $_ENV['WAAI_TOKEN'];
|
||||
$params->message = strip_tags(ltrim($records['description']));
|
||||
@ -120,14 +135,14 @@ class Notifications extends BaseController
|
||||
'message' => $records['description'],
|
||||
'result'=>$history_msg];
|
||||
$history_child_id = $NotificationModel->save_notification_history_child($history_child_data);
|
||||
$this->logger->info('Custom Notifications Whatsapp : historychildid = '.$history_child_id);
|
||||
}
|
||||
}
|
||||
$records = [];
|
||||
$data['page_name'] = 'Custom Notifications';
|
||||
$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()
|
||||
{
|
||||
$date = $this->request->getGet('date');
|
||||
|
||||
@ -129,9 +129,7 @@ class NotificationHelper
|
||||
|
||||
if ($result->status === "success") {
|
||||
$final_result['message'] = isset($result->message) ? (
|
||||
(strtolower(gettype($result->message)) === 'string') ?
|
||||
$result->message : "Sended Success"
|
||||
) : " Message Not Sent. ";
|
||||
(strtolower(gettype($result->message)) === 'string') ? $result->message : "Sent Success") : " Not Sent.";
|
||||
$final_result['receiving_status'] = isset($result->message) ? ((strtolower(gettype($result->message)) === 'string') ? 0 : 1 ) : 0 ;
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -1,342 +1,300 @@
|
||||
<style>
|
||||
/* Show the form section by default */
|
||||
#mailFormDiv { display: none; }
|
||||
#whatsappFormDiv { display: none; }
|
||||
img {
|
||||
max-width: 20px; /* Adjust as needed */
|
||||
max-height: 20px; /* Adjust as needed */
|
||||
}
|
||||
#mailSection { display: none; }
|
||||
#whatsappSection { display: none; }
|
||||
#buttonSection { display: none; }
|
||||
|
||||
</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="col-12">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
</br>
|
||||
<div class="row">
|
||||
<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')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php unset($_SESSION['success']);unset($_SESSION['error']); endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php unset($_SESSION['success']);unset($_SESSION['error']); endif; ?>
|
||||
<?php
|
||||
unset($_SESSION['success']);unset($_SESSION['error']);
|
||||
endif; ?>
|
||||
<?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||
<?= session('success') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if (session()->getFlashdata('error')) : ?>
|
||||
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||
<?= session('error') ?>
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<br>
|
||||
<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">
|
||||
<span class="widget-simple text-center">
|
||||
<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>
|
||||
</span>
|
||||
</div>
|
||||
<!-- <div id="textDiv">
|
||||
<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">×</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">×</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 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>
|
||||
const textDiv = document.getElementById('textDiv');
|
||||
|
||||
const showMailLink = document.getElementById('showMailLink');
|
||||
const mailFormDiv = document.getElementById('mailFormDiv');
|
||||
|
||||
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;
|
||||
const mailSection = document.getElementById('mailSection');
|
||||
const whatsappSection = document.getElementById('whatsappSection');
|
||||
const buttonSection = document.getElementById('buttonSection');
|
||||
|
||||
if (selectedCategories === "SEND_WAAI_GROUP_URL") {
|
||||
fieldsForGroupID.style.display = "block";
|
||||
fieldsForMobile.style.display = "none";
|
||||
|
||||
function get_notify_mode(option) {
|
||||
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 = "";
|
||||
} else if (selectedCategories === "SEND_WAAI_URL") {
|
||||
fieldsForMobile.style.display = "block";
|
||||
fieldsForGroupID.style.display = "none";
|
||||
document.getElementById("group_id").value = "";
|
||||
|
||||
document.getElementById("message").required = false;
|
||||
document.getElementById("message").value="";
|
||||
|
||||
document.getElementById("recipient").required = true;
|
||||
document.getElementById("subject").required = true;
|
||||
|
||||
document.getElementById("summernote-basic").required = true;
|
||||
|
||||
|
||||
} else {
|
||||
fieldsForMobile.style.display = "none";
|
||||
fieldsForGroupID.style.display = "none";
|
||||
document.getElementById("mobile").value = "";
|
||||
document.getElementById("group_id").value = "";
|
||||
whatsappSection.style.display = 'block';
|
||||
mailSection.style.display = 'none';
|
||||
textDiv.style.display = 'none';
|
||||
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>
|
||||
document.getElementById('myForm1').addEventListener('submit', function(event) {
|
||||
var form = event.target;
|
||||
|
||||
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 rich text field element
|
||||
var summernote = document.getElementById("summernote-basic");
|
||||
|
||||
// Get the mobile input value
|
||||
var mobileInput = document.getElementById('mobile');
|
||||
var mobileValue = mobileInput.value;
|
||||
// Add an event listener for the input event
|
||||
summernote.addEventListener("input", function() {
|
||||
// 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
|
||||
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
|
||||
$('#submitBtn2').prop('disabled', false);
|
||||
} else {
|
||||
// alert("if-else");
|
||||
$('#submitBtn2').prop('disabled', true);
|
||||
}
|
||||
}else{
|
||||
// alert("else");
|
||||
$('#submitBtn2').prop('disabled', true);
|
||||
}
|
||||
});
|
||||
// Define your onchange function
|
||||
function yourOnChangeFunction() {
|
||||
// Your logic here
|
||||
console.log("Rich text field content changed!");
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
function validateEmail(email) {
|
||||
@ -356,6 +314,45 @@ radioMediaType.addEventListener("change", function () {
|
||||
}
|
||||
}
|
||||
</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>
|
||||
function restrictNonNumeric(event) {
|
||||
var keyCode = event.which ? event.which : event.keyCode;
|
||||
@ -380,4 +377,16 @@ radioMediaType.addEventListener("change", function () {
|
||||
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>
|
||||
@ -253,8 +253,8 @@
|
||||
<a href="<?= base_url()."template_creation"; ?>">Templates</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."customer_group"; ?>">Customer Group</a>
|
||||
</li>
|
||||
<a href="<?= base_url()."customer_group"; ?>">Customer Group</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."campaign_creation"; ?>">Campaign</a>
|
||||
</li>
|
||||
@ -262,7 +262,7 @@
|
||||
<a href="<?= base_url()."acknowlegdement"; ?>">Campaign Status</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url()."mail_custom_notifications"; ?>">Ad-hoc Messages</a>
|
||||
<a href="<?= base_url()."custom_notifications"; ?>">Ad-hoc Messages</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user