'Transactions', 'header' => true), array('name' => 'All', 'url' => array('controller' => 'transactions', 'action' => 'all')), ); /************************************************************************** ************************************************************************** ************************************************************************** * override: sideMenuLinks * - Generates controller specific links for the side menu */ function sideMenuLinks() { return array_merge(parent::sideMenuLinks(), $this->sidemenu_links); } /************************************************************************** ************************************************************************** ************************************************************************** * action: index / all * - Generate a listing of transactions */ function index() { $this->all(); } function all() { $this->gridView('All Transactions', 'all'); } /************************************************************************** ************************************************************************** ************************************************************************** * virtuals: gridData * - With the application controller handling the gridData action, * these virtual functions ensure that the correct data is passed * to jqGrid. */ function gridDataCountTables(&$params, &$model) { return parent::gridDataTables($params, $model); } function gridDataTables(&$params, &$model) { $link = $this->gridDataCountTables($params, $model); $link['link']['StatementEntry'] = array('fields' => array()); return $link; } function gridDataFields(&$params, &$model) { $fields = parent::gridDataFields($params, $model); $fields[] = 'COUNT(StatementEntry.id) AS entries'; return $fields; } function gridDataPostProcessLinks(&$params, &$model, &$records, $links) { $links['Transaction'] = array('id'); return parent::gridDataPostProcessLinks($params, $model, $records, $links); } /************************************************************************** ************************************************************************** ************************************************************************** * 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')); } $transaction = $this->Transaction->find ('first', array('contain' => array(// Models 'Account' => array('fields' => array('Account.id', 'Account.name'), ), 'Ledger' => array('fields' => array('Ledger.id', 'Ledger.name'), ), ), 'conditions' => array('Transaction.id' => $id), )); // OK, prepare to render. $title = 'Transaction #' . $transaction['Transaction']['id']; $this->set(compact('transaction', 'title')); } /************************************************************************** ************************************************************************** ************************************************************************** * action: postInvoice * - handles the creation of a charge invoice */ function postInvoice() { if (!$this->RequestHandler->isPost()) { echo('

THIS IS NOT A POST FOR SOME REASON

'); return; } if (!$this->Transaction->addInvoice($this->data, null, $this->data['Lease']['id'])) { $this->Session->setFlash("INVOICE FAILED", true); // REVISIT 20090706: // Until we can work out the session problems, // just die. die("

INVOICE FAILED

"); } $this->layout = null; $this->autoLayout = false; $this->autoRender = false; } /************************************************************************** ************************************************************************** ************************************************************************** * action: postReceipt * - handles the creation of a payment receipt */ function postReceipt() { if (!$this->RequestHandler->isPost()) { echo('

THIS IS NOT A POST FOR SOME REASON

'); return; } foreach($this->data['Entry'] AS &$entry) { $entry['Tender'] = $entry['type'][$entry['tender_type_id']]; unset($entry['type']); unset($entry['tender_type_id']); } if (!$this->Transaction->addReceipt($this->data, $this->data['Customer']['id'], (isset($this->data['Lease']['id']) ? $this->data['Lease']['id'] : null ))) { $this->Session->setFlash("RECEIPT FAILED", true); // REVISIT 20090706: // Until we can work out the session problems, // just die. die("

RECEIPT FAILED

"); } $this->layout = null; $this->autoLayout = false; $this->autoRender = false; } }