public function _new() { $flash = Flash::Instance(); $errors = array(); $glaccounts = new GLAccount(); if ($glaccounts->getCount() == 0) { $errors[] = 'No GL Accounts defined'; } $glcentres = new GLCentre(); if ($glcentres->getCount() == 0) { $errors[] = 'No GL Centres defined'; } if (count($errors) > 0) { $flash->addErrors($errors); sendback(); } parent::_new(); $currency = $this->_uses[$this->modeltype]; $glaccounts = $glaccounts->getAll(); if (isset($_POST[$this->modeltype]['writeoff_glaccount_id'])) { $default_glaccount_id = $_POST[$this->modeltype]['writeoff_glaccount_id']; } elseif (isset($this->_data['writeoff_glaccount_id'])) { $default_glaccount_id = $this->_data['writeoff_glaccount_id']; } elseif ($currency->isLoaded()) { $default_glaccount_id = $currency->writeoff_glaccount_id; } else { $default_glaccount_id = key($glaccounts); } $this->view->set('glcentres', $this->getCentres($default_glaccount_id)); }
public function index() { $this->view->set('clickaction', 'edit'); parent::index(new TaxStatusCollection($this->_templateobject)); $sidebar = new SidebarController($this->view); $sidebar->addList('Actions', array('new' => array('link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'new')), 'tag' => 'new_tax_status'))); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function save() { if (!$this->CheckParams($this->modeltype)) { sendBack(); } $flash = Flash::Instance(); $errors = array(); $db = DB::Instance(); $db->StartTrans(); $current_accounts = array(); if (isset($this->_data[$this->modeltype]['id'])) { $centre = $this->_templateobject; $centre->load($this->_data[$this->modeltype]['id']); if ($centre->isLoaded()) { foreach ($centre->accounts as $accountcentre) { // Delete any existing entries not in the supplied list if (!empty($this->_data[$this->modeltype]['account_id']) && in_array($accountcentre->glaccount_id, $this->_data[$this->modeltype]['account_id'])) { $current_accounts[$accountcentre->glaccount_id] = $accountcentre->glaccount_id; } elseif (!$accountcentre->delete(null, $errors)) { $errors[] = 'Failed to update Account Centre Reference ' . $accountcentre->glaccount; } } } } if (count($errors) === 0 && parent::save_model($this->modeltype)) { if (isset($this->_data[$this->modeltype]['account_id'])) { foreach ($this->_data[$this->modeltype]['account_id'] as $account_id) { if (!key_exists($account_id, $current_accounts)) { $data = array(); $data['glaccount_id'] = $account_id; $data['glcentre_id'] = $this->saved_model->id; $accountcentre = GLAccountCentre::Factory($data, $errors, 'GLAccountCentre'); if ($accountcentre) { $accountcentre->save(); if (!$accountcentre) { $errors[] = 'Failed to save reference to Account'; break; } } else { $errors[] = 'Failed to save reference to Account'; break; } } } } if (count($errors) == 0) { $db->CompleteTrans(); sendTo($this->name, 'index', $this->_modules); } } else { $errors[] = 'Failed to save GL Centre'; } $db->FailTrans(); $flash->addErrors($errors); $this->refresh(); }
public function _new() { $flash = Flash::Instance(); $errors = array(); $currency = new Currency(); if ($currency->getCount() == 0) { $errors[] = 'No Currencies defined'; } if (count($errors) > 0) { $flash->addErrors($errors); sendback(); } parent::_new(); }
public function save() { if (!$this->CheckParams($this->modeltype)) { sendBack(); } $flash = Flash::Instance(); $errors = array(); $db = DB::Instance(); $db->StartTrans(); if (parent::save_model($this->modeltype, $this->_data[$this->modeltype], $errors)) { if (isset($this->_data[$this->modeltype]['primary_account']) && $this->_data[$this->modeltype]['primary_account'] == 'on') { $cbaccounts = new CBAccountCollection($this->_templateobject); $sh = new SearchHandler($cbaccounts, FALSE); $sh->addConstraint(new Constraint('id', '!=', $this->saved_model->id)); if ($cbaccounts->update('primary_account', FALSE, $sh) === FALSE) { $errors[] = 'Error updating bank accounts'; } } else { // Check that there is only one primary account $cc = new ConstraintChain(); $cc->add(new Constraint('primary_account', 'is', TRUE)); $count = $this->_templateobject->getCount($cc); if ($count == 0) { $flash->addWarning('No primary account defined'); } elseif ($count > 1) { $flash->addWarning('Multiple primary accounts defined'); } } } else { $errors[] = 'Error saving Bank Account details : ' . $db->ErrorMsg(); } if (count($errors) > 0) { $flash->addErrors($errors); $db->FailTrans(); } if ($db->CompleteTrans()) { sendTo($this->name, 'index', $this->_modules); } $this->refresh(); }
public function _new() { parent::_new(); $payterm = $this->_uses[$this->modeltype]; $accounts = $this->check_discount($payterm->discount, $payterm->allow_discount_on_allocation == 't' ? 'true' : 'false'); $this->view->set('pl_discount_glaccounts', $accounts['pl_discount_glaccount_id']['data']); $this->view->set('sl_discount_glaccounts', $accounts['sl_discount_glaccount_id']['data']); $centres = array('' => 'None'); if ($payterm->isLoaded()) { if (is_null($payterm->pl_discount_glaccount_id)) { $payterm->pl_discount_glaccount_id = key($accounts['pl_discount_glaccount_id']['data']); } if (is_null($payterm->sl_discount_glaccount_id)) { $payterm->sl_discount_glaccount_id = key($accounts['sl_discount_glaccount_id']['data']); } $this->view->set('pl_discount_glcentres', $this->getCentres($payterm->pl_discount_glaccount_id)); $this->view->set('sl_discount_glcentres', $this->getCentres($payterm->sl_discount_glaccount_id)); } else { $this->view->set('pl_discount_glcentres', $centres); $this->view->set('sl_discount_glcentres', $centres); } }
protected function getPageName($base = null, $type = null) { return parent::getPageName(empty($base) ? 'sales_ledger_customers' : $base, $type); }
protected function getPageName($base = null, $action = null) { return parent::getPageName(empty($base) ? 'sales_ledger_discounts' : $base, $action); }
protected function getPageName($base = null, $action = null) { return parent::getPageName(empty($base) ? 'GL Periods' : $base, $action); }
protected function getPageName($base = null, $type = null) { return parent::getPageName(empty($base) ? 'purchase_ledger_suppliers' : $base, $type); }
protected function getPageName($base = null, $type = null) { return parent::getPageName(empty($base) ? 'ledger_categories' : $base, $type); }
protected function getPageName($base = null, $action = null) { return parent::getPageName(empty($base) ? 'periodic_payments' : $base, $action); }
protected function getPageName($base = null, $action = null) { return parent::getPageName(empty($base) ? 'general_ledger_budgets' : $base, $action); }
public function index() { $this->view->set('clickaction', 'edit'); parent::index(new GLBalanceCollection($this->_templateobject)); }