コード例 #1
0
 //PRODUCT AVAILABLE IN DEPOT
 $class_pm->stockReduce($whid_depot, $oi['products_id'], $oi['products_articles_id'], $order_qty, 'RED-FG ' . $order_type . '-' . $oiid);
 $products_stock[$stock_id] -= $order_qty;
 if ($products_stock[$stock_id] < 0) {
     $products_stock[$stock_id] = 0;
 }
 if (isset($products_stock_booked_instock[$stock_id])) {
     $products_stock_booked_instock[$stock_id] -= $order_qty;
 }
 if ($order_type == 'SP') {
     $class_jo->updateItemStockStatus($oiid, 'D');
     if ($oi['status'] != $new_status) {
         //PRODUCT IS NOT YET MOVED TO IN HH TAB
         $class_jo->updateItemStatus($oiid, $new_status, 'auto-set');
         if ($oi['status'] < 4) {
             $class_jo->productionTargetInReset($oi);
         }
     }
 } elseif ($order_type == 'JG') {
     $class_o->updateProductStockStatus($oiid, 'D');
     if ($oi['status'] != $new_status) {
         //PRODUCT IS NOT YET MOVED TO IN HH TAB
         $class_o->updateProductStatus($oiid, $new_status, 'auto-set');
         if ($oi['status'] < 4) {
             $class_o->productionTargetInReset($oi);
         }
     }
 }
 //IF SOURCE ORDER STATUS IS (NEW/SOURCING) OR (READY AND PI IS NOT YET PRINTED)
 if (in_array($oi['status'], $oi_status_to_reset_stock_status) || $oi['status'] == '3' && $oi['print_count'] == 0) {
     //CHECK STOCK STATUS TO DECIDE WHAT STOCK SHOULD BE READDED
コード例 #2
0
 function updateStatus($items_id, $new_status, $updater = '', $add_to_prod_target = true)
 {
     use_class('production_target');
     $pt = new production_target();
     list($new_status, $sub_status) = explode('-', $new_status);
     $item = $this->retrieveDetail($items_id);
     $is_outsourced = $this->isOutsourceOrder($item['trans_type'], $item['trans_id']);
     $timestamp = date('Y-m-d H:i:s');
     $sub_status = trim(strtoupper($sub_status));
     if ($new_status == '10') {
         $this->doCancelOrders($items_id, $item['status'], $updater);
     } else {
         if ($add_to_prod_target) {
             if (!$is_outsourced) {
                 //outsourcing orders should never affect the Finish KPI Graphs
                 if ($new_status == '5') {
                     $pt->addDataToField($timestamp, 'finish', $item['quantity']);
                 }
             }
             if ($new_status == '6') {
                 $pt->addDataToField($timestamp, 'package', $item['quantity']);
             }
             if ($new_status == '7') {
                 $pt->addDataToField($timestamp, 'sent', $item['quantity']);
             }
         }
         if ($new_status == '4' && $sub_status != '') {
             $set_prod_status = ", prod_status = '" . $sub_status . "'";
         }
         //PS: please don't set empty prod_status when it updated to status > 4,...
         //...since this will used for check whether order could transferred to DP or not...
         //...when real order taken over by HH while order still on production
         tep_db_query("UPDATE depot_orders SET status='{$new_status}' {$set_prod_status} WHERE depot_orders_id={$items_id}");
         $save_main_status_history = true;
         //if ( ( in_array($item['status'], array('1','3','4','5')) && $new_status=='4' ) && ( $sub_status!='' && ( trim(strtoupper($item['prod_status'])) != $sub_status ) ) ) {
         /*
         $item['status'] = 1 is included here to also save prod. status history when there's real order cancelled/taken over by hh caused using depot hh stock
         while real order is already processed in production, finish, or in package. The first status created was 1.
         */
         //replace using below, allowing all process which set to production to have a chance saving the prod. status history
         if ($new_status == '4' && $sub_status != '' && trim(strtoupper($item['prod_status'])) != $sub_status) {
             $psh = array();
             $psh['orders_items_id'] = $items_id;
             $psh['type'] = 'DP';
             $psh['status'] = $sub_status;
             $psh['status_quantity'] = $item['quantity'];
             $psh['status_date'] = $timestamp;
             $psh['update_by'] = $updater;
             saveProductionStatusHistory($psh);
             if ($item['status'] == '4') {
                 $save_main_status_history = false;
             }
         }
         if ($save_main_status_history) {
             $sda = array();
             $sda['depot_orders_id'] = $items_id;
             $sda['status'] = $new_status;
             $sda['update_time'] = $timestamp;
             $sda['update_by'] = $updater;
             tep_db_perform('depot_orders_status_history', $sda);
         }
         if (!$is_outsourced) {
             if ($new_status == '2' && $item['stock_status'] != 'S' && $item['stock_status'] != 'W') {
                 $this->updateStockStatus($items_id, false);
                 $this->prodStatusReset($items_id);
                 $this->eanPrintedReset($items_id);
                 //$this->printCountReset($items_id);    //now we don't need to reset print_count for reprint pi when move to ready again.
             } elseif ($new_status == '3' && $item['stock_status'] == 'S' || $new_status == '4' && $item['stock_status'] == 'W') {
                 $eu = $this->countElementsUsage($item['products_id'], $item['articles_id']);
                 if (count($eu) > 0) {
                     $jng_warehouses_id = '1';
                     use_class('elements_stock');
                     $class_es = new elements_stock();
                     foreach ($eu as $elements_id => $euqty) {
                         $reduce_amount = $item['quantity'] * $euqty;
                         $class_es->reduceStockByPieces($jng_warehouses_id, $elements_id, $reduce_amount, 'RED DP-' . $items_id);
                     }
                 }
                 $this->updateStockStatus($items_id, 'R');
             }
         }
     }
     switch ($item['trans_type']) {
         case 'SP':
             use_class('jng_sp_orders');
             $class_jo = new jng_sp_orders();
             $item_sp = $class_jo->retrieveItemDetail($item['trans_id']);
             if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) {
                 $class_jo->productionTargetIn($timestamp, $item_sp);
             } elseif ($new_status == '6') {
                 $class_jo->productionTargetOut($timestamp, $item_sp);
             } elseif ($new_status == '12') {
                 $class_jo->productionTargetInReset($item_sp);
             }
             break;
         case 'JG':
             use_class('orders');
             $class_o = new orders();
             $item_jg = $class_o->retrieveProductDetail($item['trans_id']);
             if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) {
                 $class_o->productionTargetIn($timestamp, $item_jg);
             } elseif ($new_status == '6') {
                 $class_o->productionTargetOut($timestamp, $item_jg);
             } elseif ($new_status == '12') {
                 $class_o->productionTargetInReset($item_jg);
             }
             break;
         default:
             if ($item['status'] == '1' && ($new_status == '2' || $new_status == '3')) {
                 $this->productionTargetIn($timestamp, $item);
             } elseif ($new_status == '6') {
                 $this->productionTargetOut($timestamp, $item);
             } elseif ($new_status == '12') {
                 $this->productionTargetInReset($item);
             }
     }
     if ($new_status == '3' && !$is_outsourced) {
         //use_class('production_instruction_pdf');
         //$class_pi = new production_instruction_pdf();
         if ($item['print_count'] > 0 && $item['print_confirmed'] > 0) {
             //SECOND OR MORE PI PRINTED, could happen when there product by stock_status is "OK" but in real stock is "0" so this will set back to "NS". And when ready this will reprinted by using this block
             $this->printConfirmReset($items_id);
             $this->printCountReset($items_id);
         }
         /*
         $class_pi->addOrder('DP', $items_id);
         $add_to_daily_statistic = $item['print_count']==0 ? true : false;
         $class_pi->createPDF(false, 'F', $add_to_daily_statistic);
         */
     }
     return $new_status;
 }