Esempio n. 1
0
 function populate()
 {
     $orders = new SInvoiceCollection(new SInvoice());
     $customersales = $orders->getSalesHistory();
     $db =& DB::Instance();
     $param = new GLParams();
     $currency_symbol = utf8_decode($param->base_currency_symbol());
     $options = array();
     $options['header']['text'] = 'Sales this month ' . $param->base_currency_symbol() . $customersales['current']['this_month_to_date']['value'];
     $options['header']['text'] .= ' : this week ' . $param->base_currency_symbol() . $customersales['current']['this_week']['value'];
     $options['header']['text'] .= ' : last week ' . $param->base_currency_symbol() . $customersales['current']['last_week']['value'];
     $options['header']['textStyle']['font-size'] = '14pt';
     ksort($customersales['previous']);
     $options['date_axis'] = TRUE;
     $sales_counter = 0;
     // build up data array
     foreach ($customersales['previous'] as $period => $value) {
         $date = explode('/', $period);
         $data['x'][] = $date[1] . "/1/" . $date[0];
         $data['y'][] = (double) $value['value'];
         $label[0][$sales_counter++] = number_format($value['value'], 2);
     }
     $options['seriesList'][] = array('legendEntry' => FALSE, 'data' => $data, 'date_axis' => array('x' => TRUE), 'markers' => array('visible' => TRUE, 'type' => 'circle'));
     $options['type'] = 'line';
     $options['identifier'] = __CLASS__;
     $options['labels'] = $label;
     $this->contents = json_encode($options);
 }
Esempio n. 2
0
 function populate()
 {
     $invoices = new SInvoiceCollection();
     $pl = new PageList('overdue_accounts');
     // TODO: this returns a collection; needs to return an array
     $invoices->getOverdueInvoices();
     $customerlist = array();
     foreach ($invoices as $invoice) {
         $customerlist[$invoice->slmaster_id] = $invoice->customer;
     }
     $customers = new SLCustomerCollection();
     $customers->setParams();
     $sh = new SearchHandler($customers, false);
     if (count($customerlist) > 0) {
         $sh->addConstraint(new Constraint('id', 'in', '(' . implode(',', array_keys($customerlist)) . ')'));
     } else {
         $sh->addConstraint(new Constraint('id', '=', '0'));
     }
     $this->setSearchLimit($sh);
     $customers->load($sh);
     $this->contents = $customers;
 }
Esempio n. 3
0
 public function getInvoiceExportList($_definition_id = '')
 {
     $invoice = new SInvoice();
     $collection = new SInvoiceCollection($invoice);
     $cc = new ConstraintChain();
     $cc->add(new Constraint('transaction_type', '=', 'I'));
     $cc->add(new Constraint('status', '=', 'O'));
     $cc->add(new Constraint('despatch_date', 'is not', 'NULL'));
     $cc->add(new Constraint('print_count', '=', '0'));
     $cc->add(new Constraint('invoice_method', '=', 'D'));
     $cc->add(new Constraint('edi_invoice_definition_id', '=', $_definition_id));
     $translog = new EDITransactionLog();
     $cc1 = new ConstraintChain();
     $cc1->add(new Constraint('status', '=', 'C'));
     $cc1->add(new Constraint('action', '=', 'S'));
     $cc1->add(new Constraint('data_definition_id', '=', $_definition_id));
     $cc1->add(new Constraint('internal_id', '=', '(' . $collection->getViewName() . '.id)'));
     $cc->add(new Constraint('not', 'exists', '(select id from ' . $translog->getTableName() . ' where ' . $cc1->__toString() . ')'));
     $invoice->orderby = 'invoice_number';
     //		echo 'cc='.$cc->__toString().'<br>';
     return $invoice->getAll($cc, false, true);
 }
Esempio n. 4
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;
 }
 public function view_invoices()
 {
     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', 'customerInvoices', $s_data);
     $this->view();
     // Now load the required data
     $invoices = new SInvoiceCollection();
     $invoices->setViewName('so_product_invoices');
     $sh = $this->setSearchHandler($invoices);
     parent::index($invoices, $sh);
     $this->view->set('clickmodule', array('sales_invoicing'));
     $this->view->set('clickcontroller', 'sinvoices');
     $this->view->set('clickaction', 'view');
     $this->view->set('related_collection', $invoices);
     $this->setTemplateName('view_related');
 }
Esempio n. 6
0
 function populate()
 {
     $sinvoices = new SInvoiceCollection(new SInvoice());
     $customersales = $sinvoices->getSalesHistory();
     $this->contents = $customersales;
 }