diff --git a/app/Config/Routes.php b/app/Config/Routes.php index cfeef129..ebfe2a84 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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"); diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php index 2fb1c78a..2a0d5184 100755 --- a/app/Controllers/Notifications.php +++ b/app/Controllers/Notifications.php @@ -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 = "
 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.
Customer expiring. till dated = ".date('d-m-Y', strtotime($newDate))."
There are ".count($queryResult)." persons
"; + $response .= "Started.
Customer expiring. till dated = ".date('d/m/Y', strtotime($newDate))."
There are ".count($queryResult)." persons
"; + 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)).")
"; + $response .= ($inx+1).") #".$customerId." - Person Name : ".$fullName." ----- ( Expiry on ". date('d/m/Y', strtotime($expirydate)).")
"; if ($status === 'Approved') { # EXPIRY NOTIFY TEMPLATE EMAIL $emailTemplateName = $NotificationModel->getTempName('EXPIRY NOTIFY TEMPLATE EMAIL'); if(empty($row['email'])){ - echo ($inx+1).") Email Not Available
"; + $response .= ($inx+1).") Email Not Available
"; 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))."
"; + $response .= ($inx+1).") Email already send on - ".date('d/m/Y h:i A', strtotime($check_date))."
"; 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."
"; + $response .= ($inx+1).") ".$history_msg."
"; } 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
"; + $response .= ($inx+1).") Failed to send email
"; } } 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."
"; + $response .= $history_msg."
"; continue; } } else{ - echo ($inx+1).") Staus = ".$status."
"; + $response .= ($inx+1).") Staus = ".$status."
"; $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."
"; + $response .= ($inx+1).") whatsapp already send ".$check_date2."
"; 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."
"; + $response .= ($inx+1).") ".$history_msg."
"; 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."
"; + $response .= ($inx+1).") ".$whatsapp_result."
"; } 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
"; + $response .= ($inx+1).") Whatsapp sent successfully
"; } else { // echo "Failed to extract remoteJid"; $this->logger->error("EXPIRAY NOTIFY TEMPLATE WHATSAPP Failed to extract remoteJid "); - echo ($inx+1).") Failed to send Whatsapp
"; + $response .= ($inx+1).") Failed to send Whatsapp
"; } } } 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
"; + $response .= "There is no Whatsapp template
"; 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
"; } + $response .= "Process Completed
"; + return $this->response->setBody($response); + } diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php index fa4de006..dcf7b9b1 100755 --- a/app/Controllers/Subscription.php +++ b/app/Controllers/Subscription.php @@ -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() diff --git a/app/Views/notify_the_expiry_subscribers.php b/app/Views/notify_the_expiry_subscribers.php new file mode 100755 index 00000000..babcd8f2 --- /dev/null +++ b/app/Views/notify_the_expiry_subscribers.php @@ -0,0 +1,47 @@ +
+
+
+

+

+
+
+ + +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/app/Views/subscribers_list.php b/app/Views/subscribers_list.php index c25d0a7a..6aee1e6e 100755 --- a/app/Views/subscribers_list.php +++ b/app/Views/subscribers_list.php @@ -86,7 +86,7 @@ $message = "Expires in $daysRemaining days"; } else { $class = 'text-success'; - $message = "Expired in $daysRemaining days"; + $message = "Expires in $daysRemaining days"; } ?> diff --git a/app/Views/template/header.php b/app/Views/template/header.php index 128a2d4c..7c081b47 100755 --- a/app/Views/template/header.php +++ b/app/Views/template/header.php @@ -184,12 +184,30 @@ -
  • +
  • + + + Members + + +
    + +
    +
  • +
  • diff --git a/invoice_2024-2025-00000533.pdf b/invoice_2024-2025-00000533.pdf deleted file mode 100644 index fd23a9ab..00000000 Binary files a/invoice_2024-2025-00000533.pdf and /dev/null differ