From 60c573821b9812454f57e52cde6fc3b8f157a972 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Wed, 13 Mar 2024 14:48:01 +0700 Subject: [PATCH] Additional Cost from Customer Attributes --- system/autoload/Package.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/system/autoload/Package.php b/system/autoload/Package.php index 661fc62b..a09691c1 100644 --- a/system/autoload/Package.php +++ b/system/autoload/Package.php @@ -32,8 +32,16 @@ class Package $c = ORM::for_table('tbl_customers')->where('id', $id_customer)->find_one(); $p = ORM::for_table('tbl_plans')->where('id', $plan_id)->find_one(); + // Additional cost + $add_cost = User::getAttribute("Additional Cost", $id_customer); + if(empty($add_cost)){ + $add_cost = 0; + } + + // Zero cost recharge if (isset($zero) && $zero == 1) { $p['price'] = 0; + $add_cost = 0; } if (!$p['enabled']) { @@ -226,7 +234,7 @@ class Package $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; $t->recharged_on = $date_only; $t->recharged_time = $time_only; $t->expiration = $date_exp; @@ -306,12 +314,12 @@ class Package $fd = $td->format("%a"); $gi = ($p['price'] / 30) * $fd; if ($gi > $p['price']) { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } else { - $t->price = $gi; + $t->price = $gi + $add_cost; } } else { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } $t->recharged_on = $date_only; $t->recharged_time = $time_only; @@ -411,7 +419,7 @@ class Package $t->invoice = "INV-" . Package::_raid(); $t->username = $c['username']; $t->plan_name = $p['name_plan']; - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; $t->recharged_on = $date_only; $t->recharged_time = $time_only; $t->expiration = $date_exp; @@ -490,12 +498,12 @@ class Package $fd = $td->format("%a"); $gi = ($p['price'] / 30) * $fd; if ($gi > $p['price']) { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } else { - $t->price = $gi; + $t->price = $gi + $add_cost; } } else { - $t->price = $p['price']; + $t->price = $p['price'] + $add_cost; } $t->recharged_on = $date_only; $t->recharged_time = $time_only;