Example #1
0
 public static function useDefault($search_data = null, &$errors = array(), $defaults = null)
 {
     $search = new glaccountsSearch($defaults);
     // Search by Account
     $search->addSearchField('account', 'Account', 'is', '', 'basic');
     // Search by Description
     $search->addSearchField('description', 'Description', 'contains', '', 'basic');
     // Search by Type
     $search->addSearchField('actype', 'Type', 'select', '', 'basic');
     // Search by Control Account
     $search->addSearchField('control', 'Control Accounts Only', 'hide', '', 'advanced');
     // Search by Analysis Code
     $search->addSearchField('glanalysis_id', 'Analysis Code', 'select', '', 'advanced');
     $glaccount = new GLAccount();
     $types = $glaccount->getEnumOptions('actype');
     $options = array('' => 'All');
     $options += $types;
     $search->setOptions('actype', $options);
     $glanalysis = new GLAnalysis();
     $codes = $glanalysis->getAll();
     $options = array('' => 'All');
     $options += $codes;
     $search->setOptions('glanalysis_id', $options);
     $search->setSearchData($search_data, $errors);
     return $search;
 }
Example #2
0
 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));
 }
Example #3
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;
 }
Example #4
0
 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());
     }
 }
Example #5
0
 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));
 }
Example #6
0
 public function getCentres($_id = '')
 {
     // Used by Ajax to return Centre list after selecting the Account
     if (isset($this->_data['ajax'])) {
         if (!empty($this->_data['id'])) {
             $_id = $this->_data['id'];
         }
     }
     $account = new GLAccount();
     $account->load($_id);
     $centres = $account->getCentres();
     if (empty($centres)) {
         $centres = array('' => 'None');
     }
     if (isset($this->_data['ajax'])) {
         $this->view->set('options', $centres);
         $this->setTemplateName('select_options');
     } else {
         return $centres;
     }
 }