public function link_sales_invoices() { // Search $errors = array(); $s_data = array(); // Set context from calling module if (isset($this->_data['project_id'])) { $s_data['project_id'] = $this->_data['project_id']; } if (isset($this->_data['Search']['project_id'])) { $this->_data['project_id'] = $this->_data['Search']['project_id']; } $project = new Project(); $project->load($this->_data['project_id']); $customer = new SLCustomer(); $customer->loadBy('company_id', $project->company_id); $s_data['slmaster_id'] = $customer->id; $this->setSearch('ProjectcostchargeSearch', 'salesInvoices', $s_data); // End of search $unassigned_list = new SInvoiceLineCollection(new SInvoiceLine()); $sh = $this->setSearchHandler($unassigned_list); $sh->setFields(array('id', 'invoice_number', 'invoice_date', 'customer', 'description', 'net_value', 'tax_value', 'gross_value')); $db = DB::Instance(); $subquery = "select item_id from project_costs_charges where item_type='SI'"; $sh->addConstraint(new Constraint('id', 'not in', '(' . $subquery . ')')); $sh->setOrderby('invoice_number'); parent::index($unassigned_list, $sh); $this->view->set('unassigned_list', $unassigned_list); $this->setTemplateName('link_costs_charges'); }