Example #1
0
 public function printMultipleBalance()
 {
     $flash = Flash::Instance();
     $errors = array();
     $extra = array();
     if (!isset($this->_data['WHLocation_location']) || empty($this->_data['WHLocation_location'])) {
         $errors[] = 'Location is a required field';
     }
     if (!isset($this->_data['WHBin_bins']) || empty($this->_data['WHBin_bins'])) {
         $errors[] = 'Bin is a required field';
     }
     if (count($errors) > 0) {
         $flash->addErrors($errors);
         sendBack();
     }
     // Check and set default print set
     $userPreferences = UserPreferences::instance(EGS_USERNAME);
     $defaultPrinter = $userPreferences->getPreferenceValue('default_printer', 'shared');
     if (empty($defaultPrinter)) {
         $flash->addError('Cannot print without a default printer set');
         sendBack();
     } else {
         $this->_data['printtype'] = 'pdf';
         $this->_data['printaction'] = 'Print';
         $this->_data['printer'] = $defaultPrinter;
     }
     // construct constraint against bins
     $stbalances = new STBalanceCollection();
     $sh = new SearchHandler($stbalances, FALSE);
     $sh->addConstraint(new Constraint('balance', '<>', 0));
     $sh->addConstraint(new Constraint('whstore_id', '=', $this->_data['WHStore_store']));
     $sh->addConstraint(new Constraint('whlocation_id', '=', $this->_data['WHLocation_location']));
     $binlist = implode(',', $this->_data['WHBin_bins']);
     $sh->addConstraint(new Constraint('whbin_id', 'in', '(' . $binlist . ')'));
     $sh->setOrderby(array('whbin', 'stitem'), array('ASC', 'ASC'));
     $stbalances->load($sh);
     // set title
     $WHLocation = $this->_templateobject;
     $WHLocation->load($this->_data['WHLocation_location']);
     $WHStore = DataObjectFactory::Factory('WHStore');
     $WHStore->load($this->_data['WHStore_store']);
     $extra['title'] = 'Stock Balance for ' . $WHStore->description . ' / ' . $WHLocation->description . ' as at ' . un_fix_date(fix_date(date(DATE_FORMAT)));
     // construct xml
     $xml = $this->generateXML(array('model' => $stbalances, 'load_relationships' => FALSE, 'extra' => $extra));
     // build a basic list of options
     $options = array('report' => 'MF_MultipleStockBalance', 'xmlSource' => $xml);
     // construct the document, caputre the response
     $response = json_decode($this->constructOutput($this->_data, $options));
     // output success / failure message
     if ($response->status !== TRUE) {
         $flash->addError("Error printing document ยป " . $response->message);
     } else {
         $flash->addMessage("Document printed successfully");
     }
     // return back to eglet
     sendBack();
 }
Example #2
0
 public function unconfirm_pick_list()
 {
     if (!isset($this->_data) || !$this->loadData()) {
         $this->dataError();
         sendBack();
     }
     $sorder = $this->_uses[$this->modeltype];
     $this->view->set('no_ordering', true);
     $pick_from = array();
     foreach ($sorder->lines as $orderline) {
         if (!is_null($orderline->stitem_id)) {
             $balances = new STBalanceCollection(DataObjectFactory::Factory('STBalance'));
             $cc = new ConstraintChain();
             $cc->add(new Constraint('pickable', 'is', true));
             $pick_from[$orderline->id] = $balances->getLocationList($orderline->stitem_id, $cc);
         } else {
             $pick_from[$orderline->id] = array();
         }
     }
     $this->view->set('action_list', $pick_from);
     $this->view->set('from_locations', $sorder->despatch_from->rules_list('from_location'));
 }