100, 'group' => 'Receipt.id', 'order' => array('Receipt.stamp' => 'ASC')); var $sidemenu_links = array(array('name' => 'Receipts', 'header' => true), array('name' => 'Cleared', 'url' => array('controller' => 'receipts', 'action' => 'cleared')), array('name' => 'Unresolved', 'url' => array('controller' => 'receipts', 'action' => 'unresolved')), ); /************************************************************************** ************************************************************************** ************************************************************************** * override: sideMenuLinks * - Generates controller specific links for the side menu */ function sideMenuLinks() { return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); } /************************************************************************** ************************************************************************** ************************************************************************** * action: index * - Lists all receipts */ function index() { $this->all(); } /************************************************************************** ************************************************************************** ************************************************************************** * action: cleared * - Lists cleared receipts */ function cleared() { $this->all(); } /************************************************************************** ************************************************************************** ************************************************************************** * action: unresolved * - Lists unresolved receipts */ function unresolved() { $this->all(); } /************************************************************************** ************************************************************************** ************************************************************************** * action: all * - Lists all receipts */ function all() { $this->paginate = array_merge ($this->paginate, array('link' => array(// Models 'Charge', 'Payment' ), )); $title = 'All Receipts'; $this->set('title', $title); $this->set('heading', $title); $this->set('receipts', $this->paginate()); $this->render('index'); } /************************************************************************** ************************************************************************** ************************************************************************** * action: view * - Displays information about a specific receipt */ function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid Item.', true)); $this->redirect(array('action'=>'index')); } $this->Receipt->Behaviors->attach('Containable'); $this->Receipt->contain (array(// Models 'Charge' => array(// Models 'Lease' => array('fields' => array('number')), 'ChargesReceipt', 'ChargeType'), 'Payment' => array(// Models 'PaymentType'), ) ); $receipt = $this->Receipt->read(null, $id); //pr($receipt); $charge_amount = 0; $payment_amount = 0; foreach($receipt['Charge'] AS $charge) $charge_amount += $charge['ChargesReceipt']['amount']; foreach($receipt['Payment'] AS $payment) $payment_amount += $payment['amount']; /* $this->sidemenu_links[] = */ /* array('name' => 'Operations', 'header' => true); */ /* $this->sidemenu_links[] = */ /* array('name' => 'Move-Out', 'url' => array('controller' => 'receipts', 'action' => 'move-out')); */ $title = 'Receipt #' . $receipt['Receipt']['id']; $this->set(compact('receipt', 'title', 'charge_amount', 'payment_amount')); } }