diff --git a/controllers/customers_controller.php b/controllers/customers_controller.php index d3e8ef7..9d30858 100644 --- a/controllers/customers_controller.php +++ b/controllers/customers_controller.php @@ -122,6 +122,18 @@ class CustomersController extends AppController { return $count; } + function jqGridDataRecords(&$params, &$model, $query) { + $customers = parent::jqGridDataRecords($params, $model, $query); + + // Get the balance on each customer. + foreach ($customers AS &$customer) { + $stats = $this->Customer->stats($customer['Customer']['id']); + $customer['Customer']['balance'] = $stats['balance']; + } + + return $customers; + } + function jqGridRecordLinks(&$params, &$model, &$records, $links) { $links['Customer'] = array('name'); return parent::jqGridRecordLinks($params, $model, $records, $links); diff --git a/views/elements/customers.ctp b/views/elements/customers.ctp index f7a31fd..9b9b2e5 100644 --- a/views/elements/customers.ctp +++ b/views/elements/customers.ctp @@ -9,6 +9,7 @@ $cols['Name'] = array('index' => 'Customer.name', 'formatter $cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'formatter' => 'name'); $cols['First Name'] = array('index' => 'PrimaryContact.first_name', 'formatter' => 'name'); $cols['Leases'] = array('index' => 'lease_count', 'width' => '60'); +$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency', 'sortable' => false); $cols['Comment'] = array('index' => 'Customer.comment', 'formatter' => 'comment'); $jqGrid_options = array('jqGridColumns' => $cols,