diff --git a/site/views/customers/view.ctp b/site/views/customers/view.ctp index 28e57e5..2a55b4f 100644 --- a/site/views/customers/view.ctp +++ b/site/views/customers/view.ctp @@ -57,9 +57,12 @@ echo $this->element('contacts', /********************************************************************** * Lease History */ -echo $this->element('leases', - array('caption' => 'Lease History', - 'leases' => $customer['Lease'])); +echo $this->element('leases', array + ('config' => array + ('caption' => 'Lease History', + 'rows' => $customer['Lease'], + 'limit' => 5, + ))); /********************************************************************** diff --git a/site/views/elements/leases.ctp b/site/views/elements/leases.ctp index 26c095e..c9f5cc9 100644 --- a/site/views/elements/leases.ctp +++ b/site/views/elements/leases.ctp @@ -14,25 +14,13 @@ $cols['Move-Out'] = array('index' => 'Lease.moveout_date', 'formatter' => 'dat $cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency'); $cols['Comment'] = array('index' => 'Lease.comment', 'formatter' => 'comment'); -$custom_post_data = compact('nothing'); -$jqGrid_options = array('jqGridColumns' => $cols, - 'controller' => 'leases'); -$jqGrid_options += compact('action', 'caption', - 'grid_div_id', 'grid_div_class', 'grid_id', 'grid_setup', - 'nolinks', 'limit'); +// Set up search fields if requested by caller +if (isset($searchfields)) + $grid->searchFields(array('Customer', 'Unit')); -if (isset($leases)) { - $jqGrid_options += array('custom_ids' => - array_map(create_function('$data', - 'return $data["id"];'), - $leases), - 'limit' => 5); -} - -if (isset($searchfields)) { - $jqGrid_options += array('search_fields' => array('Customer', 'Unit')); -} - -$jqGrid_options += compact('custom_post_data'); -$jqGrid_options['sort_column'] = 'LeaseID'; -echo $this->element('jqGrid', $jqGrid_options); +// Render the grid +$grid +->columns($cols) +->sortField('LeaseID') +->defaultFields(array('LeaseID', 'Lease')) +->render($this, isset($config) ? $config : null); diff --git a/site/views/units/view.ctp b/site/views/units/view.ctp index 79e5f01..83f4d1e 100644 --- a/site/views/units/view.ctp +++ b/site/views/units/view.ctp @@ -61,9 +61,11 @@ echo '