예제 #1
0
 public static function useDefault($search_data = null, &$errors = array(), $defaults = null)
 {
     $search = new stcostsSearch($defaults);
     // Search by Stock Item
     $search->addSearchField('stitem_id', 'Stock Item', 'select', '', 'basic');
     // Search by Date
     //		$search->addSearchField(
     //			'start_date/end_date',
     //			'Date',
     //			'betweenfields',
     //			date(DATE_FORMAT),
     //			'basic'
     //		);
     // Search by Type
     $search->addSearchField('type', 'Type', 'select', '', 'basic');
     $stitem = new STItem();
     //		$chain = new ConstraintChain();
     //		$chain->add(new Constraint('comp_class','=','M'));
     //		if (isset($search_data['stitem_id'])) {
     //			$chain->add(new Constraint('id', '!=', $search_data['stitem_id']));
     //		}
     $stitems = $stitem->getAll();
     $options = array('' => 'All');
     $options += $stitems;
     $search->setOptions('stitem_id', $options);
     $stcost = new STCost();
     $options = array('' => 'All');
     $types = $stcost->getEnumOptions('type');
     $options += $types;
     $search->setOptions('type', $options);
     $search->setSearchData($search_data, $errors);
     return $search;
 }
예제 #2
0
 public static function useDefault($search_data = null, &$errors = array(), $defaults = null)
 {
     $search = new workordersSearch($defaults);
     // Search by Order No.
     $search->addSearchField('wo_number', 'Order No', 'equal');
     // Search by Status
     $search->addSearchField('status', 'status_is', 'multi_select', array());
     $wo = new MFWorkorder();
     $search->setOptions('status', $wo->getEnumOptions('status'));
     // Search by Stock Item
     $search->addSearchField('stitem_id', 'Stock Item', 'select', '', 'advanced');
     $stitem = new STItem();
     $chain = new ConstraintChain();
     $chain->add(new Constraint('comp_class', '=', 'M'));
     $stitems = $stitem->getAll($chain);
     $options = array('' => 'All');
     $options = $options + $stitems;
     $search->setOptions('stitem_id', $options);
     // Search by Required By Date
     /* 'between' is not yet implemented
      		$search->addSearchField(
     			'required_by',
     			'Required Between',
     			'between',
     			'',
     			'advanced'
     		);
     */
     $search->addSearchField('required_by', 'Required Between', 'between', '', 'advanced');
     // Search by Stock Type Code
     $search->addSearchField('type_code_id', 'Type Code', 'select', '', 'advanced');
     $typecode = new STTypecode();
     $typecodes = $typecode->getAll();
     $options = array('' => 'All');
     $options = $options + $typecodes;
     $search->setOptions('type_code_id', $options);
     $search->setSearchData($search_data, $errors);
     return $search;
 }
예제 #3
0
 public function getTransferDetails($_whaction_id = '')
 {
     // Used by Ajax to get the From/To Locations/Bins based on Stock Item
     if (isset($this->_data['ajax'])) {
         if (!empty($this->_data['entry_point'])) {
             $_entry_point = $this->_data['entry_point'];
         }
         if (!empty($this->_data['whaction_id'])) {
             $_whaction_id = $this->_data['whaction_id'];
         }
         if (!empty($this->_data['stitem_id'])) {
             $_stitem_id = $this->_data['stitem_id'];
         }
         if (!empty($this->_data['from_whlocation_id'])) {
             $_from_location_id = $this->_data['from_whlocation_id'];
         }
         if (!empty($this->_data['from_whbin_id'])) {
             $_from_bin_id = $this->_data['from_whbin_id'];
         }
         if (!empty($this->_data['to_whlocation_id'])) {
             $_to_location_id = $this->_data['to_whlocation_id'];
         }
     } else {
         // if this is Save and Add Another then need to get $_POST values to set context
         $_stitem_id = isset($_POST[$this->modeltype]['stitem_id']) ? $_POST[$this->modeltype]['stitem_id'] : '';
         $_from_location_id = isset($_POST[$this->modeltype]['from_whlocation_id']) ? $_POST[$this->modeltype]['from_whlocation_id'] : '';
     }
     //		echo '$_stitem_id='.$_stitem_id.'<br>';
     // store the ajax status in a different var, then unset the current one
     // we do this because we don't want the functions we all to get confused
     $ajax = isset($this->_data['ajax']);
     unset($this->_data['ajax']);
     // ****************************************************************************
     // Get the To Locations for the selected action
     $from_locations = $this->getFromLocations($_whaction_id);
     $from_whlocation_ids = array_keys($from_locations);
     if (empty($_entry_point) || $_entry_point == $this->modeltype . '_stitem_id') {
         $this->view->set('from_locations', $from_locations);
         if (empty($_from_location_id)) {
             $_from_location_id = key($from_locations);
         }
         $this->view->set('from_whlocation', $from_locations[$_from_location_id]);
         $output['from_whlocation_id'] = array('data' => $from_locations, 'is_array' => is_array($from_locations));
     } elseif (empty($_from_location_id)) {
         $_from_location_id = key($from_locations);
     }
     $this->view->set('from_whlocation_id', $_from_location_id);
     //		echo '$_from_location_id='.$_from_location_id.'<br>';
     $from_location = new WHLocation();
     $from_location->load($_from_location_id);
     // ****************************************************************************
     // Get the Stock Item list if no stock item is selected
     $stitem = new STItem();
     if (empty($_entry_point)) {
         // No item selected so get list of items and set default as first in list
         $stock_items = array();
         if ($from_location->haveBalances($from_whlocation_ids)) {
             $stock_items = STBalance::getStockList($from_whlocation_ids);
         } else {
             $stock_items = $stitem->getAll();
         }
         if (empty($_stitem_id)) {
             $_stitem_id = key($stock_items);
         }
         $this->view->set('stock_item', $stock_items[$_stitem_id]);
         $this->view->set('stock_items', $stock_items);
         $output['stitem_id'] = array('data' => $stock_items, 'is_array' => is_array($stock_items));
     }
     if (empty($_entry_point) || $_entry_point == $this->modeltype . '_stitem_id') {
         $_entry_point = $this->modeltype . '_from_whlocation_id';
     }
     //		echo '$_stitem_id='.$_stitem_id.'<br>';
     $stitem->load($_stitem_id);
     $this->view->set('stitem_id', $_stitem_id);
     $this->view->set('uom', $stitem->uom_name);
     $output['uom_id'] = array('data' => $stitem->uom_name, 'is_array' => is_array($stitem->uom_name));
     // ****************************************************************************
     // Get the list of bins for the To Location if it is bin controlled
     if ($_entry_point == $this->modeltype . '_from_whlocation_id') {
         $from_bins = array();
         if ($from_location->isBinControlled()) {
             $from_bins = $stitem->getBinList($_from_location_id);
             $this->view->set('from_bins', $from_bins);
             // check if the input bin present and exists in the bin list
             // if not, check for an error (exists in post data)
             // then check if in bin list; if not, use first in bin list
             if (empty($_from_bin_id) || !isset($from_bins[$_from_bin_id])) {
                 if (isset($_POST[$this->modeltype]['from_whbin_id'])) {
                     $_from_bin_id = $_POST[$this->modeltype]['from_whbin_id'];
                     if (!isset($from_bins[$_from_bin_id])) {
                         $_from_bin_id = key($from_bins);
                     }
                 } else {
                     $_from_bin_id = key($from_bins);
                 }
             }
         } else {
             $_from_bin_id = '';
         }
         $output['from_whbin_id'] = array('data' => $from_bins, 'is_array' => is_array($from_bins));
     }
     //echo 'SttransactionsController::getTransferDetails bins<pre>'.print_r($from_bins,true).'</pre><br>';
     // ****************************************************************************
     // Get the balance of the selected Item for the selected From Location/Bin
     if ($from_location->isBalanceEnabled()) {
         $balance = $this->getBalance($_stitem_id, $_from_location_id, $_from_bin_id);
         $this->view->set('balance', $balance);
         $output['balance'] = array('data' => $balance, 'is_array' => is_array($balance));
     } else {
         $output['balance'] = '';
     }
     // ****************************************************************************
     // get the associated 'To Location' values for the selected from location
     if ($_entry_point == $this->modeltype . '_from_whlocation_id') {
         $to_locations = $this->getToLocations($_from_location_id, $_whaction_id);
         $this->view->set('to_locations', $to_locations);
         $this->view->set('to_whlocation', $to_locations[$_to_location_id]);
         //			if (empty($_to_location_id)) {
         $_to_location_id = key($to_locations);
         //			}
         $output['to_whlocation_id'] = array('data' => $to_locations, 'is_array' => is_array($to_locations));
         $_entry_point = $this->modeltype . '_to_whlocation_id';
     }
     $this->view->set('to_whlocation_id', $_to_location_id);
     $to_location = new WHLocation();
     $to_location->load($_to_location_id);
     // ****************************************************************************
     // Get the bin list for the To Location if it is bin controlled
     if ($_entry_point == $this->modeltype . '_to_whlocation_id') {
         $to_bins = array();
         if ($to_location->isBinControlled()) {
             $to_bins = $this->getBinList($_to_location_id);
             $this->view->set('to_bins', $to_bins);
         }
         $output['to_whbin_id'] = array('data' => $to_bins, 'is_array' => is_array($to_bins));
     }
     if ($ajax) {
         $this->view->set('data', $output);
         $this->setTemplateName('ajax_multiple');
     }
 }
예제 #4
0
 public function _new()
 {
     parent::_new();
     $mfoperation = $this->_uses[$this->modeltype];
     $stitem = new STItem();
     if ($mfoperation->isLoaded()) {
         $this->_data['stitem_id'] = $mfoperation->stitem_id;
     }
     if (empty($this->_data['stitem_id'])) {
         $stitems = $stitem->getAll();
         $this->view->set('stitems', $stitems);
         $stitem_id = key($stitems);
     } else {
         $stitem_id = $this->_data['stitem_id'];
     }
     $stitem->load($stitem_id);
     if (!empty($this->_data['stitem_id'])) {
         $this->view->set('page_title', $this->getPageName('Operation for ' . $stitem->getIdentifierValue()));
     }
     $this->getItemData($stitem_id);
     $this->view->set('no_ordering', true);
 }