public static function useDefault(&$search_data = null, &$errors = array(), $defaults = null) { $search = new glbalancesSearch($defaults); // Search by Account $search->addSearchField('glaccount_id', 'Account', 'multi_select', array(), 'advanced'); $glaccount = new GLAccount(); $search->setOptions('glaccount_id', $glaccount->getAll()); // Search by Centre $search->addSearchField('glcentre_id', 'Centre', 'multi_select', array(), 'advanced'); $glcentre = new GLCentre(); $search->setOptions('glcentre_id', $glcentre->getAll()); // Search by Period $currentPeriod = new GLPeriod(); $currentPeriod->getCurrentPeriod(); if ($currentPeriod) { $default_period = array($currentPeriod->id); } else { $default_period = array(); } $search->addSearchField('glperiods_id', 'Period', 'multi_select', $default_period, 'advanced'); $glperiod = new GLPeriod(); $search->setOptions('glperiods_id', $glperiod->getAll()); $search->setSearchData($search_data, $errors); return $search; }
public function _new() { parent::_new(); $accounts = new GLAccount(); $this->view->set('accounts', $accounts->getAll()); $centre = $this->_uses[$this->modeltype]; if ($centre->isLoaded()) { $this->view->set('selected_accounts', $centre->getAccountIds()); } else { $this->view->set('selected_accounts', array()); } }
public function _new() { parent::_new(); $glaccount = new GLAccount(); $accounts = $glaccount->nonControlAccounts(); $this->view->set('accounts', $accounts); $budget = $this->_uses[$this->modeltype]; if (isset($_POST[$this->modeltype]['glaccount_id'])) { $default_account_id = $_POST[$this->modeltype]['glaccount_id']; } elseif ($budget->isLoaded()) { $default_account_id = $budget->glaccount_id; } else { $account = new GLAccount(); $accounts = $account->getAll(); $default_account_id = key($accounts); } $this->view->set('centres', $this->getCentres($default_account_id)); }