From b78834f7d68e91ac1a231eb9539cace356bfbbe7 Mon Sep 17 00:00:00 2001 From: abijah Date: Wed, 10 Jun 2009 09:10:09 +0000 Subject: [PATCH] Fixed problem with units that are vacant, and thus have no current lease. git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@87 97e9348a-65ac-dc4b-aefc-98561f571b83 --- controllers/units_controller.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/controllers/units_controller.php b/controllers/units_controller.php index 59515db..9fcb630 100644 --- a/controllers/units_controller.php +++ b/controllers/units_controller.php @@ -169,14 +169,18 @@ class UnitsController extends AppController { $lease['balance'] = $stats['Account']['Ledger']['balance']; } - // Figure out the outstanding balance of the current lease. - $stats = $this->Unit->stats($id); - $outstanding_balance = - $stats['CurrentLease']['Account']['Ledger']['balance']; + $outstanding_balance = 0; + $outstanding_deposit = 0; + if (isset($unit['CurrentLease']['id'])) { + // Figure out the outstanding balance of the current lease. + $stats = $this->Unit->stats($id); + $outstanding_balance = + $stats['CurrentLease']['Account']['Ledger']['balance']; - // Figure out the total security deposit for the current lease. - $deposits = $this->Unit->Lease->findSecurityDeposits($unit['CurrentLease']['id']); - $outstanding_deposit = $deposits['summary']['balance']; + // Figure out the total security deposit for the current lease. + $deposits = $this->Unit->Lease->findSecurityDeposits($unit['CurrentLease']['id']); + $outstanding_deposit = $deposits['summary']['balance']; + } $this->sidemenu_links[] = array('name' => 'Operations', 'header' => true);