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; }
public function view_orders() { if (isset($this->_data['Search']['productline_header_id'])) { $this->_data['id'] = $this->_data['Search']['productline_header_id']; } if (!isset($this->_data['id'])) { $this->DataError(); sendBack(); } $s_data = array(); // Set context from calling module $s_data['productline_header_id'] = $this->_data['id']; $this->setSearch('productlinesSearch', 'supplierOrders', $s_data); $this->view(); // Now load the required data $orders = new POrderCollection(); $orders->setViewName('po_product_orders'); $sh = $this->setSearchHandler($orders); parent::index($orders, $sh); $this->view->set('clickcontroller', 'porders'); $this->view->set('clickaction', 'view'); $this->view->set('related_collection', $orders); $this->setTemplateName('view_related'); }