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',
|
$this->addSideMenuLink('Units',
|
||||||
array('controller' => 'units', 'action' => 'index'), null,
|
array('controller' => 'units', 'action' => 'index'), null,
|
||||||
'SITE');
|
'SITE');
|
||||||
|
$this->addSideMenuLink('Locks',
|
||||||
|
array('controller' => 'locks', 'action' => 'index'), null,
|
||||||
|
'SITE');
|
||||||
$this->addSideMenuLink('Leases',
|
$this->addSideMenuLink('Leases',
|
||||||
array('controller' => 'leases', 'action' => 'index'), null,
|
array('controller' => 'leases', 'action' => 'index'), null,
|
||||||
'SITE');
|
'SITE');
|
||||||
@@ -655,6 +658,9 @@ class AppController extends Controller {
|
|||||||
$query = array_intersect_key($this->gridDataCountTableSet($params, $model),
|
$query = array_intersect_key($this->gridDataCountTableSet($params, $model),
|
||||||
array('link'=>1, 'contain'=>1));
|
array('link'=>1, 'contain'=>1));
|
||||||
|
|
||||||
|
// Conditions for the count
|
||||||
|
$query['fields'] = array($this->gridDataCountField($params, $model));
|
||||||
|
|
||||||
// Conditions for the count
|
// Conditions for the count
|
||||||
$query['conditions'] = $this->gridDataCountConditionSet($params, $model);
|
$query['conditions'] = $this->gridDataCountConditionSet($params, $model);
|
||||||
|
|
||||||
@@ -684,6 +690,10 @@ class AppController extends Controller {
|
|||||||
array('link'=>1, 'contain'=>1));
|
array('link'=>1, 'contain'=>1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gridDataCountField(&$params, &$model) {
|
||||||
|
return "COUNT(DISTINCT `".$model->alias.'`.`'.$model->primaryKey."`) AS 'count'";
|
||||||
|
}
|
||||||
|
|
||||||
function gridDataCountConditions(&$params, &$model) {
|
function gridDataCountConditions(&$params, &$model) {
|
||||||
// Same conditions for counting as for retreiving
|
// Same conditions for counting as for retreiving
|
||||||
return $this->gridDataConditions($params, $model);
|
return $this->gridDataConditions($params, $model);
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class LocksController extends AppController {
|
|||||||
function addGridViewSideMenuLinks() {
|
function addGridViewSideMenuLinks() {
|
||||||
parent::addGridViewSideMenuLinks();
|
parent::addGridViewSideMenuLinks();
|
||||||
|
|
||||||
|
$this->addSideMenuLink('List',
|
||||||
|
array('controller' => 'locks', 'action' => 'all'), null,
|
||||||
|
'CONTROLLER');
|
||||||
$this->addSideMenuLink('Add',
|
$this->addSideMenuLink('Add',
|
||||||
array('controller' => 'locks', 'action' => 'add'), null,
|
array('controller' => 'locks', 'action' => 'add'), null,
|
||||||
'CONTROLLER');
|
'CONTROLLER');
|
||||||
@@ -52,9 +55,15 @@ class LocksController extends AppController {
|
|||||||
function gridDataFields(&$params, &$model) {
|
function gridDataFields(&$params, &$model) {
|
||||||
$fields = parent::gridDataFields($params, $model);
|
$fields = parent::gridDataFields($params, $model);
|
||||||
$fields[] = 'COUNT(LocksUnit.id) AS inuse';
|
$fields[] = 'COUNT(LocksUnit.id) AS inuse';
|
||||||
|
$fields[] = 'Lock.qty - COUNT(LocksUnit.id) AS avail';
|
||||||
return $fields;
|
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) {
|
function gridDataTables(&$params, &$model) {
|
||||||
$link = $this->gridDataCountTables($params, $model);
|
$link = $this->gridDataCountTables($params, $model);
|
||||||
$link['link']['CurrentLease']['StatementEntry'] = array('fields' => array());
|
$link['link']['CurrentLease']['StatementEntry'] = array('fields' => array());
|
||||||
|
$link['link']['Lock'];
|
||||||
return $link;
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,7 +255,7 @@ class UnitsController extends AppController {
|
|||||||
$this->status($id, 'OCCUPIED');
|
$this->status($id, 'OCCUPIED');
|
||||||
|
|
||||||
// If we're not liened, we must now just be locked
|
// 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');
|
$this->status($id, 'LOCKED');
|
||||||
|
|
||||||
// Otherwise, don't change anything.
|
// Otherwise, don't change anything.
|
||||||
@@ -371,6 +372,7 @@ class UnitsController extends AppController {
|
|||||||
array('contain' =>
|
array('contain' =>
|
||||||
array(// Models
|
array(// Models
|
||||||
'UnitSize',
|
'UnitSize',
|
||||||
|
'Lock',
|
||||||
'Lease' => array('Customer'),
|
'Lease' => array('Customer'),
|
||||||
'CurrentLease' => array('Customer')
|
'CurrentLease' => array('Customer')
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
// Define the table columns
|
// Define the table columns
|
||||||
$cols = array();
|
$cols = array();
|
||||||
$cols['Name'] = array('index' => 'name', 'formatter' => 'longname');
|
$cols['Name'] = array('index' => 'name', 'formatter' => 'name');
|
||||||
$cols['Quantity'] = array('index' => 'qty', 'formatter' => 'number');
|
|
||||||
$cols['Key'] = array('index' => 'key', 'formatter' => 'shortname');
|
|
||||||
$cols['Last Key'] = array('index' => 'last_key', 'formatter' => 'shortname');
|
|
||||||
$cols['Comment'] = array('index' => 'comment', 'formatter' => 'comment');
|
$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
|
// Render the grid
|
||||||
$grid
|
$grid
|
||||||
@@ -15,4 +17,4 @@ $grid
|
|||||||
->defaultFields(array('Name'))
|
->defaultFields(array('Name'))
|
||||||
->searchFields(array('Name'))
|
->searchFields(array('Name'))
|
||||||
->render($this, isset($config) ? $config : null,
|
->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";
|
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 */
|
/* End "detail supporting" div */
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
|
|
||||||
/* End page div */
|
/* End page div */
|
||||||
echo '</div>' . "\n";
|
echo '</div>' . "\n";
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ echo '<div CLASS="detail supporting">' . "\n";
|
|||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Ledger Entries
|
* Unit Entries
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo $this->element('units', array
|
echo $this->element('units', array
|
||||||
|
|||||||
@@ -135,8 +135,3 @@ echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
|
|||||||
echo $form->end() . "\n";
|
echo $form->end() . "\n";
|
||||||
echo '</div>' . "\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'];
|
$current_lease = $unit['CurrentLease'];
|
||||||
$unit_size = $unit['UnitSize'];
|
$unit_size = $unit['UnitSize'];
|
||||||
|
|
||||||
|
if (isset($unit['Lock']))
|
||||||
|
$locks = $unit['Lock'];
|
||||||
|
|
||||||
if (isset($unit['Unit']))
|
if (isset($unit['Unit']))
|
||||||
$unit = $unit['Unit'];
|
$unit = $unit['Unit'];
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$rows[] = array('Name', $unit['name']);
|
$rows[] = array('Name', $unit['name']);
|
||||||
$rows[] = array('Status', $unit['status']);
|
$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'],
|
$rows[] = array('Size', $html->link($unit_size['name'],
|
||||||
array('controller' => 'unit_sizes',
|
array('controller' => 'unit_sizes',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
|
|||||||
Reference in New Issue
Block a user