$row_temp = array();
 $tab_have_sub_status = array('4');
 foreach ($status_to_show as $sv) {
     $colval = isset($kpi_status_cycletime[$sv]) ? array_sum($kpi_status_cycletime[$sv]) / count($kpi_status_cycletime[$sv]) : 0;
     $temp_status = explode('-', $sv);
     if ($colval > 0 || !isset($temp_status[1]) && isset($kpi_status_cycletime[$sv])) {
         $result = true;
         $total_process += $colval;
         if (isset($temp_status[1])) {
             $total_process_sub[$temp_status[0]] += $colval;
         }
         if (in_array($temp_status[0], $tab_have_sub_status) && !isset($row_temp[$temp_status[0]])) {
             $row_temp[$temp_status[0]]['c1'] = '<strong style="font-size:13px;">' . statusName($temp_status[0]) . '</strong>';
             $total_process_temp[$sv] += $colval;
         }
         $row_temp[$sv]['c1'] = $temp_status[0] == '4' && isset($temp_status[1]) ? statusNameProduction($temp_status[1]) : statusName($sv);
         $row_temp[$sv]['c2 right'] = displayDuration($colval, 'day', 2);
         if (!isset($temp_status[1])) {
             $row_temp[$sv]['c1'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c1'] . '</strong>';
             $row_temp[$sv]['c2 right'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c2 right'] . '</strong>';
         }
         if (isset($temp_status[1])) {
             $row_temp[$sv]['c1'] = '<div style="margin-left:20px;">' . $row_temp[$sv]['c1'] . '</div>';
         }
     }
 }
 //Show sub status leadtime
 foreach ($row_temp as $rk => $rv) {
     $row = array();
     if (in_array($rk, $tab_have_sub_status)) {
         if (isset($total_process_sub[$rk])) {
function oiErrorStatus($item_status)
{
    //STATUS MISMATCH HANDLER
    global $order_type, $item_id, $status_current, $status_new, $user_name, $class_do, $class_jo, $class_o, $status_name;
    $result = '';
    $add_info = '';
    if ($item_status == 'OUTSOURCING-2-PRODUCTION') {
        $result = 'ERROR: Outsourcing Orders, can not set to Production!';
    } else {
        //error when set to production
        if ($item_status == 4 || $status_current == 3 && $status_new == 4 || !is_numeric($status_new)) {
            //get additional information to be displayed on MC error message
            if ($order_type == 'SP') {
                $item = $class_jo->retrieveItemDetail($item_id);
                $item_history = $class_jo->retrieveItemHistory($item_id);
            } elseif ($order_type == 'JG') {
                $item = $class_o->retrieveProductDetail($item_id);
                $item_history = $class_o->retrieveProductHistory($item_id);
            } elseif ($order_type == 'DP') {
                $item = $class_do->retrieveDetail($item_id);
                $item_history = $class_do->retrieveHistory($item_id);
            }
            $last_history = end($item_history);
            $last_production_history = end(retrieveProductionHistory($order_type, $item_id));
            $now = time();
            if ($order_type == 'SP' || $order_type == 'JG') {
                $last_status_time = strtotime($last_production_history['status_date']) > strtotime($last_history['status_date']) ? $last_production_history['status_date'] : $last_history['status_date'];
            } elseif ($order_type == 'DP') {
                $last_status_time = strtotime($last_production_history['update_time']) > strtotime($last_history['update_time']) ? $last_production_history['update_time'] : $last_history['update_time'];
            }
            $time_duration = abs($now - strtotime($last_status_time));
            //if more than 10 minutes
            $timedur = displayDuration($time_duration, 1, 0);
            $add_info = ",\nmoved since{$timedur} ago";
            if (floor($time_duration / 60) > 10 && $item['status'] == '4') {
                //display information on which tab this order processed on production
                $line_status = statusNameProduction($item['prod_status'], false, true);
                if ($line_status != '') {
                    $add_info .= ",\nplease check {$line_status}.";
                }
            }
        }
        if (!is_numeric($item_status)) {
            //Error Message for Production Sub Status
            $result = "ERROR: Status is now " . statusNameProduction($item_status, false, true) . $add_info;
        } else {
            $status_depos_sent_cancel = array('8', '9', '10', '11', '12', '14', '15', '16', '17', '18', '19', '20', '21');
            $status_new_temp = explode('-', $status_new);
            $sub_status = isset($status_new_temp[1]) ? $status_new_temp[1] : '';
            if ($order_type != 'DP' && in_array($item_status, $status_depos_sent_cancel)) {
                //If Not a Depot Order AND Current Product Status is handled by HH
                if ($status_current == '3' && ($status_new == '4' || !is_numeric($status_new))) {
                    //FOR SET2PROD RULE
                    /* Stop process when:
                           1) Real order taken over by HH and already have stock allocated     "set2prod_rule1"
                           2) or Real order already proceed by HH (status >= 9 "sent")         "set2prod_rule2"
                       */
                    $set2prod_rule1 = $item_status == '8' && $item['stock_status'] == 'D';
                    $set2prod_rule2 = $item_status != '8';
                    if ($set2prod_rule1 || $set2prod_rule2) {
                        $ok_for_production = false;
                    } else {
                        $ok_for_production = true;
                    }
                    $item_do = $class_do->retrieveDetailTransmigran($order_type, $item_id);
                    if ($ok_for_production) {
                        if (is_null($item_do)) {
                            if (realOrderIsPossibleToTransferred($order_type, $item_id)) {
                                //Transfer to DP if order is possible to transferred
                                $item_do = $class_do->transferFromRealOrder(SEGMENT_ID_HAMBURG, $order_type, $item_id);
                                $class_do->updateStatus($item_do['depot_orders_id'], $status_new, $user_name);
                                $result = "MOVEDTODEPOT";
                            } else {
                                $result = "ERROR: {$order_type}-{$item_id} could not transferred to Depot Orders!\nplease make sure order scanned is correct!";
                            }
                        } else {
                            //If MMO then update Depot Order Status
                            if ($item_do['status'] == $status_current || $item_do['status'] == $status_new_temp[0]) {
                                //SET2PRODSUBSTATUS
                                if (!is_numeric($status_new)) {
                                    //If DP already in same sub status or status in Production or more
                                    if ($item_do['prod_status'] == $sub_status || $item_do['status'] >= 4) {
                                        $result = "ERROR: Status is now " . statusNameProduction($item_do['prod_status'], false, true) . $add_info;
                                    } else {
                                        $class_do->updateStatus($item_do['depot_orders_id'], "{$status_new}", $user_name);
                                        $result = "MOVEDTODEPOT";
                                    }
                                } else {
                                    //If Depot Order Status match OR Depot Order Status already updated
                                    //Update Order Status only if it's match and not already updated
                                    if ($item_do['status'] == $status_current) {
                                        $class_do->updateStatus($item_do['depot_orders_id'], $status_new, $user_name);
                                    }
                                    $result = "MOVEDTODEPOT";
                                }
                            } else {
                                $result = "ERROR: Status is now " . $status_name[$item_do['status']] . $add_info;
                            }
                        }
                    } else {
                        if (!is_null($item_do)) {
                            $class_do->doCancelOrders($item_do['depot_orders_id'], $item_do['status'], 'auto-set');
                        }
                        $result = "(HH) CANCEL PRODUCTION!";
                    }
                } elseif ($status_current == '4' && !is_numeric($status_new)) {
                    //FOR SET2BETWEENPRODSUBSTATUS RULE
                    $item_do = $class_do->retrieveDetailTransmigran($order_type, $item_id);
                    if (is_null($item_do)) {
                        //check from last status on production to decide whether process need to continue or stop
                        $prod_histories = retrieveProductionHistory($order_type, $item_id);
                        $n_histories = count($prod_histories);
                        $ok_for_production = true;
                        if ($n_histories > 0) {
                            $last_status_prod_hist = $prod_histories[$n_histories - 1];
                            $last_status_on_prod = $last_status_prod_hist['status'];
                            //stop process when last status is order still on Pullrack
                            if ($last_status_on_prod == 'P') {
                                $ok_for_production = false;
                            }
                        }
                        if ($ok_for_production) {
                            if (realOrderIsPossibleToTransferred($order_type, $item_id)) {
                                //Transfer to DP if order is possible to transferred
                                $item_do = $class_do->transferFromRealOrder(SEGMENT_ID_HAMBURG, $order_type, $item_id);
                                $class_do->updateStatus($item_do['depot_orders_id'], $status_new, $user_name);
                                $result = "MOVEDTODEPOT";
                            } else {
                                $result = "ERROR: {$order_type}-{$item_id} could not transferred to Depot Orders!\nplease make sure order scanned is correct!";
                            }
                        } else {
                            $result = "(HH) CANCEL PRODUCTION!";
                        }
                    } else {
                        /* Stop process when: 
                           *  1) - Depot Orders still in Pullrack                                  "setbetweenprod_rule1"
                           * and:
                              2) Real order taken over by HH and already have stock allocated      "setbetweenprod_rule2"
                              3) or Real order already proceed by HH (status >= 9 "sent")          "setbetweenprod_rule3"
                           */
                        $setbetweenprod_rule1 = $item_do['prod_status'] == 'P';
                        $setbetweenprod_rule2 = $item_status == '8' && $item['stock_status'] == 'D';
                        $setbetweenprod_rule3 = $item_status != '8';
                        if ($setbetweenprod_rule1 && ($setbetweenprod_rule2 || $setbetweenprod_rule3)) {
                            $ok_for_production = false;
                        } else {
                            $ok_for_production = true;
                        }
                        if ($ok_for_production) {
                            if ($item_do['status'] == '4') {
                                //If order moved between sub tab production
                                if ($item_do['prod_status'] == $sub_status) {
                                    //Not updating the status if order is on the same sub status production - including lines
                                    $result = "ERROR: Status is now " . statusNameProduction($sub_status, false, true) . $add_info;
                                } else {
                                    //Order moved to other sub status, then update it's production sub status to the new status
                                    $class_do->updateStatus($item_do['depot_orders_id'], $status_new, $user_name);
                                    $result = 'Updated Successfully';
                                }
                            } else {
                                /*
                                    EXCEPT revived orders, Shows error if order is not from production but tried to set back to production status
                                    NOTES >> revived MTO orders which already have DP and at that moment status of DP was >= Package then manobo will set:
                                    "Real order to status New and let DP status as it is" ...
                                    But then, when real order taken over by HH so we need to used already created DP for status changes...
                                    ...this is actually the reason why we allowed revived orders
                                */
                                if (orderIsRevived($order_type, $item_id)) {
                                    $class_do->updateStatus($item_do['depot_orders_id'], $status_new, $user_name);
                                    $result = 'Updated Successfully';
                                } else {
                                    $result = "ERROR: Status is now " . $status_name[$item_do['status']] . $add_info;
                                }
                            }
                        } else {
                            if (!is_null($item_do)) {
                                $class_do->doCancelOrders($item_do['depot_orders_id'], $item_do['status'], 'auto-set');
                            }
                            $result = "(HH) CANCEL PRODUCTION!";
                        }
                    }
                } elseif ($status_current == '4' && $status_new == '5') {
                    //FOR SET2FINISH RULE
                    if (realOrderIsPossibleToTransferred($order_type, $item_id)) {
                        $item_do = $class_do->transferFromRealOrder(SEGMENT_ID_HAMBURG, $order_type, $item_id);
                        $class_do->updateStatus($item_do['depot_orders_id'], $status_new, $user_name);
                        $result = "(HH) PUT PRODUCT TO DEPO BOX";
                    } else {
                        $result = "ERROR: {$order_type}-{$item_id} could not transferred to Depot Orders!\nplease make sure order scanned is correct!";
                    }
                }
            } elseif ($item_status == '4' && $status_new != '' && !is_numeric($status_new) && $item['prod_status'] != $sub_status) {
                if ($sub_status == 'P') {
                    //Production Pullrack only allowed for order moved from ready tab to production, other will be rejected
                    $result = "ERROR: Status is now " . $status_name[$item_status] . $add_info;
                } else {
                    //moved between prod sub status >> $status_new is production sub status (S1..Sn, A, L)
                    if ($order_type == 'SP') {
                        $item = $class_jo->retrieveItemDetail($item_id);
                        $class_jo->updateItemStatus($item_id, $status_new, $user_name);
                    } elseif ($order_type == 'JG') {
                        $item = $class_o->retrieveProductDetail($item_id);
                        $class_o->updateProductStatus($item_id, $status_new, $user_name);
                    } elseif ($order_type == 'DP') {
                        $item = $class_do->retrieveDetail($item_id);
                        $class_do->updateStatus($item_id, $status_new, $user_name);
                    }
                    $result = 'Updated Successfully';
                }
            }
        }
    }
    if ($result == '') {
        $result = "ERROR: Status is now " . $status_name[$item_status] . $add_info;
    }
    return $result;
}
Esempio n. 3
0
    $ht['sort'] = $count;
    $ht['date_add'] = date('d.m.y H:i:s', $timestamp);
    $ht['status'] = $statusName[$h['status']];
    //$ht['qty'] = intval($h['status_quantity']);
    $ht['login'] = $h['update_by'];
    $htable[] = $ht;
    if ($h['status'] == '4' && count($history_prod) > 0) {
        $next_timestamp = isset($history[$hk + 1]) ? strtotime($history[$hk + 1]['status_date']) : time();
        foreach ($history_prod as $hpk => $hp) {
            $tsproductionstatus = strtotime($hp['status_date']);
            if ($tsproductionstatus >= $timestamp && $tsproductionstatus <= $next_timestamp) {
                $count++;
                $htp = array();
                $htp['sort'] = $count;
                $htp['date_add'] = date('d.m.y H:i:s', $tsproductionstatus);
                $htp['status'] = 'Production: ' . statusNameProduction($hp['status']);
                $htp['login'] = $hp['update_by'];
                $htable[] = $htp;
                unset($history_prod[$hpk]);
            }
        }
    }
}
$content .= '<div style="float:left;">';
$content .= webImage($product['p']['products_image'], '80', '80', $item['products_id'], 'img-padding img-border');
$content .= '</div>';
$content .= '<div style="padding:3px 0 20px 100px;">';
$content .= '<h2 style="margin:0;">Order ' . $order['orders_no'] . '</h2>';
$content .= '<h2 style="margin:0;">Product ' . $item['order_item_count'] . '/' . $item['order_item_total'] . '</h2>';
$content .= '<h2 style="margin:0;">' . $item['products_model'] . '</h2>';
$content .= '<h2 style="margin:0">' . $item['products_name'] . '</h2>';
 $p_image = DIR_WS_IMAGES . $row['products_image'];
 if (isset($article_rowstart)) {
     mergeArticleRowsToProduct($article_rowstart, $product_row - 1);
 }
 $article_rowstart = $product_row;
 if (is_file($p_image)) {
     $img_path = thumbimage($p_image, $pi_width, $pi_height, 1, 1, DIR_WS_IMAGES . 'imagecache');
     $obj_excel_draw = new PHPExcel_Worksheet_Drawing();
     $obj_excel_draw->setWorksheet($obj_ws);
     $obj_excel_draw->setPath($img_path);
     $obj_excel_draw->setCoordinates('F' . $product_row);
     $obj_excel_draw->setOffsetX($img_offset);
     $obj_excel_draw->setOffsetY($img_offset);
 }
 if ($order_status == '4' && isset($prod_status) && $prod_status != '') {
     $current_status = statusNameProduction($prod_status, false, true);
 } else {
     $current_status = statusNameShort($order_status);
 }
 foreach ($orders_late_status as $status => $name) {
     if ($late_order_status == $status) {
         $check_status = $name;
     }
 }
 $pattern = "/[<][a][[:space:]][href]+/";
 $need_remove_links = preg_match($pattern, $sp_name);
 if ($need_remove_links) {
     $pattern2 = "/[[:upper:]]+[-]+\\d+/";
     preg_match($pattern2, $sp_name, $matches);
     $sp_name = $matches[0];
 }
Esempio n. 5
0
         } else {
             $order_detail = '<a href="?open=order&id=' . $row['order_id'] . '&opid=' . $row['order_items_id'] . '&hidemenu=true class="view_webpage">' . $row['type'] . '-' . $row['order_items_id'] . '</a>';
         }
         $late_orders .= '<td style="text-align:center;">' . $order_detail . '</td>';
         $late_orders .= '<td style="text-align:center;">' . displayDuration(strtotime('now') - strtotime($row['leadtime_start_date']), 'day', 1) . '</td>';
         if ($row['type'] == 'SP') {
             $late_orders .= '<td style="text-align:center;">' . $row['sp_name'] . '</td>';
         } elseif ($row['type'] == 'DP') {
             $late_orders .= '<td style="text-align:center;">' . $class_do->translateOrderSource($row['trans_type'], $row['trans_id'], true, null, $row['products_id']) . '</td>';
         } else {
             $late_orders .= '<td style="text-align:center;">JG</td>';
         }
         $late_orders .= '<td style="text-align:center;">' . $row['customers_name'] . '</td>';
         $late_orders .= '<td style="text-align:center;"><div>' . webImage($row['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $row['products_id'], 'img-border') . '</div><a title="View product detail" target="_blank" href="?open=product-detail&amp;products_id=' . $row['products_id'] . '" class="view_webpage">' . $row['products_id'] . '</a></td>';
         if ($order_status == '4' && isset($prod_status) && $prod_status != '') {
             $late_orders .= '<td style="text-align:center;">' . statusNameProduction($prod_status, false, true) . '</td>';
         } else {
             $late_orders .= '<td style="text-align:center;">' . statusNameShort($order_status) . '</td>';
         }
         $status_dropdown = '<select class="order_late_status">' . loadComboListFromArray($orders_late_status, null, $late_order_status, false) . '</select>';
         $status_dropdown .= '<input type="hidden" id="opid-' . $row['order_items_id'] . '" name="op_id" value="' . $row['order_items_id'] . '" />';
         $late_orders .= '<td style="text-align:center;">' . $status_dropdown . '</td>';
         $late_orders .= '<td style="text-align:center;"><input type="hidden" id="opid-issue-' . $row['order_items_id'] . '" name="op_id" value="' . $row['order_items_id'] . '" /><textarea class="issue_text" style="width:200px;height:100px;">' . $row['issue'] . '</textarea></td>';
         $late_orders .= "</tr>";
         if (strtotime($row['reported_date']) != $current_date) {
             $late_orders .= "</tbody>";
             $late_orders .= "</table></div><br>";
         }
     }
     $late_orders .= '<input type="text" id="order-item-ids" style="display:none;" value="' . implode(',', $order_item_ids) . '" />';
 } else {
 public function renderLeadtimePopup($order_type, $orders_items_id)
 {
     $query = '';
     if ($order_type == self::ORDER_TYPE_SP) {
         $query = " SELECT * FROM (";
         $query .= "SELECT joi.jng_sp_orders_items_id, joi.leadtime_start_date, joish.status, joish.status_date";
         $query .= " FROM jng_sp_orders_items joi";
         $query .= " INNER JOIN jng_sp_orders_items_status_history joish ON joish.jng_sp_orders_items_id = joi.jng_sp_orders_items_id";
         $query .= " WHERE joi.status >= 1 AND joi.jng_sp_orders_items_id = {$orders_items_id}";
         $query .= " UNION ALL";
         $query .= " SELECT psh.orders_items_id AS jng_sp_orders_items_id, joi.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date";
         $query .= " FROM jng_sp_orders_items joi";
         $query .= " INNER JOIN production_status_history psh ON psh.type='SP' AND psh.orders_items_id = joi.jng_sp_orders_items_id";
         $query .= " WHERE joi.status >= 1 AND joi.jng_sp_orders_items_id = {$orders_items_id}";
         $query .= " ) dt";
         $query .= " ORDER BY status_date, status";
     } elseif ($order_type == self::ORDER_TYPE_JG) {
         $query = " SELECT * FROM (";
         $query .= " SELECT opsh.orders_products_id, op.leadtime_start_date, opsh.status, opsh.status_date";
         $query .= " FROM orders_products op";
         $query .= " INNER JOIN orders_products_status_history opsh ON opsh.orders_products_id = op.orders_products_id";
         $query .= " WHERE op.status >= 1 AND op.orders_products_id = {$orders_items_id}";
         $query .= " UNION ALL";
         $query .= " SELECT psh.orders_items_id AS orders_products_id, op.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date";
         $query .= " FROM orders_products op";
         $query .= " INNER JOIN production_status_history psh ON psh.type='JG' AND psh.orders_items_id = op.orders_products_id";
         $query .= " WHERE op.status >= 1 AND op.orders_products_id = {$orders_items_id}";
         $query .= " ) dt";
         $query .= " ORDER BY status_date, status";
     } elseif ($order_type == self::ORDER_TYPE_DP) {
         $query = " SELECT * FROM (";
         $query .= " SELECT do.depot_orders_id, do.leadtime_start_date, dosh.status, dosh.update_time AS status_date";
         $query .= " FROM depot_orders do";
         $query .= " INNER JOIN depot_orders_status_history dosh ON dosh.depot_orders_id = do.depot_orders_id";
         $query .= " WHERE do.status >= 1 AND do.depot_orders_id = {$orders_items_id}";
         $query .= " UNION ALL";
         $query .= " SELECT psh.orders_items_id AS depot_orders_id, do.leadtime_start_date, CONCAT('4-',SUBSTR(psh.status,1,1)) status, psh.status_date";
         $query .= " FROM depot_orders do";
         $query .= " INNER JOIN production_status_history psh ON psh.type='DP' AND psh.orders_items_id = do.depot_orders_id";
         $query .= " WHERE do.status >= 1 AND do.depot_orders_id = {$orders_items_id}";
         $query .= " ) dt";
         $query .= " ORDER BY status_date, status";
     }
     if ($query != '') {
         $dbq = tep_db_query($query);
         $prev_oi_id = '';
         $kpi_status_cycletime = array();
         while ($row = tep_db_fetch_array($dbq)) {
             $leadtime_start_date = $row['leadtime_start_date'];
             $current_status = $row['status'];
             $oi_id = $row['jng_sp_orders_items_id'];
             //use leadtime start date as start date when orders processed
             if ($current_status == 1) {
                 $row['status_date'] = $leadtime_start_date;
             }
             if ($oi_id == $prev_oi_id && isset($prev_status)) {
                 //UPDATED TO USE AVERAGE VALUE
                 if (!isset($kpi_status_cycletime[$prev_status])) {
                     $kpi_status_cycletime[$prev_status] = array();
                 }
                 if (!isset($kpi_status_cycletime[$prev_status][$oi_id])) {
                     $kpi_status_cycletime[$prev_status][$oi_id] = 0;
                 }
                 $kpi_status_cycletime[$prev_status][$oi_id] += strtotime($row['status_date']) - strtotime($prev_status_time);
             }
             $prev_status = $row['status'];
             $prev_status_time = $row['status_date'];
             $prev_oi_id = $oi_id;
         }
         //---START Manage status to show using below array (notes: status need to be sorted based on real process - from new until ends)
         $status_to_show = array('1', '2', '3', '4');
         //Include also production sub status
         $prod_sub_status = getProductionSubStatus(4);
         foreach ($prod_sub_status as $pss_k => $pss_v) {
             array_push($status_to_show, "4-{$pss_k}");
         }
         for ($s = 5; $s <= 7; $s++) {
             array_push($status_to_show, "{$s}");
         }
         //Also Depot/Mixed status, in case there order taken over by HH then set back to MTO
         array_push($status_to_show, '8');
         //---END Manage status to show...
         $row = array();
         $tooltip_leadtime = array();
         $row['c1'] = 'Tabs Through';
         $row['c2'] = 'Lead Time';
         $tooltip_leadtime[] = $row;
         $total_process = 0;
         $total_process_sub = array();
         $total_process_temp = array();
         $result = false;
         $row_temp = array();
         $tab_have_sub_status = array('4');
         foreach ($status_to_show as $sv) {
             $colval = isset($kpi_status_cycletime[$sv]) ? array_sum($kpi_status_cycletime[$sv]) / count($kpi_status_cycletime[$sv]) : 0;
             $temp_status = explode('-', $sv);
             if ($colval > 0 || !isset($temp_status[1]) && isset($kpi_status_cycletime[$sv])) {
                 $result = true;
                 $total_process += $colval;
                 if (isset($temp_status[1])) {
                     $total_process_sub[$temp_status[0]] += $colval;
                 }
                 if (in_array($temp_status[0], $tab_have_sub_status) && !isset($row_temp[$temp_status[0]])) {
                     $row_temp[$temp_status[0]]['c1'] = '<strong style="font-size:13px;">' . statusName($temp_status[0]) . '</strong>';
                     $total_process_temp[$sv] += $colval;
                 }
                 $row_temp[$sv]['c1'] = $temp_status[0] == '4' && isset($temp_status[1]) ? statusNameProduction($temp_status[1]) : statusName($sv);
                 $row_temp[$sv]['c2 right'] = displayDuration($colval, 'day', 2);
                 if (!isset($temp_status[1])) {
                     $row_temp[$sv]['c1'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c1'] . '</strong>';
                     $row_temp[$sv]['c2 right'] = '<strong style="font-size:13px;">' . $row_temp[$sv]['c2 right'] . '</strong>';
                 }
                 if (isset($temp_status[1])) {
                     $row_temp[$sv]['c1'] = '<div style="margin-left:20px;">' . $row_temp[$sv]['c1'] . '</div>';
                 }
             }
         }
         //Show sub status leadtime
         foreach ($row_temp as $rk => $rv) {
             $row = array();
             if (in_array($rk, $tab_have_sub_status)) {
                 if (isset($total_process_sub[$rk])) {
                     $tps = $total_process_sub[$rk];
                     $total_process -= $total_process_temp[$rk];
                 } else {
                     $tps = $total_process_temp[$rk];
                 }
                 $row_temp[$rk]['c2 right'] = '<strong style="font-size:13px;">' . displayDuration($tps, 'day', 2) . '</strong>';
             }
             $row['c1'] = $row_temp[$rk]['c1'];
             $row['c2 right'] = $row_temp[$rk]['c2 right'];
             $tooltip_leadtime[] = $row;
         }
         if (!$result) {
             $result = "No lead time per tab measured yet for this";
         } else {
             $row['c1'] = '<span style="font-size:13px;">Total</span>';
             $row['c2 right'] = '<span style="font-size:13px;">' . displayDuration($total_process, 'day', 2) . '</span>';
             $tooltip_leadtime[] = $row;
             $result = tep_draw_table('summary2', $tooltip_leadtime, false, true);
         }
     } else {
         $result = 'Query not found for this order type';
     }
     return $result;
 }
Esempio n. 7
0
 function retrieveListProductOverview($status, $ean_list = '', $date_start = null, $date_end = null, $brand_id = null, $cat_id = null)
 {
     use_class('payone_invoice');
     //use_class('product');
     use_class('Product');
     global $STOCKLESS_ELEMENTS_CATEGORY, $PROD_SUBSTATUS_USE_LINE;
     $USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI = false;
     $filter_date_shown = ($status < 2 or $status > 7) ? 'Date' : 'Started Date';
     $show_stock_status = $status == '1' || $status == '2' || $status == '3' || $status == '4' || $status == '8';
     $orders_products = $this->retrieveOrdersProducts($status, $ean_list, $date_start, $date_end, $brand_id, $cat_id);
     list($status, $sub_status) = explode('-', $status);
     $filters = $this->retrieveListProductOverview_drawFilter($ean_list, $date_start, $date_end, $brand_id, $cat_id);
     $result = '';
     if (count($orders_products) > 0) {
         use_class('products_minierp');
         $class_pm = new products_minierp();
         if ($status == '5') {
             //Query Package for Finish Products
             use_class('minierp_packages');
             $class_mp = new minierp_packages();
             $usable_packages = $class_mp->getUsablePackages();
             $packages_exist = count($usable_packages) > 0;
         }
         $orders = array();
         $orders_items = array();
         $orders_onhold_notice = array();
         $orders_vorkasse_unpaid = array();
         $orders_vorkasse_notice = array();
         $order_pi_print_count = array();
         $order_pi_ready = array();
         $order_pi_collection = array();
         $order_pi_unscanned = array();
         $header = array();
         //$header['d'] = (($status < 2) OR ($status > 7)) ? 'Date' : 'Lead Time';
         //if (!(($status < 2) OR ($status > 7))) $header['d2'] = 'Started Date';
         $header['d'] = $status > 9 ? 'Date' : 'Lead Time';
         if ($status <= 9) {
             $header['d2'] = 'Cycle Time';
         }
         $header['r'] = 'Source';
         $header['c'] = 'Customer / Order No';
         $header['o'] = 'Order ID';
         $header['a'] = 'Product Code';
         $header['e'] = 'Customized';
         $header['p'] = 'Price';
         $header['q'] = 'Qty';
         if ($show_stock_status) {
             $header['s'] = $status == '8' ? 'Status' : 'Stock';
         }
         if ($status == '3') {
             $header['pc1'] = '<abbr title="PI has been sent to PRINTER by MC">P</abbr>';
             $header['pc2'] = '<abbr title="PI has been SCANNED for EAN label in MC">S</abbr>';
         }
         $sub_status = trim($sub_status);
         $sub_prod_show_line_only = in_array($sub_status[0], $PROD_SUBSTATUS_USE_LINE);
         if ($status == '4' && $sub_prod_show_line_only) {
             $header['g'] = 'Status';
         }
         $header['t'] = 'Action';
         $timestamp = date('Y-m-d H:i:s');
         foreach ($orders_products as $row) {
             $oiid = $row['orders_products_id'];
             $orders_items[$oiid] = $row;
             $oid = $row['orders_id'];
             $order_pi_print_count[$oid][$oiid] = $row['print_count'];
             $order_pi_unscanned[$oid][$oiid] = $row['print_confirmed'];
             if (!isset($order_pi_collection[$oid])) {
                 $order_pi_ready[$oid] = false;
                 $order_pi_collection[$oid] = array();
             }
             $order_pi_collection[$oid][] = $row['orders_products_id'];
             if (count($order_pi_collection[$oid]) == $row['order_item_total']) {
                 $order_pi_ready[$oid] = true;
                 if (orderItemHaveStatus($oid, 10, 'JG')) {
                     $order_pi_ready[$oid] = false;
                 }
             }
             $products_id = $row['products_id'];
             $articles_id = $row['products_articles_id'];
             //$obj_product = new product($products_id);
             $obj_product = new Product($products_id);
             $order_vorkasse_unpaid = $row['payment_method'] == PAYMENT_METHOD_BANK_TRANSFER && $row['paid_status'] == '0';
             $order_date = strtotime($row['date_purchased']);
             $o = array();
             $date_used = $status < 3 ? strtotime($row['status_date']) : strtotime($row['prod_target_in']);
             /*
                                 if (($status < 2) OR ($status > 7)) {
                $value_date = date('d-M-y', $order_date);
                                 } else {
                $value_date = displayLeadTime($row['prod_target_in'], $date_used);
                                 }
                                 $o['d'] = $value_date;
             */
             $o['d'] = $order_vorkasse_unpaid ? date('d-M-y', $order_date) : displayLeadTime($row['leadtime_start_date'], strtotime($row['leadtime_start_date']));
             if ($status <= 9 && !$order_vorkasse_unpaid) {
                 $previous_moved_date = $status == 4 ? $row['status_date_prod'] : $row['status_date'];
                 $o['d2'] = displayCycleTime($previous_moved_date);
             }
             $o['r'] = $row['dti_referrers_code'] == '' ? '<span class="notice">julie-grace.de</span>' : $row['dti_referrers_code'];
             $cust = '<a href="?open=customer&amp;id=' . $row['customers_id'] . '&amp;hidemenu=true" class="view_webpage" >' . $row['customers_name'] . '</a> <sup>' . $row['customers_order_count'] . '</sup>';
             $crown_img_col = array('V' => 'vip', 'B' => 'black');
             if ($row['list_type'] != '' && array_key_exists($row['list_type'], $crown_img_col)) {
                 $crown_img_title = array('V' => 'VIP Customer', 'B' => 'Blacklist Customer');
                 $crown_img = '<a href="?open=customers-special-detail&amp;id=' . $row['customers_id'] . '&amp;hidemenu=true" class="view_webpage">';
                 $crown_img .= '<img src="images/list-' . $crown_img_col[$row['list_type']] . '.gif" title="' . $crown_img_title[$row['list_type']] . '" />';
                 $crown_img .= '</a> ';
                 $cust = $crown_img . $cust;
             }
             $orders_products_id = 'JG-' . $row['orders_products_id'];
             $orders_products_id = '<a href="?open=order-history&amp;opid=' . $row['orders_products_id'] . '&amp;hidemenu=true" class="view_webpage">' . $orders_products_id . '</a>';
             $order_no = '<a href="?open=customer-care-order-detail&amp;source=JG&amp;id=' . $row['orders_id'] . '&amp;hidemenu=true" class="view_webpage">' . $row['orders_no'] . '</a>';
             if ($row['order_item_total'] > 1) {
                 $orders_products_id .= " <sup>{$row['order_item_count']}/{$row['order_item_total']}</sup>";
             }
             if ($row['products_problem'] != '0') {
                 $rep_img = array('R' => 'icon-hazard', 'W' => 'icon-hazard-red');
                 $return = $this->retrieveReturnDetailLatest($row['orders_products_id']);
                 $return_id = $return['orders_products_return_id'];
                 $order_no = '<a href="?open=order-return&amp;id=' . $return_id . '&amp;hidemenu=true" class="view_webpage" title="View Return Detail"><img src="images/' . $rep_img[$row['products_problem']] . '.png" class="repro-' . $row['products_problem'] . '"/></a> ' . $order_id;
             }
             $o['c'] = $cust . '<br /><small>order no:</small> ' . $order_no;
             $o['o'] = $orders_products_id;
             $promod = $row['products_model'];
             if ($row['products_length'] > 0) {
                 $promod .= '_' . textLength($row['products_length'], false);
             }
             $product = '<div><a href="?open=product-detail&amp;products_id=' . $row['products_id'] . '" target="_blank" title="View product detail">' . $promod . '</a></div>';
             $pimg = webImageSource($row['products_image'], '500');
             if ($pimg != '') {
                 //                        $dbqtooltip = tep_db_query("SELECT SUM(total_sold) total_sold, AVG(returned_rate) returned_rate, MAX(active_age) active_age FROM jng_sp_catalog WHERE products_id = $row[products_id] GROUP BY products_id");
                 //                        $restooltip = tep_db_fetch_array($dbqtooltip);
                 /*
                                         $thumb_title  = 'Tot.Sold: '.floor($restooltip['total_sold']);
                                         $thumb_title .= ' &bull; Returns: '.number_format($restooltip['returned_rate'],1);
                                         $thumb_title .= '% &bull; Age: '.intval($restooltip['active_age']).' days';
                 */
                 //                        $restooltip['sold_monthly_1'] = $row['sold_monthly_1'];
                 //                        $thumb_title = displayTooltipThumb($restooltip);
                 $thumb = '<div class="thumb" thumbid="' . "{$products_id}-{$articles_id}" . '"><a href="' . $pimg . '" class="view_image" title="' . $thumb_title . '">' . webImage($row['products_image'], '80', '80', '', 'img-border img-padding') . '</a></div>';
                 $product = $thumb . $product;
             }
             //$diamond_icon = ($obj_product->brand_id == 14) ? drawDiamondIcon('Diamond Product', ' ') : '';
             $diamond_icon = $obj_product->isUsingDiamond() ? drawDiamondIcon('Diamond Product', ' ') : '';
             $gold_icon = drawGoldIcon($obj_product->metal_stamp_code, $obj_product->metal_stamp_info, '', ' ');
             $icons = $gold_icon . $diamond_icon;
             $o['a'] = drawTableArticleInfoWithIcons($product, $icons);
             $customized = '';
             if ($row['customers_image_id'] != '') {
                 $custom_image = '<a class="view_webpage" href="?open=customers-images&amp;id=' . $row['customers_image_id'] . '&amp;hidemenu=true" title="View uploaded image and comment">';
                 $custom_image .= '<span class="thumb" style="display:none;">';
                 $custom_image .= webImage($row['customers_image'], '80', '80', '', 'img-border img-padding');
                 $custom_image .= '<br /></span>';
                 $custom_image .= '<span>Image</span></a>';
                 $customized = $custom_image;
             }
             if ($row['customers_text_id'] != '') {
                 $custom_text = array();
                 $custom_text[] = $row['customers_text_line1'];
                 if ($row['customers_text_line2'] != '') {
                     $custom_text[] = $row['customers_text_line2'];
                 }
                 $customized = implode('<br />', $custom_text);
             }
             if ($customized == '') {
                 $customized = '&nbsp;';
             }
             $o['e'] = $customized;
             $o['p'] = number_format($row['final_price'], 2);
             $o['q'] = $row['products_quantity'];
             $action = '';
             //                  $el_link = '<a href="?open=elements-stock&amp;products_id='.$products_id.'&amp;hidemenu=true" class="view_webpage"></a>'; //PREVIOUS
             $el_link = '<a href="?open=products-elements-stock&amp;products_id=' . $products_id . '&amp;paid=' . $row['products_articles_id'] . '&amp;qty=' . $row['products_quantity'] . '&amp;status=' . $row['stock_status'] . '&amp;hidemenu=true" class="view_webpage"></a>';
             $pr_link = '<a href="javascript:void();" onclick="alert(\'Please use Finish Good Stock\');"></a>';
             $dp_link = '<a href="javascript:void();" onclick="alert(\'Please use Depot Stock\');"></a>';
             switch ($row['stock_status']) {
                 case '0':
                     $stock_status = '<strong class="red">!</strong>';
                     if ($status == '8') {
                         //$do_status = statusNameShort($row['depot_orders_status']);
                         $do_status = $row['depot_orders_status'] == '4' && isset($row['depot_orders_prod_status']) && $row['depot_orders_prod_status'] != '' ? statusNameProduction($row['depot_orders_prod_status'], false, true) : statusNameShort($row['depot_orders_status']);
                         if (!is_array($do_status)) {
                             //$stock_status = '<span class="red">'.$do_status.'</span>';
                             $stock_status = '<a href="?open=depot-order&amp;id=' . $row['depot_orders_id'] . '&amp;hidemenu=true" title="MMO product, current status is ' . $do_status . '" class="red view_webpage">' . $do_status . '</a>';
                         }
                     }
                     break;
                 case 'R':
                     $show_btn_inprod = true;
                     $stock_status = $el_link . '<abbr title="Element Stock OK, Ready for Production" class="green">OK</abbr>';
                     break;
                 case 'S':
                     $show_btn_insrcn = true;
                     $stock_status = $el_link . '<abbr title="Element Stock Need Sourcing" class="red">NS</abbr>';
                     break;
                 case 'P':
                     $show_btn_inprod = true;
                     $stock_status = $pr_link . '<abbr title="Use Finished Goods Stock" class="green">FG</abbr>';
                     break;
                 case 'D':
                     if (is_null($row['depot_orders_id'])) {
                         $stock_status = $dp_link . '<abbr title="Use Depot Stock" class="green">DS</abbr>';
                     } else {
                         $stock_status = '<a href="?open=depot-order&amp;id=' . $row['depot_orders_id'] . '&amp;hidemenu=true" class="green view_webpage">DS</a>';
                     }
                     break;
                 case 'W':
                     $stock_status = $el_link . '<abbr title="Product is using Wholesale Element" class="red">WP</abbr>';
                     break;
                 default:
                     $stock_status = '<strong class="red">?</strong>';
             }
             if ($show_stock_status) {
                 $o['s'] = $stock_status;
             }
             if ($status == '3') {
                 $o['pc1'] = $row['print_count'] > 0 ? '<img title="Printed ' . $row['print_count'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet printed" src="images/icon-tick-dis.png">';
                 $o['pc2'] = $row['print_confirmed'] > 0 ? '<img title="Scanned ' . $row['print_confirmed'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet scanned" src="images/icon-tick-dis.png">';
             }
             if ($status == '4' && $sub_prod_show_line_only) {
                 $o['g'] = isset($row['prod_status']) && $row['prod_status'] != '' ? strtoupper(statusNameProduction($row['prod_status'], true)) : '';
             }
             $disabled = $this->isDelayInfoSent($row['orders_products_id']) ? 'disabled="disabled"' : '';
             $late_button = '<input type="button" class="actbtn" name="delay" value="Delay" title="Inform Customer about delivery delay" ' . $disabled . ' />';
             //                    if($row['status']<='2' && !$order_vorkasse_unpaid) $action .= '<input type="button" class="actbtn" name="3" value="Ready" title="Set to Ready for Production" />';
             if ($row['status'] == '1') {
                 if ($row['payment_method'] == PAYMENT_METHOD_BANK_TRANSFER && $row['paid_status'] == '0') {
                     $order_vorkasse_unpaid = true;
                 }
                 if (!$order_vorkasse_unpaid) {
                     //$action .= '<input type="button" class="actbtn" name="4" value="PI & Set2Prod" title="Print PI and Set to In Production" />';
                     //$action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Add this product to Cancel Request List" />';
                     if ($row['stock_status'] == 'P' || $row['stock_status'] == 'R' || $row['stock_status'] == 'W') {
                         $action .= '<input type="button" class="actbtn green" name="3" value="Ready" title="Set to Ready for Production" style="width:70px;" />';
                     } elseif ($row['stock_status'] == 'S') {
                         $action .= '<input type="button" class="actbtn red" name="2" value="Sourcing" title="Set to In Sourcing" style="width:70px;" />';
                     }
                     $action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Cancel this product" />';
                 } else {
                     if ($row['last_sent_date'] == '') {
                         $action .= '<span class="green">Reminder Not Sent</span>';
                         /*
                         if(!in_array($row['orders_id'],$orders_vorkasse_notice)) {
                             $orders_vorkasse_notice[] = $row['orders_id'];
                             $action .= '<input type="button" class="actbtn" name="reminder" value="Reminder" title="Send payment reminder to customer" />';
                         } else {
                             $action .= '<input type="button" value="Reminder" disabled="disabled" />';
                         }
                         */
                     } else {
                         $overtime = strtotime($row['last_sent_date']) < strtotime('-' . PAYMENT_METHOD_BANK_TRANSFER_OVERDUE);
                         if ($row['sent_count'] > 1) {
                             $action .= '<span class="red">Cancel Notification Sent</span>';
                         } else {
                             $action .= '<span class="blue">Reminder Sent</span>';
                         }
                         /*
                         if(!in_array($row['orders_id'],$orders_vorkasse_notice) && $overtime) {
                             $orders_vorkasse_notice[] = $row['orders_id'];
                             $action .= '<input type="button" class="actbtn red" name="unpaidcancel" value="CANCEL" title="Cancel order and send email notification to customer" />';
                         } else {
                             $btn_text = ($overtime) ? 'CANCEL' : 'Reminder Sent';
                             $action .= '<input type="button" value="'.$btn_text.'" disabled="disabled" />';
                         }
                         */
                     }
                 }
             }
             if ($row['status'] == '2') {
                 $action .= '<input type="button" class="actbtn" name="3" value="Ready" title="Set to Ready for Production" />';
                 $action .= $late_button;
                 $action .= '<input type="button" class="actbtn" name="1" value="N" title="Set back to New" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
             }
             if ($row['status'] == '3') {
                 //$action .= '<input type="button" class="actbtn" name="4" value="PI & Set2Prod" title="Print PI and Set to In Production" />';
                 //$action .= $late_button;
                 if (!$USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI) {
                     $hid = '';
                     $action .= '<input type="button" class="actbtn" name="printpi" value="Print PI" title="Print Production Instruction" ' . $hid . '/>';
                     $action .= '<input type="hidden" name="oi_id_cols" value="' . $row['orders_products_id'] . '" />';
                 }
                 //$action .= '<input type="button" class="actbtn" name="1" value="N" title="Set back to New" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Add this product to Cancel Request List" />';
                 $action .= '<input type="button" class="actbtn" name="2" value="S" title="Set to In Sourcing" />';
             }
             if ($row['status'] == '4') {
                 $action .= '<input type="button" class="actbtn" name="5" value="Finish" title="Set to Finish" />';
                 $action .= $late_button;
                 $action .= '<input type="button" class="actbtn" name="4" value="PI" title="Reprint Production Instruction" />';
                 //				$action .= '<input type="button" class="actbtn" name="13" value="H" title="Set to On Hold" />';
                 $action .= '<input type="button" class="actbtn" name="2" value="S" title="Set to In Sourcing" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Add this product to Cancel Request List" />';
                 $prod_sub_status = getProductionSubStatus(4);
                 if (count($prod_sub_status) > 0) {
                     $action .= '<br/>';
                 }
                 foreach ($prod_sub_status as $pss => $pss_name) {
                     if (in_array($pss, $PROD_SUBSTATUS_USE_LINE)) {
                         continue;
                     }
                     if ($pss == $sub_status[0]) {
                         continue;
                     }
                     $action .= '<input type="button" class="actbtn" name="4-' . $pss . '" value="' . $pss . '" title="Moved to ' . $pss_name . '" />';
                 }
             }
             if ($row['status'] == '5') {
                 if ($order_vorkasse_unpaid) {
                     if ($row['last_sent_date'] == '') {
                         if (!in_array($row['orders_id'], $orders_vorkasse_notice)) {
                             $orders_vorkasse_notice[] = $row['orders_id'];
                             $action .= '<input type="button" class="actbtn" name="reminder" value="Reminder" title="Send payment reminder to customer" />';
                         } else {
                             $action .= '<input type="button" value="Reminder" disabled="disabled" />';
                         }
                     } else {
                         $overtime = strtotime($row['last_sent_date']) < strtotime('-' . PAYMENT_METHOD_BANK_TRANSFER_OVERDUE);
                         if (!in_array($row['orders_id'], $orders_vorkasse_notice) && $overtime) {
                             $orders_vorkasse_notice[] = $row['orders_id'];
                             if ($row['sent_count'] == '1') {
                                 $action .= '<input type="button" class="actbtn" name="reminder2" value="Reminder 2" title="Send 2nd payment reminder to customer" />';
                             } else {
                                 $action .= '<input type="button" class="actbtn red" name="unpaidcancel" value="CANCEL" title="Cancel order and send email notification to customer" />';
                             }
                         } else {
                             if ($overtime) {
                                 $btn_text = $row['sent_count'] == '1' ? 'Reminder 2' : 'CANCEL';
                             } else {
                                 $btn_text = $row['sent_count'] == '1' ? 'Reminder' : 'Reminder 2';
                             }
                             $action .= '<input type="button" value="' . $btn_text . '" disabled="disabled" />';
                         }
                     }
                 } else {
                     $action .= '<input type="button" class="actbtn" name="6" value="Package" title="Add to Selected Package" ' . (!$packages_exist ? 'style="display:none;"' : '') . ' />';
                     $disabled = $this->isDelayInfoSent($row['orders_products_id']) ? 'disabled="disabled"' : '';
                     $action .= '<input type="button" class="actbtn" name="delay" value="Delay" title="Inform Customer about delivery delay" ' . $disabled . ' />';
                 }
                 $action .= '<input type="button" class="actbtn" name="4-P" value="Prod" title="Set back to Production" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Add this product to Cancel Request List" />';
             }
             if ($row['status'] == '8') {
                 $action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Add this product to Cancel Request List" />';
             }
             if ($row['status'] == '13') {
                 $action .= '<input type="button" class="actbtn" name="5" value="Finish" title="Set to Finish" />';
                 if ($row['last_sent_date'] == '' && !in_array($row['orders_id'], $orders_onhold_notice)) {
                     $orders_onhold_notice[] = $row['orders_id'];
                     $action .= '<input type="button" class="actbtn" name="holdnotice" value="Notify" title="Send on Hold notice to customer" />';
                 } else {
                     $action .= '<input type="button"  value="Notify" disabled="disabled" />';
                 }
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Add this product to Cancel Request List" />';
             }
             //Default Row Action Value (id, status)
             $action .= '<input type="hidden" id="opid-' . $row['orders_products_id'] . '" name="op_id" value="' . $row['orders_products_id'] . '" />';
             $action .= '<input type="hidden" name="op_status" value="' . $row['status'] . '" />';
             $action .= '<input type="hidden" name="csl_type" value="' . ($order_vorkasse_unpaid ? 'B' : $row['list_type']) . '" />';
             if ($show_stock_status) {
                 $action .= '<input type="hidden" name="oi_stock_status" value="' . $row['stock_status'] . '" >';
             }
             $o['t'] = $action;
             if ($order_vorkasse_unpaid) {
                 $orders_vorkasse_unpaid[$row['orders_products_id']] = $o;
             } else {
                 $orders[$row['orders_products_id']] = $o;
             }
         }
         $buttons = '';
         switch ($status) {
             case '1':
                 /*
                    $buttons .= 'Product Amount: <input type="text" class="iwbutton" id="pi_print_amount" name="ppa" value="10" title="Set number of products to print" style="width:50px;text-align=center;" />';
                    $buttons .= ' <input type="button" class="grpbtn button" name="printmultpi" value="Print PI and set to Production" title="Print Production Instruction of a set number of products" />';
                 *
                 */
                 break;
             case '3':
                 //if(!$USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI) {
                 //    $buttons .= '<input type="button" class="grpbtn button" name="togglehideoi" value="Toggle Printed" title="Show or hide already printed items" />';
                 //} else {
                 $buttons .= '<div>';
                 $buttons .= '<input type="button" id="btn-reprint-pi-now" class="button help" value="REPRINT NOW for All Already Printed, Unscanned PI (0)" title="Reprint automatically NOW for all PI which<br/><strong>Already printed but not EAN scanned yet</strong>"/>&nbsp;&nbsp;&nbsp;';
                 $buttons .= '<input type="button" id="btn-reprint-pi-nextbatch" class="button help" value="REPRINT ON NEXT BATCH for All Already Printed, Unscanned PI (0)" title="Reprint ON NEXT BATCH print PI for all PI which<br/><strong>Already printed but not EAN scanned yet</strong>"/><br/><br/>';
                 $buttons .= '</div>';
                 $buttons .= '<table class="form" border="0" cellpadding="0" cellspacing="0"><tr>';
                 $buttons .= '<td class="bold">Show Products</td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-2" type="radio" class="readyfilter" name="readyfilter" value="2"/></td>';
                 $buttons .= '<td><label for="rb-orf-2">Unprinted <span id="orfc-up">(0)</span></label></td>';
                 //$buttons .= '<td style="padding-left:30px;"><input id="rb-orf-1" type="radio" class="readyfilter" name="readyfilter" value="1" /></td>';
                 //$buttons .= '<td><label for="rb-orf-1">Ready to be printed <span id="orfc-rp">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-4" type="radio" class="readyfilter" name="readyfilter" value="4" /></td>';
                 $buttons .= '<td><label for="rb-orf-4">Already Printed <span id="orfc-ap">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-5" type="radio" class="readyfilter" name="readyfilter" value="5" /></td>';
                 $buttons .= '<td><label for="rb-orf-5">Already Printed, Unscanned <span id="orfc-apun">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-3" type="radio" class="readyfilter" name="readyfilter" value="3" checked="checked" /></td>';
                 $buttons .= '<td><label class="bold" for="rb-orf-3">All <span id="orfc-al">(0)</span></label></td>';
                 $buttons .= '</tr></table>';
                 //}
                 break;
             case '5':
                 //                        if($packages_exist) {
                 //                            $packages  = '<h3>';
                 //                            $packages .= 'Package: '.$class_mp->packageCombo($usable_packages, 'package', '', 'id="selpack"');
                 //                            $packages .= ' <input type="button" class="pkgbtn" name="addall2pack" value="Add all products to this Package" title="Add all listed products to the selected package" />';
                 //                            $packages .= '</h3>';
                 //                        } else {
                 //                            $packages = '<h3>Please create a new package</h3>';
                 //                        }
                 //                        $buttons .= '<div style="float:right;"><input type="button" class="pkgbtn button" name="createnewpackage" value="Create New Package" title="Create a new package for shipping" /></div>';
                 //                        $buttons .= '<div id="pack_cont" style="padding:10px 0px;">'.$packages.'</div>';
                 $jp_mb = new messagebox();
                 $jp_mb->add('Package Management is prohibited here, please <a href="?open=packaging" class="bold">click here and use module Packaging Process</a>');
                 $buttons = $jp_mb->build();
                 break;
         }
         if ($status == 3 || $status == 4 || $status == 5 || $status == 13) {
             $style = $status == 5 && !$packages_exist ? 'style="display:none;"' : '';
             //$buttons .= '<input type="button" class="button barcode-form-trigger" value="BARCODE ENTRY" '.$style.' />';
         }
         if ($buttons != '') {
             $buttons = '<div class="spb" style="margin-bottom:10px;"><input type="hidden" name="grp_status" value="' . $status . '" />' . $buttons . '</div>';
         }
         $result .= '<div id="orders-' . $status . '">';
         $result .= $buttons;
         $orders_total = count($orders);
         $orders_vorkasse_unpaid_total = count($orders_vorkasse_unpaid);
         if ($orders_total > 0) {
             $result .= $this->drawTableListProduct($header, $orders, $orders_items, $USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI, 4, $order_pi_print_count, $order_pi_ready, $order_pi_collection, $order_pi_unscanned);
         }
         if ($orders_vorkasse_unpaid_total > 0) {
             $header['d'] = 'Date';
             unset($header['d2']);
             if ($orders_total > 0) {
                 $result .= '<div>&nbsp;</div>';
             }
             $result .= '<h3 class="red">Unpaid Prepayment (' . $orders_vorkasse_unpaid_total . ') - <span class="notice">No need to process these orders</span></h3>';
             $result .= $this->drawTableListProduct($header, $orders_vorkasse_unpaid, $orders_items, $USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI, 3);
         }
         $result .= '</div>';
     } else {
         $result .= '<h3>No Orders in this status</h3>';
     }
     return $filters . $result;
 }
Esempio n. 8
0
 function manageOrderList($status, $dpo_option = 'ALL', $dpo_group = '', $ean_list = '', $date_start = null, $date_end = null, $brand_id = null, $cat_id = null)
 {
     global $PROD_SUBSTATUS_USE_LINE;
     $show_stock_status = $status == '1' || $status == '2' || $status == '3' || $status == '4';
     $depot_orders = $this->retrieveOrders($status, $dpo_option, $dpo_group, $ean_list, $date_start, $date_end, $brand_id, $cat_id);
     $orders_items = $this->translateOrdersForSP($depot_orders);
     list($status, $sub_status) = explode('-', $status);
     $orders = array();
     $filter_date_shown = $status > 7 ? 'Date' : 'Started Date';
     $result = $this->manageOrderList_drawFilter($dpo_option, $dpo_group, $ean_list, $date_start, $date_end, $brand_id, $cat_id);
     if (count($orders_items) > 0) {
         if ($status == '7') {
             //Info how depot orders closed in Sent to HH Tab
             $result .= '<div class="sop-box ui-corner-all">';
             $result .= '<h3>How Depot Orders in "Sent to HH" tab is closed</h3>';
             $result .= '<ol>';
             $result .= '<li>Depot orders 1 qty is closed automatically with bin ins of EAN</li>';
             $result .= '<li>Outsourcing Depot Orders is closed automatically with bin ins of Order ID';
             $result .= '<li>Depot orders &gt; 1 qty is closed automatically by cron';
             $result .= '<li>In a special case cron might not be able to close it ' . '<br/>(e.g. Depot order 3 qty is open, 3 qty is binned in, 2 other depot orders ' . '1 qty is closed instead with bin ins, leaving only 1 bin in qty open and ' . 'can not be used to close the Depot order 3 qty)';
             $result .= '</ol>';
             $result .= '</div>';
             $result .= '<div style="clear:both;">&nbsp;</div>';
         }
         $class_pm = new products_minierp();
         $header = array();
         //$header['d'] = (($status < 2) OR ($status > 7)) ? 'Date' : 'Lead Time';
         $header['d'] = $status > 7 ? 'Date' : 'Lead Time';
         $header['d2'] = 'Cycle Time';
         $header['c'] = 'Segment';
         $header['o'] = 'Order ID';
         $header['e'] = 'Order Source';
         $header['a'] = 'Article No';
         $header['p'] = 'Price';
         $header['q'] = 'Qty';
         if ($show_stock_status) {
             $header['s'] = 'Stock';
         }
         if ($status == '3') {
             $header['pc1'] = '<abbr title="PI has been sent to PRINTER by MC">P</abbr>';
             $header['pc2'] = '<abbr title="PI has been SCANNED for EAN label in MC">S</abbr>';
         }
         $sub_status = trim($sub_status);
         $sub_prod_show_line_only = in_array($sub_status[0], $PROD_SUBSTATUS_USE_LINE);
         if ($status == '4' && $sub_prod_show_line_only) {
             $header['g'] = 'Status';
         }
         $header['t'] = 'Action';
         $timestamp = date('Y-m-d H:i:s');
         $order_pi_print_count = array();
         $order_pi_unscanned = array();
         //echo "<pre>";var_dump($orders_items);die();
         foreach ($orders_items as $row) {
             $oid = $row['jng_sp_orders_items_id'];
             $products_id = $row['products_id'];
             $articles_id = $row['products_articles_id'];
             $is_outsourced = $this->isOutsourceOrder($row['trans_type'], $row['trans_id']);
             $order_pi_print_count[$oid] = $row['print_count'];
             $order_pi_unscanned[$oid] = $row['print_confirmed'];
             $obj_product = new Product($products_id);
             $o = array();
             /* COMMENT THIS, SO WE GRAB prod_target_in DIRECTLY ON $this->retrieveOrders, SO IT WOULD BE POSSIBLE SORTED BY prod_target_in
                if ($row['trans_type'] == 'SP') {
                    $qTemp = "SELECT prod_target_in FROM jng_sp_orders_items ";
                    $qTemp .= " WHERE jng_sp_orders_items_id = ".$row['trans_id'];
                    $rowTemp = tep_db_fetch_array(tep_db_query($qTemp));
                    $prod_target_in = $rowTemp['prod_target_in'];
                } elseif ($row['trans_type'] == 'JG') {
                    $qTemp = "SELECT prod_target_in FROM orders_products ";
                    $qTemp .= " WHERE orders_products_id = ".$row['trans_id'];
                    $rowTemp = tep_db_fetch_array(tep_db_query($qTemp));
                    $prod_target_in = $rowTemp['prod_target_in'];
                } else {
                    $prod_target_in = $row['prod_target_in'];
                }
                 */
             /*
                             $prod_target_in = $row['prod_target_in'];
                             $date_used = ($status < 3) ? strtotime($row['update_time']) : strtotime($prod_target_in);
                             if (($status < 2) OR ($status > 7)) {
                $value_date = date('d-M-y', strtotime($row['order_date']));
                             } else {
                $value_date = displayLeadTime($prod_target_in, $date_used);
                             }
                             $o['d'] = $value_date;
             */
             $o['d'] = $status > 7 ? date('d-M-y', strtotime($row['order_date'])) : displayLeadTime($row['leadtime_start_date'], strtotime($row['leadtime_start_date']));
             if ($status == 1 && $row['update_time'] == '') {
                 $row['update_time'] = $row['leadtime_start_date'];
             }
             $previous_status_date = $status == 4 ? $row['status_date_prod'] : $row['update_time'];
             $o['d2'] = displayCycleTime($previous_status_date);
             $o['c'] = $row['customer_name'];
             $o['o'] = '<a href="?open=depot-order&amp;id=' . $oid . '&amp;hidemenu=true" class="view_webpage">DP-' . $oid . '</a>';
             $o['e'] = $this->translateOrderSource($row['trans_type'], $row['trans_id'], true, null, $row['products_id']);
             $article = '<div><a href="?open=product-detail&amp;products_id=' . $products_id . '" target="_blank" title="View Product Detail">' . $row['article_number'] . '</a></div>';
             $pimg = webImageSource($row['products_image'], '500');
             if ($pimg != '') {
                 //$thumb_title = $row['article_number'];
                 //                    $thumb_title = displayTooltipThumb($row);
                 $thumb = '<div class="thumb" thumbid="' . "{$products_id}-{$articles_id}" . '"><a href="' . $pimg . '" class="view_image" title="' . $thumb_title . '">' . webImage($row['products_image'], '80', '80', '', 'img-border img-padding') . '</a></div>';
                 $article = $thumb . $article;
             }
             //$diamond_icon = ($obj_product->brand_id == 14) ? drawDiamondIcon('Diamond Product', ' ') : '';
             $diamond_icon = $obj_product->isUsingDiamond() ? drawDiamondIcon('Diamond Product', ' ') : '';
             $gold_icon = drawGoldIcon($obj_product->metal_stamp_code, $obj_product->metal_stamp_info, '', ' ');
             $icons = $gold_icon . $diamond_icon;
             $o['a'] = drawTableArticleInfoWithIcons($article, $icons);
             $o['p'] = $row['price'];
             $qty = intval($row['order_quantity']);
             $o['q'] = $qty;
             //                $el_link = '<a href="?open=elements-stock&amp;products_id='.$products_id.'&amp;hidemenu=true" class="view_webpage"></a>'; //PREVIOUS
             $el_link = '<a href="?open=products-elements-stock&amp;products_id=' . $products_id . '&amp;paid=' . $articles_id . '&amp;qty=' . $qty . '&amp;status=' . $row['stock_status'] . '&amp;hidemenu=true" class="view_webpage"></a>';
             $pr_link = '<a href="javascript:void();" onclick="alert(\'Please use Finish Good Stock\');"></a>';
             switch ($row['stock_status']) {
                 case '0':
                     $stock_status = '<strong class="red">!</strong>';
                     break;
                 case 'R':
                     $show_btn_inprod = true;
                     $stock_status = $el_link . '<abbr title="Element Stock OK, Ready for Production" class="green">OK</abbr>';
                     break;
                 case 'S':
                     $show_btn_insrcn = true;
                     $stock_status = $el_link . '<abbr title="Element Stock Need Sourcing" class="red">NS</abbr>';
                     break;
                 case 'P':
                     $show_btn_inprod = true;
                     $stock_status = $pr_link . '<abbr title="Use Finished Goods Stock" class="green">FG</abbr>';
                     break;
                 case 'W':
                     $stock_status = $el_link . '<abbr title="Product is using Wholesale Element" class="red">WP</abbr>';
                     break;
                 default:
                     $stock_status = '<strong class="red">?</strong>';
             }
             if ($show_stock_status) {
                 $o['s'] = $stock_status;
             }
             if ($status == '3') {
                 $o['pc1'] = $row['print_count'] > 0 ? '<img title="Printed ' . $row['print_count'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet printed" src="images/icon-tick-dis.png">';
                 $o['pc2'] = $row['print_confirmed'] > 0 ? '<img title="Scanned ' . $row['print_confirmed'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet scanned" src="images/icon-tick-dis.png">';
             }
             if ($status == '4' && $sub_prod_show_line_only) {
                 $o['g'] = isset($row['prod_status']) && $row['prod_status'] != '' ? strtoupper(statusNameProduction($row['prod_status'], true)) : '';
             }
             $action = '';
             $disabled = 'disabled="disabled"';
             if ($row['status'] == '1') {
                 //19112010 : DEWA add Ready and Sourcing button
                 if ($row['stock_status'] == 'R' || $row['stock_status'] == 'P' || $row['stock_status'] == 'W') {
                     $action .= '<input type="button" class="actbtn green" name="3" value="Ready" title="Set to Ready for Production" />';
                 } elseif ($row['stock_status'] == 'S') {
                     $action .= '<input type="button" class="actbtn red" name="2" value="Sourcing" title="Set to In Sourcing" />';
                 }
                 $action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Cancel this product" />';
             }
             if ($row['status'] == '2') {
                 if ($row['stock_status'] != 'S') {
                     $action .= '<input type="button" class="actbtn" name="3" value="Ready" title="Set to Ready for Production" />';
                 }
                 $action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Cancel this product" />';
             }
             if ($row['status'] == '3') {
                 $action .= '<input type="hidden" name="oi_id_cols" value="' . $row['jng_sp_orders_items_id'] . '" />';
                 if ($is_outsourced) {
                     $action .= '<input type="button" class="actbtn" name="22" value="Outsourcing PI" title="Print PI and move to Outsourcing" />';
                 } else {
                     $action .= '<input type="button" class="actbtn" name="printpi" value="Print PI" title="Print Production Instruction" />';
                     $action .= '<input type="button" class="actbtn" name="2" value="S" title="Set to In Sourcing" />';
                 }
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
             }
             if ($row['status'] == '4' || $row['status'] == '22') {
                 if ($row['status'] == '4') {
                     $action .= '<input type="button" class="actbtn" name="5" value="Finish" title="Set to Finish" />';
                 }
                 if ($row['status'] == '22') {
                     $action .= '<input type="button" class="actbtn" name="7" value="to HH" title="Set as Sent to HH" />';
                 }
                 $action .= '<input type="button" class="actbtn" name="' . $row['status'] . '" value="PI" title="Reprint Production Instruction" />';
                 if (!$is_outsourced) {
                     $action .= '<input type="button" class="actbtn" name="2" value="S" title="Set to In Sourcing" />';
                 }
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
                 $prod_sub_status = getProductionSubStatus(4);
                 if (count($prod_sub_status) > 0) {
                     $action .= '<br/>';
                 }
                 foreach ($prod_sub_status as $pss => $pss_name) {
                     if (in_array($pss, $PROD_SUBSTATUS_USE_LINE)) {
                         continue;
                     }
                     if ($pss == $sub_status[0]) {
                         continue;
                     }
                     $action .= '<input type="button" class="actbtn" name="4-' . $pss . '" value="' . $pss . '" title="Moved to ' . $pss_name . '" />';
                 }
             }
             if ($row['status'] == '5') {
                 //$action .= '<input type="button" class="actbtn" name="6" value="Package" title="Add to Selected Package" '.((!$packages_exist) ? 'style="display:none;"' : '').'/>';
                 if (!$is_outsourced) {
                     $action .= '<input type="button" class="actbtn" name="4-P" value="Prod" title="Set back to Production" />';
                 } else {
                     $action .= '<input type="button" class="actbtn" name="22" value="Outsourcing" title="Move back to Outsourcing" />';
                 }
                 //$action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';    //activate this only when needed.
             }
             if ($row['status'] == '7' && $row['trans_type'] == '') {
                 $action .= '<input type="button" class="actbtn" name="8" value="Received" title="Received in HH" />';
             }
             //Default Row Action Value (id, status, stock status)
             $action .= '<input type="hidden" id="oiid-' . $row['jng_sp_orders_items_id'] . '" name="oi_id" value="' . $row['jng_sp_orders_items_id'] . '" >';
             $action .= '<input type="hidden" name="oi_status" value="' . $row['status'] . '" >';
             $action .= '<input type="hidden" name="csl_type" value="' . $row['list_type'] . '" />';
             if ($show_stock_status) {
                 $action .= '<input type="hidden" name="oi_stock_status" value="' . $row['stock_status'] . '" >';
             }
             $o['t'] = $action;
             $orders[$row['jng_sp_orders_items_id']] = $o;
         }
         $buttons = '';
         switch ($status) {
             case '1':
                 //hide by request of markus so pic must check line by line
                 //if ($show_btn_inprod && $show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusall" value="Set ALL" title="Set all product status according to the stock status" />';
                 //if ($show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusns" value="Set all NS to Sourcing" title="Set all product with status NS to In Sourcing" />';
             //hide by request of markus so pic must check line by line
             //if ($show_btn_inprod && $show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusall" value="Set ALL" title="Set all product status according to the stock status" />';
             //if ($show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusns" value="Set all NS to Sourcing" title="Set all product with status NS to In Sourcing" />';
             case '2':
                 //hide by request of markus so pic must check line by line
                 //if ($show_btn_inprod) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusok" value="Set all OK/FG to Ready" title="Set all product with status OK/FG to Ready for Production" />';
                 break;
             case '3':
                 //hide due to printing PI is now done per order
                 //$buttons .= 'Product Amount: <input type="text" class="iwbutton" id="pi_print_amount" name="ppa" value="10" title="Set number of products to print" style="width:50px;text-align=center;" />';
                 //$buttons .= ' <input type="button" class="grpbtn button" name="printmultpi" value="Print PI and set to Production" title="Print Production Instruction of a set number of products" />';
                 //$buttons .= '<input type="button" class="grpbtn button" name="togglehideoi" value="Toggle Printed" title="Show or hide already printed items" />';
                 $buttons .= '<div>';
                 $buttons .= '<input type="button" id="btn-reprint-pi-now" class="button help" value="REPRINT NOW for All Already Printed, Unscanned PI (0)" title="Reprint automatically NOW for all PI which<br/><strong>Already printed but not EAN scanned yet</strong>"/>&nbsp;&nbsp;&nbsp;';
                 $buttons .= '<input type="button" id="btn-reprint-pi-nextbatch" class="button help" value="REPRINT ON NEXT BATCH for All Already Printed, Unscanned PI (0)" title="Reprint ON NEXT BATCH print PI for all PI which<br/><strong>Already printed but not EAN scanned yet</strong>"/><br/><br/>';
                 $buttons .= '</div>';
                 $buttons .= '<table class="form" border="0" cellpadding="0" cellspacing="0"><tr>';
                 $buttons .= '<td class="bold">Show Products</td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-2" type="radio" class="readyfilter" name="readyfilter" value="2"/></td>';
                 $buttons .= '<td><label for="rb-orf-2">Unprinted <span id="orfc-up">(0)</span></label></td>';
                 //$buttons .= '<td style="padding-left:30px;"><input id="rb-orf-1" type="radio" class="readyfilter" name="readyfilter" value="1" /></td>';
                 //$buttons .= '<td><label for="rb-orf-1">Ready to be printed <span id="orfc-rp">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-4" type="radio" class="readyfilter" name="readyfilter" value="4" /></td>';
                 $buttons .= '<td><label for="rb-orf-4">Already Printed <span id="orfc-ap">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-5" type="radio" class="readyfilter" name="readyfilter" value="5" /></td>';
                 $buttons .= '<td><label for="rb-orf-5">Already Printed, Unscanned <span id="orfc-apun">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-3" type="radio" class="readyfilter" name="readyfilter" value="3" checked="checked" /></td>';
                 $buttons .= '<td><label class="bold" for="rb-orf-3">All <span id="orfc-al">(0)</span></label></td>';
                 $buttons .= '</tr></table>';
                 break;
             case '5':
                 $jp_mb = new messagebox();
                 $jp_mb->add('Package Management is prohibited here, please <a href="?open=packaging" class="bold">click here and use module Packaging Process</a>');
                 $buttons = $jp_mb->build();
                 break;
         }
         $barcode_rule1 = $status == 3;
         $barcode_rule2 = $status == 4;
         //$barcode_rule2 = ($status==5 && $jng_sp_id!='0');
         if ($barcode_rule1 || $barcode_rule2) {
             $style = $status == 5 && !$packages_exist ? 'style="display:none;"' : '';
             //$buttons .= '<input type="button" class="button barcode-form-trigger" value="BARCODE ENTRY" '.$style.' />';
         }
         if ($buttons != '') {
             $buttons = '<div class="spb" style="margin-bottom:10px;"><input type="hidden" name="grp_status" value="' . $status . '" />' . $buttons . '</div>';
         }
         $result .= '<div id="sp-orders-' . $status . '">';
         $result .= $buttons;
         //$result .= tep_draw_table('spo', $orders);
         //DRAW MANUALLY
         $result .= '<div class="draw-table"><table class="spo sticky-tablehead" border="0" cellpadding="0" cellspacing="0">';
         $result .= '<thead><tr>';
         foreach ($header as $c => $h) {
             $result .= '<th class="' . $c . '">' . $h . '</th>';
         }
         $result .= '</tr></thead><tbody>';
         $prev_oid = null;
         $order_counter = 0;
         $rowclass = 'e';
         foreach ($orders as $oiid => $order) {
             $order_counter++;
             $oi = $orders_items[$oiid];
             $oid = $oi['jng_sp_orders_id'];
             if ($oid != $prev_oid) {
                 $item_counter = 0;
             }
             $item_counter++;
             if ($item_counter == 1) {
                 $rowclass = $rowclass == 'e' ? 'o' : 'e';
             }
             $result .= '<tr class="' . $rowclass . '">';
             $hidecol = 4;
             $use_hide = $item_counter > 1;
             //$use_hide = ($status=='3' && $item_counter>1);
             if ($use_hide) {
                 $result .= '<td colspan="' . $hidecol . '">&nbsp;</td>';
             }
             $col_counter = 0;
             foreach ($order as $c => $o) {
                 $col_counter++;
                 if ($status == '3' && $c == 't') {
                     $action = '<input type="button" class="actbtn" name="4" value="Production" style="display:none;" />';
                     $cla = array();
                     $cla[] = $order_pi_print_count[$oid] > 0 ? 'oi-printed' : '';
                     $cla[] = $order_pi_ready[$oid] ? 'oi-ready' : '';
                     $cla[] = $order_pi_unscanned[$oid] == 0 ? 'oi-unscanned' : '';
                     $action .= '<input type="hidden" name="orf" class="' . implode(' ', $cla) . '"/>';
                     $o = $action . $o;
                 }
                 if ($use_hide) {
                     if ($col_counter == $hidecol + 1) {
                         $o_pos = strpos($o, '<sup');
                         $o = $o_pos === false ? '' : substr($o, $o_pos);
                     }
                     if ($col_counter > $hidecol) {
                         $result .= '<td class="' . $c . '">' . $o . '</td>';
                     }
                 } else {
                     $result .= '<td class="' . $c . '">' . $o . '</td>';
                 }
             }
             $result .= '</tr>';
             $prev_oid = $oid;
         }
         $result .= '</tbody><table></div>';
     } else {
         $result .= '<h3>No Orders in this status</h3>';
     }
     return $result;
 }
Esempio n. 9
0
 function manageOrderList($jng_sp_id, $status, $ean_list = null, $date_start = null, $date_end = null, $brand_id = null, $cat_id = null, $orders_no = '')
 {
     global $STOCKLESS_ELEMENTS_CATEGORY, $PROD_SUBSTATUS_USE_LINE;
     $USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI = false;
     $show_stock_status = $status == '1' || $status == '2' || $status == '3' || $status == '4' || $status == '8';
     $orders_items = $this->retrieveOrdersItems($jng_sp_id, $status, $ean_list, $date_start, $date_end, $brand_id, $cat_id, $orders_no);
     list($status, $sub_status) = explode('-', $status);
     if ($status == '10') {
         $cancel = $this->retrieveCancelList($jng_sp_id);
         if (count($cancel) > 0) {
             foreach ($cancel as $c) {
                 $orders_items[] = $c;
             }
         }
     }
     $orders = array();
     $result = $this->manageOrderList_drawFilter($jng_sp_id, $ean_list, $date_start, $date_end, $brand_id, $cat_id, $orders_no);
     if ($status == '1') {
         //Check if there are orders below the shipping window
         $orders_hidden_by_shipping_window = $this->statusCounterQuery($jng_sp_id, $status, true, $ean_list, $date_start, $date_end, $brand_id, '', '', '', null, $orders_no);
         if ($orders_hidden_by_shipping_window > 0) {
             $result .= '<h3 class="red">' . $orders_hidden_by_shipping_window . ' rows are hidden due to their long Shipping Window</h3>';
         }
     }
     if ($status == '10') {
         $result .= '<h2>Cancelled Products <a href="?open=sp-orders-cancel&amp;hidemenu=true" class="view_webpage" title="Cancel Products"></a><input type="button" id="btn_canceladd" name="canceladd" value="Add" /></h2>';
     }
     if (count($orders_items) > 0) {
         $class_pm = new products_minierp();
         $header = array();
         //$header['d'] = (($status < 2) OR ($status > 7)) ? 'Date' : 'Lead Time';
         $header['d'] = $status > 9 ? 'Date' : 'Lead Time';
         if ($status <= 9) {
             $header['d2'] = 'Cycle Time';
         }
         //            $header['d2'] = ($status=='10') ? 'Cancel' : '<abbr title="Reported Shipping Date">RSD</abbr>';
         //if (!(($status < 2) OR ($status > 7))) $header['d2'] = 'Started Date';
         $header['l'] = 'SP';
         $header['c'] = 'Customer / Order No';
         $header['o'] = 'Order ID';
         $header['a'] = 'Article No';
         $header['p'] = 'Price';
         $header['q'] = 'Qty';
         $header['m'] = 'Margin';
         if ($show_stock_status) {
             $header['s'] = $status == '8' ? 'Status' : 'Stock';
         }
         if ($status == '3') {
             $header['pc1'] = '<abbr title="PI has been sent to PRINTER by MC">P</abbr>';
             $header['pc2'] = '<abbr title="PI has been SCANNED for EAN label in MC">S</abbr>';
         }
         $sub_status = trim($sub_status);
         $sub_prod_show_line_only = in_array($sub_status[0], $PROD_SUBSTATUS_USE_LINE);
         if ($status == '4' && $sub_prod_show_line_only) {
             $header['g'] = 'Status';
         }
         $header['t'] = 'Action';
         //$orders[] = $o;
         $orders_vorkasse_unpaid = array();
         $orders_sent_unconfirmed = array();
         $show_btn_inprod = false;
         $show_btn_insrcn = false;
         if ($status == '5' || $status == '14') {
             //Query Package for Finish and Return Products
             $package_type = $status == '14' ? 'R' : null;
             use_class('jng_sp_packages');
             $class_jp = new jng_sp_packages();
             $usable_packages = $class_jp->getUsablePackages($jng_sp_id, $package_type);
             $packages_exist = count($usable_packages) > 0;
         }
         $timestamp = date('Y-m-d H:i:s');
         $order_pi_print_count = array();
         $order_pi_ready = array();
         $order_pi_collection = array();
         $order_pi_unscanned = array();
         foreach ($orders_items as $oiid => $row) {
             $oid = $row['jng_sp_orders_id'];
             $products_id = $row['products_id'];
             $articles_id = $row['products_articles_id'];
             $order_pi_print_count[$oid][$oiid] = $row['print_count'];
             $order_pi_unscanned[$oid][$oiid] = $row['print_confirmed'];
             $obj_product = new Product($products_id);
             if (!isset($order_pi_collection[$oid])) {
                 $order_pi_ready[$oid] = false;
                 $order_pi_collection[$oid] = array();
             }
             $order_pi_collection[$oid][] = $row['jng_sp_orders_items_id'];
             if (count($order_pi_collection[$oid]) == $row['order_item_total']) {
                 $order_pi_ready[$oid] = true;
                 if (orderItemHaveStatus($oid, 10, 'SP')) {
                     $order_pi_ready[$oid] = false;
                 }
             }
             /* 
                             ### CHANGED THIS TO USING invoice balance, SINCE PREPAYMENT PREAUTH COULD ALSO PROCESSED WHEN 'U-Underpaid' BUT THEN THERES CANCEL CONFIRMED AND MAKE STATUS BECOME 'P-Paid OR O-Overpaid' ###
                             $order_vorkasse_unpaid = (strtoupper($row['payment_method'])==strtoupper(PAYMENT_METHOD_PREPAYMENT) && $row['invoice_complete_status']!='P' && $row['invoice_complete_status']!='O' && $row['invoice_complete_status']!='1');
             */
             $order_vorkasse_unpaid = strtoupper($row['payment_method']) == strtoupper(PAYMENT_METHOD_PREPAYMENT) && !conditionPrepaymentIsPaid($row);
             $order_sent_unconfirmed = $row['status'] == '9' && $row['confirm_delivery'] == '0';
             $o = array();
             $order_date = strtotime($row['order_date']);
             /*
                             $date_used = ($status < 3) ? strtotime($row['status_date']) : strtotime($row['prod_target_in']);
                             if (($status < 2) OR ($status > 7)) {
                $value_date = date('d-M-y', $order_date);
                             } else {
                $value_date = displayLeadTime($row['prod_target_in'], $date_used);
                             }
                             $o['d'] = $value_date;
             */
             $o['d'] = $order_vorkasse_unpaid || $status > 9 ? date('d-M-y', $order_date) : displayLeadTime($row['leadtime_start_date'], strtotime($row['leadtime_start_date']));
             if ($status <= 9 && !$order_vorkasse_unpaid) {
                 $previous_moved_date = $status == 4 ? $row['status_date_prod'] : $row['status_date'];
                 $o['d2'] = displayCycleTime($previous_moved_date);
             }
             //                if($status=='10') {
             //                    $o['d2'] = date('d-M-y', strtotime($row['status_date']));
             //                } else {
             //                    $o['d2'] = $this->reportedShippingDate($order_date, $status, $row['delivery_time'], $row['delivery_replacement_time']);
             //                    if($row['service_code']!='' && $row['service_code']!='ZRE') {
             //                        $title = 'Use Service Code: '.$row['service_code'];
             //                        $new = '<div style="border-bottom:1px solid #f00;text-decoration:blink;cursor:pointer;color:#f00;" title="'.$title.'" onclick="alert(\''.$title.'\');" ';
             //                        $old = '<div ';
             //                        $o['d2'] = str_replace($old, $new, $o['d2']);
             //                    }
             //                }
             //                if (!(($status < 2) OR ($status > 7))) $o['d2'] = date('d-M-y', $date_used);
             $o['l'] = $row['package_prefix'];
             $cust = '<a href="?open=sp-customer&amp;id=' . $row['jng_sp_customers_id'] . '&amp;hidemenu=true" class="view_webpage" >' . $row['customer_name'] . '</a>';
             $crown_img_col = array('V' => 'vip', 'B' => 'black');
             if ($row['list_type'] != '' && array_key_exists($row['list_type'], $crown_img_col)) {
                 $crown_img_title = array('V' => 'VIP Customer', 'B' => 'Blacklist Customer');
                 $crown_img = '<a href="?open=sp-customers-special-detail&amp;id=' . $row['jng_sp_customers_id'] . '&amp;hidemenu=true" class="view_webpage">';
                 $crown_img .= '<img src="images/list-' . $crown_img_col[$row['list_type']] . '.gif" title="' . $crown_img_title[$row['list_type']] . '" />';
                 $crown_img .= '</a> ';
                 $cust = $crown_img . $cust;
             }
             $cust .= ' <sup>' . $row['customers_order_count'] . '</sup>';
             $jng_sp_orders_items_id = 'SP-' . $row['jng_sp_orders_items_id'];
             $jng_sp_orders_items_id = '<a href="?open=sp-order-history&amp;oi_id=' . $row['jng_sp_orders_items_id'] . '&amp;hidemenu=true" class="view_webpage">' . $jng_sp_orders_items_id . '</a>';
             $order_no = $row['order_id'];
             if ($order_no == '') {
                 $order_no = 'J&amp;G ID: ' . $row['jng_sp_orders_id'];
             }
             $order_no = '<a href="?open=customer-care-order-detail&amp;source=SP&amp;id=' . $row['jng_sp_orders_id'] . '&amp;hidemenu=true" class="view_webpage">' . $order_no . '</a>';
             if ($row['order_item_total'] > 1) {
                 $jng_sp_orders_items_id .= ' <sup>' . $row['order_item_count'] . '/' . $row['order_item_total'] . '</sup>';
             }
             if ($row['cod_costs'] > 0) {
                 $order_no = '<img src="images/list-cod.gif" title="COD Method" /> ' . $order_no;
             }
             $o['c'] = $cust . '<br /><small>order no:</small> ' . $order_no;
             $o['o'] = $jng_sp_orders_items_id;
             //$diamond_icon = ($obj_product->brand_id == 14) ? drawDiamondIcon('Diamond Product', ' ') : '';
             $diamond_icon = $obj_product->isUsingDiamond() ? drawDiamondIcon('Diamond Product', ' ') : '';
             $gold_icon = drawGoldIcon($obj_product->metal_stamp_code, $obj_product->metal_stamp_info, '', ' ');
             $article = '<div><a href="?open=product-detail&amp;products_id=' . $products_id . '" target="_blank" title="View Product Detail">' . $row['article_number'] . '</a></div>';
             $icons = $gold_icon . $diamond_icon;
             $pimg = webImageSource($row['products_image'], '500');
             if ($pimg != '') {
                 $thumb = '<div class="thumb" thumbid="' . "{$products_id}-{$articles_id}-{$jng_sp_id}" . '"><a href="' . $pimg . '" class="view_image" title="Click to view larger image">' . webImage($row['products_image'], '80', '80', '', 'img-border img-padding') . '</a></div>';
                 $article = $thumb . $article;
             }
             $o['a'] = drawTableArticleInfoWithIcons($article, $icons);
             $o['p'] = $row['price'];
             $qty = intval($row['order_quantity']);
             $o['q'] = $qty;
             $mat_exp = $row['material_expenses'] > 0 ? $row['material_expenses'] : $row['current_mat_exp'];
             $margin = number_format($class_pm->calculateMargin($row['price'], $mat_exp), 1) . '%';
             $o['m'] = '<span class="' . ($class_pm->priceMargindIsGood($row['price'], $margin) ? 'green' : 'red') . '">' . $margin . '</span>';
             //                $el_link = '<a href="?open=elements-stock&amp;products_id='.$products_id.'&amp;hidemenu=true" class="view_webpage"></a>'; //PREVIOUS
             $el_link = '<a href="?open=products-elements-stock&amp;products_id=' . $products_id . '&amp;paid=' . $row['products_articles_id'] . '&amp;qty=' . $qty . '&amp;status=' . $row['stock_status'] . '&amp;hidemenu=true" class="view_webpage"></a>';
             $pr_link = '<a href="javascript:void();" onclick="alert(\'Please use Finish Good Stock\');"></a>';
             $dp_link = '<a href="javascript:void();" onclick="alert(\'Please use Depot Stock\');"></a>';
             switch ($row['stock_status']) {
                 case '0':
                     $stock_status = '<strong class="red">!</strong>';
                     if ($status == '8') {
                         //$do_status = statusNameShort($row['depot_orders_status']);
                         $do_status = $row['depot_orders_status'] == '4' && isset($row['depot_orders_prod_status']) && $row['depot_orders_prod_status'] != '' ? statusNameProduction($row['depot_orders_prod_status'], false, true) : statusNameShort($row['depot_orders_status']);
                         if (!is_array($do_status)) {
                             //$stock_status = '<span class="red">'.$do_status.'</span>';
                             $stock_status = '<a href="?open=depot-order&amp;id=' . $row['depot_orders_id'] . '&amp;hidemenu=true" title="MMO product, current status is ' . $do_status . '" class="red view_webpage">' . $do_status . '</a>';
                         }
                     }
                     break;
                 case 'R':
                     $show_btn_inprod = true;
                     $stock_status = $el_link . '<abbr title="Element Stock OK, Ready for Production" class="green">OK</abbr>';
                     break;
                 case 'S':
                     $show_btn_insrcn = true;
                     $stock_status = $el_link . '<abbr title="Element Stock Need Sourcing" class="red">NS</abbr>';
                     break;
                 case 'P':
                     $show_btn_inprod = true;
                     $stock_status = $pr_link . '<abbr title="Use Finished Goods Stock" class="green">FG</abbr>';
                     break;
                 case 'D':
                     if (is_null($row['depot_orders_id'])) {
                         $stock_status = $dp_link . '<abbr title="Use Depot Stock" class="green">DS</abbr>';
                     } else {
                         $stock_status = '<a href="?open=depot-order&amp;id=' . $row['depot_orders_id'] . '&amp;hidemenu=true" class="green view_webpage">DS</a>';
                     }
                     break;
                 case 'W':
                     $stock_status = $el_link . '<abbr title="Product is using Wholesale Element" class="red">WP</abbr>';
                     break;
                 default:
                     $stock_status = '<strong class="red">?</strong>';
             }
             if ($show_stock_status) {
                 $o['s'] = $stock_status;
             }
             if ($status == '3') {
                 $o['pc1'] = $row['print_count'] > 0 ? '<img title="Printed ' . $row['print_count'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet printed" src="images/icon-tick-dis.png">';
                 $o['pc2'] = $row['print_confirmed'] > 0 ? '<img title="Scanned ' . $row['print_confirmed'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet scanned" src="images/icon-tick-dis.png">';
             }
             if ($status == '4' && $sub_prod_show_line_only) {
                 $o['g'] = isset($row['prod_status']) && $row['prod_status'] != '' ? strtoupper(statusNameProduction($row['prod_status'], true)) : '';
             }
             $action = '';
             //late button
             $nolate_buttons = in_array($row['jng_sp_id'], $this->sp_nolatebtns);
             $delay_info_sent = $this->isDelayInfoSent($row['jng_sp_orders_items_id']);
             $nmi_tolerance = 2;
             //tolerance in days before showing NMI=>LATE button in Sourcing Tab
             $rsd_plain = $this->reportedShippingDate($order_date, $status, $row['delivery_time'], $row['delivery_replacement_time'], true);
             $disabled = 'disabled="disabled"';
             $delay_class = '';
             if ($nolate_buttons) {
                 $delay_class = ' red';
             } else {
                 if ($delay_info_sent) {
                     $delay_class = ' green';
                 } else {
                     if ($row['status'] != '2') {
                         $disabled = '';
                     } else {
                         if (time() > $rsd_plain + ($nmi_tolerance + 1) * 24 * 60 * 60) {
                             $disabled = '';
                         }
                     }
                 }
             }
             $late_button = '<input type="button" class="actbtn' . $delay_class . '" name="delay" value="LATE" title="Inform SP/Cust about delivery delay" ' . $disabled . ' />';
             if ($row['status'] == '1') {
                 if (!$order_vorkasse_unpaid) {
                     if ($row['stock_status'] == 'P' || $row['stock_status'] == 'R' || $row['stock_status'] == 'W') {
                         $action .= '<input type="button" class="actbtn green" name="3" value="Ready" title="Set to Ready for Production" style="width:70px;" />';
                     } elseif ($row['stock_status'] == 'S') {
                         $action .= '<input type="button" class="actbtn red" name="2" value="Sourcing" title="Set to In Sourcing" style="width:70px;" />';
                     }
                     $action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Cancel this product" />';
                 } else {
                     if ($row['jng_sp_id'] == '8') {
                         $action .= '<span class="green">Waiting Payment Status</span>';
                     } else {
                         if ($row['last_sent_date'] == '') {
                             $action .= '<span class="green">Reminder Not Sent</span>';
                             /*
                             if(!in_array($row['orders_id'],$orders_vorkasse_notice)) {
                                 $orders_vorkasse_notice[] = $row['orders_id'];
                                 $action .= '<input type="button" class="actbtn" name="reminder" value="Reminder" title="Send payment reminder to customer" />';
                             } else {
                                 $action .= '<input type="button" value="Reminder" disabled="disabled" />';
                             }
                             */
                         } else {
                             $overtime = strtotime($row['last_sent_date']) < strtotime('-' . PAYMENT_METHOD_BANK_TRANSFER_OVERDUE);
                             if ($row['sent_count'] > 1) {
                                 $action .= '<span class="red">Cancel Notification Sent</span>';
                             } else {
                                 $action .= '<span class="blue">Reminder Sent</span>';
                             }
                             /*
                             if(!in_array($row['orders_id'],$orders_vorkasse_notice) && $overtime) {
                                 $orders_vorkasse_notice[] = $row['orders_id'];
                                 $action .= '<input type="button" class="actbtn red" name="unpaidcancel" value="CANCEL" title="Cancel order and send email notification to customer" />';
                             } else {
                                 $btn_text = ($overtime) ? 'CANCEL' : 'Reminder Sent';
                                 $action .= '<input type="button" value="'.$btn_text.'" disabled="disabled" />';
                             }
                             */
                         }
                     }
                 }
             }
             //                if($row['status']<='2') $action .= '<input type="button" class="actbtn" name="3" value="Ready" title="Set to Ready for Production" />';
             if ($row['status'] == '2') {
                 $action .= '<input type="button" class="actbtn" name="3" value="Ready" title="Set to Ready for Production" />';
                 $action .= $late_button;
                 $action .= '<input type="button" class="actbtn" name="1" value="N" title="Set back to New" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
             }
             /*
                             if($row['status']=='1') {
                $action .= '<input type="button" class="actbtn" name="2" value="Sourcing" title="Set to In Sourcing" />';
                $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
                             }
             */
             if ($row['status'] == '3') {
                 //$action .= '<input type="button" class="actbtn" name="4" value="PI & Set2Prod" title="Print PI and Set to In Production" />';
                 //$action .= $late_button;
                 if (!$USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI) {
                     $hid = '';
                     $action .= '<input type="button" class="actbtn" name="printpi" value="Print PI" title="Print Production Instruction" ' . $hid . '/>';
                     $action .= '<input type="hidden" name="oi_id_cols" value="' . $row['jng_sp_orders_items_id'] . '" />';
                 }
                 //$action .= '<input type="button" class="actbtn" name="1" value="N" title="Set back to New" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
                 $action .= '<input type="button" class="actbtn" name="2" value="S" title="Set to In Sourcing" />';
             }
             if ($row['status'] == '4') {
                 $action .= '<input type="button" class="actbtn" name="5" value="Finish" title="Set to Finish" />';
                 $action .= $late_button;
                 $action .= '<input type="button" class="actbtn" name="4" value="PI" title="Reprint Production Instruction" />';
                 $action .= '<input type="button" class="actbtn" name="2" value="S" title="Set to In Sourcing" />';
                 $action .= '<input type="button" class="actbtn" name="10" value="C" title="Cancel this product" />';
                 $prod_sub_status = getProductionSubStatus(4);
                 if (count($prod_sub_status) > 0) {
                     $action .= '<br/>';
                 }
                 foreach ($prod_sub_status as $pss => $pss_name) {
                     if (in_array($pss, $PROD_SUBSTATUS_USE_LINE)) {
                         continue;
                     }
                     if ($pss == $sub_status[0]) {
                         continue;
                     }
                     $action .= '<input type="button" class="actbtn" name="4-' . $pss . '" value="' . $pss . '" title="Moved to ' . $pss_name . '" />';
                 }
             }
             if ($row['status'] == '5') {
                 //$action .= '<input type="button" class="actbtn" name="6" value="Package" title="Add to Selected Package" '.((!$packages_exist) ? 'style="display:none;"' : '').'/>';
                 $action .= '<input type="button" class="actbtn" name="4-P" value="Prod" title="Set back to Production" />';
                 $action .= $late_button;
             }
             if ($row['status'] == '8') {
                 $action .= '<input type="button" class="actbtn" name="10" value="Cancel" title="Cancel this product" />';
             }
             if ($row['status'] == '10') {
                 $action .= '<input type="button" class="actbtn" name="1" value="Revive" title="Revive this product as New" />';
             }
             if ($row['status'] == '14') {
                 $action .= '<input type="button" class="actbtn" name="16" value="Package" title="Add to Selected Package" ' . (!$packages_exist ? 'style="display:none;"' : '') . '/>';
                 $action .= '<input type="button" class="actbtn" name="15" value="Keep" title="Set to Keep" />';
             }
             if ($row['status'] == '15') {
                 $action .= '<input type="button" class="actbtn" name="14" value="Return" title="Set Back to Return" />';
             }
             if ($row['confirm_delivery'] == '1' && $row['status'] < 14) {
                 $action = '<div class="green">confirmed</div>';
             }
             //Default Row Action Value (id, status, stock status)
             $action .= '<input type="hidden" id="oiid-' . $row['jng_sp_orders_items_id'] . '" name="oi_id" value="' . $row['jng_sp_orders_items_id'] . '" >';
             $action .= '<input type="hidden" name="oi_status" value="' . $row['status'] . '" >';
             $action .= '<input type="hidden" name="csl_type" value="' . $row['list_type'] . '" />';
             if ($show_stock_status) {
                 $action .= '<input type="hidden" name="oi_stock_status" value="' . $row['stock_status'] . '" >';
             }
             $o['t'] = $action;
             if ($order_vorkasse_unpaid) {
                 $orders_vorkasse_unpaid[$row['jng_sp_orders_items_id']] = $o;
             } elseif ($order_sent_unconfirmed) {
                 $orders_sent_unconfirmed[$row['jng_sp_orders_items_id']] = $o;
             } else {
                 $orders[$row['jng_sp_orders_items_id']] = $o;
             }
         }
         $buttons = '';
         switch ($status) {
             case '1':
                 //hide by request of markus so pic must check line by line
                 //if($show_btn_inprod && $show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusall" value="Set ALL" title="Set all product status according to the stock status" />';
                 //if($show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusns" value="Set all NS to Sourcing" title="Set all product with status NS to In Sourcing" />';
             //hide by request of markus so pic must check line by line
             //if($show_btn_inprod && $show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusall" value="Set ALL" title="Set all product status according to the stock status" />';
             //if($show_btn_insrcn) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusns" value="Set all NS to Sourcing" title="Set all product with status NS to In Sourcing" />';
             case '2':
                 //hide by request of markus so pic must check line by line
                 //if($show_btn_inprod) $buttons .= '<input type="button" class="grpbtn button" name="stockstatusok" value="Set all OK/FG to Ready" title="Set all product with status OK/FG to Ready for Production" />';
                 break;
             case '3':
                 //hide due to printing PI is now done per order
                 //$buttons .= 'Product Amount: <input type="text" class="iwbutton" id="pi_print_amount" name="ppa" value="10" title="Set number of products to print" style="width:50px;text-align=center;" />';
                 //$buttons .= ' <input type="button" class="grpbtn button" name="printmultpi" value="Print PI and set to Production" title="Print Production Instruction of a set number of products" />';
                 //if(!$USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI) {
                 //    $buttons .= '<input type="button" class="grpbtn button" name="togglehideoi" value="Toggle Printed" title="Show or hide already printed items" />';
                 //} else {
                 $buttons .= '<div>';
                 $buttons .= '<input type="button" id="btn-reprint-pi-now" class="button help" value="REPRINT NOW for All Already Printed, Unscanned PI (0)" title="Reprint automatically NOW for all PI which<br/><strong>Already printed but not EAN scanned yet</strong>"/>&nbsp;&nbsp;&nbsp;';
                 $buttons .= '<input type="button" id="btn-reprint-pi-nextbatch" class="button help" value="REPRINT ON NEXT BATCH for All Already Printed, Unscanned PI (0)" title="Reprint ON NEXT BATCH print PI for all PI which<br/><strong>Already printed but not EAN scanned yet</strong>"/><br/><br/>';
                 $buttons .= '</div>';
                 $buttons .= '<table class="form" border="0" cellpadding="0" cellspacing="0"><tr>';
                 $buttons .= '<td class="bold">Show Products</td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-2" type="radio" class="readyfilter" name="readyfilter" value="2"/></td>';
                 $buttons .= '<td><label for="rb-orf-2">Unprinted <span id="orfc-up">(0)</span></label></td>';
                 //$buttons .= '<td style="padding-left:30px;"><input id="rb-orf-1" type="radio" class="readyfilter" name="readyfilter" value="1" /></td>';
                 //$buttons .= '<td><label for="rb-orf-1">Ready to be printed <span id="orfc-rp">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-4" type="radio" class="readyfilter" name="readyfilter" value="4" /></td>';
                 $buttons .= '<td><label for="rb-orf-4">Already Printed <span id="orfc-ap">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-5" type="radio" class="readyfilter" name="readyfilter" value="5" /></td>';
                 $buttons .= '<td><label for="rb-orf-5">Already Printed, Unscanned <span id="orfc-apun">(0)</span></label></td>';
                 $buttons .= '<td style="padding-left:30px;"><input id="rb-orf-3" type="radio" class="readyfilter" name="readyfilter" value="3" checked="checked" /></td>';
                 $buttons .= '<td><label class="bold" for="rb-orf-3">All <span id="orfc-al">(0)</span></label></td>';
                 $buttons .= '</tr></table>';
                 //}
                 break;
             case '5':
                 $jp_mb = new messagebox();
                 $jp_mb->add('Package Management is prohibited here, please <a href="?open=packaging" class="bold">click here and use module Packaging Process</a>');
                 $buttons = $jp_mb->build();
                 break;
             case '14':
                 if ($jng_sp_id == '0') {
                     $jp_mb = new messagebox();
                     $jp_mb->add('You must select a Sales Partner before managing packages for ' . ($status == '5' ? 'finished' : 'returned') . ' products, please change the <strong>All Sales Partners</strong> filter to a specific SP.', 'green');
                     $buttons = $jp_mb->build();
                 } else {
                     if ($packages_exist) {
                         $packages = '<h3>';
                         $packages .= 'Package: ' . $class_jp->packageCombo($usable_packages, 'package', '', 'id="selpack"');
                         $packages .= ' <input type="button" class="pkgbtn" name="addall2pack" value="Add all products to this Package" title="Add all listed products to the selected package" />';
                         $packages .= '</h3>';
                     } else {
                         $packages = '<h3>Please create a new package</h3>';
                     }
                     $buttons .= '<div style="float:right;"><input type="button" class="pkgbtn button" name="createnewpackage" value="Create New Package" title="Create a new package for shipping" /></div>';
                     $buttons .= '<div id="pack_cont" style="padding:10px 0px;">' . $packages . '</div>';
                 }
                 break;
             case '16':
                 if ($jng_sp_id == '0') {
                     //$buttons .= '<input type="button" class="button grpbtn" name="printpackagechecklist" value="Print Checklist" title="Print Package Checklist" />';
                     $buttons .= '<input type="button" class="button grpbtn" name="printpackagefakeinvoice" value="Print Invoice" title="Print Fake Invoice for Bali Customs" />';
                     $buttons .= '<input type="button" class="button grpbtn" name="sendpackage" value="Send to Bali" title="Send this Package to Bali" />';
                 } else {
                     $jp_mb = new messagebox();
                     $jp_mb->add('Please change the SP filter to <strong>All Sales Partners</strong> to continue.', 'green');
                     $buttons = $jp_mb->build();
                 }
                 break;
         }
         $barcode_rule1 = $status == 3;
         $barcode_rule2 = $status == 4;
         //$barcode_rule2 = ($status==5 && $jng_sp_id!='0');
         if ($barcode_rule1 || $barcode_rule2) {
             $style = $status == 5 && !$packages_exist ? 'style="display:none;"' : '';
             //$buttons .= '<input type="button" class="button barcode-form-trigger" value="BARCODE ENTRY" '.$style.' />';
         }
         if ($buttons != '') {
             $buttons = '<div class="spb" style="margin-bottom:10px;"><input type="hidden" name="grp_status" value="' . $status . '" />' . $buttons . '</div>';
         }
         $result .= '<div id="sp-orders-' . $status . '">';
         $result .= $buttons;
         //DRAW MANUALLY
         $orders_total = count($orders);
         $orders_sent_unconfirmed_total = count($orders_sent_unconfirmed);
         $orders_vorkasse_unpaid_total = count($orders_vorkasse_unpaid);
         if ($status == '9') {
             if ($orders_sent_unconfirmed_total > 0) {
                 $result .= '<h3 class="red">Unconfirmed to Sales Partner (' . $orders_sent_unconfirmed_total . ')</h3>';
                 $result .= $this->drawTableListProduct($header, $orders_sent_unconfirmed, $orders_items);
                 $result .= '<div>&nbsp;</div>';
             }
             $result .= '<h3 class="green">Recently Confirmed to Sales Partner (' . $orders_total . ')</h3>';
         }
         if ($orders_total > 0) {
             $result .= $this->drawTableListProduct($header, $orders, $orders_items, $USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI, 5, $order_pi_print_count, $order_pi_ready, $order_pi_collection, $order_pi_unscanned);
             $result .= '<div>&nbsp;</div>';
         }
         if ($orders_vorkasse_unpaid_total > 0) {
             $header['d'] = 'Date';
             unset($header['d2']);
             $result .= '<h3 class="red">Unpaid Prepayment (' . $orders_vorkasse_unpaid_total . ')<span class="notice"> - No need to process these orders</span></h3>';
             $result .= $this->drawTableListProduct($header, $orders_vorkasse_unpaid, $orders_items, $USE_ORDER_FILTER_TO_ALLOW_PRINTING_PI, 4);
         }
         if ($status == '5') {
             $result .= '<div id="crnew-pack-form" style="display:none;">';
             $result .= 'Leave blank to use auto-generated code<br />';
             $result .= '<input type="text" id="crnew-pack-form-pcode" value="" class="iwbutton" />';
             $result .= '<input type="button" id="crnew-pack-form-submit" value="Create!" class="button" />';
             $result .= '</div>';
         }
         $result .= '</div>';
     } else {
         $result .= '<h3 style="margin:0;">No Orders in this status</h3>';
     }
     return $result;
 }