function populate() { $invoices = new PInvoiceCollection(); $invoices->setParams(); $sh = new SearchHandler($invoices, FALSE); $sh->addConstraint(new Constraint('status', '=', 'Q')); $this->setSearchLimit($sh); $sh->setOrderBy('due_date'); $invoices->load($sh); $this->contents = $invoices; // set vars $this->vars['type_label'] = 'Supplier'; $this->vars['type_field'] = 'supplier'; $this->vars['module'] = 'purchase_invoicing'; $this->vars['controller'] = 'pinvoices'; }
public function hasCurrentActivity() { $db = DB::Instance(); // Check that no orders/invoices have been raised $model = DataObjectFactory::Factory('POrder'); $collection = new POrderCollection($model); $sh = new SearchHandler($collection, FALSE); $sh->addConstraint(new Constraint('plmaster_id', '=', $this->id)); $sh->addConstraint(new Constraint('status', 'NOT IN', '(' . $db->qstr($model->cancelStatus()) . ', ' . $db->qstr($model->invoiceStatus()) . ')')); if (count($collection->load($sh, null, RETURN_ROWS)) > 0) { return TRUE; } $model = DataObjectFactory::Factory('PInvoice'); $collection = new PInvoiceCollection($model); $sh = new SearchHandler($collection, FALSE); $sh->addConstraint(new Constraint('plmaster_id', '=', $this->id)); $sh->addConstraint(new Constraint('status', '!=', $model->paidStatus())); if (count($collection->load($sh, null, RETURN_ROWS)) > 0) { return TRUE; } $model = DataObjectFactory::Factory('PLTransaction'); $collection = new PLTransactionCollection($model); $sh = new SearchHandler($collection, FALSE); $sh->addConstraint(new Constraint('plmaster_id', '=', $this->id)); $sh->addConstraint(new Constraint('status', '!=', $model->paid())); if (count($collection->load($sh, null, RETURN_ROWS)) > 0) { return TRUE; } return FALSE; }