Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public function _new()
 {
     parent::_new();
     $account = $this->_uses[$this->modeltype];
     $centres = new GLCentre();
     $centres_list = $centres->getAll();
     $this->view->set('centres', $centres_list);
     $this->view->set('actypes', $account->getEnumOptions('actype'));
     if ($account->isLoaded()) {
         $this->view->set('selected_centres', $account->getCentreIds());
         $this->view->set('selected_actype', $account->getEnumValue('actype'));
     } else {
         $this->view->set('selected_centres', array());
         $this->view->set('selected_actype', '');
     }
 }