diff --git a/system/controllers/customers.php b/system/controllers/customers.php index 8328c7b9..da0299cc 100644 --- a/system/controllers/customers.php +++ b/system/controllers/customers.php @@ -655,12 +655,28 @@ switch ($action) { $query = ORM::for_table('tbl_customers'); $query->where("status", $filter); } + if ($orderby == 'asc') { $query->order_by_asc($order); } else { $query->order_by_desc($order); } - $d = $query->findMany(); + + $customers = $query->findMany(); + + foreach ($customers as $customer) { + $d = ORM::for_table('tbl_user_recharges')->where('customer_id', $customer->id)->findOne(); + if ($d) { + if ($d['status'] == 'on') { + $customer->recharge_status = '' . $d['namebp'] . ''; + } else { + $customer->recharge_status = '' . $d['namebp'] . ''; + } + } else { + $customer->recharge_status = ''; + } + } + if (_post('export', '') == 'csv') { $h = false; set_time_limit(-1); @@ -680,13 +696,14 @@ switch ($action) { 'email', 'balance', 'service_type', + 'recharge_status' ]; $fp = fopen('php://output', 'wb'); if (!$h) { fputcsv($fp, $headers, ";"); $h = true; } - foreach ($d as $c) { + foreach ($customers as $c) { $row = [ $c['id'], $c['username'], @@ -696,14 +713,16 @@ switch ($action) { $c['email'], $c['balance'], $c['service_type'], + $c->recharge_status ]; fputcsv($fp, $row, ";"); } fclose($fp); die(); } + $ui->assign('xheader', ''); - $ui->assign('d', $d); + $ui->assign('customers', $customers); $ui->assign('statuses', ORM::for_table('tbl_customers')->getEnum("status")); $ui->assign('filter', $filter); $ui->assign('search', $search); diff --git a/ui/ui/customers.tpl b/ui/ui/customers.tpl index 534b5941..77f159bf 100644 --- a/ui/ui/customers.tpl +++ b/ui/ui/customers.tpl @@ -99,7 +99,7 @@ - {foreach $d as $ds} + {foreach $customers as $ds} {$ds['username']} @@ -122,8 +122,8 @@ class="glyphicon glyphicon-map-marker"> {/if} - - + + {$ds.recharge_status} {$ds['service_type']} {Lang::T($ds['status'])}