public function _new() { parent::_new(); // work_order_id is set for adding a new structure // otherwise id is set, which is the id of the structure element $uom_list = array(); $wostructure = $this->_uses[$this->modeltype]; if (isset($this->_data['work_order_id'])) { $work_order_id = $this->_data['work_order_id']; $stitem_id = key($items_list); $uom_id = ''; } elseif ($wostructure->isLoaded()) { $work_order_id = $wostructure->work_order_id; $stitem_id = $wostructure->ststructure_id; $uom_id = $wostructure->uom_id; } if (isset($this->_data['ststructure_id'])) { $stitem_id = $this->_data['ststructure_id']; } $stitem = new STItem(); $stitem->load($stitem_id); $items_list = STItem::nonObsoleteItems(); if (!isset($items_list[$stitem_id])) { $items_list += array($stitem->id => $stitem->getIdentifierValue() . '(Obsolete)'); } $this->view->set('ststructures', $items_list); $uom_id = empty($uom_id) ? $stitem->uom_id : $uom_id; $this->view->set('uom_id', $uom_id); $uom_list = $stitem->getUomList(); if (isset($work_order_id)) { $this->view->set('elements', self::showParts($work_order_id)); $this->view->set('no_ordering', true); } $this->view->set('uom_list', $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 = 40; // must be even $pages = 1; $extra = array(); // get product 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++) { $extra['pages'][$p]['page'][$r]['line'] = array('field1' => '', 'field2' => ''); } } // construct filler xml to prevent repeating xsl $dummy_tables = array('table_1' => 6); 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_BLKOrderForm', '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)); }
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']; // looks like we're always just going to print one page $pages = 1; $dynamic_limit = 40; // 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); } } // generate the XML, include the extras array too $xml = $this->controller->generateXML(array('model' => $MFWorkorders, 'extra' => $extra)); if (isset($args['merge_file_name'])) { $options['merge_file_name'] = $args['merge_file_name']; } // build a basic list of options $options = array('report' => 'MF_DFCOrderForm', 'xmlSource' => $xml); return json_decode($this->controller->generate_output($data, $options)); }
public function save() { $flash = Flash::Instance(); $stitem = new STItem(); $stitem->load($this->_data['STuomconversion']['stitem_id']); if ($stitem->uom_id == $this->_data['STuomconversion']['from_uom_id'] || $stitem->uom_id == $this->_data['STuomconversion']['to_uom_id']) { if (parent::save('STuomconversion')) { sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null); } } else { $flash->addError('The From UoM or the To UoM must be the base UoM'); } $this->_data['stitem_id'] = $this->_data['STuomconversion']['stitem_id']; $this->refresh(); }
public function save() { $flash = Flash::Instance(); $db = DB::Instance(); $db->StartTrans(); $errors = array(); if (parent::save('MFOutsideOperation')) { $stitem = new STItem(); if ($stitem->load($this->saved_model->stitem_id)) { $old_cost = $stitem->latest_osc; $stitem->calcLatestCost(); $new_cost = $stitem->latest_osc; if (bccomp($old_cost, $new_cost, $stitem->cost_decimals) != 0) { if ($stitem->saveCosts() && STCost::saveItemCost($stitem)) { if (!$stitem->rollUp(STItem::ROLL_UP_MAX_LEVEL)) { $errors[] = 'Could not roll-up latest costs'; $db->FailTrans(); } } else { $errors[] = 'Could not save latest costs'; $db->FailTrans(); } } } else { $errors[] = 'Could not save latest costs'; $db->FailTrans(); } } else { $errors[] = 'Could not save outside operation'; $db->FailTrans(); } $db->CompleteTrans(); if (count($errors) == 0) { sendTo('STItems', 'viewoutside_operations', $this->_modules, array('id' => $this->_data['MFOutsideOperation']['stitem_id'])); } else { $flash->addErrors($errors); $this->_data['stitem_id'] = $this->_data['MFOutsideOperation']['stitem_id']; $this->refresh(); } }
function __construct($MFWorkorders) { $this->printparams['subject'] = 'DFCCONVFlowWrapChecksheet'; $this->printparams['defaultfilename'] = 'DFCCONVFlowWrapChecksheet'; $this->document['title'] = 'DFC-CONV Flow-Wrap Checksheet'; $this->document['size'] = 'A4'; $this->document['orientation'] = 'landscape'; // get product code --- $stitem = new STItem(); $stitem->load($MFWorkorders->stitem_id); $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('top-margin' => 580, 'format' => array('textCol' => $this->textcol, 'rowGap' => 3, 'colGap' => 2, 'showHeadings' => 0, 'shaded' => 0, 'width' => 800, 'showLines' => 0, 'shaded' => 1, 'lineCol' => $this->linecol, 'xPos' => 420, 'xOrientation' => 'center', 'fontSize' => 13), 'cols' => array('1' => array('title' => '<b>DFC-CONV FLOW-WRAP CHECKSHEET</b>', 'width' => 800, 'justification' => 'center')))); $header_text = array(array('value' => 'Initial checks to be made at start up'), array('value' => 'Further checks to be made at 1 hourly intervals or following breakdown')); $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('top-margin' => 555, 'uses' => $header_text, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'showHeadings' => 0, 'width' => 300, 'showLines' => 0, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 9), 'cols' => array('value' => array('title' => 'Description')))); $header_table = array(array('desc' => 'PRODUCT CODE', 'value' => $stitem->item_code . ''), array('desc' => 'WORKS ORDER', 'value' => $MFWorkorders->wo_number . ''), array('desc' => 'DATE CODE AT START', 'value' => '')); $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('top-margin' => 570, 'uses' => $header_table, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'showHeadings' => 0, 'width' => 110, 'showLines' => 2, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 612, 'xOrientation' => 'right', 'fontSize' => 9, 'float-bottom-margin' => true), 'cols' => array('desc' => array('title' => 'desc', 'width' => 110), 'value' => array('title' => 'value', 'width' => 100)))); $data = array(); for ($counter = 1; $counter <= 30; $counter++) { $data[$counter] = array('1' => '', '2' => '', '3' => '', '4' => '', '5' => '', '6' => '', '7' => '', '8' => '', '9' => '', '10' => '', '11' => '', '12' => ''); } $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('spacebefore' => 10, 'uses' => $data, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'colGap' => 2, 'showHeadings' => 1, 'width' => 800, 'showLines' => 2, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 9, 'float-bottom-margin' => true), 'cols' => array('1' => array('title' => 'DATE', 'width' => 55, 'justification' => 'center'), '2' => array('title' => 'TIME', 'width' => 55, 'justification' => 'center'), '3' => array('title' => 'SHEET SIZE LENGTH / WIDTH', 'width' => 90, 'justification' => 'center'), '5' => array('title' => 'SHEET COUNT', 'width' => 50, 'justification' => 'center'), '6' => array('title' => 'DATE CODE / TIME LEGIBLE', 'width' => 90, 'justification' => 'center'), '7' => array('title' => 'NETT PACK WEIGHT (GMS)', 'width' => 90, 'justification' => 'center'), '8' => array('title' => 'OPENING FLAP OPENS CLEANLY', 'width' => 90, 'justification' => 'center'), '9' => array('title' => 'FIRMLY GLUED END', 'width' => 90, 'justification' => 'center'), '10' => array('title' => 'APPEARANCE', 'width' => 90, 'justification' => 'center'), '11' => array('title' => 'MET.DET Y/N', 'width' => 50, 'justification' => 'center'), '12' => array('title' => 'INITIALS', 'width' => 50, 'justification' => 'center')))); $this->document['footer']['content'][] = array('type' => 'table', 'contains' => array('top-margin' => 30, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'showHeadings' => 0, 'width' => 555, 'showLines' => 0, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 5), 'cols' => array('1' => array('value' => 'DFC-FW/HCS Issue 1 10/02/2009')))); $this->document['criteria'] = ''; }
function __construct($MFWorkorders) { $this->printparams['subject'] = 'DFCCONVReelLoadingChecksheet'; $this->printparams['defaultfilename'] = 'DFCCONVReelLoadingChecksheet'; $this->document['title'] = 'DFC-CONV Reel Loading Checksheet'; $this->document['size'] = 'A4'; $this->document['orientation'] = 'portrait'; // get product code --- $stitem->item_code $stitem = new STItem(); $stitem->load($MFWorkorders->stitem_id); $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('spacebefore' => 0, 'format' => array('textCol' => $this->textcol, 'rowGap' => 3, 'colGap' => 2, 'showHeadings' => 0, 'shaded' => 0, 'width' => 555, 'showLines' => 0, 'shaded' => 1, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 13), 'cols' => array('1' => array('title' => '<b>DFC-CONV REEL LOADING CHECKSHEET</b>', 'width' => 555, 'justification' => 'center')))); $header_text = array(array('value' => 'Date and time of each reel loaded to be entered onto sheet')); $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('spacebefore' => 10, 'uses' => $header_text, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'showHeadings' => 0, 'width' => 300, 'showLines' => 0, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 9), 'cols' => array('value' => array('title' => 'Description')))); $header_table = array(array('desc' => 'PRODUCT CODE', 'value' => $stitem->item_code . ''), array('desc' => 'WORKS ORDER', 'value' => $MFWorkorders->wo_number . '')); $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('spacebefore' => 10, 'uses' => $header_table, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'colGap' => 2, 'showHeadings' => 0, 'width' => 110, 'showLines' => 2, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 9, 'float-bottom-margin' => true), 'cols' => array('desc' => array('title' => 'desc', 'width' => 110), 'value' => array('title' => 'value', 'width' => 100)))); $data = array(); for ($counter = 1; $counter <= 40; $counter++) { $data[$counter] = array('1' => '', '2' => '', '3' => '', '4' => '', '5' => '', '6' => ''); } $this->document['header']['content'][] = array('type' => 'table', 'contains' => array('spacebefore' => 10, 'uses' => $data, 'format' => array('textCol' => $this->textcol, 'rowGap' => 3, 'colGap' => 2, 'showHeadings' => 1, 'width' => 555, 'showLines' => 2, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 9, 'float-bottom-margin' => true), 'cols' => array('1' => array('title' => 'DATE', 'width' => 70, 'justification' => 'center'), '2' => array('title' => 'TIME', 'width' => 70, 'justification' => 'center'), '3' => array('title' => 'REEL NUMBER', 'width' => 137.5, 'justification' => 'center'), '4' => array('title' => 'DATE', 'width' => 70, 'justification' => 'center'), '5' => array('title' => 'TIME', 'width' => 70, 'justification' => 'center'), '6' => array('title' => 'REEL NUMBER', 'width' => 137.5, 'justification' => 'center')))); $footer_ref = array(array('value' => 'Issue 2:'), array('value' => '13/02/2006')); $this->document['footer']['content'][] = array('type' => 'table', 'contains' => array('top-margin' => 40, 'uses' => $footer_ref, 'format' => array('textCol' => $this->textcol, 'rowGap' => 2, 'showHeadings' => 0, 'width' => 555, 'showLines' => 0, 'shaded' => 0, 'lineCol' => $this->linecol, 'xPos' => 20, 'xOrientation' => 'right', 'fontSize' => 5), 'cols' => array('value' => array('title' => 'Description')))); $this->document['criteria'] = ''; }
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'); } }
public function save() { $flash = Flash::Instance(); $db = DB::Instance(); $db->StartTrans(); $errors = array(); $update_cost = false; if (isset($this->_data[$this->modeltype]['id']) && $this->_data[$this->modeltype]['id']) { $mfresource = new MFResource(); $mfresource->load($this->_data[$this->modeltype]['id']); $old_rate = $mfresource->resource_rate; $new_rate = $this->_data[$this->modeltype]['resource_rate']; $update_cost = $old_rate != $new_rate; } if (parent::save_model($this->modeltype, null, $errors)) { if ($update_cost) { $cc = new ConstraintChain(); $cc->add(new Constraint('mfresource_id', '=', $this->_data[$this->modeltype]['id'])); $db = DB::Instance(); $date = Constraint::TODAY; $between = $date . ' BETWEEN ' . $db->IfNull('start_date', $date) . ' AND ' . $db->IfNull('end_date', $date); $cc->add(new Constraint('', '', '(' . $between . ')')); $mfoperation = new MFOperation(); //$db->Debug(); $mfoperation_ids = array_keys($mfoperation->getAll($cc)); $stitem_ids = array(); foreach ($mfoperation_ids as $mfoperation_id) { if (!$mfoperation->load($mfoperation_id)) { $errors[] = 'Could not save latest costs'; $db->FailTrans(); break; } if (in_array($mfoperation->stitem_id, $stitem_ids)) { continue; } $stitem_ids[] = $mfoperation->stitem_id; } if (count($stitem_ids) > 0) { $stitem = new STItem(); } foreach ($stitem_ids as $stitem_id) { if (!$stitem->load($stitem_id)) { $errors[] = 'Could not save latest costs'; $db->FailTrans(); break; } $old_cost = $stitem->latest_lab; $stitem->calcLatestCost(); $new_cost = $stitem->latest_lab; if (bccomp($old_cost, $new_cost, $stitem->cost_decimals) == 0) { continue; } if (!$stitem->saveCosts() || !STCost::saveItemCost($stitem)) { $errors[] = 'Could not save latest costs'; $db->FailTrans(); break; } if (!$stitem->rollUp(STItem::ROLL_UP_MAX_LEVEL)) { $errors[] = 'Could not roll-up latest costs'; $db->FailTrans(); break; } } } } else { $errors[] = 'Could not save resource'; $db->FailTrans(); } $db->CompleteTrans(); if (count($errors) == 0) { sendTo($_SESSION['refererPage']['controller'], $_SESSION['refererPage']['action'], $_SESSION['refererPage']['modules'], isset($_SESSION['refererPage']['other']) ? $_SESSION['refererPage']['other'] : null); } else { $flash->addErrors($errors); $this->refresh(); } }
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)); }
/** * Build the line * */ public static function makeLine($order, $orderline, &$errors) { $despatchline = array(); if ($order->isLoaded()) { if ($order->customerdetails->accountStopped()) { $errors['id' . $order->id] = 'Cannot despatch order ' . $order->order_number . ' (' . $order->customerdetails->name . ') Account Stopped'; } else { $despatchline['order_id'] = $order->id; $despatchline['orderline_id'] = $orderline->id; $despatchline['slmaster_id'] = $order->slmaster_id; $despatchline['stuom_id'] = $orderline->stuom_id; if ($orderline->stitem_id) { $despatchline['stitem_id'] = $orderline->stitem_id; } if ($orderline->productline_id) { $despatchline['productline_id'] = $orderline->productline_id; } $despatchline['despatch_qty'] = $orderline->os_qty; $despatchline['despatch_date'] = date(DATE_FORMAT); $despatchline['despatch_action'] = $order->despatch_action; $despatchline['status'] = 'N'; $stitem = new STItem(); $stitem->load($data['stitem_id']); $param = new GLParams(); $net_mass_uom_id = $param->intrastat_net_mass(); if ($stitem->isLoaded() && !empty($net_mass_uom_id)) { $despatchline['net_mass'] = $stitem->convertToUoM($despatchline['stuom_id'], $net_mass_uom_id, $despatchline['despatch_qty']); } } } if (empty($despatchline['net_mass']) || $despatchline['net_mass'] === false) { $despatchline['net_mass'] = 0; } return $despatchline; }
public function getUomList($_stitem_id = '') { // used by ajax to get the UoM if (isset($this->_data['ajax'])) { if (!empty($this->_data['stitem_id'])) { $_stitem_id = $this->_data['stitem_id']; } } $stitem = new STItem(); $stitem->load($_stitem_id); $list = $stitem->getUomList(); if (isset($this->_data['ajax'])) { $this->view->set('options', $list); $this->setTemplateName('select_options'); } else { return $list; } }
public function getItemDetail($_budget_item_id = '', $_budget_item_type = '') { if (!empty($this->_data['budget_item_id'])) { $_budget_item_id = $this->_data['budget_item_id']; } if (!empty($this->_data['budget_item_type'])) { $_budget_item_type = $this->_data['budget_item_type']; } $uom_id = ''; switch ($_budget_item_type) { case 'R': $budgetitem = new SOProductline(); $budgetitem->load($_budget_item_id); $uom_id = $budgetitem->stuom_id; $cost_rate = 0; $setup_cost = 0; $charge_rate = $budgetitem->price; $setup_charge = 0; break; case 'E': $budgetitem = new ProjectEquipment(); $budgetitem->load($_budget_item_id); $uom_id = $budgetitem->uom_id; $cost_rate = $budgetitem->cost_rate; $setup_cost = $budgetitem->setup_cost; $charge_rate = 0; $setup_charge = 0; break; case 'M': $budgetitem = new STItem(); $budgetitem->load($_budget_item_id); $uom_id = $budgetitem->uom_id; $cost_rate = $budgetitem->latest_cost; $setup_cost = 0; $charge_rate = 0; $setup_charge = 0; break; case 'L': $budgetitem = new MFResource(); $budgetitem->load($_budget_item_id); $cost_rate = $budgetitem->resource_rate; $uom_id = 11; $setup_cost = 0; $charge_rate = 0; $setup_charge = 0; break; default: $budgetitem = false; } if ($budgetitem && $budgetitem->isLoaded()) { $output['description'] = array('data' => $budgetitem->getIdentifierValue(), 'is_array' => false); $output['uom_id'] = array('data' => $uom_id, 'is_array' => false); $output['cost_rate'] = array('data' => $cost_rate, 'is_array' => false); $output['setup_cost'] = array('data' => $setup_cost, 'is_array' => false); $output['charge_rate'] = array('data' => $charge_rate, 'is_array' => false); $output['setup_charge'] = array('data' => $setup_charge, 'is_array' => false); } else { $output['description'] = array('data' => '', 'is_array' => false); $output['uom_id'] = array('data' => '', 'is_array' => false); $output['cost_rate'] = array('data' => 0, 'is_array' => false); $output['setup_cost'] = array('data' => 0, 'is_array' => false); $output['charge_rate'] = array('data' => 0, 'is_array' => false); $output['setup_charge'] = array('data' => 0, 'is_array' => false); } if (isset($this->_data['ajax'])) { $this->view->set('data', $output); $this->setTemplateName('ajax_multiple'); } else { return $output; } }
public function save() { $flash = Flash::Instance(); if (!$this->checkParams('MFOperation')) { sendBack(); } $data = $this->_data['MFOperation']; $db = DB::Instance(); $db->StartTrans(); $errors = array(); if (!($data['volume_target'] > 0)) { $errors[] = 'Volume target must be a number greater than zero'; } if (!($data['uptime_target'] > 0)) { $errors[] = 'Uptime target must be a number greater than zero'; } if (!($data['quality_target'] > 0)) { $errors[] = 'Quality target must be a number greater than zero'; } if (!($data['resource_qty'] > 0)) { $errors[] = 'Resource quantity must be a number greater than zero'; } if (count($errors) == 0 && parent::save_model('MFOperation')) { $stitem = new STItem(); if ($stitem->load($this->saved_model->stitem_id)) { $old_costs = array($stitem->latest_lab, $stitem->latest_ohd); $stitem->calcLatestCost(); $new_costs = array($stitem->latest_lab, $stitem->latest_ohd); $equal_costs = true; $total_costs = count($old_costs); for ($i = 0; $i < $total_costs; $i++) { if (bccomp($old_costs[$i], $new_costs[$i], $stitem->cost_decimals) != 0) { $equal_costs = false; break; } } if (!$equal_costs) { if ($stitem->saveCosts() && STCost::saveItemCost($stitem)) { if (!$stitem->rollUp(STItem::ROLL_UP_MAX_LEVEL)) { $errors[] = 'Could not roll-up latest costs'; } } else { $errors[] = 'Could not save latest costs'; } } } else { $errors[] = 'Could not save latest costs'; } } else { $errors[] = 'Could not save operation'; } if (count($errors) > 0) { $db->FailTrans(); } $db->CompleteTrans(); if (count($errors) == 0) { sendTo($this->name, 'index', $this->_modules, array('stitem_id' => $data['stitem_id'])); } else { $flash->addErrors($errors); $this->_data['stitem_id'] = $data['stitem_id']; $this->refresh(); } }