public function allocate() { if (!$this->loadData()) { $this->dataError(); sendBack(); } $customer = $this->_uses[$this->modeltype]; $transaction = DataObjectFactory::Factory('SLTransaction'); $transactions = new SLTransactionCollection($transaction, 'sl_allocation_overview'); $sh = new SearchHandler($transactions, false); $db = DB::Instance(); $sh->addConstraint(new Constraint('status', 'in', '(' . $db->qstr($transaction->open()) . ',' . $db->qstr($transaction->partPaid()) . ')')); $sh->addConstraint(new Constraint('slmaster_id', '=', $customer->id)); $sh->setOrderby('transaction_date'); $transactions->load($sh); $this->view->set('allocated_total', 0); $this->view->set('transactions', $transactions); $this->view->set('no_ordering', true); }
public function hasCurrentActivity() { $db = DB::Instance(); // Check that no orders/invoices have been raised $model = DataObjectFactory::Factory('SOrder'); $collection = new SOrderCollection($model); $sh = new SearchHandler($collection, FALSE); $sh->addConstraint(new Constraint('slmaster_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('SInvoice'); $collection = new SInvoiceCollection($model); $sh = new SearchHandler($collection, FALSE); $sh->addConstraint(new Constraint('slmaster_id', '=', $this->id)); $sh->addConstraint(new Constraint('status', '!=', $model->paidStatus())); if (count($collection->load($sh, null, RETURN_ROWS)) > 0) { return TRUE; } $model = DataObjectFactory::Factory('SLTransaction'); $collection = new SLTransactionCollection($model); $sh = new SearchHandler($collection, FALSE); $sh->addConstraint(new Constraint('slmaster_id', '=', $this->id)); $sh->addConstraint(new Constraint('status', '!=', $model->paid())); if (count($collection->load($sh, null, RETURN_ROWS)) > 0) { return TRUE; } return FALSE; }