Exemplo n.º 1
0
 public static function useDefault($search_data = null, &$errors = array(), $defaults = null)
 {
     $search = new structuresSearch($defaults);
     // Search by Stock Item
     $search->addSearchField('stitem_id', 'Stock Item', 'hidden', $search_data['stitem_id'], 'hidden');
     // Search by Date
     $search->addSearchField('start_date/end_date', 'Date', 'betweenfields', date(DATE_FORMAT), 'basic');
     // Search by Stock Item Used
     $search->addSearchField('ststructure_id', 'Stock Item Used', 'select', '', 'advanced');
     $stitem = DataObjectFactory::Factory('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($chain);
     $options = array('' => 'All');
     $options = $options + $stitems;
     $search->setOptions('ststructure_id', $options);
     $search->setSearchData($search_data, $errors);
     return $search;
 }
Exemplo n.º 2
0
 public function preorder()
 {
     //		foreach ($this->_data as $key=>$value) {
     //			echo $key.'='.$value.'<br>';
     //		}
     if (isset($this->_data['stitem_id'])) {
         $id = $this->_data['stitem_id'];
         $stitem = DataObjectFactory::Factory('STItem');
         $stitem->load($id);
         $this->view->set('transaction', $stitem);
         $s_data = array('stitem_id' => $id, 'start_date/end_date' => date(DATE_FORMAT));
         $this->search = structuresSearch::useDefault($s_data, $errors);
         if (count($errors) == 0) {
             self::showParts();
         }
         if (!isset($this->_data['qty'])) {
             $this->_data['qty'] = 1;
         }
         $this->view->set('qty', $this->_data['qty']);
         $this->view->set('clickmodule', array('module' => 'purchase_order'));
         $this->view->set('clickcontroller', 'poproductlineheaders');
         $this->view->set('clickaction', 'viewbydates');
         $this->view->set('linkvaluefield', 'ststructure_id');
         $this->view->set('no_ordering', true);
         $this->view->set('page_title', 'Pre-Order Requirements');
     }
 }
Exemplo n.º 3
0
 public function getItemData($_stitem_id = '')
 {
     // Used by Ajax to get the From/To Locations/Bins based on Stock Item
     if (isset($this->_data['ajax'])) {
         if (!empty($this->_data['stitem_id'])) {
             $_stitem_id = $this->_data['stitem_id'];
         }
     } else {
         // if this is Save and Add Another then need to get $_POST values to set context
         $_stitem_id = isset($_POST[$modeltype]['stitem_id']) ? $_POST[$modeltype]['stitem_id'] : $_stitem_id;
     }
     // 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']);
     $uom_list = $this->getUomList($_stitem_id);
     if ($ajax) {
         $output['uom_list'] = array('data' => $uom_list, 'is_array' => is_array($uom_list));
     } else {
         $this->view->set('uom_list', $uom_list);
     }
     $errors = array();
     $s_data = array('stitem_id' => $_stitem_id, 'start_date/end_date' => date(DATE_FORMAT));
     $this->search = structuresSearch::useDefault($s_data, $errors);
     if (count($errors) == 0) {
         self::showParts();
     }
     if ($ajax) {
         $html = $this->view->fetch($this->getTemplateName('show_parts'));
         $output['show_parts'] = array('data' => $html, 'is_array' => is_array($html));
     }
     // ****************************************************************************
     // Finally, if this is an ajax call, set the return data area
     if ($ajax) {
         $this->view->set('data', $output);
         $this->setTemplateName('ajax_multiple');
     }
 }