From a0b9e85f38d11de6ab72f6fd9eb0dd02b96f6945 Mon Sep 17 00:00:00 2001
From: Ibnu Maksum <ibnumaksum@gmail.com>
Date: Wed, 28 Feb 2024 11:31:36 +0700
Subject: [PATCH] Add Expired date for reminder

---
 CHANGELOG.md                |  5 +++++
 system/autoload/Message.php |  4 ++++
 ui/ui/app-notifications.tpl | 25 +++++++++++++++++--------
 version.json                |  2 +-
 4 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7e3c66b..df88411e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
 
 # CHANGELOG
 
+## 2024.2.28
+
+- Fix Buy Plan with Balance
+- Add Expired date for reminder
+
 ## 2024.2.27
 
 - fix path notification
diff --git a/system/autoload/Message.php b/system/autoload/Message.php
index 256129de..a8005898 100644
--- a/system/autoload/Message.php
+++ b/system/autoload/Message.php
@@ -68,9 +68,13 @@ class Message
 
     public static function sendPackageNotification($phone, $name, $package, $price, $message, $via)
     {
+        global $u;
         $msg = str_replace('[[name]]', $name, $message);
         $msg = str_replace('[[package]]', $package, $msg);
         $msg = str_replace('[[price]]', $price, $msg);
+        if($u){
+            $msg = str_replace('[[expired_date]]', Lang::dateAndTimeFormat($u['expiration'], $u['time']), $msg);
+        }
         if (
             !empty($phone) && strlen($phone) > 5
             && !empty($message) && in_array($via, ['sms', 'wa'])
diff --git a/ui/ui/app-notifications.tpl b/ui/ui/app-notifications.tpl
index 2691593f..30220a31 100644
--- a/ui/ui/app-notifications.tpl
+++ b/ui/ui/app-notifications.tpl
@@ -15,13 +15,14 @@
                     <div class="form-group">
                         <label class="col-md-2 control-label">{Lang::T('Expired Notification Message')}</label>
                         <div class="col-md-6">
-                            <textarea class="form-control" id="expired"
-                                name="expired"
+                            <textarea class="form-control" id="expired" name="expired"
                                 placeholder="Hello [[name]], your internet package [[package]] has been expired"
                                 rows="3">{if $_json['expired']!=''}{Lang::htmlspecialchars($_json['expired'])}{else}Hello [[name]], your internet package [[package]] has been expired.{/if}</textarea>
                         </div>
                         <p class="help-block col-md-4">
-                            <b>[[name]]</b> will be replaced with Customer Name. <b>[[package]]</b> will be replaced with Package name. <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[name]]</b> will be replaced with Customer Name.
+                            <b>[[package]]</b> will be replaced with Package name.
+                            <b>[[price]]</b> will be replaced with Package price.
                         </p>
                     </div>
                 </div>
@@ -33,7 +34,10 @@
                                 rows="3">{Lang::htmlspecialchars($_json['reminder_7_day'])}</textarea>
                         </div>
                         <p class="help-block col-md-4">
-                            <b>[[name]]</b> will be replaced with Customer Name. <b>[[package]]</b> will be replaced with Package name. <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[name]]</b> will be replaced with Customer Name.
+                            <b>[[package]]</b> will be replaced with Package name.
+                            <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[expired_date]]</b> will be replaced with Expiration date.
                         </p>
                     </div>
                 </div>
@@ -45,7 +49,10 @@
                                 rows="3">{Lang::htmlspecialchars($_json['reminder_3_day'])}</textarea>
                         </div>
                         <p class="help-block col-md-4">
-                            <b>[[name]]</b> will be replaced with Customer Name. <b>[[package]]</b> will be replaced with Package name. <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[name]]</b> will be replaced with Customer Name.
+                            <b>[[package]]</b> will be replaced with Package name.
+                            <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[expired_date]]</b> will be replaced with Expiration date.
                         </p>
                     </div>
                 </div>
@@ -57,7 +64,10 @@
                                 rows="3">{Lang::htmlspecialchars($_json['reminder_1_day'])}</textarea>
                         </div>
                         <p class="help-block col-md-4">
-                            <b>[[name]]</b> will be replaced with Customer Name. <b>[[package]]</b> will be replaced with Package name. <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[name]]</b> will be replaced with Customer Name.
+                            <b>[[package]]</b> will be replaced with Package name.
+                            <b>[[price]]</b> will be replaced with Package price.
+                            <b>[[expired_date]]</b> will be replaced with Expiration date.
                         </p>
                     </div>
                 </div>
@@ -149,8 +159,7 @@
 
             <div class="panel-body">
                 <div class="form-group">
-                    <button class="btn btn-success btn-block"
-                        type="submit">{Lang::T('Save Changes')}</button>
+                    <button class="btn btn-success btn-block" type="submit">{Lang::T('Save Changes')}</button>
                 </div>
             </div>
         </div>
diff --git a/version.json b/version.json
index b8373514..60dd994c 100644
--- a/version.json
+++ b/version.json
@@ -1,3 +1,3 @@
 {
-    "version": "2024.2.27.1"
+    "version": "2024.2.28"
 }
\ No newline at end of file