From 112a1284928adfd796580d23c96f13846febbfdd Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 2 Jul 2010 13:38:38 +0000 Subject: [PATCH] Minor change to the display and sort order of unit sizes git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@992 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/controllers/unit_sizes_controller.php | 17 +++++++++++++++++ site/views/elements/unit_sizes.ctp | 17 ++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/site/controllers/unit_sizes_controller.php b/site/controllers/unit_sizes_controller.php index a6f3633..ccc341e 100644 --- a/site/controllers/unit_sizes_controller.php +++ b/site/controllers/unit_sizes_controller.php @@ -148,6 +148,23 @@ class UnitSizesController extends AppController { return $conditions; } + function gridDataOrder(&$params, &$model, $index, $direction) { + if ($index == 'UnitType.name') + $index = 'UnitType.code'; + + $order = parent::gridDataOrder($params, $model, $index, $direction); + + // After sorting by whatever the user wants, add these + // defaults into the sort mechanism. If we're already + // sorting by one of them, it will only be redundant, + // and should cause no harm (possible a longer query?) + $order[] = 'UnitType.code ' . $direction; + $order[] = 'sqft ' . $direction; + $order[] = 'UnitSize.rent ' . $direction; + + return $order; + } + function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { $links['UnitSize'] = array('name'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); diff --git a/site/views/elements/unit_sizes.ctp b/site/views/elements/unit_sizes.ctp index 4c96f98..1d4a0b0 100644 --- a/site/views/elements/unit_sizes.ctp +++ b/site/views/elements/unit_sizes.ctp @@ -3,6 +3,7 @@ // Define the table columns $cols = array(); $cols['Size'] = array('index' => 'UnitSize.name', 'formatter' => 'shortname'); +$cols['Type'] = array('index' => 'UnitType.name', 'formatter' => 'shortname'); $cols['Width'] = array('index' => 'UnitSize.width', 'formatter' => 'number'); $cols['Depth'] = array('index' => 'UnitSize.depth', 'formatter' => 'number'); $cols['Height'] = array('index' => 'UnitSize.height', 'formatter' => 'number'); @@ -10,8 +11,8 @@ $cols['Area'] = array('index' => 'sqft', 'formatter' => 'nu $cols['Volume'] = array('index' => 'cuft', 'formatter' => 'number'); $cols['Deposit'] = array('index' => 'UnitSize.deposit', 'formatter' => 'currency'); $cols['Rent'] = array('index' => 'UnitSize.rent', 'formatter' => 'currency'); -$cols['A. Cost'] = array('index' => 'sqcost', 'formatter' => 'currency'); -$cols['V. Cost'] = array('index' => 'cucost', 'formatter' => 'currency'); +$cols['Per Foot'] = array('index' => 'sqcost', 'formatter' => 'currency'); +$cols['Per Cubic Ft'] = array('index' => 'cucost', 'formatter' => 'currency'); $cols['Unavailable'] = array('index' => 'unavailable', 'formatter' => 'number'); $cols['Occupied'] = array('index' => 'occupied', 'formatter' => 'number'); $cols['Available'] = array('index' => 'available', 'formatter' => 'number'); @@ -27,7 +28,13 @@ $grid ->defaultFields(array('Size', 'Area')) ->searchFields(array('Size', 'Width', 'Depth', 'Area', 'Deposit', 'Rent')) ->render($this, isset($config) ? $config : null, - array_diff(array_keys($cols), array('Height', 'Volume', - 'A. Cost', 'V. Cost', - 'Occupied', 'Total', 'Occupancy', 'Vacancy', + array_diff(array_keys($cols), array('Width', 'Depth', + 'Deposit', + 'Height', 'Volume', + //'Per Foot', + 'Per Cubic Ft', + 'Occupied', + //'Total', + 'Occupancy', + //'Vacancy', 'Comment')));