/** * Update Credit note * * * @return Boolean */ public static function updateTotals($id) { $total_price = 0; $total_vat = 0; $total = 0; if (!empty($id) && is_numeric($id)) { $cn = CreditNotesItems::getDetails($id); foreach ($cn as $item) { $total_price += $item['price']; $total_vat += $item['vat']; $total += $item['total']; } $creditnote = self::find($id); $creditnote['total_net'] = $total_price; $creditnote['total_vat'] = $total_vat; $creditnote['total'] = $total; return $creditnote->trySave(); } return false; }
/** * * Enter description here ... */ private function itemsGrid() { $request = Zend_Controller_Front::getInstance()->getRequest(); if (!empty($request->id) && is_numeric($request->id)) { return array('records' => CreditNotesItems::getDetails($request->id), 'delete' => array('controller' => 'creditnotes', 'action' => 'deleteitem'), 'pager' => true); } }