$packages = $class_ml->retrievePackages($logistic_id, true);
 foreach ($packages as $type => $pack) {
     if ($type == 'P') {
         use_class('jng_sp_packages');
         $class_jp = new jng_sp_packages();
         use_class('jng_sp_orders');
         $class_jo = new jng_sp_orders();
         foreach ($pack as $p) {
             $items = $class_jp->sendPackage($p['packages_id']);
             foreach ($items as $items_id) {
                 $class_jo->updateItemStatus($items_id, '7', $session_userinfo['username']);
             }
         }
     } elseif ($type == 'J') {
         use_class('minierp_packages');
         $class_mp = new minierp_packages();
         use_class('orders');
         $class_o = new orders();
         foreach ($pack as $p) {
             $items = $class_mp->sendPackage($p['packages_id']);
             foreach ($items as $items_id) {
                 $class_o->updateProductStatus($items_id, '7', $session_userinfo['username']);
             }
         }
     } else {
         use_class('depot_orders');
         $class_do = new depot_orders();
         foreach ($pack as $p) {
             $class_do->packageSetSent($p['packages_id'], $session_userinfo['username']);
         }
     }
    $sp_prefix = array();
    foreach ($splist as $sp) {
        $sp_prefix[$sp['jng_sp_id']] = $sp['package_prefix'];
    }
    use_class("jng_sp_packages");
    $class_jp = new jng_sp_packages();
    use_class("jng_sp_orders");
    $class_jo = new jng_sp_orders();
    $package_id = tep_db_prepare_input($_GET['id']);
    $orders_array = $class_jp->getOrders($package_id);
    $items_array = $class_jp->getItems($package_id);
} elseif (isset($_GET['pid']) && $_GET['pid'] != '') {
    $type = 'jng';
    //JNG PACKAGES
    use_class("minierp_packages");
    $class_mp = new minierp_packages();
    use_class("orders");
    $class_o = new orders();
    $package_id = tep_db_prepare_input($_GET['pid']);
    $orders_array = $class_mp->getOrders($package_id);
    $items_array = $class_mp->getProducts($package_id);
} else {
    exit;
}
class PDF extends FPDF
{
    var $left_margin;
    var $page_width;
    var $label_width;
    var $label_height;
    var $label_per_width;
    foreach ($items as $item_id) {
        $ih = $class_jo->retrieveItemHistory($item_id);
        foreach ($ih as $h) {
            if (in_array($h['status'], $status_check)) {
                $counter++;
                $class_jp->setReceiveDate($pid, $h['status_date']);
                break 2;
            }
        }
    }
}
$logger->write("- {$counter} SP Items Updated");
//JNG PACKAGES
$counter = 0;
use_class('minierp_packages');
$class_mp = new minierp_packages();
use_class('orders');
$class_o = new orders();
$packages = $class_mp->retrieveUnreceivedPackages();
foreach ($packages as $pid => $p) {
    $status_check = array('8', '9');
    $items = $class_mp->getProducts($pid);
    foreach ($items as $item_id) {
        $ih = $class_o->retrieveProductHistory($item_id);
        foreach ($ih as $h) {
            if (in_array($h['status'], $status_check)) {
                $counter++;
                $class_mp->setReceiveDate($pid, $h['status_date']);
                break 2;
            }
        }
//AJAX ACTION
use_class('orders');
use_class('depot_orders');
use_class('jng_sp');
use_class('jng_sp_orders');
use_class('jng_sp_packages');
use_class('minierp_packages');
use_class('products_ean');
use_class('bins');
$class_o = new orders();
$class_do = new depot_orders();
$class_sp = new jng_sp();
$class_jo = new jng_sp_orders();
$class_jp = new jng_sp_packages();
$class_mp = new minierp_packages();
$class_ean = new products_ean();
$class_bins = new bins();
$item_status = statusName();
define('EAN_MISMATCH_ERROR', 'EANMISMATCH');
$waiting_box_name = 'Waiting Box';
$packing_box_name = 'Packing Box';
$finish_box_name = 'Finish Box';
$order_show_sp_info = array('9');
//am.fr
function printPackageTip($type, $no, $info = '', $spname = '', $spclass = '')
{
    global $waiting_box_name, $packing_box_name;
    if ($type == EAN_MISMATCH_ERROR) {
        $result = '<div class="package-tip red-bright">';
        $result .= 'EAN Code<br />MISMATCH';
     $package_id = tep_db_prepare_input($_POST['package_id']);
     $package_awb = tep_db_prepare_input($_POST['package_awb']);
     use_class('minierp_packages');
     $class_mp = new minierp_packages();
     $class_mp->updateAWBno($package_id, $package_awb);
     $result = array();
     $result['package_id'] = $package_id;
     $result['package_awb'] = $package_awb;
     ajaxReturn($result);
     exit;
 } elseif ($_POST['me_action'] == 'SENDTOCUSTOMER') {
     $package_id = tep_db_prepare_input($_POST['package_id']);
     $old_status = '8';
     $new_status = '9';
     use_class('minierp_packages');
     $class_mp = new minierp_packages();
     $products = $class_mp->getProducts($package_id);
     $total_products = 0;
     foreach ($products as $opid) {
         $product = $class_o->retrieveProductDetail($opid);
         if ($product['status'] == $old_status) {
             $total_products++;
             $class_o->updateProductStatus($opid, $new_status, $session_userinfo['username']);
         }
     }
     $class_o->sendProductStatusNotification($products, $new_status, $languages[2]['path']);
     $result = array();
     $result['package_id'] = $package_id;
     $result['old_status'] = $old_status;
     $result['new_status'] = $new_status;
     $result['total_products'] = $total_products;
Exemple #6
0
<?php

use_class('minierp_packages');
$class_mp = new minierp_packages();
use_class("orders");
$class_o = new orders();
//SUBMIT ACTION
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'SUBMITPACKAGECODE') {
        if (isset($_POST['code']) && $_POST['code'] != '') {
            $package_code = tep_db_prepare_input($_POST['code']);
            $package_query = tep_db_query("SELECT packages_id FROM minierp_packages WHERE packages_code='{$package_code}'");
            if (tep_db_num_rows($package_query) > 0) {
                $package = tep_db_fetch_array($package_query);
                $package_id = $package['packages_id'];
                header("Location: ?open=package&package_id={$package_id}");
                exit;
            }
        }
    } elseif ($_POST['me_action'] == 'SAVEPACKAGE') {
        $package_id = tep_db_prepare_input($_POST['package_id']);
        $package_code = tep_db_prepare_input($_POST['package_code']);
        $logistic_partner = tep_db_prepare_input($_POST['logistic_partner']);
        $sql_data_array['packages_code'] = $package_code;
        $sql_data_array['logistic_partners'] = $logistic_partner;
        $sql_data_array['package_unlock'] = '0';
        if (isset($_POST['sent_date'])) {
            $sent_date = tep_db_prepare_input($_POST['sent_date']);
            $sent_date = explode('.', $sent_date);
            $sql_data_array['sent_date'] = implode('-', array_reverse($sent_date));
        }
    $type = 'sp';
    //SP PACKAGES
    use_class("jng_sp_packages");
    $class_jp = new jng_sp_packages();
    use_class("jng_sp_orders");
    $class_jo = new jng_sp_orders();
    $package_id = tep_db_prepare_input($_GET['id']);
    $package = $class_jp->retrieveDetail($package_id);
    $package_code = $package['package_code'];
    $orders_array = $class_jp->getOrders($package_id);
    $items_array = $class_jp->getItems($package_id);
} elseif (isset($_GET['pid']) && $_GET['pid'] != '') {
    $type = 'jng';
    //JNG PACKAGES
    use_class("minierp_packages");
    $class_mp = new minierp_packages();
    use_class("orders");
    $class_o = new orders();
    $package_id = tep_db_prepare_input($_GET['pid']);
    $package = $class_mp->retrieveDetail($package_id);
    $package_code = $package['packages_code'];
    $orders_array = $class_mp->getOrders($package_id);
    $items_array = $class_mp->getProducts($package_id);
} else {
    exit;
}
$order_counter = 0;
$lines = array();
$col = array();
$no_colname = $type == 'sp' && $package_id >= 230 ? 'longno' : 'no';
$col[$no_colname] = 'No';
Exemple #8
0
<?php

use_class('minierp_packages');
$class_mp = new minierp_packages();
$page = 1;
if (isset($_GET['page'])) {
    $page = $_GET['page'];
}
$filter_query = '';
if (isset($_POST['filterby'])) {
    $_SESSION['packages_filterby'] = tep_db_prepare_input($_POST['filterby']);
} else {
    if (!isset($_SESSION['packages_filterby'])) {
        $_SESSION['packages_filterby'] = '';
    }
}
$filterby = $_SESSION['packages_filterby'];
switch ($filterby) {
    case '1':
        $filter_query = " WHERE YEAR(received_date) < 2007";
        break;
    case '2':
        $filter_query = " WHERE YEAR(received_date) >= 2007";
        break;
    case '3':
        $filter_query = " WHERE logistic_partners='" . $logistic_partners_option[0] . "'";
        break;
    case '4':
        $filter_query = " WHERE logistic_partners='" . $logistic_partners_option[1] . "'";
        break;
    case '5':
Exemple #9
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;
 }
<?php

global $db;
require_once '../confy.php';
require_once '../functions.php';
require_once '../functions-2.php';
tep_db_connect();
use_class('orders');
$class_o = new orders();
use_class('minierp_packages');
$class_mp = new minierp_packages();
$export = 'NONE';
$packages = $class_mp->getReceivedPackages();
$lines = array();
if (count($packages) > 0) {
    foreach ($packages as $package) {
        $id = $package['packages_id'];
        $orders_array = $class_mp->getOrders($id);
        $items_array = $class_mp->getProducts($id);
        $order_counter = 0;
        foreach ($orders_array as $order_id) {
            $order_counter++;
            $items = $class_o->retrieveProducts($order_id);
            $item_counter = 0;
            foreach ($items as $item) {
                if (!$class_o->productStatusIsCancelled($item['status']) && in_array($item['orders_products_id'], $items_array)) {
                    $item_counter++;
                }
            }
            if ($item_counter > 0) {
                $order = $class_o->retrieveDetail($order_id);
 function updatePackagesAWBno($logistic_id, $awb_no)
 {
     $packages = $this->retrievePackages($logistic_id, true);
     foreach ($packages as $type => $packs) {
         switch ($type) {
             case 'J':
                 use_class('minierp_packages');
                 $class_mp = new minierp_packages();
                 foreach ($packs as $p) {
                     //if($p['awb_no']=='') {
                     $class_mp->updateAWBno($p['packages_id'], $awb_no);
                     //}
                 }
                 break;
             case 'P':
                 use_class('jng_sp_packages');
                 $class_jp = new jng_sp_packages();
                 foreach ($packs as $p) {
                     //if($p['awb_no']=='') {
                     $class_jp->updateAWBno($p['packages_id'], $awb_no);
                     //}
                 }
                 break;
             case 'D':
                 use_class('depot_orders');
                 $class_do = new depot_orders();
                 foreach ($packs as $p) {
                     $class_do->packageUpdateAWB($p['packages_id'], $awb_no);
                 }
         }
     }
 }