public function delete() { $flash = Flash::Instance(); $db = DB::Instance(); $db->StartTrans(); $result = parent::delete(); // Save the header to update the header totals if ($result && !$this->invoice_detail->save()) { $result = false; $flash->addError('Error updating header'); } if ($result) { // Now update the line numbers of following lines $sinvoicelines = new SInvoiceLineCollection($this); $sh = new SearchHandler($sinvoicelines, false); $sh->addConstraint(new Constraint('invoice_id', '=', $this->invoice_id)); $sh->addConstraint(new Constraint('line_number', '>', $this->line_number)); if ($sinvoicelines->update('line_number', '(line_number-1)', $sh) === false) { $flash->addError('Error updating line numbers ' . $db->ErrorMsg()); $result = false; } } if ($result === false) { $db->FailTrans(); } $db->CompleteTrans(); return $result; }
function populate() { $orders = new SInvoiceLineCollection(new SInvoiceLine()); $pl = new PageList('top_sales_orders'); $customersales = $orders->getTopSales(10); $this->contents = $customersales; }
public function sorders_summary() { $orders = new SInvoiceLineCollection(); $customersales = $orders->getTopSales(10, $this->_data['type']); $this->view->set('content', $customersales); }