From ab51fd32d268648108e79dd67ea7aedd07d790b4 Mon Sep 17 00:00:00 2001 From: abijah Date: Mon, 22 Jun 2009 17:58:13 +0000 Subject: [PATCH] Added a balance column to customer. Like lease, since it's based on additional queries for stats, it's not sortable. git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@176 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/controllers/customers_controller.php | 12 ++++++++++++ site/views/elements/customers.ctp | 1 + 2 files changed, 13 insertions(+) diff --git a/site/controllers/customers_controller.php b/site/controllers/customers_controller.php index d3e8ef7..9d30858 100644 --- a/site/controllers/customers_controller.php +++ b/site/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/site/views/elements/customers.ctp b/site/views/elements/customers.ctp index f7a31fd..9b9b2e5 100644 --- a/site/views/elements/customers.ctp +++ b/site/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,