function populate() { $orders = new POrderCollection(); $orders->setParams(); $sh = new SearchHandler($orders, false); $sh->addConstraint(new Constraint('status', '=', 'O')); $this->setSearchLimit($sh); $sh->setOrderBy('due_date'); $orders->load($sh); $this->contents = $orders; }
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; }