Cleaned up the controllers and now make use of the Linkable behavior for listing out items.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@53 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -4,6 +4,7 @@ class ContactsController extends AppController {
|
||||
var $helpers = array('Html');
|
||||
|
||||
var $paginate = array('limit' => 100,
|
||||
'group' => 'Contact.id',
|
||||
'order' => array('Contact.last_name' => 'ASC',
|
||||
'Contact.first_name' => 'ASC'));
|
||||
|
||||
@@ -46,13 +47,21 @@ class ContactsController extends AppController {
|
||||
*/
|
||||
|
||||
function tenants() {
|
||||
$this->Contact->recursive = 0;
|
||||
$this->Contact->bindModel(array('hasOne' => array('ContactsLease')),
|
||||
false);
|
||||
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'Lease' =>
|
||||
array('fields' => array(),
|
||||
'type' => 'INNER',
|
||||
),
|
||||
),
|
||||
'conditions' => array('ContactsLease.type !=' => 'ALTERNATE')
|
||||
));
|
||||
|
||||
$title = 'All Tenants';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('contacts', $this->paginate(array('ContactsLease.type != "ALTERNATE"')));
|
||||
$this->set('contacts', $this->paginate());
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
@@ -65,18 +74,22 @@ class ContactsController extends AppController {
|
||||
*/
|
||||
|
||||
function current() {
|
||||
$this->Contact->recursive = 0;
|
||||
$this->Contact->bindModel(array('hasOne' => array('ContactsLease',
|
||||
'Lease' => array(
|
||||
'foreignKey' => false,
|
||||
'conditions' => array('Lease.id = ContactsLease.lease_id')
|
||||
))),
|
||||
false);
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'Lease' =>
|
||||
array('fields' => array(),
|
||||
'type' => 'INNER',
|
||||
),
|
||||
),
|
||||
'conditions' => array('ContactsLease.type !=' => 'ALTERNATE',
|
||||
'Lease.close_date IS NULL')
|
||||
));
|
||||
|
||||
$title = 'Current Tenants';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('contacts', $this->paginate(array('Lease.close_date IS NULL',
|
||||
'ContactsLease.type != "ALTERNATE"')));
|
||||
$this->set('contacts', $this->paginate());
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
@@ -89,124 +102,22 @@ class ContactsController extends AppController {
|
||||
*/
|
||||
|
||||
function past() {
|
||||
/* $this->Contact->contain */
|
||||
/* (array(// Models */
|
||||
/* 'ContactPhone', */
|
||||
/* 'ContactEmail', */
|
||||
/* 'ContactAddress', */
|
||||
/* 'Lease' => */
|
||||
/* array('order' => 'movein_date', */
|
||||
/* 'conditions' => array('Lease.close_date IS NOT NULL', */
|
||||
/* 'ContactsLease.type !=' => 'ALTERNATE'), */
|
||||
/* // Models */
|
||||
/* 'Unit' => */
|
||||
/* array('order' => array('sort_order'), */
|
||||
/* 'fields' => array('id', 'name'), */
|
||||
/* ), */
|
||||
/* /\* 'Charge' => *\/ */
|
||||
/* /\* array('order' => array('charge_date'), *\/ */
|
||||
/* /\* // Models *\/ */
|
||||
/* /\* 'ChargeType', *\/ */
|
||||
/* /\* 'Receipt', *\/ */
|
||||
/* /\* ) *\/ */
|
||||
/* ) */
|
||||
/* ) */
|
||||
/* ); */
|
||||
|
||||
/* $contact = $this->Contact->find('all', */
|
||||
/* array('order' => 'id DESC', */
|
||||
/* 'conditions' => array('Lease.id IS NOT NULL'), */
|
||||
/* 'contain' => */
|
||||
/* array( */
|
||||
/* // Models */
|
||||
/* 'Lease' => */
|
||||
/* array('order' => 'movein_date', */
|
||||
/* 'conditions' => array('Lease.lease_date IS NOT NULL', */
|
||||
/* 'Lease.close_date IS NOT NULL', */
|
||||
/* 'ContactsLease.type !=' => 'ALTERNATE'), */
|
||||
/* ) */
|
||||
/* ) */
|
||||
/* )); */
|
||||
|
||||
/* $contacts = $this->Contact->find */
|
||||
/* ('all', array */
|
||||
/* ('contain' => array */
|
||||
/* ('Lease' => array */
|
||||
/* ('conditions' => array('lease_date >' => "2009-04-01"), */
|
||||
/* ) */
|
||||
/* ), */
|
||||
/* 'order' => 'id DESC', */
|
||||
/* 'conditions' => array('Lease.id IS NOT NULL') */
|
||||
/* )); */
|
||||
|
||||
/* $contacts = $this->Contact->find('all', */
|
||||
/* array('order' => 'id DESC', */
|
||||
/* 'contain' => 'Lease.lease_date > "2009-04-01"' */
|
||||
/* )); */
|
||||
/* pr($contacts); */
|
||||
/* $this->set('contacts', $contacts); */
|
||||
|
||||
/* $this->Contact->Behaviors->attach('Containable'); */
|
||||
/* $this->Contact->contain */
|
||||
/* (array(// Models */
|
||||
/* 'ContactPhone', */
|
||||
/* 'ContactEmail', */
|
||||
/* 'ContactAddress', */
|
||||
/* 'Lease' => */
|
||||
/* array('order' => 'movein_date', */
|
||||
/* 'conditions' => array('Lease.close_date IS NOT NULL', */
|
||||
/* 'ContactsLease.type !=' => 'ALTERNATE'), */
|
||||
/* // Models */
|
||||
/* 'Unit' => */
|
||||
/* array('order' => array('sort_order'), */
|
||||
/* 'fields' => array('id', 'name'), */
|
||||
/* ), */
|
||||
/* /\* 'Charge' => *\/ */
|
||||
/* /\* array('order' => array('charge_date'), *\/ */
|
||||
/* /\* // Models *\/ */
|
||||
/* /\* 'ChargeType', *\/ */
|
||||
/* /\* 'Receipt', *\/ */
|
||||
/* /\* ) *\/ */
|
||||
/* ) */
|
||||
/* ) */
|
||||
/* ); */
|
||||
|
||||
|
||||
$this->paginate =
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'ContactPhone' => array('fields' => array('phone'),
|
||||
//'type' => 'INNER'
|
||||
),
|
||||
//'ContactEmail',
|
||||
//'ContactAddress',
|
||||
'Lease' =>
|
||||
array('fields' => array(),
|
||||
'type' => 'LEFT',
|
||||
// Models
|
||||
'Unit' => array('fields' => array('name'),
|
||||
//'type' => 'INNER',
|
||||
),
|
||||
)
|
||||
),
|
||||
'order' => 'Contact.last_name, Contact.first_name',
|
||||
'conditions' => array(//'ContactsLease.type !=' => 'ALTERNATE',
|
||||
//'Lease.id IS NOT NULL',
|
||||
//'Lease.lease_date IS NOT NULL',
|
||||
//'Lease.close_date IS NOT NULL'
|
||||
),
|
||||
'group' => 'Contact.id',
|
||||
'fields' => array('id', 'first_name', 'last_name', 'company_name', 'comment'),
|
||||
);
|
||||
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'Lease' =>
|
||||
array('fields' => array(),
|
||||
'type' => 'INNER',
|
||||
),
|
||||
),
|
||||
'conditions' => array('ContactsLease.type !=' => 'ALTERNATE',
|
||||
'Lease.close_date IS NOT NULL')
|
||||
));
|
||||
|
||||
$title = 'Past Tenants';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('contacts', $this->paginate());
|
||||
//$this->set('contacts', $this->Contact->find('all', array('order' => 'id DESC')));
|
||||
//$this->set('contacts', $this->Contact->find('all'));
|
||||
/* $this->set('contacts', $this->Contact->find('all')); */
|
||||
/* $this->set('contacts', $this->Contact->find('all')); */
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
@@ -219,7 +130,6 @@ class ContactsController extends AppController {
|
||||
*/
|
||||
|
||||
function all() {
|
||||
$this->Contact->recursive = 0;
|
||||
$title = 'All Contacts';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('contacts', $this->paginate());
|
||||
@@ -240,9 +150,6 @@ class ContactsController extends AppController {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
//pr($this->Contact);
|
||||
//pr($this->Contact->ContactPhone);
|
||||
|
||||
$this->Contact->Behaviors->attach('Containable');
|
||||
$this->Contact->contain
|
||||
(array(// Models
|
||||
@@ -267,32 +174,7 @@ class ContactsController extends AppController {
|
||||
)
|
||||
)
|
||||
);
|
||||
$contact = $this->Contact->read(null, $id);
|
||||
|
||||
/* $contact = $this->Contact->find */
|
||||
/* ('first', */
|
||||
/* array('link' => array */
|
||||
/* (// Models */
|
||||
/* 'ContactPhone', */
|
||||
/* 'ContactEmail', */
|
||||
/* 'ContactAddress', */
|
||||
/* 'Lease' => */
|
||||
/* array(// Models */
|
||||
/* 'Unit' => array('fields' => array('id', 'name')), */
|
||||
/* 'Charge' => array(// Models */
|
||||
/* 'ChargeType', */
|
||||
/* 'Receipt', */
|
||||
/* ) */
|
||||
/* ) */
|
||||
/* ), */
|
||||
/* 'order' => 'Lease.movein_date, Unit.sort_order, Charge.charge_date', */
|
||||
/* 'conditions' => array('Lease.lease_date IS NOT NULL', */
|
||||
/* 'ContactsLease.type !=' => 'ALTERNATE'), */
|
||||
/* )); */
|
||||
|
||||
/* pr($contact); */
|
||||
|
||||
$title = $contact['Contact']['display_name'];
|
||||
$contact = $this->Contact->read(null, $id);
|
||||
|
||||
$outstanding_deposit = 0;
|
||||
$outstanding_balance = 0;
|
||||
@@ -315,10 +197,9 @@ class ContactsController extends AppController {
|
||||
$this->sidemenu_links[] =
|
||||
array('name' => 'Move-Out', 'url' => array('controller' => 'units', 'action' => 'move-out'));
|
||||
|
||||
$title = $contact['Contact']['display_name'];
|
||||
$this->set(compact('contact', 'title',
|
||||
'outstanding_balance',
|
||||
'outstanding_deposit'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -4,6 +4,7 @@ class UnitsController extends AppController {
|
||||
var $helpers = array('Html');
|
||||
|
||||
var $paginate = array('limit' => 100,
|
||||
'group' => 'Unit.id',
|
||||
'order' => array('Unit.sort_order' => 'ASC'));
|
||||
|
||||
var $sidemenu_links =
|
||||
@@ -34,93 +35,7 @@ class UnitsController extends AppController {
|
||||
*/
|
||||
|
||||
function index() {
|
||||
//$this->Unit->recursive = 0;
|
||||
|
||||
// $units = $this->Unit->find
|
||||
// ('all',
|
||||
$this->paginate =
|
||||
array(
|
||||
'link' => array
|
||||
('UnitSize' //=> array('fields' => array('name')),
|
||||
//=> array('fields' => true),
|
||||
=> array('fields' => array('name')),
|
||||
//=> array('fields' => array()),
|
||||
//=> array(),
|
||||
|
||||
//'Lease',
|
||||
),
|
||||
'conditions' => array('UnitSize.name =' => "10x30",
|
||||
'UnitSize.id IS NOT NULL'),
|
||||
//'fields' => true
|
||||
'fields' => array('id', 'name', 'status', 'comment')
|
||||
// )
|
||||
);
|
||||
|
||||
$units = $this->paginate();
|
||||
|
||||
|
||||
/* Array */
|
||||
/* ( */
|
||||
/* [joins] => Array */
|
||||
/* ( */
|
||||
/* [0] => Array */
|
||||
/* ( */
|
||||
/* [type] => LEFT */
|
||||
/* [alias] => UnitSize */
|
||||
/* [conditions] => `UnitSize`.`id` = `Unit`.`unit_size_id` */
|
||||
/* [table] => `pmgr_unit_sizes` */
|
||||
/* ) */
|
||||
|
||||
/* ) */
|
||||
|
||||
/* [conditions] => Array */
|
||||
/* ( */
|
||||
/* [UnitSize.name =] => 10x30 */
|
||||
/* [0] => UnitSize.id IS NOT NULL */
|
||||
/* ) */
|
||||
|
||||
/* [fields] => Array */
|
||||
/* ( */
|
||||
/* [0] => id */
|
||||
/* [1] => name */
|
||||
/* [2] => status */
|
||||
/* [3] => comment */
|
||||
/* [4] => `UnitSize`.`name` */
|
||||
/* ) */
|
||||
|
||||
/* [limit] => */
|
||||
/* [offset] => */
|
||||
/* [order] => Array */
|
||||
/* ( */
|
||||
/* [0] => */
|
||||
/* ) */
|
||||
|
||||
/* [page] => 1 */
|
||||
/* [group] => */
|
||||
/* [callbacks] => 1 */
|
||||
/* [link] => Array */
|
||||
/* ( */
|
||||
/* [UnitSize] => Array */
|
||||
/* ( */
|
||||
/* [fields] => Array */
|
||||
/* ( */
|
||||
/* [0] => name */
|
||||
/* ) */
|
||||
|
||||
/* ) */
|
||||
|
||||
/* ) */
|
||||
|
||||
/* [recursive] => -1 */
|
||||
/* ) */
|
||||
|
||||
|
||||
pr($units);
|
||||
$title = 'Index Units';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('units', $units);
|
||||
|
||||
//$this->all();
|
||||
$this->all();
|
||||
}
|
||||
|
||||
|
||||
@@ -132,10 +47,18 @@ class UnitsController extends AppController {
|
||||
*/
|
||||
|
||||
function unavailable() {
|
||||
$this->Unit->recursive = 0;
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'UnitSize' => array('fields' => array('name')),
|
||||
),
|
||||
'conditions' => $this->Unit->conditionUnavailable()
|
||||
));
|
||||
|
||||
$title = 'Unavailable Units';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('units', $this->paginate(array($this->Unit->conditionUnavailable())));
|
||||
$this->set('units', $this->paginate());
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
@@ -148,10 +71,18 @@ class UnitsController extends AppController {
|
||||
*/
|
||||
|
||||
function vacant() {
|
||||
$this->Unit->recursive = 0;
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'UnitSize' => array('fields' => array('name')),
|
||||
),
|
||||
'conditions' => $this->Unit->conditionVacant()
|
||||
));
|
||||
|
||||
$title = 'Vacant Units';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('units', $this->paginate(array($this->Unit->conditionVacant())));
|
||||
$this->set('units', $this->paginate());
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
@@ -164,10 +95,25 @@ class UnitsController extends AppController {
|
||||
*/
|
||||
|
||||
function occupied() {
|
||||
$this->Unit->recursive = 0;
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'UnitSize' => array('fields' => array('name')),
|
||||
'Lease' => array('fields' => array(),
|
||||
|
||||
// Models
|
||||
'Contact' => array('fields' => array('display_name'),
|
||||
//'type' => 'LEFT',
|
||||
),
|
||||
),
|
||||
),
|
||||
'conditions' => $this->Unit->conditionOccupied()
|
||||
));
|
||||
|
||||
$title = 'Occupied Units';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('units', $this->paginate(array($this->Unit->conditionOccupied())));
|
||||
$this->set('units', $this->paginate());
|
||||
$this->render('index');
|
||||
}
|
||||
|
||||
@@ -180,7 +126,14 @@ class UnitsController extends AppController {
|
||||
*/
|
||||
|
||||
function all() {
|
||||
$this->Unit->recursive = 0;
|
||||
$this->paginate = array_merge
|
||||
($this->paginate,
|
||||
array('link' =>
|
||||
array(// Models
|
||||
'UnitSize' => array('fields' => array('name')),
|
||||
),
|
||||
));
|
||||
|
||||
$title = 'All Units';
|
||||
$this->set('title', $title); $this->set('heading', $title);
|
||||
$this->set('units', $this->paginate());
|
||||
@@ -238,5 +191,3 @@ class UnitsController extends AppController {
|
||||
'outstanding_deposit'));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user