if ($status_current == '4' && $status_new == '5' && $item['prod_status'] != '') { tep_db_perform('orders_products', array('prod_status' => ''), 'update', "orders_products_id='{$item_id}'"); } if ($status_current == '4' && $status_new == '5' && $at_machine > 0) { //IF PRODUCT IS FINISH, ALSO SET ANTITARNISH USAGE FOR NON OXIDIZED PRODUCTS $silver_usage = $class_o->calcSilverUsage($item_id); antitarnishUsageAdd($at_machine, $silver_usage); } } } } } elseif ($order_type == 'DP') { //Handle Depot Orders $item = $class_do->retrieveDetail($item_id); $sub_status_different = "{$item['status']}-{$item['prod_status']}" != $status_new; $is_outsourced = $class_do->isOutsourceOrder($item['trans_type'], $item['trans_id']); if (isset($item['status'])) { //Allow Products in Outsourcing to be set as Finish also using MC if ($item['status'] == '22' && $status_current == '4') { $status_current = '22'; } //Validate current status if ($item['status'] != $status_current && $sub_status_different) { //Handle invalid current status //ex 1: when trying to move from "ready" to "production", but current status is not "ready" //ex 2: when trynig to move from "production" to "finish", but current status is not "finish" $oiErrorStatus = oiErrorStatus($item['status']); if ($oiErrorStatus == 'MOVEDTODEPOT') { $result['status'] = 'UPDATED'; } else { $result['status'] = 'BADSTATUS';