FIX_Implement sub menu for membership

This commit is contained in:
VE10-Sanjeev 2024-11-22 12:19:10 +00:00
parent 9f1c5550df
commit 2590d153b4
7 changed files with 97 additions and 24 deletions

View File

@ -98,6 +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");

View File

@ -571,9 +571,8 @@ class Notifications extends BaseController
################################################################
public function getExpCustomerDetail($window_time = null)
{
// Email flow only Whatsapp flow Deleted.
$this->update_expired_members();
echo "Hi, ";
$response = "<pre> Hi, ";
# Step 1: add the days to retrive the data//
$providedDate = date('Y-m-d');
$newDate = date('Y-m-d', strtotime($providedDate . ' + ' . $window_time . ' days'));
@ -602,12 +601,17 @@ class Notifications extends BaseController
$notification = new NotificationHelper();
if (empty($queryResult)) {
$this->logger->error("There is no customer expiring on date:{$newDate}");
echo " There is no customer expiring. till dated :{$newDate}";
$response .= " There is no customer expiring. till dated :{$newDate}";
return;
}
$emailTemplateName = $NotificationModel->getTempName('EXPIRY NOTIFY TEMPLATE EMAIL');
echo "Started.<br> Customer expiring. till dated = ".date('d-m-Y', strtotime($newDate))." <br> There are ".count($queryResult)." persons <br>";
$response .= "Started.<br> Customer expiring. till dated = ".date('d/m/Y', strtotime($newDate))." <br> There are ".count($queryResult)." persons <br>";
if(!empty($queryResult)){
usort($queryResult, function ($a, $b) {
return $b['to_subscription'] <=> $a['to_subscription']; // Descending order
});
}
foreach ($queryResult as $inx => $row) {
$status = $row['status'];
$userFirstName = $row['first_name'];
@ -623,12 +627,12 @@ class Notifications extends BaseController
$this->logger->error('There is no subcription Name');
continue;
}
echo ($inx+1).") #".$customerId." - Person Name : ".$fullName." ----- ( Expiry on ". date('d-m-Y', strtotime($expirydate)).") <br>";
$response .= ($inx+1).") #".$customerId." - Person Name : ".$fullName." ----- ( Expiry on ". date('d/m/Y', strtotime($expirydate)).") <br>";
if ($status === 'Approved') {
# EXPIRY NOTIFY TEMPLATE EMAIL
$emailTemplateName = $NotificationModel->getTempName('EXPIRY NOTIFY TEMPLATE EMAIL');
if(empty($row['email'])){
echo ($inx+1).") Email Not Available <br>";
$response .= ($inx+1).") Email Not Available <br>";
continue;
}
@ -656,7 +660,7 @@ class Notifications extends BaseController
}
if($check_existing){
echo ($inx+1).") Email already send on - ".date('d-m-Y h:i A', strtotime($check_date))."<br>";
$response .= ($inx+1).") Email already send on - ".date('d/m/Y h:i A', strtotime($check_date))."<br>";
continue;
}
@ -717,7 +721,7 @@ class Notifications extends BaseController
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->error($history_parent_statement);
echo ($inx+1).") ".$history_msg."<br>";
$response .= ($inx+1).") ".$history_msg."<br>";
} else {
$history_msg = (strtolower(gettype($emailResult)) == "string" ? $emailResult : json_encode($emailResult)) ;
$history_child_updatedata = ['receiving_status'=>0,'result'=>$history_msg];
@ -727,18 +731,18 @@ class Notifications extends BaseController
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->error($history_parent_statement);
echo ($inx+1).") Failed to send email <br>";
$response .= ($inx+1).") Failed to send email <br>";
}
} else {
$history_msg = 'There is no email template found by the name of EXPIRY NOTIFY TEMPLATE EMAIL';
// $receiving_status = 0 ;
$this->logger->error($history_msg);
echo $history_msg."<br>";
$response .= $history_msg."<br>";
continue;
}
}
else{
echo ($inx+1).") Staus = ".$status." <br>";
$response .= ($inx+1).") Staus = ".$status." <br>";
$this->logger->error("status is Draft");
}
# EXPIRY NOTIFY TEMPLATE EMAIL Closed
@ -765,7 +769,7 @@ class Notifications extends BaseController
}
}
if($check_existing2){
echo ($inx+1).") whatsapp already send ".$check_date2."<br>";
$response .= ($inx+1).") whatsapp already send ".$check_date2."<br>";
continue;
}
# EXPIRY NOTIFY TEMPLATE WHATSAPP
@ -785,7 +789,7 @@ class Notifications extends BaseController
$history_parent_statement = $NotificationModel->update_notification_history_parent_status(['status' => 1],$history_parent_id,$campaign_id);
$this->logger->error($history_parent_statement);
$this->logger->error($history_msg);
echo ($inx+1).") ".$history_msg."<br>";
$response .= ($inx+1).") ".$history_msg."<br>";
continue;
}
# Insertion on History Whatsapp Means Campaign ID 2 Hardcoded
@ -839,7 +843,7 @@ class Notifications extends BaseController
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Reponse = " . $history_msg);
if(strtolower(gettype($whatsapp_result)) == "string"){
echo ($inx+1).") ".$whatsapp_result."<br>";
$response .= ($inx+1).") ".$whatsapp_result."<br>";
}
else{
$result = json_encode($whatsapp_result['reponse']);
@ -847,18 +851,18 @@ class Notifications extends BaseController
if ($decodedResult && isset($decodedResult['message']['key']['remoteJid'])) {
$remoteJid = $decodedResult['message']['key']['remoteJid'];
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Remote Jid = " . $remoteJid);
echo ($inx+1).") Whatsapp sent successfully <br>";
$response .= ($inx+1).") Whatsapp sent successfully <br>";
} else {
// echo "Failed to extract remoteJid";
$this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Failed to extract remoteJid ");
echo ($inx+1).") Failed to send Whatsapp <br>";
$response .= ($inx+1).") Failed to send Whatsapp <br>";
}
}
} else {
// $receiving_status = 0;
$history_msg = 'There is no Whatsapp template found by the name of EXPIRAY NOTIFY TEMPLATE WHATSAPP ';
$this->logger->error($history_msg);
echo "There is no Whatsapp template <br>";
$response .= "There is no Whatsapp template <br>";
continue;
}
# EXPIRY NOTIFY TEMPLATE WHATSAPP Closed
@ -867,8 +871,10 @@ class Notifications extends BaseController
$this->logger->error("status is draft");
}
# Loop Closed
echo "Process Completed <br>";
}
$response .= "Process Completed <br></pre>";
return $this->response->setBody($response);
}

View File

@ -281,9 +281,10 @@ public function download_details()
}
}
public function notify_the_expiry_subscribers(){
$data['page_name'] = 'Notify the Expiry Subscribers';
$this->render_page('notify_the_expiry_subscribers',$data);
}
}
// public function generate_pdf()

View File

@ -0,0 +1,47 @@
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body"><br>
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
<div class="row">
<div class="col-md-3">
<input type="number" class="form-control" id="params" name="params" placeholder="Number of Days" required />
</div>
<div class="col-md-3">
<button type="button" id="callajax" class="btn btn-primary" onclick="sendsms()">Send Message</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> <!-- end card -->
</div><!-- end col-->
</div><!-- end row-->
<script>
function sendsms(){
var params = $("#params").val();
if(params && params > 0){
$.ajax({
type: "GET",
url: "<?= base_url() . 'getExpCustomerDetail/'?>"+params,
success: function(response) {
$('#target-div').html(response); // Insert raw HTML into the target div
$("#params").val('');
console.log(response);
},
error: function(xhr, status, error) {
console.error("AJAX Error:", error);
}
});
}else{
alert("Invalid Numbers");
$("#params").val('');
}
}
</script>

View File

@ -86,7 +86,7 @@
$message = "Expires in $daysRemaining days";
} else {
$class = 'text-success';
$message = "Expired in $daysRemaining days";
$message = "Expires in $daysRemaining days";
}
?>
<tr>

View File

@ -184,12 +184,30 @@
</li>
<?php endif; ?>
<?php if ($loggedin_person_role !== 'sadmin') : ?>
<li>
<li>
<a href="#subscribersLayouts" data-toggle="collapse">
<i class="ri-shield-user-line"></i>
<span> Members </span>
<span class="menu-arrow"></span>
</a>
<div class="collapse" id="subscribersLayouts">
<ul class="nav-second-level">
<li>
<a href="<?= base_url()."subscribers_list"; ?>">Membership list</a>
</li>
<li>
<a href="<?= base_url()."notify_the_expiry_subscribers"; ?>">Send Expiry message</a>
</li>
</ul>
</div>
</li>
<!-- <li>
<a href="<?= base_url()."subscribers_list"; ?>">
<i class="ri-shield-user-line"></i>
<span>Members </span>
</a>
</li>
</li> -->
<?php endif; ?>
<?php if ($loggedin_person_role !== 'manager' && $loggedin_person_role !== 'sadmin') : ?>
<li>

Binary file not shown.