public function outstanding_transactions() { if (!$this->loadData()) { $this->dataError(); sendBack(); } $customer = $this->_uses[$this->modeltype]; $category = DataObjectFactory::Factory('LedgerCategory'); $categories = $category->checkCompanyUsage($customer->company_id); // Check for Sales Ledger account and Contra Control account $glparams = DataObjectFactory::Factory('GLParams'); // Does this SL Customer also have a PL Supplier account // and does the Contras Control Account also exist // if so, then allow contras $can_contra = isset($categories['PL']['exists']) && $categories['PL']['exists'] && $glparams->contras_control_account() != FALSE; $this->view->set('can_contra', $can_contra); $transaction = DataObjectFactory::Factory('SLTransaction'); $transactions = new SLTransactionCollection($transaction); $db = DB::Instance(); $sh = $this->setSearchHandler($transactions); $sh->addConstraint(new Constraint('status', 'in', '(' . $db->qstr($transaction->open()) . ',' . $db->qstr($transaction->partPaid()) . ')')); $sh->addConstraint(new Constraint('slmaster_id', '=', $customer->id)); parent::index($transactions, $sh); if ($can_contra) { // create session object to handle paged data input $contras_sessionobject = new SessionData('sl_contras'); if (!$contras_sessionobject->PageDataExists()) { // session object does not exist so register it $contras_sessionobject->registerPageData(array('os_value', 'contra')); } // Check for form input due to paging or ordering if (isset($this->_data['SLTransaction'])) { foreach ($this->_data['SLTransaction'] as $id => $fields) { if ($fields['contra'] == 'on') { $contras_sessionobject->updatePageData($id, $fields, $errors); } else { $contras_sessionobject->deletePageData($id); } } } $contras_data = $contras_sessionobject->getPageData($errors); $contra_total = 0; foreach ($contras_data as $value) { if (isset($value['contra']) && $value['contra']) { $contra_total += $value['os_value']; } } $this->view->set('contra_total', $contra_total); $this->view->set('page_data', $contras_data); } $this->view->set('ledger_account', $customer); $this->view->set('collection', $transactions); $this->view->set('clickaction', 'view'); $this->view->set('clickcontroller', 'sltransactions'); $this->view->set('invoice_module', 'sales_invoicing'); $this->view->set('invoice_controller', 'sinvoices'); $this->_templateName = $this->getTemplateName('view_ledger_trans'); }