public function getUomList() { $uom_list = array(); $product = self::newProductline(); if ($this->productline_id && $product && $product->stuom_id) { $uom_list[$product->stuom_id] = $product->uom_name; } else { $uom = DataObjectFactory::Factory('STuom'); $stitem = DataObjectFactory::Factory('STItem'); if ($stitem->load($this->stitem_id)) { // Get UoM list for Stock Conversions $uom_temp_list = STuomconversion::getUomList($stitem->id, $stitem->uom_id); if (count($uom_temp_list) == 0) { // Get UoM list for world conversions $uom_temp_list = SYuomconversion::getUomList($stitem->uom_id); } $uom->load($stitem->uom_id); // Get the UoM of the Stock Item $uom_list[$stitem->uom_id] = $uom->getUomName(); if (count($uom_temp_list) > 0) { $uom_list += $uom_temp_list; } } else { // No stock item so just get the list of UoMs $uom_list = $uom->getAll(); } } return $uom_list; }
function buildReport($args) { // $MFWorkorders, $data, $bulk=true) { // specify default args $default_args = array('bulk' => TRUE); // build args from merged args + defaults $args = array_merge($default_args, $args); // make sure required items have been set if (!isset($args['model']) || !isset($args['data'])) { return FALSE; } // set a few vars $MFWorkorders = $args['model']; $data = $args['data']; $bulk = $args['bulk']; $dynamic_limit = 30; // must be even $pages = 1; $cases; $pallets; $extra = array(); if ($MFWorkorders->order_qty != '' && $bulk == true) { $st_uom_conversion = new STuomconversion(); $st_uom = new STuom(); $cases = $MFWorkorders->order_qty; // get the id of each uom we need $uom_pallet_id = $st_uom->getUomID('pallet'); $uom_case_id = $st_uom->getUomID('case'); $pallets = ceil($st_uom_conversion->convertFrom($MFWorkorders->stitem_id, $uom_case_id, $uom_pallet_id, $MFWorkorders->order_qty)); $pages = ceil($pallets / $dynamic_limit); if ($pages == 0) { $pages = 1; } } else { $cases = ''; $pallets = ''; // fire report with single page } $extra['cases'] = $cases; $extra['pallets'] = $pallets; // get stitem item_code $stitem = new STItem(); $stitem->load($MFWorkorders->stitem_id); $extra['item_code'] = $stitem->item_code; // construct the lines $row_count = $dynamic_limit / 2; /* * $p = page * $r = row */ for ($p = 0; $p < $pages; $p++) { $start_value = $dynamic_limit * $p + 1; for ($r = 0; $r < $row_count; $r++) { if ($bulk == true) { $field1 = $r + $start_value; $field2 = $r + $start_value + $row_count; } else { $field1 = '-'; $field2 = '-'; } $extra['pages'][$p]['page'][$r]['line'] = array('field1' => $field1, 'field2' => $field2); } } // construct filler xml to prevent repeating xsl $dummy_tables = array('table_1' => 9, 'table_2' => 6, 'table_3' => 2); foreach ($dummy_tables as $table => $rows) { for ($i = 0; $i < $rows; $i++) { $extra[$table][]['line'] = ''; } } // generate the XML, include the extras array too $xml = $this->controller->generateXML(array('model' => $MFWorkorders, 'extra' => $extra)); // build a basic list of options $options = array('report' => 'MF_PCMCOrderForm', 'xmlSource' => $xml); if (isset($args['merge_file_name'])) { $options['merge_file_name'] = $args['merge_file_name']; } return json_decode($this->controller->generate_output($data, $options)); }
public function view() { if (!$this->loadData()) { $this->dataError(); sendBack(); } $transaction = $this->_uses[$this->modeltype]; $id = $this->_data['id']; $this->view->set('transaction', $transaction); $item = DataObjectFactory::Factory('STItem'); $item->load($transaction->stitem_id); $obsolete = $item->isObsolete(); $active = $transaction->isActive(); $this->view->set('showform', !$obsolete && $active); if (!$obsolete && $active) { $this->_new(); $substitute = $transaction->getSubstitute(); $uom_list = array(); $substitute_used = false; if ($substitute) { // There is a future dated substitution, so get the details of it $ststructure = DataObjectFactory::Factory('STItem'); $ststructure->load($substitute->ststructure_id); if ($ststructure) { $uom_temp_list = STuomconversion::getUomList($substitute->ststructure_id, $ststructure->uom_id); $uom_temp_list += SYuomconversion::getUomList($ststructure->uom_id); $uom = DataObjectFactory::Factory('STuom'); $uom->load($ststructure->uom_id); $uom_list[$ststructure->uom_id] = $uom->getUomName(); $uom_list += $uom_temp_list; $this->view->set('uom_id', $ststructure->uom_id); } $wostructures = new MFWOStructureCollection(); $sh = new SearchHandler($wostructures); $sh->addConstraint(new Constraint('ststructure_id', '=', $substitute->id)); $wostructures->load($sh); $substitute_used = $wostructures->count() > 0; $this->view->set('uom_list', $uom_list); } else { $substitute = DataObjectFactory::Factory('MFStructure'); } $this->view->set('substitute', $substitute); } $sidebar = new SidebarController($this->view); $sidebar->addList('This Parent Item', array('view' => array('tag' => 'Show Structure', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index', 'stitem_id' => $transaction->stitem_id)))); $sidebar->addList('This Part Item', array('view' => array('tag' => 'Show Structure', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'index', 'stitem_id' => $transaction->ststructure_id)))); $sidebarlist = array(); if (!$obsolete && $active) { $sidebarlist['edit'] = array('tag' => 'Edit', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'edit', 'id' => $id, 'stitem_id' => $transaction->stitem_id, 'ststructure_id' => $transaction->ststructure_id)); } if (!$obsolete && !$transaction->end_date) { $sidebarlist['delete'] = array('tag' => 'End Today', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'delete', 'id' => $id, 'stitem_id' => $transaction->stitem_id)); } $sidebarlist['item'] = array('tag' => 'Show Parent Item', 'link' => array('modules' => $this->_modules, 'controller' => 'STItems', 'action' => 'view', 'id' => $transaction->stitem_id)); $sidebarlist['structure'] = array('tag' => 'Show Part Item', 'link' => array('modules' => $this->_modules, 'controller' => 'STItems', 'action' => 'view', 'id' => $transaction->ststructure_id)); $sidebar->addList('Current Structure', $sidebarlist); if (!$obsolete && $active && $substitute->isLoaded()) { $sidebarlist = array(); if (!$substitute_used) { $sidebarlist['delete'] = array('tag' => 'Delete', 'link' => array('modules' => $this->_modules, 'controller' => $this->name, 'action' => 'deleteSubstitute', 'id' => $id, 'stitem_id' => $transaction->stitem_id)); } $sidebar->addList('New Structure', $sidebarlist); } $this->view->register('sidebar', $sidebar); $this->view->set('sidebar', $sidebar); }
public function getUomList() { $uom_list = array(); if ($this->isLoaded()) { $uom_temp_list = STuomconversion::getUomList($this->id, $this->uom_id); if (count($uom_temp_list) == 0) { $uom_temp_list = SYuomconversion::getUomList($this->uom_id); } $uom = DataObjectFactory::Factory('STuom'); $uom->load($this->uom_id); $uom_list[$this->uom_id] = $uom->getUomName(); $uom_list += $uom_temp_list; } else { $uom = DataObjectFactory::Factory('STuom'); $uom_list = $uom->getAll(); } return $uom_list; }