public function _new() { $flash = Flash::Instance(); parent::_new(); $gl_params = $this->_uses[$this->modeltype]; $unassigned = $gl_params->unassignedParams(); if (count($unassigned) > 0) { $this->view->set('unassigned', $unassigned); } elseif (count($unassigned) == 0 && $this->_data['action'] == 'new') { $flash->addMessage('All parameters have been assigned'); sendTo($this->name, 'index', $this->_modules); } elseif ($this->_data['action'] == 'new') { $flash->addError('Error getting Parameter List'); sendback(); } if (isset($_POST[$this->modeltype]['paramdesc'])) { $this->selectlist($_POST[$this->modeltype]['paramdesc']); } elseif ($gl_params->isLoaded()) { $this->selectlist($gl_params->paramdesc); $this->view->set('selected', $gl_params->paramvalue_id); } else { $this->selectlist(key($unassigned)); } $sidebar = new SidebarController($this->view); $sidebarlist = array(); $sidebarlist['view'] = array('tag' => 'View Parameters', 'link' => array_merge($this->_modules, array('controller' => $this->name, 'action' => 'index'))); $sidebar->addList('Actions', $sidebarlist); $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function _new() { parent::_new(); $supplier = $this->_uses[$this->modeltype]; if ($supplier->isLoaded()) { $this->view->set('transaction_count', $supplier->transactions->count()); $emails = $this->getEmailAddresses($supplier->company_id); unset($emails['']); $this->view->set('emails', $emails); } elseif (isset($this->_data['company_id'])) { $supplier->company_id = $this->_data['company_id']; $this->view->set('payee', $supplier->name); } else { $unassigned_list = $supplier->getUnassignedCompanies(); if (count($unassigned_list) > 0) { $this->view->set('company_list', $unassigned_list); $emails = $this->getEmailAddresses(key($unassigned_list)); unset($emails['']); $this->view->set('emails', $emails); $this->view->set('payee', current($unassigned_list)); $supplier->company_id = key($unassigned_list); } else { $flash = Flash::Instance(); $flash->addMessage('All companies are assigned as suppliers'); sendBack(); } } $this->view->set('payment_addresses', $supplier->getRemittanceAddresses()); $this->view->set('receive_actions', WHAction::getReceiveActions()); }
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 _new() { parent::_new(); $sldiscount = $this->_uses[$this->modeltype]; if (!$sldiscount->isLoaded() && isset($this->_data['slmaster_id'])) { $sldiscount->slmaster_id = $this->_data['slmaster_id']; } $customers = $this->getOptions($this->_templateobject, 'slmaster_id', 'getOptions', 'getOptions', array('use_collection' => true)); $this->view->set('customers', $customers); $this->view->set('prod_groups', $this->getProductGroups($sldiscount->slmaster_id)); }
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(); $gl_account = DataObjectFactory::Factory('GLAccount'); $gl_accounts = $gl_account->getAll(); $this->view->set('gl_accounts', $gl_accounts); $pp = $this->_uses[$this->modeltype]; if (isset($_POST[$this->modeltype]['source'])) { $default_source = $_POST[$this->modeltype]['source']; } elseif ($pp->isLoaded()) { $default_source = $pp->source; } else { // following line commented out and replacing with next two lines // due to possible php bug that causes problems on template // $default_source=key($pp->getEnumOptions('source')); $sources = $pp->getEnumOptions('source'); $default_source = key($sources); } $companies = $this->getCompanies($default_source); $this->view->set('companies', $companies); if (isset($_POST[$this->modeltype]['company_id'])) { $default_company_id = $_POST[$this->modeltype]['company_id']; } elseif ($pp->isLoaded()) { $default_company_id = $pp->company_id; } else { $default_company_id = key($companies); } $this->view->set('people', $this->getPeople($default_company_id)); $cb_account = DataObjectFactory::Factory('CBAccount'); $cb_accounts = $cb_account->getAll(); if (isset($_POST[$this->modeltype]['cb_account_id'])) { $default_cb_account_id = $_POST[$this->modeltype]['cb_account_id']; } elseif ($pp->isLoaded()) { $default_cb_account_id = $pp->cb_account_id; } else { $cb_account->getDefaultAccount(key($cb_accounts)); $default_cb_account_id = $cb_account->{$cb_account->idField}; } $this->view->set('cb_account_id', $default_cb_account_id); if ($pp->isLoaded()) { $this->view->set('currency', $pp->currency_id); } else { $this->view->set('currency', $this->getCurrencyId($default_company_id, $default_cb_account_id, $default_source)); } if (isset($_POST[$this->modeltype]['glaccount_id'])) { $default_glaccount_id = $_POST[$this->modeltype]['glaccount_id']; } elseif ($pp->isLoaded()) { $default_glaccount_id = $pp->glaccount_id; } else { $default_glaccount_id = key($gl_accounts); } $this->view->set('gl_centres', $this->getCentres($default_glaccount_id)); }
public function _new() { parent::_new(); $ledgercategory = $this->_uses[$this->modeltype]; if (!$ledgercategory->isLoaded()) { $current = $ledgercategory->getAll(); $categories = new ContactCategory(); $cc = new ConstraintChain(); if (count($current) > 0) { $cc->add(new Constraint('id', 'not in', '(' . implode(',', $current) . ')')); } $this->view->set('categories', $categories->getAll($cc)); } }
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 _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', ''); } }
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)); }
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); } }
public function _new() { $flash = Flash::Instance(); $errors = array(); $glaccounts = DataObjectFactory::Factory('GLAccount'); if ($glaccounts->getCount() == 0) { $errors[] = 'No GL Accounts defined'; } $glcentres = DataObjectFactory::Factory('GLCentre'); if ($glcentres->getCount() == 0) { $errors[] = 'No GL Centres defined'; } $currency = DataObjectFactory::Factory('Currency'); if ($currency->getCount() == 0) { $errors[] = 'No Currencies defined'; } if (count($errors) > 0) { $flash->addErrors($errors); sendback(); } parent::_new(); $cbaccount = $this->_uses[$this->modeltype]; if (!$cbaccount->isLoaded()) { $params = DataObjectFactory::Factory('GLParams'); $currency = $params->base_currency(); $this->view->set('currency', $currency); } $glaccounts = $glaccounts->getAll(); $this->view->set('glaccounts', $glaccounts); if (isset($_POST[$this->modeltype]['glaccount_id'])) { $default_glaccount_id = $_POST[$this->modeltype]['glaccount_id']; } elseif ($cbaccount->isLoaded()) { $default_glaccount_id = $cbaccount->glaccount_id; } else { $default_glaccount_id = key($glaccounts); } $this->view->set('glcentres', $this->getCentres($default_glaccount_id)); }
public function _new() { parent::_new(); $customer = $this->_uses[$this->modeltype]; if ($customer->isLoaded()) { $this->view->set('transaction_count', $customer->transaction_count()); $emails = $this->getEmailAddresses($customer->company_id); unset($emails['']); $this->view->set('emails', $emails); } elseif (isset($this->_data['company_id'])) { $customer->company_id = $this->_data['company_id']; } else { $unassigned_list = $customer->getUnassignedCompanies(); if (count($unassigned_list) > 0) { $this->view->set('company_list', $unassigned_list); $emails = $this->getEmailAddresses(key($unassigned_list)); unset($emails['']); $this->view->set('emails', $emails); $customer->company_id = key($unassigned_list); } else { $flash = Flash::Instance(); $flash->addMessage('All companies are assigned as customers'); sendBack(); } } $this->view->set('billing_addresses', $customer->getInvoiceAddresses()); $this->view->set('despatch_actions', WHAction::getDespatchActions()); }