Compare commits

..

10 Commits

Author SHA1 Message Date
Abijah
a3148cc17d Fixed bug that was using an existing entry, even when the source had been selected as new.
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1029 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-05-30 03:38:17 +00:00
Abijah
c709f0bbf5 Prevent redirection when in dev mode, so that we can see the debug output from each page
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1028 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-05-30 03:36:38 +00:00
Abijah
8faafe7f4e Fixed a very long-standing but with a unclosed <div> tag. Also forced autocomplete to OFF for the new items. I wouldn't really care, but this was causing a bug with Chrome where the autocomplete was forcing the radio buttons to be unchecked.
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1027 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-05-30 03:35:55 +00:00
Abijah
4319847665 Bug fixes that have been made since going live.
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1026 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-05-30 02:04:42 +00:00
Abijah
d22a69b510 Fix for annoying 400 error from apache on lunarpages when the requested url is a top level request without a trailing slash.
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1025 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-02-16 00:10:48 +00:00
Abijah
e9028b7558 Fixed the rebuild mechanism to run directly without scripts
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1024 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-02-16 00:09:39 +00:00
Abijah
26559f3c59 Bug fixes to work with lunarpages
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1023 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-02-15 21:04:41 +00:00
abijah
4d24428a19 First pass at conversion for lunarpages. Untested as of yet, but this checkin will allow an svn export, and I can work on the bugs then.
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1022 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-02-15 19:08:29 +00:00
abijah
15fc04e690 Branch to prepare for moving from local server to a hosted machine on the cloud
git-svn-id: file:///svn-source/pmgr/branches/hosted_migration_20130215@1021 97e9348a-65ac-dc4b-aefc-98561f571b83
2013-02-15 16:59:27 +00:00
abijah
60254860b4 Releasing fixes, most notably the jqGrid update
git-svn-id: file:///svn-source/pmgr/tags/v0.3.2@1020 97e9348a-65ac-dc4b-aefc-98561f571b83
2012-11-17 18:26:03 +00:00
24 changed files with 59 additions and 945 deletions

View File

@@ -200,9 +200,6 @@ 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');
@@ -275,25 +272,25 @@ class AppController extends Controller {
$this->addSideMenuLink('Unpaid Charges', $this->addSideMenuLink('Unpaid Charges',
array('controller' => 'statement_entries', 'action' => 'unpaid'), null, array('controller' => 'statement_entries', 'action' => 'unpaid'), null,
'REPORT'); 'REPORT');
$this->addSideMenuLink('Unit Summary',
array('controller' => 'units', 'action' => 'overview'), null,
'REPORT');
$this->addSideMenuLink('Lease Up', $this->addSideMenuLink('Lease Up',
array('controller' => 'leases', 'action' => 'overview'), null, array('controller' => 'leases', 'action' => 'overview'), null,
'REPORT'); 'REPORT');
$this->addSideMenuLink('Unit Summary',
array('controller' => 'units', 'action' => 'overview'), null,
'REPORT');
/* $this->addSideMenuLink('Monthly Income', */ /* $this->addSideMenuLink('Monthly Income', */
/* array('controller' => 'statement_entries', 'action' => 'incomebymonth'), null, */ /* array('controller' => 'statement_entries', 'action' => 'incomebymonth'), null, */
/* 'REPORT'); */ /* 'REPORT'); */
/* $this->addSideMenuLink('Monthly Expenses', */ /* $this->addSideMenuLink('Monthly Expenses', */
/* array('controller' => 'statement_entries', 'action' => 'expensebymonth'), null, */ /* array('controller' => 'statement_entries', 'action' => 'expensebymonth'), null, */
/* 'REPORT'); */ /* 'REPORT'); */
/* $this->addSideMenuLink('Quickbook Invoice', */ $this->addSideMenuLink('Quickbook Invoice',
/* array('controller' => 'statement_entries', 'action' => 'incomebymonth', 4, 1), null, */ array('controller' => 'statement_entries', 'action' => 'incomebymonth', 4, 1), null,
/* 'REPORT'); */ 'REPORT');
/* $this->addSideMenuLink('Quickbook Credits', */ $this->addSideMenuLink('Quickbook Credits',
/* array('controller' => 'statement_entries', 'action' => 'expensebymonth', 4, 0), null, */ array('controller' => 'statement_entries', 'action' => 'expensebymonth', 4, 0), null,
/* 'REPORT'); */ 'REPORT');
$this->addSideMenuLink('Monthly Income', $this->addSideMenuLink('Monthly Net',
array('controller' => 'statement_entries', 'action' => 'netbymonth'), null, array('controller' => 'statement_entries', 'action' => 'netbymonth'), null,
'REPORT'); 'REPORT');
} }
@@ -542,9 +539,6 @@ class AppController extends Controller {
// Retreive the appropriate subset of data // Retreive the appropriate subset of data
$records = $this->gridDataRecords($params, $model, $pagination); $records = $this->gridDataRecords($params, $model, $pagination);
// If subtotaling, figure out the running total before pagination...
$this->gridDataRecordsRunningSubtotal($params, $model, $pagination);
// Post process the records // Post process the records
$this->gridDataPostProcess($params, $model, $records); $this->gridDataPostProcess($params, $model, $records);
@@ -658,9 +652,6 @@ 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);
@@ -690,10 +681,6 @@ 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);
@@ -1048,53 +1035,6 @@ class AppController extends Controller {
return $model->find($type, $query); return $model->find($type, $query);
} }
function gridDataRecordsRunningSubtotal(&$params, $model, $pagination) {
// REVISIT <AP>: 20090722
// Horrible solution to something that should be done
// in SQL. Doesn't really work, but for a grid that contains
// ALL records, and is sorted on the correct field, it does
// actually work.
//
// If this function worked correctly, this mechanism would also
// work for grids that did not contain ALL records.
$subtotals = array();
foreach ($params['post']['fields'] AS $field) {
if (preg_match('/subtotal-(.*)$/', $field, $matches))
$subtotals[] = array('field' => $matches[1],
'name' => $field,
'amount' => 0);
}
// This part, if functioning, should do a sub-total off all records
// that are not part of the grid, instead of starting at zero, so that
// the totals come out correctly for the each record entry.
/* $pagination['start'] = $pagination['start'] + $pagination['limit']; */
/* $pagination['limit'] = 10000000; */
/* // Retreive the appropriate subset of data */
/* $params_copy = $params; */
/* $records = $this->gridDataRecords($params_copy, $model, $pagination); */
/* foreach ($records AS &$record) { */
/* foreach ($subtotals AS &$subtotal) { */
/* $field = $subtotal['field']; */
/* if (preg_match("/\./", $field)) { */
/* list($tbl, $col) = explode(".", $field); */
/* $record['subtotal-'.$tbl][$col] = */
/* ($subtotal['amount'] += $record[$tbl][$col]); */
/* } */
/* else { */
/* $record[$model->alias]['subtotal-'.$field] = */
/* ($subtotal['amount'] += $record[$model->alias][$field]); */
/* } */
/* } */
/* } */
$params['subtotals'] = $subtotals;
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
@@ -1145,11 +1085,15 @@ class AppController extends Controller {
// REVISIT <AP>: 20090722 // REVISIT <AP>: 20090722
// Horrible solution to something that should be done // Horrible solution to something that should be done
// in SQL. Doesn't really work, but for a grid that contains // in SQL. But, it works for now, so what the heck...
// ALL records, and is sorted on the correct field, it does
// actually work.
$subtotals = $params['subtotals']; $subtotals = array();
foreach ($params['post']['fields'] AS $field) {
if (preg_match('/subtotal-(.*)$/', $field, $matches))
$subtotals[] = array('field' => $matches[1],
'name' => $field,
'amount' => 0);
}
foreach ($records AS &$record) { foreach ($records AS &$record) {
foreach ($subtotals AS &$subtotal) { foreach ($subtotals AS &$subtotal) {

View File

@@ -334,6 +334,15 @@ class LeasesController extends AppController {
* - Closes a lease to any further action * - Closes a lease to any further action
*/ */
// REVISIT <AP>: 20090809
// While cleaning up the sitelink data, then delete reldep()
function reldep($id) {
$this->Lease->id = $id;
$stamp = $this->Lease->field('moveout_date');
$this->Lease->releaseSecurityDeposits($id, $stamp);
$this->redirect(array('action'=>'view', $id));
}
function close($id) { function close($id) {
// REVISIT <AP>: 20090708 // REVISIT <AP>: 20090708
// We should probably seek confirmation first... // We should probably seek confirmation first...
@@ -346,21 +355,6 @@ class LeasesController extends AppController {
$this->redirect(array('action'=>'view', $id)); $this->redirect(array('action'=>'view', $id));
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* action: open
* - Re-opens a lease for further action
*/
function open($id) {
// REVISIT <AP>: 20131204
// We should probably seek confirmation first, since this wipes out
// the old close date, with no way to restore that date.
$this->Lease->reopen($id);
$this->redirect(array('action'=>'view', $id));
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
@@ -580,18 +574,13 @@ class LeasesController extends AppController {
$this->addSideMenuLink('Write-Off', $this->addSideMenuLink('Write-Off',
array('action' => 'bad_debt', $id), null, array('action' => 'bad_debt', $id), null,
'ACTION'); 'ACTION');
if ($this->Lease->closeable($id))
$this->addSideMenuLink('Close',
array('action' => 'close', $id), null,
'ACTION');
} }
if ($this->Lease->closeable($id))
$this->addSideMenuLink('Close',
array('action' => 'close', $id), null,
'ACTION');
if ($this->Lease->isClosed($id))
$this->addSideMenuLink('Re-Open',
array('action' => 'open', $id), null,
'ACTION');
// Prepare to render // Prepare to render
$title = 'Lease: #' . $lease['Lease']['id']; $title = 'Lease: #' . $lease['Lease']['id'];
$this->set(compact('lease', 'title', $this->set(compact('lease', 'title',

View File

@@ -1,216 +0,0 @@
<?php
class LocksController extends AppController {
/**************************************************************************
**************************************************************************
**************************************************************************
* override: addGridViewSideMenuLinks
* - Adds grid view navigation side menu links
*/
function addGridViewSideMenuLinks() {
parent::addGridViewSideMenuLinks();
$this->addSideMenuLink('List',
array('controller' => 'locks', 'action' => 'all'), null,
'CONTROLLER');
$this->addSideMenuLink('Add',
array('controller' => 'locks', 'action' => 'add'), null,
'CONTROLLER');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: index / all
* - Generate a listing of locks
*/
function index() { $this->all(); }
function all() { $this->gridView('Locks', 'all'); }
/**************************************************************************
**************************************************************************
**************************************************************************
* virtuals: gridData
* - With the application controller handling the gridData action,
* these virtual functions ensure that the correct data is passed
* to jqGrid.
*/
/* function gridDataCountTables(&$params, &$model) { */
/* return array('link' => array('Unit')); */
/* } */
function gridDataTables(&$params, &$model) {
$tables = parent::gridDataTables($params, $model);
$tables['link']['LocksUnit'] = array();
return $tables;
}
function gridDataFields(&$params, &$model) {
$fields = parent::gridDataFields($params, $model);
$fields[] = 'COUNT(LocksUnit.id) AS inuse';
$fields[] = 'IF(Lock.qty > COUNT(LocksUnit.id), Lock.qty - COUNT(LocksUnit.id), 0) AS avail';
return $fields;
}
function gridDataPostProcessLinks(&$params, &$model, &$records, $links) {
$links['Lock'] = array('name');
return parent::gridDataPostProcessLinks($params, $model, $records, $links);
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: view
* - Displays information about a specific entry
*/
function view($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('controller' => 'locks', 'action'=>'index'));
}
// Get the lock and related fields
$this->Lock->id = $id;
$lock = $this->Lock->find
('first', array
('contain' => array(),
));
//$lock['Lock'] = $lock[0] + $lock['lock'];
//unset($lock[0]);
$this->addSideMenuLink('Edit',
array('action' => 'edit', $id), null,
'ACTION');
$this->addSideMenuLink('Delete',
array('action' => 'delete', $id), null,
'ACTION');
$this->set(compact('lock'));
// Prepare to render.
$title = "Lock : {$lock['Lock']['name']}";
$this->set(compact('title'));
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: edit
* - Edit customer information
*/
function edit($id = null) {
if (isset($this->data)) {
// Check to see if the operation was cancelled.
if (isset($this->params['form']['cancel'])) {
if (isset($this->data['Lock']['id']))
$this->redirect(array('action'=>'view', $this->data['Lock']['id']));
$this->redirect(array('action'=>'index'));
}
// Save the lock and all associated data
if (!$this->Lock->saveLock($this->data)) {
$this->Session->setFlash("LOCK SAVE FAILED", true);
pr("LOCK SAVE FAILED");
}
// View the lock by redirect
$this->redirect(array('action'=>'view', $this->Lock->id));
}
if ($id) {
// Get details on this customer, its contacts and leases
$lock = $this->Lock->find
('first', array
('conditions' => array('Lock.id' => $id),
));
$this->data = $lock;
$title = 'Lock: ' . $this->data['Lock']['name'] . " : Edit";
}
else {
$title = "Enter New Lock Information";
$this->data = array();
}
// Prepare to render.
//pr($this->data);
$this->set(compact('title'));
$this->render('edit');
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: add
* - Add a new lock
*/
function add() {
$this->edit();
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: delete
* - Deletes an old lock
*/
function delete($id) {
if (isset($this->data)) {
// Check to see if the operation was cancelled.
if (isset($this->params['form']['cancel'])) {
if (isset($this->data['Lock']['id']))
$this->redirect(array('action'=>'view', $this->data['Lock']['id']));
$this->redirect(array('action'=>'index'));
}
// Delete the lock and all associated data
if (!$this->Lock->destroy($this->data['Lock']['id'])) {
$this->Session->setFlash(__('Failed to delete lock.', true));
$this->redirect(array('action'=>'view', $this->data['Lock']['id']));
}
// It's gone. Go back to the list of locks
$this->redirect(array('controller' => 'locks', 'action'=>'index'));
}
// User must specify an ID.
if (!$id) {
$this->Session->setFlash(__('Invalid Item.', true));
$this->redirect(array('controller' => 'locks', 'action'=>'index'));
}
// Get the lock and related fields
$this->Lock->id = $id;
$lock = $this->Lock->find
('first', array
('contain' => array('Unit'),
));
// Make sure the lock isn't in use.
if (isset($lock['Unit']) && count($lock['Unit']) > 0) {
$this->Session->setFlash(__('Lock currently on units. Cannot be deleted!', true));
$this->redirect(array('action'=>'view', $id));
}
// Prepare to render.
$this->data = $lock;
$title = "Delete Lock : {$lock['Lock']['name']}";
$this->set(compact('title'));
}
}

View File

@@ -93,8 +93,7 @@ class TransactionsController extends AppController {
$fields[] = ("IF(Transaction.type = 'DEPOSIT'," . $fields[] = ("IF(Transaction.type = 'DEPOSIT'," .
" COUNT(DepositTender.id)," . " COUNT(DepositTender.id)," .
" COUNT(StatementEntry.id)) AS entries"); " COUNT(StatementEntry.id)) AS entries");
return array_merge($fields, return $fields;
$this->Transaction->LedgerEntry->debitCreditFields(false, true, 'Transaction'));
} }
function gridDataConditions(&$params, &$model) { function gridDataConditions(&$params, &$model) {

View File

@@ -83,7 +83,6 @@ 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;
} }
@@ -214,7 +213,7 @@ class UnitsController extends AppController {
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************
* action: lock/unlock/lien * action: lock/unlock
* - Transitions the unit into / out of the LOCKED state * - Transitions the unit into / out of the LOCKED state
*/ */
@@ -222,73 +221,8 @@ class UnitsController extends AppController {
$this->Unit->updateStatus($id, $status, true); $this->Unit->updateStatus($id, $status, true);
$this->redirect(array('action' => 'view', $id)); $this->redirect(array('action' => 'view', $id));
} }
function lock($id) { $this->status($id, 'LOCKED'); }
function lock($id) { function unlock($id) { $this->status($id, 'OCCUPIED'); }
if (isset($this->data)) {
$id = $this->id = $this->data['Unit']['id'];
// Check to see if the operation was cancelled.
if (isset($this->params['form']['cancel'])) {
if (isset($id))
$this->redirect(array('action'=>'view', $id));
$this->redirect(array('action'=>'index'));
}
// Figure out which locks the user put on
$locks = array();
if (isset($this->data['Lock']) && is_array($this->data['Lock'])) {
foreach ($this->data['Lock'] AS $lock) {
$locks[] = $lock['id'];
}
}
// Save the lock and all associated data
if (!$this->Unit->lockUnit($id, $locks)) {
$this->Session->setFlash("UNIT LOCK FAILED", true);
pr("UNIT LOCK FAILED");
}
// If it's no longer locked, change status to OCCUPIED
// Could still be liened... but that would be odd.
if (count($locks) == 0)
$this->status($id, 'OCCUPIED');
// If we're not liened, we must now just be locked
if (!$this->Unit->liened(intval($id)))
$this->status($id, 'LOCKED');
// Otherwise, don't change anything.
$this->redirect(array('action' => 'view', $id));
}
if (!$id)
$this->INTERNAL_ERROR("$id cannot be NULL");
// Get all locks on this unit
$this->data = $this->Unit->find
('first',
array('contain' => array('Lock' => array('id')),
'fields' => array('id', 'name'),
'conditions' => array('Unit.id' => $id)
));
$locks = $this->Unit->Lock->lockList();
/* $locksold = $locks; */
/* foreach ($locksold AS $name) { */
/* $locks[$name] = $name; */
/* } */
$this->set(compact('locks'));
// Prepare to render.
//pr($this->data);
$this->set(compact('title'));
// $this->render('lock');
}
function unlock($id) { $this->lock($id); }
function lien($id) { $this->status($id, 'LIENED'); }
/************************************************************************** /**************************************************************************
@@ -372,7 +306,6 @@ 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')
), ),
@@ -398,16 +331,23 @@ class UnitsController extends AppController {
$outstanding_deposit = $this->Unit->Lease->securityDepositBalance($unit['CurrentLease']['id']); $outstanding_deposit = $this->Unit->Lease->securityDepositBalance($unit['CurrentLease']['id']);
} }
// Add a mechanism to lock ANY unit, regardless of status // If the unit is occupied, but not locked, provide a
$this->addSideMenuLink($this->Unit->lockCount($id) == 0 ? 'Lock' : 'Relock/Unlock', // mechanism to do so. This doesn't have to be restricted
array('action' => 'lock', $id), null, // to past due customers. There are times we need to
'ACTION'); // overlock customers in good standing, such as if their
// lock breaks, is cut, or missing for any reason.
if ($this->Unit->occupied($unit['Unit']['status']) &&
!$this->Unit->locked($unit['Unit']['status']))
$this->addSideMenuLink('Lock',
array('action' => 'Lock', $id), null,
'ACTION');
// If the unit is locked, but not liened, give option to lien. // If the unit is locked, provide an option to unlock it,
// unless it's locked due to lien, which is not so simple.
if ($this->Unit->locked($unit['Unit']['status']) && if ($this->Unit->locked($unit['Unit']['status']) &&
!$this->Unit->liened($unit['Unit']['status'])) !$this->Unit->liened($unit['Unit']['status']))
$this->addSideMenuLink('Lien', $this->addSideMenuLink('Unlock',
array('action' => 'lien', $id), null, array('action' => 'unlock', $id), null,
'ACTION'); 'ACTION');
// If there is a current lease on this unit, then provide // If there is a current lease on this unit, then provide

View File

@@ -728,53 +728,6 @@ class Lease extends AppModel {
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* function: reopen
* - Re-Opens the lease for further action
*/
function reopen($id) {
$this->prEnter(compact('id'));
if (!$this->isClosed($id))
return $this->prReturn(false);
// Reset the data
$this->create();
$this->id = $id;
// Set the close date
$this->data['Lease']['close_date'] = null;
// Save it!
$this->save($this->data, false);
// Update the current lease count for the customer
$this->Customer->updateLeaseCount($this->field('customer_id'));
return $this->prReturn(true);
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: isClosed
* - Checks to see if the lease is closed
*/
function isClosed($id) {
$this->prEnter(compact('id'));
$this->recursive = -1;
$this->read(null, $id);
return $this->prReturn(!empty($this->data['Lease']['close_date']));
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************

View File

@@ -1,110 +0,0 @@
<?php
class Lock extends AppModel {
var $name = 'Lock';
var $validate = array(
'id' => array('numeric'),
'name' => array('notempty'),
'key' => array('notempty')
);
var $hasMany = array(
'LocksUnits'
);
var $hasAndBelongsToMany = array(
'Unit'
);
var $default_log_level = array('log' => 30, 'show' => 15);
/**************************************************************************
**************************************************************************
**************************************************************************
* function: saveLock
* - save data about a new or existing lock
*/
function saveLock($data) {
$this->prEnter(compact('data'));
$id = $data['Lock']['id'];
if ($id) {
$this->id = $id;
// Save the old key
$oldkey = $this->field('key');
$this->pr(5, compact('oldkey'));
if ($this->field('key') != $data['Lock']['key']) {
$data['Lock']['key_last'] = $this->field('key');
$data['Lock']['key_ts'] = date('Y-m-d G:i:s');
}
/* // Find the number of outstanding locks in use */
/* $locks = $this->find('first', */
/* array('link' => array('Unit' => array('fields' => array('Unit.id'))), */
/* 'fields' => 'SUM(Unit.id) AS inuse', */
/* 'conditions' => array('Lock.id' => $id), */
/* )); */
/* $this->pr(5, compact('locks')); */
/* // Can't reduce the locks if there are all in use */
/* if ($locks[0]['inuse'] > $data['Lock']['qty']) */
/* return $this->prReturn(false); */
}
else {
// Brand new lock
}
if (!$data['Lock']['qty'])
$data['Lock']['qty'] = 1;
// Everything looks good... save it!
return $this->prReturn($this->save($data, false));
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: destroy
* - destroys a lock
*/
function destroy($id) {
$this->prEnter(compact('id'));
// Can't delete a lock that's in use... check.
$this->id = $id;
$lock = $this->find
('first', array
('contain' => array('Unit'),
));
// If it's in use, bail with error
$this->pr(1, $lock);
if (isset($lock['Unit']) && count($lock['Unit']) > 0)
return $this->prReturn(false);
// Otherwise, attempt to delete the lock from the database
return $this->prReturn($this->delete());
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: lockList
* - list of all locks in the system
*/
function lockList() {
return $this->find('list',
array('order' =>
array('name'),
));
}
}

View File

@@ -1,11 +0,0 @@
<?php
class LocksUnit extends AppModel {
var $primaryKey = false;
var $belongsTo = array(
'Lock',
'Unit',
);
}
?>

View File

@@ -25,11 +25,6 @@ class Unit extends AppModel {
var $hasMany = array( var $hasMany = array(
'Lease', 'Lease',
'LocksUnit'
);
var $hasAndBelongsToMany = array(
'Lock'
); );
//var $default_log_level = array('log' => 30, 'show' => 15); //var $default_log_level = array('log' => 30, 'show' => 15);
@@ -214,57 +209,6 @@ class Unit extends AppModel {
} }
/**************************************************************************
**************************************************************************
**************************************************************************
* function: lockUnit
* - Put lock on unit
*/
function lockUnit($id, $lock_ids) {
$this->prEnter(compact('id', 'lock_ids'));
$this->id = $id;
// Remove any exising locks for this unit
$this->LocksUnit->deleteAll
(array('unit_id' => $id), false);
// We'll proceed forward as much as possible, even
// if we encounter an error. For now, we'll assume
// the operation will succeed.
$ret = true;
// Go through each lock, and put them on the unit
foreach ($lock_ids AS $lock_id) {
$pair['unit_id'] = $id;
$pair['lock_id'] = $lock_id;
// Save the relationship between lock and unit
$LU = new LocksUnit();
if (!$LU->save($pair, false))
$ret = false;
}
return $this->prReturn($ret);
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: lockCount
* - Number of locks on a unit
*/
function lockCount($id) {
$this->prEnter(compact('id'));
return $this->prReturn($this->find
('count', array
('fields' => array("COUNT(Lock.id) AS count"),
'link' => array('Lock'),
'conditions' => array('Unit.id' => $id),
)));
}
/************************************************************************** /**************************************************************************
************************************************************************** **************************************************************************
************************************************************************** **************************************************************************

View File

@@ -301,7 +301,7 @@ echo $this->element('customers', array
), ),
'action' => 'current', 'action' => 'current',
'nolinks' => true, 'nolinks' => true,
'limit' => 20, 'limit' => 10,
))); )));
echo ('<DIV CLASS="receipt grid-selection-text">' . echo ('<DIV CLASS="receipt grid-selection-text">' .

View File

@@ -157,14 +157,13 @@ echo $this->element('contacts', array
/********************************************************************** /**********************************************************************
* Customer Statement History * Customer Account History
*/ */
echo $this->element('statement_entries', array echo $this->element('statement_entries', array
(// Grid configuration (// Grid configuration
'config' => array 'config' => array
('caption' => 'Customer Statement', ('caption' => 'Customer Statement',
'grid_setup' => array('hiddengrid' => true),
'filter' => array('Customer.id' => $customer['Customer']['id'], 'filter' => array('Customer.id' => $customer['Customer']['id'],
'type !=' => 'VOID'), 'type !=' => 'VOID'),
//'include' => array('Sub-Total'), //'include' => array('Sub-Total'),
@@ -172,28 +171,6 @@ echo $this->element('statement_entries', array
))); )));
/**********************************************************************
* Customer Transaction History
*/
echo $this->element('transactions', array
(// Grid configuration
'config' => array
('caption' => 'Balance History',
'limit' => 10000,
'limitOptions' => array('10000'),
'sort_column' => 'Timestamp',
'sort_order' => 'ASC',
'grid_setup' => array('hiddengrid' => true),
'filter' => array('Customer.id' => $customer['Customer']['id']),
'include' => array('Comment', 'PosNeg', 'Balance'),
'exclude' => array('Amount', 'Entries'),
'remap' => array(//'ID' => 'Invoice',
'PosNeg' => 'Amount',
//'Entries' => 'Charges',
),
)));
/* End "detail supporting" div */ /* End "detail supporting" div */
echo '</div>' . "\n"; echo '</div>' . "\n";

View File

@@ -2,7 +2,6 @@
// Define the table columns // Define the table columns
$cols = array(); $cols = array();
$cols['Customer'] = array('index' => 'Customer.id', 'formatter' => 'id');
$cols['Relationship'] = array('index' => 'ContactsCustomer.type', 'formatter' => 'enum'); $cols['Relationship'] = array('index' => 'ContactsCustomer.type', 'formatter' => 'enum');
$cols['Name'] = array('index' => 'Customer.name', 'formatter' => 'longname'); $cols['Name'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'formatter' => 'name'); $cols['Last Name'] = array('index' => 'PrimaryContact.last_name', 'formatter' => 'name');

View File

@@ -113,7 +113,7 @@ foreach ($fields AS $field => $config) {
if (isset($config['with_value_after'])) if (isset($config['with_value_after']))
$value = $value . $config['with_value_after']; $value = $value . $config['with_value_after'];
elseif (isset($with_value_after)) elseif (isset($with_value_after))
$value = $value . $with_value_after; $value = $valeu . $with_value_after;
$cells[] = $value; $cells[] = $value;
if ($include_after) { if ($include_after) {

View File

@@ -130,12 +130,12 @@ foreach ($jqGridColumns AS $header => &$col) {
elseif ($col['formatter'] === 'currency') { elseif ($col['formatter'] === 'currency') {
// Use our custom formatting for currency // Use our custom formatting for currency
$col['formatter'] = array('--special' => 'currencyFormatter'); $col['formatter'] = array('--special' => 'currencyFormatter');
$default['width'] = 65; $default['width'] = 85;
$default['align'] = 'right'; $default['align'] = 'right';
} }
elseif ($col['formatter'] === 'date') { elseif ($col['formatter'] === 'date') {
$default['formatoptions'] = array('newformat' => 'm/d/Y'); $default['formatoptions'] = array('newformat' => 'm/d/Y');
$default['width'] = 90; $default['width'] = 95;
$default['align'] = 'center'; $default['align'] = 'center';
} }
elseif (preg_match("/^(long|short)?name$/", elseif (preg_match("/^(long|short)?name$/",

View File

@@ -1,20 +0,0 @@
<?php /* -*- mode:PHP -*- */
// Define the table columns
$cols = array();
$cols['Name'] = array('index' => 'name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'comment', 'formatter' => 'comment');
$cols['Key/Combo'] = array('index' => 'key', 'formatter' => 'number');
$cols['Previous Key'] = array('index' => 'key_last', '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
->columns($cols)
->sortField('Name')
->defaultFields(array('Name'))
->searchFields(array('Name'))
->render($this, isset($config) ? $config : null,
array_diff(array_keys($cols), array('Previous Key')));

View File

@@ -5,7 +5,7 @@ $cols = array();
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); $cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Item'] = array('index' => 'Tender.name', 'formatter' => 'longname'); $cols['Item'] = array('index' => 'Tender.name', 'formatter' => 'longname');
$cols['Type'] = array('index' => 'TenderType.name', 'formatter' => 'shortname'); $cols['Type'] = array('index' => 'TenderType.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'Tender.comment', 'formatter' => 'comment'); $cols['Comment'] = array('index' => 'Tender.comment', 'formatter' => 'comment');
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency'); $cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
$cols['Sub-Total'] = array('index' => 'subtotal-LedgerEntry.amount', 'formatter' => 'currency'); $cols['Sub-Total'] = array('index' => 'subtotal-LedgerEntry.amount', 'formatter' => 'currency');

View File

@@ -11,11 +11,9 @@ $cols['ID'] = array('index' => 'Transaction.id', 'formatter' =
$cols['Type'] = array('index' => 'Transaction.type', 'formatter' => 'enum'); $cols['Type'] = array('index' => 'Transaction.type', 'formatter' => 'enum');
$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); $cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment', 'sortable' => false);
$cols['Entries'] = array('index' => 'entries', 'formatter' => 'number'); $cols['Entries'] = array('index' => 'entries', 'formatter' => 'number');
$cols['Amount'] = array('index' => 'Transaction.amount', 'formatter' => 'currency'); $cols['Amount'] = array('index' => 'Transaction.amount', 'formatter' => 'currency');
$cols['PosNeg'] = array('index' => 'balance', 'formatter' => 'currency'); $cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment');
$cols['Balance'] = array('index' => 'subtotal-balance', 'formatter' => 'currency', 'sortable' => false);
// Render the grid // Render the grid
$grid $grid
@@ -24,4 +22,4 @@ $grid
->defaultFields(array('ID', 'Timestamp')) ->defaultFields(array('ID', 'Timestamp'))
->searchFields(array('Type', 'Comment')) ->searchFields(array('Type', 'Comment'))
->render($this, isset($config) ? $config : null, ->render($this, isset($config) ? $config : null,
array_merge($include, array_diff(array_keys($cols), array('Customer', 'PosNeg', 'Balance', 'Comment')))); array_merge($include, array_diff(array_keys($cols), array('Customer', 'Comment'))));

View File

@@ -1,18 +0,0 @@
<?php /* -*- mode:PHP -*- */
; // alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Lock Delete
*/
echo '<div class="lock delete">' . "\n";
echo $form->create('Lock', array('action' => 'delete')) . "\n";
echo $form->input('id') . "\n";
echo $form->submit('Delete Lock') . "\n";
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
echo $form->end() . "\n";
echo '</div>' . "\n";

View File

@@ -1,48 +0,0 @@
<?php /* -*- mode:PHP -*- */
//pr($this->data);
?>
<script type="text/javascript"><!--
// Reset the form
function newKey(dig) {
$('#LockKey').val(("000000000" + Math.floor(Math.random()*(Math.pow(10,dig)))) . slice(-1*dig));
}
--></script>
<?php
; // alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Lock Edit
*/
echo '<div class="lock edit">' . "\n";
echo $form->create('Lock', array('action' => 'edit')) . "\n";
echo $form->input('id') . "\n";
echo($this->element
('form_table',
array('class' => 'item lock detail',
'caption' => isset($this->data['Lock']) ? 'Edit Lock' : 'New Lock',
'fields' => array
('name' => array('label_attributes' => array('class' => 'empty'),
'after' => ("Name of the Lock Set")),
'qty' => array('label_attributes' => array('class' => 'empty'),
'after' => ("Quantity")),
'key' => array('label_attributes' => array('class' => 'empty'),
'after' => ('(<A HREF="#" ONCLICK="newKey(4); return false;">New</A>) Key Code / Combination')),
'comment' => array('label_attributes' => array('class' => 'optional empty'),
'after' => 'Optional: Comments about this lock set.'),
))) . "\n");
echo $form->submit(isset($this->data['Lock']) ? 'Update' : 'Add New Lock') . "\n";
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
echo $form->end() . "\n";
echo '</div>' . "\n";

View File

@@ -1,60 +0,0 @@
<?php /* -*- mode:PHP -*- */
echo '<div class="lock view">' . "\n";
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Lock Detail Main Section
*/
$lock = $lock['Lock'];
$rows = array();
$rows[] = array('Name', $lock['name']);
if ($lock['qty'] > 1)
$rows[] = array('Quantity', $lock['qty']);
$rows[] = array('Key', $lock['key']);
if (!empty($lock['key_last'])) {
$rows[] = array('Previous Key', $lock['key_last'] . " (Changed on " . FormatHelper::datetime($lock['key_ts']) . ")");
}
$rows[] = array('Comment', $lock['comment']);
echo $this->element('table',
array('class' => 'item lock detail',
'caption' => 'Lock Information',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
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";

View File

@@ -64,7 +64,6 @@ else {
'config' => array 'config' => array
( (
'caption' => 'Deposited Items', 'caption' => 'Deposited Items',
'sort_column' => 'Item',
'filter' => array('deposit_transaction_id' 'filter' => array('deposit_transaction_id'
=> $deposit['Transaction']['id'], => $deposit['Transaction']['id'],
), ),

View File

@@ -68,7 +68,7 @@ echo '<div CLASS="detail supporting">' . "\n";
/********************************************************************** /**********************************************************************
* Unit Entries * Ledger Entries
*/ */
echo $this->element('units', array echo $this->element('units', array

View File

@@ -1,132 +0,0 @@
<?php /* -*- mode:PHP -*- */
/**********************************************************************
* Because we make use of functions here,
* we need to put our top level variables somewhere
* we can access them.
*/
$this->varstore = compact('locks');
function lockDiv($obj) {
$div =
// BEGIN lock-div
'<DIV>' . "\n" .
// BEGIN lock-fieldset
'<FIELDSET CLASS="lock subset">' . "\n" .
'<LEGEND>Lock #%{id} (%{remove})</LEGEND>' . "\n" .
// BEGIN lock-n-div
'<div id="lock-%{id}-div">' . "\n" .
$obj->element
('form_table',
array('class' => "item lock entry",
'field_prefix' => 'Lock.%{id}',
'fields' => array
(
'id' => array('name' => 'Select Lock',
'opts' => array('options' => $obj->varstore['locks'])),
))) . "\n" .
// END lock-n-div
'</div>' . "\n" .
// END lock-fieldset
'</FIELDSET>' . "\n" .
// END lock-div
'</DIV>'
;
return $div;
}
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Javascript
*/
?>
<script type="text/javascript"><!--
function addLock(flash) {
addDiv('lock-entry-id', 'lock', 'locks', flash, <?php
echo FormatHelper::phpVarToJavascript
(lockDiv($this),
null,
' ');
?>
);
}
// Reset the form
function resetForm() {
$('#locks').html('');
$('#lock-entry-id').val(1);
<?php foreach ($this->data['Lock'] AS $lock): ?>
addDiv('lock-entry-id', 'lock', 'locks', false, <?php
echo FormatHelper::phpVarToJavascript
(lockDiv($this),
null,
' ');
?>
);
$('#Lock'+($('#lock-entry-id').val()-1)+'Id').val(<?php echo $lock['id'] ?>);
<?php endforeach; ?>
if ($("#lock-entry-id").val() == 1) {
addDiv('lock-entry-id', 'lock', 'locks', false, <?php
echo FormatHelper::phpVarToJavascript
(lockDiv($this),
null,
' ');
?>
);
}
}
$(document).ready(function(){
resetForm();
});
--></script>
<?php
; // alignment
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Unit-Lock Edit
*/
echo '<div class="unit-lock edit">' . "\n";
echo $form->create('Unit', array('action' => 'lock')) . "\n";
echo $form->hidden('id') . "\n";
?>
<div CLASS="dynamic-set">
<h3>Set Locks on Unit <?php echo $this->data['Unit']['name']; ?></h3>
<input type="hidden" id="lock-entry-id" value="0">
<div id="locks"></div>
<fieldset> <legend>
<a href="#" onClick="addLock(true); return false;">Add a Lock</a>
</legend> </fieldset>
</div>
<?php
; // Alignment
echo $form->submit('Update Locks') . "\n";
echo $form->submit('Cancel', array('name' => 'cancel')) . "\n";
echo $form->end() . "\n";
echo '</div>' . "\n";

View File

@@ -13,25 +13,12 @@ $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',