Expired Date by created date

This commit is contained in:
Ibnu Maksum 2024-03-12 15:28:32 +07:00
parent c9058769ce
commit 2bb664e241
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -48,10 +48,14 @@ class Package
if ($p['validity_unit'] == 'Period') { if ($p['validity_unit'] == 'Period') {
$f = ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one(); $f = ORM::for_table('tbl_customers_fields')->where('field_name', 'Expired Date')->where('customer_id', $c['id'])->find_one();
if (!$f) { if (!$f) {
$day = date('d', strtotime($c['created_at']));
if ($day > 28) {
$day = 1;
}
$f = ORM::for_table('tbl_customers_fields')->create(); $f = ORM::for_table('tbl_customers_fields')->create();
$f->customer_id = $c['id']; $f->customer_id = $c['id'];
$f->field_name = 'Expired Date'; $f->field_name = 'Expired Date';
$f->field_value = 20; $f->field_value = $day;
$f->save(); $f->save();
} }
} }