Added more lock functionality, and fixed a couple bugs
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1039 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -200,6 +200,9 @@ class AppController extends Controller {
|
||||
$this->addSideMenuLink('Units',
|
||||
array('controller' => 'units', 'action' => 'index'), null,
|
||||
'SITE');
|
||||
$this->addSideMenuLink('Locks',
|
||||
array('controller' => 'locks', 'action' => 'index'), null,
|
||||
'SITE');
|
||||
$this->addSideMenuLink('Leases',
|
||||
array('controller' => 'leases', 'action' => 'index'), null,
|
||||
'SITE');
|
||||
@@ -655,6 +658,9 @@ class AppController extends Controller {
|
||||
$query = array_intersect_key($this->gridDataCountTableSet($params, $model),
|
||||
array('link'=>1, 'contain'=>1));
|
||||
|
||||
// Conditions for the count
|
||||
$query['fields'] = array($this->gridDataCountField($params, $model));
|
||||
|
||||
// Conditions for the count
|
||||
$query['conditions'] = $this->gridDataCountConditionSet($params, $model);
|
||||
|
||||
@@ -684,6 +690,10 @@ class AppController extends Controller {
|
||||
array('link'=>1, 'contain'=>1));
|
||||
}
|
||||
|
||||
function gridDataCountField(&$params, &$model) {
|
||||
return "COUNT(DISTINCT `".$model->alias.'`.`'.$model->primaryKey."`) AS 'count'";
|
||||
}
|
||||
|
||||
function gridDataCountConditions(&$params, &$model) {
|
||||
// Same conditions for counting as for retreiving
|
||||
return $this->gridDataConditions($params, $model);
|
||||
|
||||
@@ -13,6 +13,9 @@ class LocksController extends AppController {
|
||||
function addGridViewSideMenuLinks() {
|
||||
parent::addGridViewSideMenuLinks();
|
||||
|
||||
$this->addSideMenuLink('List',
|
||||
array('controller' => 'locks', 'action' => 'all'), null,
|
||||
'CONTROLLER');
|
||||
$this->addSideMenuLink('Add',
|
||||
array('controller' => 'locks', 'action' => 'add'), null,
|
||||
'CONTROLLER');
|
||||
@@ -52,9 +55,15 @@ class LocksController extends AppController {
|
||||
function gridDataFields(&$params, &$model) {
|
||||
$fields = parent::gridDataFields($params, $model);
|
||||
$fields[] = 'COUNT(LocksUnit.id) AS inuse';
|
||||
$fields[] = 'Lock.qty - COUNT(LocksUnit.id) AS avail';
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
|
||||
$links['Lock'] = array('name');
|
||||
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
@@ -83,6 +83,7 @@ class UnitsController extends AppController {
|
||||
function gridDataTables(&$params, &$model) {
|
||||
$link = $this->gridDataCountTables($params, $model);
|
||||
$link['link']['CurrentLease']['StatementEntry'] = array('fields' => array());
|
||||
$link['link']['Lock'];
|
||||
return $link;
|
||||
}
|
||||
|
||||
@@ -254,7 +255,7 @@ class UnitsController extends AppController {
|
||||
$this->status($id, 'OCCUPIED');
|
||||
|
||||
// If we're not liened, we must now just be locked
|
||||
if (!$this->Unit->liened($id))
|
||||
if (!$this->Unit->liened(intval($id)))
|
||||
$this->status($id, 'LOCKED');
|
||||
|
||||
// Otherwise, don't change anything.
|
||||
@@ -371,6 +372,7 @@ class UnitsController extends AppController {
|
||||
array('contain' =>
|
||||
array(// Models
|
||||
'UnitSize',
|
||||
'Lock',
|
||||
'Lease' => array('Customer'),
|
||||
'CurrentLease' => array('Customer')
|
||||
),
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
|
||||
// Define the table columns
|
||||
$cols = array();
|
||||
$cols['Name'] = array('index' => 'name', 'formatter' => 'longname');
|
||||
$cols['Quantity'] = array('index' => 'qty', 'formatter' => 'number');
|
||||
$cols['Key'] = array('index' => 'key', 'formatter' => 'shortname');
|
||||
$cols['Last Key'] = array('index' => 'last_key', 'formatter' => 'shortname');
|
||||
$cols['Name'] = array('index' => 'name', 'formatter' => 'name');
|
||||
$cols['Comment'] = array('index' => 'comment', 'formatter' => 'comment');
|
||||
$cols['Key'] = array('index' => 'key', 'formatter' => 'number');
|
||||
$cols['Last Key'] = array('index' => 'last_key', 'formatter' => 'number');
|
||||
$cols['Quantity'] = array('index' => 'qty', 'formatter' => 'number');
|
||||
$cols['In Use'] = array('index' => 'inuse', 'formatter' => 'number');
|
||||
$cols['Available']= array('index' => 'avail', 'formatter' => 'number');
|
||||
|
||||
// Render the grid
|
||||
$grid
|
||||
@@ -15,4 +17,4 @@ $grid
|
||||
->defaultFields(array('Name'))
|
||||
->searchFields(array('Name'))
|
||||
->render($this, isset($config) ? $config : null,
|
||||
array_diff(array_keys($cols), array('Comment')));
|
||||
array_diff(array_keys($cols), array('Last Key')));
|
||||
|
||||
@@ -36,8 +36,23 @@ echo $this->element('table',
|
||||
|
||||
echo '<div CLASS="detail supporting">' . "\n";
|
||||
|
||||
/**********************************************************************
|
||||
* Unit Entries
|
||||
*/
|
||||
|
||||
echo $this->element('units', array
|
||||
(// Grid configuration
|
||||
'config' => array
|
||||
('caption' => "Units locked by " . $lock['name'],
|
||||
'filter' => array('Lock.id' => $lock['id']),
|
||||
'include' => array('Comment'),
|
||||
'exclude' => array('Size', 'Area', 'Rent'),
|
||||
)));
|
||||
|
||||
|
||||
/* End "detail supporting" div */
|
||||
echo '</div>' . "\n";
|
||||
|
||||
/* End page div */
|
||||
echo '</div>' . "\n";
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ echo '<div CLASS="detail supporting">' . "\n";
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* Ledger Entries
|
||||
* Unit Entries
|
||||
*/
|
||||
|
||||
echo $this->element('units', array
|
||||
|
||||
@@ -135,8 +135,3 @@ echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
||||
echo $form->end() . "\n";
|
||||
echo '</div>' . "\n";
|
||||
|
||||
echo "\n<PRE>\n";
|
||||
echo print_r($this->data, true);
|
||||
echo print_r($this->varstore, true);
|
||||
echo "\n</PRE>\n";
|
||||
|
||||
|
||||
@@ -13,12 +13,25 @@ $leases = $unit['Lease'];
|
||||
$current_lease = $unit['CurrentLease'];
|
||||
$unit_size = $unit['UnitSize'];
|
||||
|
||||
if (isset($unit['Lock']))
|
||||
$locks = $unit['Lock'];
|
||||
|
||||
if (isset($unit['Unit']))
|
||||
$unit = $unit['Unit'];
|
||||
|
||||
$rows = array();
|
||||
$rows[] = array('Name', $unit['name']);
|
||||
$rows[] = array('Status', $unit['status']);
|
||||
if (count($locks) > 0) {
|
||||
$links = array();
|
||||
foreach ($locks AS $lock) {
|
||||
$links[] = $html->link($lock['name'],
|
||||
array('controller' => 'locks',
|
||||
'action' => 'view',
|
||||
$lock['id']));
|
||||
}
|
||||
$rows[] = array('Locks', count($locks) . ": " . implode(", ", $links));
|
||||
}
|
||||
$rows[] = array('Size', $html->link($unit_size['name'],
|
||||
array('controller' => 'unit_sizes',
|
||||
'action' => 'view',
|
||||
|
||||
Reference in New Issue
Block a user