'Common', 'header' => true),
array('name' => 'Site Map', 'url' => array('controller' => 'maps', 'action' => 'view', 1)),
array('name' => 'Units', 'url' => array('controller' => 'units', 'action' => 'index')),
array('name' => 'Leases', 'url' => array('controller' => 'leases', 'action' => 'index')),
array('name' => 'Customers', 'url' => array('controller' => 'customers', 'action' => 'index')),
array('name' => 'Contacts', 'url' => array('controller' => 'contacts', 'action' => 'index')),
array('name' => 'Accounts', 'url' => array('controller' => 'accounts', 'action' => 'index')),
array('name' => 'Ledgers', 'url' => array('controller' => 'ledgers', 'action' => 'index')),
);
}
function beforeRender() {
$this->set('sidemenu', $this->sideMenuLinks());
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: jqGridData
* - Fetches the actual data requested by jqGrid as XML
*/
function jqGridData($model, $records, $query) {
// Assume we're debugging.
// The actual jqGrid request will set this to false
$debug = true;
$model_alias = $model->alias;
$model_id = $model_alias . '.id';
if (isset($this->passedArgs['debug']))
$debug = $this->passedArgs['debug'];
if (!$debug) {
$this->layout = null;
$this->autoLayout = false;
$this->autoRender = false;
Configure::write('debug', '0');
}
// Set up some defaults
$page = 1; // page number
$rows = 20; // rows in the grid - rowNum parameter
$sidx = $model_id; // sort column - index from colModel
$sord = 'ASC'; // sort order
// Extract the actual settings from the jqGrid request
if (isset($this->params['url']) && is_array($this->params['url']))
extract($this->params['url']);
// Unserialize our complex structure of fields
// This SHOULD be always set, except when debugging
if (isset($fields))
$fields = unserialize($fields);
else
$fields = array($model_id);
if (isset($_search) && $_search === 'true') {
$ops = array('eq' => array('op' => null, 'pre' => '', 'post' => ''),
'ne' => array('op' => '<>', 'pre' => '', 'post' => ''),
'lt' => array('op' => '<', 'pre' => '', 'post' => ''),
'le' => array('op' => '<=', 'pre' => '', 'post' => ''),
'gt' => array('op' => '>', 'pre' => '', 'post' => ''),
'ge' => array('op' => '>=', 'pre' => '', 'post' => ''),
'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'),
'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''),
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
);
$op = $ops[$searchOper];
$field = $searchField . ($op['op'] ? ' '.$op['op'] : '');
$val = $op['pre'] . $searchString . $op['post'];
$query['conditions'][] = array($field => $val);
}
// Verify a few parameters and determine our starting row
$total = ($records < 0) ? 0 : ceil($records/$rows);
$page = ($page < 1) ? 1 : (($page > $total) ? $total : $page);
$start = $rows*$page - $rows;
// the actual query for the grid data
$query['group'] = $model_id;
$query['order'] = "$sidx $sord";
$query['limit'] = "$start, $rows";
$results = $model->find('all', $query);
if ($debug) {
ob_start();
print_r(compact('records', 'rows', 'total', 'page', 'start'));
}
else {
header("Content-type: text/xml;charset=utf-8");
}
echo "\n";
echo "
\n$xml\n\n"); } } } ?>