コード例 #1
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;
 }
コード例 #2
0
ファイル: orders.php プロジェクト: blasiuscosa/manobo-2008
 function retrieveReturnList()
 {
     //use_class('product');
     use_class('Product');
     $first_opid_using_paypal_in_payone = 40024;
     $returns = $this->retrieveReturnListData();
     $result = '';
     $result .= '<h2>';
     $result .= 'Return List ';
     $result .= ' <span><a href="?open=orders-return&amp;hidemenu=true" class="view_webpage" title="Add Products to Return list"></a><input type="button" id="btn_returnadd" name="returnadd" value="Add" /></span>';
     $result .= ' <span><a href="?open=orders-return-list&amp;hidemenu=true" class="view_webpage" title="List of Return Products"></a><input type="button" id="btn_returnlist" name="returnlist" value="View Finished" /></span>';
     $result .= '</h2>';
     if (count($returns) > 0) {
         use_class('products_minierp');
         $class_pm = new products_minierp();
         $orders = array();
         $orders_items = array();
         $header = array();
         $header['d'] = 'Date';
         $header['r'] = 'Source';
         $header['c'] = 'Customer / Order No';
         $header['o'] = 'Order ID';
         $header['a'] = 'Product Code';
         $header['q'] = 'Qty';
         $header['id1'] = 'Payment Method';
         //$header['e'] = 'Cust Request';
         $header['t'] = 'Action';
         $return_not_notified = array();
         foreach ($returns as $row) {
             //$obj_product = new product($row['products_id']);
             $obj_product = new Product($row['products_id']);
             $orders_items[$row['orders_products_id']] = $row;
             $return_id = $row['orders_products_return_id'];
             $order_date = strtotime($row['date_purchased']);
             $o = array();
             $o['d'] = date('d-M-y', $order_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>';
             if ($row['list_type'] != '') {
                 $crown_img_col = array('V' => 'vip', 'B' => 'black');
                 $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>";
             }
             $o['c'] = $cust . '<br /><small>order no:</small> ' . $order_no;
             $o['o'] = $orders_products_id;
             $product = '<div><a href="?open=product-detail&amp;products_id=' . $row['products_id'] . '" target="_blank" title="View product detail">' . $row['products_model'] . '</a></div>';
             $pimg = webImageSource($row['products_image'], '500');
             if ($pimg != '') {
                 $thumb = '<div class="thumb"><a href="' . $pimg . '" class="view_image" title="Image of ' . $row['products_model'] . '">' . webImage($row['products_image'], '80', '80', $row['products_id'], '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);
             $o['q'] = $row['return_qty'];
             $o['id1'] = $row['payment_method'] . ($row['payment_method'] == PAYMENT_METHOD_PAYPAL && $row['orders_products_id'] < $first_opid_using_paypal_in_payone ? '<br ><span class="smallText red">(Need Transfer)</span>' : '');
             //$o['e'] = $this->productReturnRequestText($row['return_type']);
             $action = '';
             $action_style = ' style="width:120px;"';
             if ($row['return_type'] == 'C') {
                 $cb_detail = $this->getChargedbackDetail($row['orders_products_id']);
             }
             if ($row['return_type'] != 'C' || $row['return_type'] == 'C' && !is_null($cb_detail)) {
                 $rndis = $row['email_last_sent'] == '' ? '' : ' disabled="disabled"';
                 $detail_btn_text = 'Detail';
                 if ($row['return_type'] == 'C' && $row['product_received'] == '1' && $cb_detail['chargedback_status'] == '0') {
                     $detail_btn_text = 'Set Payment';
                 } else {
                     $action .= '<input type="button" class="actbtn" name="retclose" value="Close"' . $action_style . ' /><br />';
                     $action .= '<input type="button" class="actbtn" name="retnotify" value="Notify"' . $rndis . $action_style . ' /><br />';
                 }
             } else {
                 $detail_btn_text = 'Set Payment';
             }
             $action .= '<span>';
             $action .= '<a href="?open=order-return&amp;id=' . $return_id . '&amp;hidemenu=true" class="view_webpage" title="View Return Detail"></a>';
             $action .= '<input type="button" class="actbtn" name="retdetail" value="' . $detail_btn_text . '"' . $action_style . ' />';
             $action .= '</span>';
             //Default Row Action Value (id, status)
             $action .= '<input type="hidden" id="ret_id-' . $return_id . '" name="ret_id" value="' . $return_id . '" >';
             $o['t'] = $action;
             $orders[$row['orders_products_id']] = $o;
         }
         $result .= '<div id="orders-' . $status . '">';
         //$result .= tep_draw_table('spo', $orders);
         $result .= $this->drawTableListProduct($header, $orders, $orders_items);
         $result .= '</div>';
     } else {
         $result .= '<h3>No Orders in this status</h3>';
     }
     return $result;
 }
コード例 #3
0
 /**
  * Retrieve order items data on Package
  * @global array $SP_DOESNT_NEED_EASYLOG
  * @param int $jng_sp_id
  * @param int $status
  * @param string $ean_list
  * @param string $date_start
  * @param string $date_end
  * @param int $brand_id
  * @param int $cat_id
  * @param string $orders_no
  * @return array of order items
  */
 function manageOrderPackageList($jng_sp_id, $status, $ean_list = null, $date_start = null, $date_end = null, $brand_id = null, $cat_id = null, $orders_no = '')
 {
     use_class('jng_sp');
     $class_sp = new jng_sp();
     $SP_DOESNT_NEED_EASYLOG = array_keys($class_sp->retrieveList('use_easylog=0'));
     $query = "SELECT CONCAT(jo.customer_billing_firstname,' ',jo.customer_billing_lastname) AS customer_name";
     $query .= ", jo.order_id, jo.order_date, jo.customers_order_count, joi.*, p.products_image, p.products_brand_id, joih.status_date";
     $query .= ", jp.jng_sp_id, jp.jng_sp_packages_id, jp.package_code, jp.awb_no, jcust.jng_sp_customers_id, jscs.list_type";
     $query .= ", IFNULL(joi.leadtime_start_date, jo.order_date) AS date_for_sorting";
     $query .= " FROM jng_sp_orders jo";
     $query .= " LEFT JOIN jng_sp_customers jcust ON jcust.jng_sp_id=jo.jng_sp_id AND jcust.customer_id=jo.customer_billing_id";
     $query .= " LEFT JOIN jng_sp_customers_special jscs ON jscs.jng_sp_customers_id=jcust.jng_sp_customers_id";
     $query .= " LEFT JOIN jng_sp_orders_items joi ON joi.jng_sp_orders_id=jo.jng_sp_orders_id";
     $query .= " LEFT JOIN jng_sp_orders_items_status_history joih ON joih.jng_sp_orders_items_id=joi.jng_sp_orders_items_id AND joih.status=joi.status";
     $query .= " INNER JOIN jng_sp_packages_items jpi ON jpi.jng_sp_orders_items_id=joi.jng_sp_orders_items_id";
     $query .= " LEFT JOIN products p ON p.products_id=joi.products_id";
     $query .= " LEFT JOIN jng_sp_packages jp ON jp.jng_sp_packages_id=jpi.jng_sp_packages_id";
     $query .= " LEFT JOIN products_to_categories ptc ON ptc.categories_id=joi.products_id";
     $query .= " WHERE joi.status='{$status}'";
     if ($jng_sp_id != '0') {
         $query .= " AND jo.jng_sp_id={$jng_sp_id}";
     }
     $query .= $this->eanListFilterQuery($ean_list, 'AND', '');
     $query .= $this->leadtimeFilterQuery($status, $date_start, $date_end, 'AND', '');
     if ($brand_id > 0) {
         $query .= " AND p.products_brand_id='{$brand_id}' ";
     }
     if ($cat_id > 0) {
         $query .= " AND ptc.categories_id='{$cat_id}' ";
     }
     if ($orders_no != '') {
         $query .= " AND jo.order_id IN ('" . (is_array($orders_no) ? implode("','", $orders_no) : $orders_no) . "') ";
     }
     $query .= " ORDER BY IFNULL(jp.sent_date, NOW()) ";
     $query .= $status < 14 ? 'ASC' : 'DESC';
     $query .= ", date_for_sorting ASC, jo.jng_sp_orders_id ASC, joi.order_item_count ASC";
     $result = tep_db_query($query);
     $orders = array();
     $package_code = array();
     $package_awb = array();
     $package_sp_id = array();
     $all_package_receivable = true;
     $filters = $this->manageOrderList_drawFilter($jng_sp_id, $ean_list, $date_start, $date_end, $brand_id, $cat_id, $orders_no);
     if (tep_db_num_rows($result) > 0) {
         $header = array();
         $header['d'] = ($status < 6 or $status > 7) ? 'Date' : 'Lead Time';
         //$header['d2'] = '<abbr title="Reported Shipping Date">RSD</abbr>';
         if (!($status < 6 || $status > 7)) {
             $header['d3'] = 'Cycle Time';
             $header['d2'] = 'Started Date';
         }
         $header['c'] = 'Customer / Order No';
         $header['o'] = 'Order ID';
         $header['a'] = 'Article No';
         $header['p'] = 'Price';
         $header['q'] = 'Qty';
         $header['t'] = 'Action';
         $orders_items = array();
         $items_listed = array();
         while ($row = tep_db_fetch_array($result)) {
             if (!in_array($row['jng_sp_orders_items_id'], $items_listed)) {
                 $obj_product = new Product($row['products_id']);
                 $orders_items[$row['jng_sp_orders_items_id']] = $row;
                 $items_listed[] = $row['jng_sp_orders_items_id'];
                 $package_id = $row['jng_sp_packages_id'];
                 if (!isset($orders[$package_id])) {
                     $orders[$package_id] = array();
                     $package_code[$package_id] = $row['package_code'];
                     $package_awb[$package_id] = $row['awb_no'];
                     if ($row['awb_no'] == '') {
                         $all_package_receivable = false;
                     }
                 }
                 $order_date = strtotime($row['order_date']);
                 $o = array();
                 /*
                                     $date_used = strtotime($row['prod_target_in']);
                                     if (($status < 6) 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'] = displayLeadTime($row['leadtime_start_date'], strtotime($row['leadtime_start_date']));
                 //$o['d'] = '<div title="'.date('H:i:s', $order_date).'">'.date('d-M-y', $order_date).'</div>';
                 //$o['d2'] = $this->reportedShippingDate($order_date, $status, $row['delivery_time'], $row['delivery_replacement_time']);
                 if (!($status < 6 or $status > 7)) {
                     $o['d3'] = displayCycleTime($row['status_date']);
                     //$o['d2'] = date('d-M-y', $date_used);
                     $o['d2'] = date('d-M-y', strtotime($row['leadtime_start_date']));
                 }
                 $cust = '<a href="?open=sp-customer&amp;id=' . $row['jng_sp_customers_id'] . '&amp;hidemenu=true" class="view_webpage" >' . $row['customer_name'] . '</a>';
                 if ($row['list_type'] != '') {
                     $crown_img_col = array('V' => 'vip', 'B' => 'black');
                     $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>';
                 $link_item = '<a href="?open=sp-order-history&amp;oi_id=' . $row['jng_sp_orders_items_id'] . '&amp;hidemenu=true" class="view_webpage">SP-' . $row['jng_sp_orders_items_id'] . '</a>';
                 $order_id_info = $link_item;
                 $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) {
                     $order_id_info .= ' <sup>' . $row['order_item_count'] . '/' . $row['order_item_total'] . '</sup>';
                 }
                 $o['c'] = $cust . '<br /><small>order no:</small> ' . $order_no;
                 $o['o'] = $order_id_info;
                 $article = $row['article_number'];
                 $pimg = webImageSource($row['products_image'], '500');
                 $article = '<div><a href="?open=product-detail&amp;products_id=' . $row['products_id'] . '" target="_blank" title="View Product Detail">' . $article . '</a></div>';
                 if ($pimg != '') {
                     $thumb = '<div class="thumb"><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;
                 }
                 //$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'];
                 $o['q'] = intval($row['order_quantity']);
                 $action = '';
                 if ($row['status'] == '6') {
                     $action .= '<input type="button" class="actbtn" name="5" value="Remove" title="Remove from package" />';
                 }
                 if ($row['status'] == '7' || $row['status'] == '8') {
                     $action .= '<input type="button" class="actbtn" name="10" value="DOA" title="Received DOA, cancel this product" />';
                 }
                 if ($row['status'] == '16') {
                     $action .= '<input type="button" class="actbtn" name="15" value="Keep" title="Remove from package and Set to Keep" />';
                 }
                 if ($row['status'] == '18') {
                     $action .= '<input type="button" class="actbtn" name="20" value="Stock" title="Add product to Stock" />';
                     $action .= '<input type="button" class="actbtn" name="21" value="Disass" title="Disassemble and add elements to Stock" />';
                 }
                 if ($row['status'] == '17' || $row['status'] == '18') {
                     $action .= '<input type="button" class="actbtn" name="19" value="Lost" title="Product is lost" />';
                 }
                 //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'] . '" >';
                 $o['t'] = $action;
                 $orders[$package_id][$row['jng_sp_orders_items_id']] = $o;
                 if (!isset($package_sp_id[$package_id])) {
                     $package_sp_id[$package_id] = $row['jng_sp_id'];
                 }
             }
         }
         $result = '<div id="packages">';
         /*
         if($status=='7' && count($orders)>1 && $all_package_receivable) $result .= '<div style="margin-bottom:20px;"><input type="button" class="pkgbtn button" name="receiveallpackage" value="Receive All Packages" title="Receive all packages listed in HH" /></div>';
         if($status=='8') {
             //$result .= ;
             if($this->easylogImportDataExist()) {
                 $import_stats = '';
                 $import_class = ' red ';
                 $import_value = 'Import file found. Click here to set status to Sent.';
                 $import_title = 'Import shipping data exported from EASYLOG';
             } else {
                 $import_class = ' ';
                 $import_stats = 'disabled="disabled"';
                 $import_value = 'There is no import file to proccess';
                 $import_title = $import_value;
             }
             $result .= '<div style="margin-bottom:20px;">';
             $result .= '<input type="button" class="pkgbtn'.$import_class.'button" name="importeasylog" value="'.$import_value.'" title="'.$import_title.'" '.$import_stats.' />';
             $result .= '</div>';
         }
         */
         foreach ($orders as $pid => $package) {
             $result .= '<div id="package-' . $pid . '" style="margin-bottom:20px;">';
             $button = '';
             if ($status == '6') {
                 //$button .= ' <input type="button" class="pkgbtn" name="printpackagelabel" value="Print Labels" title="Print Labels for products in this package" />';
                 $button .= ' <input type="button" class="pkgbtn" name="printpackagechecklist" value="Print Checklist" title="Print Package Checklist" />';
                 $button .= ' <input type="button" class="pkgbtn" name="sendpackage" value="Send" title="Send this Package to HH" />';
             }
             if ($status == '7' || $status == '8' || $status == '17' || $status == '18') {
                 use_class('jng_sp_packages');
                 if ($status < 14) {
                     $class_jp = new jng_sp_packages();
                     $awb_code = $class_jp->awbCodeLink($package_awb[$pid]);
                 } else {
                     $awb_code = $package_awb[$pid];
                 }
                 if ($awb_code == '') {
                     $awb = $awb_code;
                     $awb_button_tips = 'Add AWB no to this Package';
                 } else {
                     $awb = '(AWB: ' . $awb_code . ')';
                     $awb_button_tips = 'Change AWB';
                 }
                 $button .= ' <span id="awb-' . $pid . '" style="font-weight:normal;">' . $awb . '</span>';
                 $button .= ' <input type="button" class="pkgbtn" name="updateawb" value="AWB" title="' . $awb_button_tips . '" />';
                 //$button .= ' <input type="button" class="pkgbtn" name="printpackagepicklist" value="Print Picklist" title="Print Package Picklist" />';
             }
             //if($status=='7') $button .= ' <input type="button" class="pkgbtn" name="receivepackage" value="Receive" title="Receive this Package in HH" />';
             if ($status == '7') {
                 //if($status=='8') {
                 if (in_array($package_sp_id[$pid], $SP_DOESNT_NEED_EASYLOG)) {
                     //for SP that use manual button instead of Easylog
                     $button .= ' <input type="button" class="pkgbtn" name="printdeliverydocsingle" value="Invoice / Delivery Document" title="Print Invoice / Delivery Documents of this package" />';
                     $button .= ' <input type="button" class="pkgbtn" name="setsent2cust" value="Set as Sent to Customer" title="Set all orders in this package as Sent to Customer" disabled="disabled" />';
                 }
             }
             if ($status == '16') {
                 $button .= ' <input type="button" class="pkgbtn" name="printpackagechecklist" value="Print Checklist" title="Print Package Checklist" />';
                 $button .= ' <input type="button" class="pkgbtn" name="printpackagefakeinvoice" value="Print Invoice" title="Print Fake Invoice for Bali Customs" />';
                 $button .= ' <input type="button" class="pkgbtn" name="sendpackage" value="Send" title="Send this Package to Bali" />';
             }
             if ($status == '17') {
                 $button .= ' <input type="button" class="pkgbtn" name="receivepackage" value="Receive" title="Receive this Package in Bali" />';
             }
             $result .= '<h3>Package ' . $package_code[$pid] . ' ' . $button . ' <input type="hidden" name="package_id" value="' . $pid . '" /></h3>';
             //$result .= tep_draw_table('spo', $package);
             //DRAW MANUALLY
             $result .= '<div class="draw-table"><table class="spo" border="0" cellpadding="0" cellspacing="0">';
             $result .= '<tr>';
             foreach ($header as $c => $h) {
                 $result .= '<th class="' . $c . '">' . $h . '</th>';
             }
             $result .= '</tr>';
             $prev_oid = null;
             $order_counter = 0;
             $rowclass = 'e';
             foreach ($package 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 = 5;
                 $use_hide = $item_counter > 1;
                 //$use_hide = ($status=='3' && $item_counter>1);
                 // Logic for lead time
                 /*
                                     $date_used = strtotime($oi['prod_target_in']);
                                     if (($oi['status'] < 2) OR ($oi['status'] > 7)) {
                    $value_date = "";
                                     } else {
                    $value_date = displayLeadTime($oi['prod_target_in'], $date_used);
                                     }
                                     if (!(($oi['status'] < 2) OR ($oi['status'] > 7))) {
                    $started_date = date('d-M-y', $date_used);
                                     }
                 */
                 $started_date = date('d-M-y', strtotime($oi['leadtime_start_date']));
                 $value_date = displayLeadTime($oi['leadtime_start_date'], strtotime($oi['leadtime_start_date']));
                 if ($use_hide) {
                     $result .= '<td class="d">' . $value_date . '</td>';
                     if (!($status < 6 || $status > 7)) {
                         $result .= '<td class="d3">' . displayCycleTime($oi['status_date']) . '</td>';
                         $result .= '<td class="d2">' . $started_date . '</td>';
                     }
                     $result .= '<td>&nbsp;</td>';
                 }
                 $col_counter = 0;
                 foreach ($order as $c => $o) {
                     $col_counter++;
                     if ($use_hide) {
                         /*
                                                     if($col_counter==$hidecol) {
                            $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 .= '</table></div>';
             $result .= '</div>';
             //close package-pid
         }
         $result .= '</div>';
         //close packages
     } else {
         $result = '<h3>No Orders in this status </h3>';
     }
     $result = $filters . $result;
     return $result;
 }