FIrst pass implementation to accept payments. Nowhere near complete, but things are working relatively well, and I have a plethora of different attempts saved in comment blocks. I really want to clean up though, so I'm snapshotting it.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@99 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -12,6 +12,9 @@ class CustomersController extends AppController {
|
||||
array('name' => 'All', 'url' => array('controller' => 'customers', 'action' => 'all')),
|
||||
);
|
||||
|
||||
var $components = array('RequestHandler');
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -117,45 +120,10 @@ class CustomersController extends AppController {
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
|
||||
$customer = $this->Customer->find
|
||||
('first', array
|
||||
('contain' => array
|
||||
(// Models
|
||||
'Contact' =>
|
||||
array(// Models
|
||||
'ContactPhone',
|
||||
'ContactEmail',
|
||||
'ContactAddress',
|
||||
),
|
||||
'Account',
|
||||
'Lease' =>
|
||||
array('Unit' =>
|
||||
array('order' => array('sort_order'),
|
||||
'fields' => array('id', 'name'),
|
||||
),
|
||||
),
|
||||
),
|
||||
$customer = $this->Customer->details($id);
|
||||
|
||||
'conditions' => array('Customer.id' => $id),
|
||||
));
|
||||
|
||||
// Add the lease balance to each lease.
|
||||
foreach ($customer['Lease'] AS &$lease) {
|
||||
$stats = $this->Customer->Lease->stats($lease['id']);
|
||||
$lease['balance'] = $stats['Account']['Ledger']['balance'];
|
||||
}
|
||||
|
||||
// Figure out the outstanding balance of the current lease.
|
||||
$stats = $this->Customer->stats($id);
|
||||
$outstanding_balance = $stats['balance'];
|
||||
|
||||
// Figure out the total security deposit for the current lease.
|
||||
$deposits = $this->Customer->findSecurityDeposits($id);
|
||||
$outstanding_deposit = $deposits['summary']['balance'];
|
||||
|
||||
// Add statistics into the customer account.
|
||||
$customer['Account'] = array_merge($customer['Account'],
|
||||
$stats['Account']['Ledger']);
|
||||
$outstanding_balance = $customer['stats']['balance'];
|
||||
$outstanding_deposit = $customer['deposits']['summary']['balance'];
|
||||
|
||||
$this->sidemenu_links[] =
|
||||
array('name' => 'Operations', 'header' => true);
|
||||
@@ -168,4 +136,36 @@ class CustomersController extends AppController {
|
||||
'outstanding_balance',
|
||||
'outstanding_deposit'));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: payment
|
||||
* - Sets up the payment entry page for the given customer.
|
||||
*/
|
||||
|
||||
function payment($id = null) {
|
||||
/* if (!$id) { */
|
||||
/* $this->Session->setFlash(__('Invalid Item.', true)); */
|
||||
/* $this->redirect(array('action'=>'index')); */
|
||||
/* } */
|
||||
|
||||
if ($this->RequestHandler->isPost()) {
|
||||
pr($this->data);
|
||||
//$this->redirect(array('action'=>'index'));
|
||||
$customer = $this->data;
|
||||
}
|
||||
elseif (isset($id)) {
|
||||
$customer = $this->Customer->details($id);
|
||||
unset($customer['deposits']['Entries']);
|
||||
}
|
||||
else {
|
||||
$customer = null;
|
||||
}
|
||||
|
||||
$title = 'Payment Entry';
|
||||
$this->set(compact('customer', 'title'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user