From 8e0d353c8e2191af4be121349f9a0cb954ce7dc2 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 23 Jan 2024 16:05:29 +0530 Subject: [PATCH] Notification : ps --- .env | 4 ++-- app/Controllers/Invoice.php | 10 +++++++--- app/Controllers/Notifications.php | 9 +++++++-- app/Models/InvoiceModel.php | 22 ++++++++++++++++++++++ app/Views/campaign_creation_form.php | 7 +++++-- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.env b/.env index 323b5f43..020debd5 100644 --- a/.env +++ b/.env @@ -147,8 +147,8 @@ APP_TIMEZONE = 'Asia/Kolkata' # Whatsapp Access Token And Instance ID #-------------------------------------------------------------------- # for Live Don't delete it -WAAI_TOKEN = '6568739969f28' -WAAI_INSTANCE = '656876690A9FD' +WAAI_TOKEN = '6582950cb468b' +WAAI_INSTANCE = '6582F04394D59' # Dummy Account by sanjeev created on 14th dec Testing purpose office mail ID (user name - Venba V1 - Krish12345) # WAAI_TOKEN = '657af9bf8cad1' diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 7a31fd60..d15ea1d5 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -293,8 +293,10 @@ class Invoice extends BaseController ]; $get_subscription_draft_dtl_where = ['S.customer_id'=>$customer_id,'I.status'=>$invoice_status]; - $get_subscription_draft_dtl_id = $model->InactiveSubscriptionDraftDetails($get_subscription_draft_dtl_where,get_logged_user_id()); - $this->logger->info($msg_flag_name.": has been Inactived. Inv ID = ".implode(", ", $get_subscription_draft_dtl_id)); + // $get_subscription_draft_dtl_id = $model->InactiveSubscriptionDraftDetails($get_subscription_draft_dtl_where,get_logged_user_id()); + // $this->logger->info($msg_flag_name.": has been Inactived. Inv ID = ".implode(", ", $get_subscription_draft_dtl_id)); + $get_subscription_draft_dtl_id = $model->deleteSubscriptionDraftDetails($get_subscription_draft_dtl_where,get_logged_user_id()); + $this->logger->info($msg_flag_name.": has been Deleted. Inv ID = ".implode(", ", $get_subscription_draft_dtl_id)); $subscriptionModel->insertSubscriptionData($subscription_data); } } @@ -361,7 +363,9 @@ class Invoice extends BaseController if (!empty($missingValues)) { $where = ['isactive' => 1, 'invoice_id' => (int)$id]; - $model->inactiveMissingInvoiceItemDetails($where, $missingValues); + // $model->inactiveMissingInvoiceItemDetails($where, $missingValues); + $model->deleteMissingInvoiceItemDetails($where, $missingValues); + $this->logger->info("Child Item Details : has been Deleted. Inv Child ID = ".implode(", ", $missingValues)); } } } diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php index ee6f7f98..f00f0251 100755 --- a/app/Controllers/Notifications.php +++ b/app/Controllers/Notifications.php @@ -561,7 +561,7 @@ class Notifications extends BaseController # EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP $whatsappTemplateName = $NotificationModel->getTempName(EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP); if (count($whatsappTemplateName) && !empty($whatsappTemplateName)) { - $campaign_id = 2; + $campaign_id = 2; // hardcoded because static Template. $history_parents_data = ['campaign_id' => $campaign_id,'status' => 0]; $history_parent_id = $NotificationModel->save_notification_history_parents($history_parents_data); if (empty($userMobileNumber)) { @@ -741,8 +741,13 @@ class Notifications extends BaseController { $model = new NotificationModel(); $today = date('Y-m-d'); + $currentTime = date('H:i:s'); + $endTime = date('H:i:s', strtotime('+30 minutes')); + $where = ['scheduled_date' => $today,'isactive' => 1, + 'scheduled_time >=' => $currentTime, + 'scheduled_time <=' => $endTime + ]; $model->setTable('notification_campaign'); - $where = ['scheduled_date'=>$today,'isactive'=>1]; $notification_campaign_result = $model->where($where)->findAll(); return $notification_campaign_result; } diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 1e2da91f..d60964dd 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -37,6 +37,13 @@ public function inactiveMissingInvoiceItemDetails($where,$missingValues){ $this->db->table('invoiceitems')->where($where)->whereIn('invoice_child_id',$missingValues)->update($dataToUpdate); } +public function deleteMissingInvoiceItemDetails($where, $missingValues) { + $this->db->table('invoiceitems') + ->where($where) + ->whereIn('invoice_child_id', $missingValues) + ->delete(); +} + public function updateData($table, $data, $where) { $this->db->table($table)->update($data, $where); @@ -63,6 +70,21 @@ public function InactiveSubscriptionDraftDetails($where,$update_by_id) return $inactive_invoice_ids; } +public function deleteSubscriptionDraftDetails($where,$update_by_id) +{ + $result = $this->getJoinedData($where); + $delete_invoice_ids = array(); + foreach ($result as $item) { + $delete_invoice_ids[] = $item['invoice_id']; + } + if(count($delete_invoice_ids)>0){ + $this->db->table('subscription') + ->whereIn('invoice_id', $delete_invoice_ids) + ->delete(); + } + return $delete_invoice_ids; +} + ## check the customer the scheme already Exist public function existsSubscriptionDetails($where){ $result = $this->getJoinedData($where); diff --git a/app/Views/campaign_creation_form.php b/app/Views/campaign_creation_form.php index 0df4ab01..ca9339d4 100644 --- a/app/Views/campaign_creation_form.php +++ b/app/Views/campaign_creation_form.php @@ -38,14 +38,17 @@
- +
+
Please provide.
- + + +
Please provide.