示例#1
0
 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;
 }
示例#2
0
 public function printOrderList($status = 'generate')
 {
     // this function is very extensive, and thus we'll remove the max_execution_time
     set_time_limit(0);
     // build options array
     $options = array('type' => array('pdf' => '', 'xml' => ''), 'output' => array('print' => '', 'save' => '', 'email' => '', 'view' => ''), 'filename' => 'SOrderList' . fix_date(date(DATE_FORMAT)), 'report' => 'SalesOrderList');
     if (strtolower($status) == "dialog") {
         return $options;
     }
     // load the model
     $orders = new SOrderCollection($this->_templateobject);
     $sh = new SearchHandler($orders, false);
     $sh->addConstraint(new Constraint('status', '=', $this->_templateobject->newStatus()));
     $orders->load($sh);
     // build extra array
     $extra = array('title' => prettify($title) . ' Sales Orders as at ' . un_fix_date(fix_date(date(DATE_FORMAT))), 'showlines' => true);
     // generate the xml and add it to the options array
     $options['xmlSource'] = $this->generateXML(array('model' => $orders, 'extra' => $extra, 'relationship_whitelist' => array('lines')));
     // execute the print output function, echo the returned json for jquery
     echo $this->constructOutput($this->_data['print'], $options);
     exit;
 }