FEAT_FILTER ADDED IN SEND EXPIRY MESSAGE

This commit is contained in:
Srinivas-Saravanan 2024-12-04 12:05:10 +05:30
parent 3038e19ca6
commit 7027d8bdbf
8 changed files with 125 additions and 21 deletions

View File

@ -98,7 +98,7 @@ $routes->get("subscribers_list/", "Subscription::index");
$routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1");
$routes->post("add_subscription/", "Subscription::add_subscription/");
$routes->post('subscription/download_details', 'Subscription::download_details');
$routes->get("notify_the_expiry_subscribers/", "Subscription::notify_the_expiry_subscribers");
$routes->match(['get','post'],"notify_the_expiry_subscribers/", "Subscription::notify_the_expiry_subscribers");

View File

@ -666,7 +666,7 @@ class Customer extends BaseController
$result = $model->storeCustomerAddresses($billingData, $shippingData);
if (!empty($result['billing_addr_id']) && !empty($result['shipping_addr_id'])) {
$results = ['status' => true, 'message' => 'New addresses saved successfully', 'cus_id' =>$this->request->getPost('customer_id'),"billing_addr_id"=>$result['billing_addr_id'],"shipping_addr_id"=>$result['shipping_addr_id']];
$results = ['status' => true, 'message' => 'New Address Saved Successfully', 'cus_id' =>$this->request->getPost('customer_id'),"billing_addr_id"=>$result['billing_addr_id'],"shipping_addr_id"=>$result['shipping_addr_id']];
} else {
$results = ['status' => false, 'message' => 'Failed to save New addresses'];
}

View File

@ -7,6 +7,7 @@ use App\Models\CustomerModel;
use App\Models\SubscriptionModel;
use App\Models\SchemeModel;
use App\Models\InvoiceModel;
use App\Models\NotificationModel;
use Mpdf\Mpdf;
class Subscription extends BaseController
@ -298,7 +299,20 @@ public function download_details()
}
public function notify_the_expiry_subscribers(){
if ($this->request->is('post')){
$dateParts = explode(' - ', $this->request->getPost('date'));
$fromDate = $dateParts[0];
$toDate = $dateParts[1];
$from_date = \DateTime::createFromFormat('d/m/Y', $fromDate);
$to_date = \DateTime::createFromFormat('d/m/Y', $toDate);
$model = new NotificationModel();
$response['data'] = $model->get_email_data($from_date->format('Y-m-d'), $to_date->format('Y-m-d'));
// log_message('info','Selected from date is '.$from_date);
$response['selected_data'] = $this->request->getPost('date');
return $this->response->setJson($response);
}
$data['page_name'] = 'Notify the Expiry Subscribers';
$data['selected_data'] = '';
$this->render_page('notify_the_expiry_subscribers',$data);
}

View File

@ -347,6 +347,24 @@ public function getExpDate2(){
->where('nhc.receiving_status = ',1)
->get()->getResultArray();
}
public function get_email_data($f_date = null , $t_date = null){
$builder = $this->db->table('notification_history_parents as nhp');
$builder->select('nhp.*, nhc.*, nc.*,C.first_name,C.last_name,C.email, S.sub_id,S.membership_id, DATEDIFF(S.to_subscription, CURDATE()) AS countdays');
$builder->join('notification_history_children as nhc', 'nhc.fkid = nhp.id');
$builder->join('notification_campaign as nc', 'nc.campaign_id = nhp.campaign_id');
$builder->join('customers as C', 'C.customer_id = nhc.customer_id');
$builder->join('subscription as S', 'S.sub_id = nhc.subscription_id');
$builder->where('nhp.start_date_time >=', $f_date);
$builder->where('nhp.start_date_time <=', $t_date);
$builder->whereIn('nhp.campaign_id', [1, 2]);
$builder->where('nc.isactive', 1);
$query = $builder->get();
$results = $query->getResult();
log_message('info',json_encode($results));
return $results;
}
}

View File

@ -381,6 +381,7 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
}

View File

@ -847,7 +847,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
<div class="col-md-4">
<div class="form-group">
<label for="quick_billing_country"> Country</label>
<label for="quick_billing_country"> Country<span class="text-danger"> *</span></label>
<select class="form-control" id="quick_billing_country">
<option value="">Select Country</option>
</select>
@ -889,7 +889,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
<div class="col-md-4">
<div class="form-group">
<label for="quick_shipping_country"> Country</label>
<label for="quick_shipping_country"> Country<span class="text-danger"> *</span></label>
<select class="form-control" id="quick_shipping_country">
<option value="">Select Country</option>
</select>
@ -1401,6 +1401,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
$("#editAddressesCheckbox").on("change", function() {
if ($(this).is(":checked")) {
$('#quick_shipping_country').attr('required',true);
// $("#storeBillingAddress").prop("readonly", false);
$("#storeBillingAddress").prop("readonly", true);
@ -1512,7 +1513,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
console.log("cFAFAFAbbb",cb);
$.each(cb, function(k, v) {
var state = v.state_name ? v.state_name : v.state;
state = v.postal_code ? state + v.postal_code : state;
state = v.postal_code ? state +' ' + v.postal_code : state;
v.address_1 ? customer_billing_addressDetails.push(v.address_1 + " " + v.address_2) : "";
v.city ? customer_billing_addressDetails.push(v.city) : "";
state ? customer_billing_addressDetails.push(state) : "";
@ -1582,7 +1583,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
if (cs.length > 0) {
$.each(cs, function(k, v) {
var state = v.state_name ? v.state_name : v.state;
state = v.postal_code ? state + v.postal_code : state;
state = v.postal_code ? state + ' ' + v.postal_code : state;
v.address_1 ? customer_shipping_addressDetails.push(v.address_1 + " " + v.address_2) : "";
v.city ? customer_shipping_addressDetails.push(v.city) : "";
state ? customer_shipping_addressDetails.push(state) : "";
@ -2032,7 +2033,8 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
const formattedShippingAddress = [
saddress1 + " " + (saddress2 || ""),
scity,
(sstate ? sstate + szip : ""),
(sstate ? sstate : ""),
szip,
scountry
]
.filter(Boolean)

View File

@ -8,27 +8,54 @@
<input type="number" class="form-control" id="params" name="params" placeholder="Number of Days" required />
</div>
<div class="col-md-3"><?php $selected_data = '';?>
<input id = 'date_picker' class="form-control input-daterange-datepicker" type="text" name="date" value="<?php echo $selected_data; ?>" />
</div>
<div class="col-md-3">
<button type="button" id="callajax" class="btn btn-primary" onclick="sendsms()">Send Message</button>
</div>
<div class="col-md-4">
<input id = 'date_picker' class="form-control input-daterange-datepicker" type="text" name="date" value="<?php echo $selected_data; ?>" />
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary" onclick="generateData()">Generate Report</button>
</div>
</div>
<div class="row">
<br>
<div class="col-md-12" style="margin: 15px;" id="target-div"></div>
</div>
</div> <!-- end card body-->
<div id="modal_table">
<div class="table-responsive">
<table id="datatable-buttons" class="table table-striped nowrap w-100">
<thead>
<tr>
<th hidden>id</th>
<th>Customer Name</th>
<th>Sent Date</th>
<th>Membership ID</th>
<th>Email/Mobile</th>
<th>Mode</th>
<th>Status</th>
</tr>
</thead>
<tbody id="table-body">
</tbody>
</table>
</div></div></div></div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div><!-- end row-->
</div><!-- end col--><!-- end row-->
<script>
$(document).ready(function() {
$(document).ready(function() {
var $select_data = '<?php echo $selected_data; ?>';
$('#modal_table').hide();
$('#datatable-buttons').DataTable({
"dom": 'frtip',
"ordering": false,
"paging": true,
"searching": true,
"autoWidth":true
});
var $select_data = '<?php echo $selected_data; ?>';
var dateRangeFilter = $('input.input-daterange-datepicker').daterangepicker({
locale: {
format: 'DD/MM/YYYY',
@ -49,8 +76,6 @@
$(this).val('');
});
});
});
</script>
<script>
@ -93,5 +118,49 @@
}
}
function generateData(){
var date = $("#date_picker").val();
console.log(date);
$.ajax({
type: 'POST',
url: '<?= base_url('notify_the_expiry_subscribers') ?>',
data: {
date: date
},
success: function(response){
console.log(response);
var data = response.data;
var table = $('#datatable-buttons').DataTable();
var tableBody = $('#table-body');
table.clear();
tableBody.empty();
if (data && data.length > 0) {
data.forEach(function(item) {
var status = (item.receiving_status == 1) ? 'Success' : 'Fail';
table.row.add([
item.first_name + ' ' + item.last_name,
item.sent_time,
item.membership_id,
item.receiving_entity,
item.mode,
status
]);
});
table.draw();
$('#modal_table').show();
// table.draw();
} else {
tableBody.append('<tr><td colspan="6" class="text-center">No data available</td></tr>');
table.draw();
$('#modal_table').show();
}
},
error: function(xhr, status, error){
console.error("Ajax Error: ", error);
}
});
}
</script>

View File

@ -78,19 +78,19 @@
<div class="modal-body">
<!-- Add checkboxes for each column -->
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input column-toggle" data-column="1" checked> Book Name
<input type="checkbox" class="form-check-input column-toggle" data-column="1" checked> Invoice Date
</div><br>
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input column-toggle" data-column="2" checked> Author
<input type="checkbox" class="form-check-input column-toggle" data-column="2" checked> Book Name
</div><br>
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input column-toggle" data-column="3" checked> Cost
<input type="checkbox" class="form-check-input column-toggle" data-column="3" checked> Author
</div><br>
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input column-toggle" data-column="4" checked> Published By
</div><br>
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input column-toggle" data-column="5" checked> Inv Date
<input type="checkbox" class="form-check-input column-toggle" data-column="5" checked> Cost
</div><br>