100, 'group' => 'Transaction.id', 'order' => array('Transaction.stamp' => 'ASC')); var $sidemenu_links = array(array('name' => 'Transactions', 'header' => true), array('name' => 'Cleared', 'url' => array('controller' => 'transactions', 'action' => 'cleared')), array('name' => 'Unresolved', 'url' => array('controller' => 'transactions', '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 transactions */ function index() { $this->all(); } /************************************************************************** ************************************************************************** ************************************************************************** * action: cleared * - Lists cleared transactions */ function cleared() { $this->all(); } /************************************************************************** ************************************************************************** ************************************************************************** * action: unresolved * - Lists unresolved transactions */ function unresolved() { $this->all(); } /************************************************************************** ************************************************************************** ************************************************************************** * action: all * - Lists all transactions */ function all() { $this->paginate = array_merge ($this->paginate, array('link' => array(// Models 'Customer', 'LedgerEntry' => array('DebitLedger', 'CreditLedger') ), )); $title = 'All Transactions'; $this->set('title', $title); $this->set('heading', $title); $this->set('transactions', $this->paginate()); $this->render('index'); } /************************************************************************** ************************************************************************** ************************************************************************** * action: view * - Displays information about a specific transaction */ function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid Item.', true)); $this->redirect(array('action'=>'index')); } $this->Transaction->Behaviors->attach('Containable'); $this->Transaction->contain (array(// Models 'LedgerEntry' => array(//Models 'DebitLedger', 'CreditLedger', ), ) ); $transaction = $this->Transaction->read(null, $id); $this->Transaction->Behaviors->detach('Containable'); // Figure out the transaction total $total = 0; foreach($transaction['LedgerEntry'] AS $entry) $total += $entry['amount']; // OK, prepare to render. $title = 'Transaction #' . $transaction['Transaction']['id']; $this->set(compact('transaction', 'title', 'total')); } }