From 2bb664e241c63baf2466c309f5e7d9588d7ef34f Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Tue, 12 Mar 2024 15:28:32 +0700 Subject: [PATCH] Expired Date by created date --- system/autoload/Package.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index c6c9b902..3bbc7405 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -48,10 +48,14 @@ class Package if ($p['validity_unit'] == 'Period') { $f = ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one(); if (!$f) { + $day = date('d', strtotime($c['created_at'])); + if ($day > 28) { + $day = 1; + } $f = ORM::for_table('tbl_customers_fields')->create(); $f->customer_id = $c['id']; $f->field_name = 'Expired Date'; - $f->field_value = 20; + $f->field_value = $day; $f->save(); } }