diff --git a/site/controllers/charges_controller.php b/site/controllers/charges_controller.php new file mode 100644 index 0000000..8458124 --- /dev/null +++ b/site/controllers/charges_controller.php @@ -0,0 +1,129 @@ + 100, + 'group' => 'Charge.id', + 'order' => array('Charge.charge_date' => 'ASC')); + + var $sidemenu_links = + array(array('name' => 'Charges', 'header' => true), + array('name' => 'Cleared', 'url' => array('controller' => 'charges', 'action' => 'cleared')), + array('name' => 'Unresolved', 'url' => array('controller' => 'charges', '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 charges + */ + + function index() { + $this->all(); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: cleared + * - Lists cleared charges + */ + + function cleared() { + $this->all(); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: unresolved + * - Lists unresolved charges + */ + + function unresolved() { + $this->all(); + } + + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: all + * - Lists all charges + */ + + function all() { + $this->paginate = array_merge + ($this->paginate, + array('link' => + array(// Models + 'ChargeType', + 'Receipt', + 'Lease' => array('fields' => array('number')) + ), + )); + + $title = 'All Charges'; + $this->set('title', $title); $this->set('heading', $title); + $this->set('charges', $this->paginate()); + $this->render('index'); + } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: view + * - Displays information about a specific charge + */ + + function view($id = null) { + if (!$id) { + $this->Session->setFlash(__('Invalid Item.', true)); + $this->redirect(array('action'=>'index')); + } + + $this->Charge->Behaviors->attach('Containable'); + $this->Charge->contain + (array(// Models + 'ChargeType', + 'Receipt', + 'Lease' => array('fields' => array('number')), + ) + ); + $charge = $this->Charge->read(null, $id); + //pr($charge); + + $payment_amount = 0; + foreach($charge['Receipt'] AS $receipt) + $payment_amount += $receipt['ChargesReceipt']['amount']; + $balance_amount = $charge['Charge']['total'] - $payment_amount; + +/* $this->sidemenu_links[] = */ +/* array('name' => 'Operations', 'header' => true); */ +/* $this->sidemenu_links[] = */ +/* array('name' => 'Move-Out', 'url' => array('controller' => 'charges', 'action' => 'move-out')); */ + + $title = 'Charge #' . $charge['Charge']['id']; + $this->set(compact('charge', 'title', + 'payment_amount', + 'balance_amount')); + } +} diff --git a/site/views/charges/index.ctp b/site/views/charges/index.ctp new file mode 100644 index 0000000..1d4e8e3 --- /dev/null +++ b/site/views/charges/index.ctp @@ -0,0 +1,3 @@ +