FEATURE DATE RANGE FILTER ADDED IN EMAIL
This commit is contained in:
parent
32a66b2069
commit
3038e19ca6
@ -157,8 +157,9 @@ $routes->match(['get','post'],'/itemwise_report_with_payment_method','Invoice::i
|
||||
|
||||
# Notifications Routes
|
||||
// $routes->get('controller/SubExpdetail/(:num)', 'YourController::SubExpdetail/$1');
|
||||
|
||||
$routes->get("getExpCustomerDetail",'Notifications::getExpCustomerDetail/');
|
||||
$routes->get("getExpCustomerDetail/(:any)",'Notifications::getExpCustomerDetail/$1');
|
||||
$routes->get("getExpCustomerDetail/(:any)/(:any)",'Notifications::getExpCustomerDetail/$1/$2');
|
||||
$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');
|
||||
|
||||
@ -200,7 +200,7 @@ class Event extends BaseController
|
||||
$update_result = $EventModel->updateData('events', $data, $where);
|
||||
|
||||
if ($update_result['info']) {
|
||||
$response = "Event set as Default";
|
||||
$response = "You have set this event as the Default";
|
||||
$this->logger->info($update_result['info']);
|
||||
} else {
|
||||
$response = $update_result['err'];
|
||||
|
||||
@ -1435,7 +1435,7 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
|
||||
$response = array();
|
||||
if ($bookId) {
|
||||
$response['success'] = true;
|
||||
$response['message'] = 'Book saved successfully.';
|
||||
$response['message'] = 'Book Added Successfully';
|
||||
$response['book_id'] = $bookId; // Include the book ID in the response
|
||||
$response['title'] = $bookName;
|
||||
// $response['tax'] = $bookId;
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Controllers;
|
||||
use App\Helpers\NotificationHelper;
|
||||
use App\Models\NotificationModel;
|
||||
use App\Models\SubscriptionModel;
|
||||
use DateTime;
|
||||
|
||||
class Notifications extends BaseController
|
||||
{
|
||||
@ -569,37 +570,59 @@ class Notifications extends BaseController
|
||||
################################################################
|
||||
# Expiry Notification ReferWith : Hema
|
||||
################################################################
|
||||
public function getExpCustomerDetail($window_time = null)
|
||||
public function getExpCustomerDetail($window_time = null,$to_time = null)
|
||||
{
|
||||
$NotificationModel = new NotificationModel();
|
||||
$this->update_expired_members();
|
||||
$response ="<pre>";// $response = "<pre> Hi, Started. <br>";
|
||||
# Step 1: add the days to retrive the data//
|
||||
$providedDate = date('Y-m-d');
|
||||
if($window_time >= 0){
|
||||
$newDate = date('Y-m-d', strtotime("$providedDate + $window_time days"));
|
||||
$window_time = $this->request->getGet('params');
|
||||
if ($window_time!= ''){
|
||||
if($window_time >= 0){
|
||||
$newDate = date('Y-m-d', strtotime("$providedDate + $window_time days"));
|
||||
}else{
|
||||
$newDate = date('Y-m-d', strtotime("$providedDate $window_time days"));
|
||||
}
|
||||
$ExpCustomerDetail = $NotificationModel->getExpDate(); // Retrieve the stored query
|
||||
|
||||
}else{
|
||||
$newDate = date('Y-m-d', strtotime("$providedDate $window_time days"));
|
||||
$dateData = $this->request->getGet('to_date');
|
||||
$newDate = date('Y-m-d',strtotime($dateData));
|
||||
$ExpCustomerDetail = $NotificationModel->getExpDate2();
|
||||
}
|
||||
|
||||
|
||||
# Step 2 :Get the customer detail//
|
||||
$NotificationModel = new NotificationModel();
|
||||
$ExpCustomerDetail = $NotificationModel->getExpDate(); // Retrieve the stored query
|
||||
|
||||
|
||||
if (empty($ExpCustomerDetail)) {
|
||||
$this->logger->error('No customer group found by the name of EXPIRYDATE');
|
||||
return;
|
||||
}
|
||||
if($window_time != ''){
|
||||
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
|
||||
//print_r($modifiedQuery);die;
|
||||
|
||||
|
||||
# Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
|
||||
$modifiedQuery = str_replace('WINDOW_TIME', $window_time, $ExpCustomerDetail);
|
||||
// print_r($modifiedQuery);die;
|
||||
}
|
||||
else{
|
||||
$from_date2 = $this->request->getGet('from_date');
|
||||
$to_date2 = $this->request->getGet('to_date');
|
||||
$from_date = DateTime::createFromFormat('d/m/Y', $from_date2)->format('Y-m-d');
|
||||
$to_date = DateTime::createFromFormat('d/m/Y', $to_date2)->format('Y-m-d');
|
||||
// Add single quotes around the date values during the replacement
|
||||
$modifiedQuery = str_replace('FROM_DATE', "'$from_date'", $ExpCustomerDetail);
|
||||
$modifiedQuery = str_replace('TO_DATE', "'$to_date'", $modifiedQuery);
|
||||
|
||||
}
|
||||
if (empty($modifiedQuery)) {
|
||||
$this->logger->error('There is no sub query');
|
||||
return;
|
||||
}
|
||||
# Step 3: Replace the placeholder WINDOW_TIME with the user-provided value
|
||||
$db = \Config\Database::connect();
|
||||
$queryResult = $db->query($modifiedQuery)->getResultArray();
|
||||
|
||||
$notification = new NotificationHelper();
|
||||
if (empty($queryResult)) {
|
||||
$this->logger->error("There is no customer expiring on date:{$newDate}");
|
||||
@ -615,7 +638,6 @@ class Notifications extends BaseController
|
||||
return $a['to_subscription'] <=> $b['to_subscription']; //Asc order
|
||||
});
|
||||
}
|
||||
|
||||
foreach ($queryResult as $inx => $row) {
|
||||
$subscription_id = $row['sub_id'];
|
||||
$status = $row['status'];
|
||||
@ -822,6 +844,7 @@ class Notifications extends BaseController
|
||||
->update();
|
||||
log_message('error','inside the update function');
|
||||
}
|
||||
|
||||
# getExpCustomerDetail fns Closed
|
||||
|
||||
################################################################
|
||||
|
||||
@ -177,6 +177,24 @@ public function customerGroupQueryExecution($queries){
|
||||
}
|
||||
}
|
||||
|
||||
public function getExpDate2(){
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$query = "SELECT * FROM customer_groups WHERE group_name = 'EXPIRYDATE_2' AND isactive = 1";
|
||||
|
||||
$result = $db->query($query)->getResultArray();
|
||||
|
||||
if (isset($result[0]["group_query"])) {
|
||||
return $result[0]["group_query"];
|
||||
} else {
|
||||
|
||||
error_log('group_query is not available in getExpDate()');
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function getTempName($name)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
@ -2122,7 +2122,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
|
||||
isValid = false;
|
||||
}
|
||||
if (Quickadd_publishersCode === '') {
|
||||
errorMessage += 'Book Publishers Code\n';
|
||||
errorMessage += 'Publisher Code\n';
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,9 @@
|
||||
<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>
|
||||
@ -21,15 +24,62 @@
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div><!-- end row-->
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
var $select_data = '<?php echo $selected_data; ?>';
|
||||
var dateRangeFilter = $('input.input-daterange-datepicker').daterangepicker({
|
||||
locale: {
|
||||
format: 'DD/MM/YYYY',
|
||||
cancelLabel: 'Clear'
|
||||
},
|
||||
startDate: $select_data ? moment($select_data.split(' - ')[0], 'DD/MM/YYYY') : moment(),
|
||||
endDate: $select_data ? moment($select_data.split(' - ')[1], 'DD/MM/YYYY') : moment(),
|
||||
ranges: {
|
||||
'Today': [moment(), moment()],
|
||||
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
'This Month': [moment().startOf('month'), moment().endOf('month')]
|
||||
}
|
||||
})
|
||||
.on('apply.daterangepicker', function(ev, picker) {
|
||||
console.log(`Selected: ${picker.startDate.format('DD/MM/YYYY')} - ${picker.endDate.format('DD/MM/YYYY')}`);
|
||||
})
|
||||
.on('cancel.daterangepicker', function() {
|
||||
$(this).val('');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
function sendsms(){
|
||||
var params = $("#params").val();
|
||||
|
||||
if(params){
|
||||
var params2 = $("#date_picker").val();
|
||||
console.log("The param passed is "+params2);
|
||||
if(params2){
|
||||
var dates = params2.split(" - ");
|
||||
var from_date = dates[0];
|
||||
var to_date = dates[1];
|
||||
}
|
||||
if (!params && !(params2)) {
|
||||
alert("Enter a valid number of days.");
|
||||
return;
|
||||
}else{
|
||||
console.log("param 1 is "+params);
|
||||
console.log("params 2 is "+ params2);
|
||||
console.log('<?= base_url() . 'getExpCustomerDetail/' ?>');
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "<?= base_url() . 'getExpCustomerDetail/'?>"+params,
|
||||
success: function(response) {
|
||||
url: `<?= base_url() . 'getExpCustomerDetail/' ?>${params}/${params2}`,
|
||||
data: {
|
||||
from_date : from_date,
|
||||
to_date : to_date,
|
||||
params : params
|
||||
|
||||
},
|
||||
success: function(response) {
|
||||
$('#target-div').html(response); // Insert raw HTML into the target div
|
||||
$("#params").val('');
|
||||
console.log(response);
|
||||
@ -41,9 +91,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
alert("Invalid Numbers");
|
||||
$("#params").val('');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</script>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
text-align: center; /* Center-align content */
|
||||
border: none; /* No border for container */
|
||||
background-color: transparent; /* Transparent container */
|
||||
width: 190px; /* Card width */
|
||||
width: 160px; /* Card width */
|
||||
height: 50px; /* Card height */
|
||||
padding-left: 20px;
|
||||
|
||||
@ -72,7 +72,8 @@
|
||||
<ul class="nav">
|
||||
<?php foreach ($payment_data['result2'] as $key => $amount) {
|
||||
if ($key != '' && $key != null) {
|
||||
$displayKey = str_ireplace('banktransfer', 'BANK TRANSFER', strtoupper($key));?>
|
||||
$displayKey2 = str_ireplace('banktransfer', 'BANK TRANSFER', strtoupper($key));
|
||||
$displayKey = str_ireplace("Cash on delivery",'COD',strtoupper($displayKey2));?>
|
||||
<li>
|
||||
<div class="card-summary">
|
||||
<button id = 'payment_method_button' class="payment-button" style="font-weight: 401;">
|
||||
@ -170,9 +171,13 @@
|
||||
|
||||
$(document).on('click', '.payment-button', function () {
|
||||
var paymentMethod = $(this).contents().first().text().trim().toUpperCase().split(" ").join("");
|
||||
console.log(paymentMethod);
|
||||
if (!paymentMethod) {
|
||||
return;
|
||||
}
|
||||
if(paymentMethod === 'COD'){
|
||||
paymentMethod = 'Cash on delivery';
|
||||
}
|
||||
table.column(3)
|
||||
.search(paymentMethod, true, false)
|
||||
.draw();
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<!-- Form Section -->
|
||||
<div class="col-md-5 offset-md-3">
|
||||
<form action="<?php echo base_url('expired_customer_report'); ?>" method="post">
|
||||
<form action="<?php echo base_url('general_inv_rp'); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<!-- Form Section -->
|
||||
<div class="col-md-5 offset-md-3">
|
||||
<form action="<?php echo base_url('expired_customer_report'); ?>" method="post">
|
||||
<form action="<?php echo base_url('report_userwise_and_eventwise'); ?>" method="post">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user