$class_ean = new products_ean();
$class_bin = new bins();
$ean_collection = array();
$orders = array();
$orders_barcode = array();
$jng_sp_id = tep_db_prepare_input($_GET['spid']);
$destination = tep_db_prepare_input($_GET['dest']);
$order_type = tep_db_prepare_input($_GET['ot']);
$date_send = tep_db_prepare_input($_GET['datesend']);
$box_switch_time = $_GET['bst'] == '' ? array() : explode(',', tep_db_prepare_input($_GET['bst']));
$date_filter = generateMysqlDateFromGerman($date_send);
if ($jng_sp_id == '' || $date_filter == '') {
    exit;
}
$sp_detail = $class_sp->retrieveDetail($jng_sp_id);
$amvdsl = loadAMVDsendListWithSSCC($jng_sp_id, $destination, $order_type, $date_filter, $box_switch_time);
$asns = $amvdsl['asns'];
$orders = $amvdsl['orders'];
$orders_data = $amvdsl['orders_data'];
$orders_products = $amvdsl['orders_products'];
$orders_sscc = $amvdsl['orders_sscc'];
$box_total = count($orders_sscc);
class PDF extends PDF_Draw
{
    public $header_date;
    public $printed_po;
    public $current_page;
    //Page header
    public function Header()
    {
    }
     for ($bc = 1; $bc <= $box_total; $bc++) {
         $sscc_nr[] = generateAmazonSSCCNumber($send_date, $dest, $order_type, $bc);
     }
     $result = implode("<br />", $sscc_nr) . '<br /><br />In AVC, go to next step';
     echo utf8_encode($result);
     exit;
 } elseif ($_POST['me_action'] == 'SSCC-GENERATE-TOTAL-BOX') {
     $list_gap = 'style="margin-top:8px;"';
     $spid = tep_db_prepare_input($_POST['spid']);
     $destination = tep_db_prepare_input($_POST['destination']);
     $order_type = tep_db_prepare_input($_POST['order_type']);
     $send_date = tep_db_prepare_input($_POST['send_date']);
     $datefilter_sql = generateMysqlDateFromGerman($send_date);
     $box_switch_time = array();
     $box_number = array();
     $amvdsl = loadAMVDsendListWithSSCC($spid, $destination, $order_type, $datefilter_sql, $box_switch_time);
     $polist = $amvdsl['orders'];
     $total_po = count($polist);
     $result = '<strong>' . $total_po . '</strong> PO found for' . ' destination <strong>' . $destination . '</strong> sending date <strong>' . $send_date . '</strong>';
     if ($total_po > 0) {
         $box_number_query = 'SELECT * FROM orders_use_packaging_box WHERE order_id IN ("' . implode('", "', $polist) . '") AND date_allocation = "' . $datefilter_sql . '" ORDER BY packaging_box ASC';
         $box_number_result = tep_db_query($box_number_query);
         while ($row = tep_db_fetch_array($box_number_result)) {
             $box_number[$row['order_id']] = $row['packaging_box'];
         }
         $total_box_query = "SELECT MAX(packaging_box) FROM orders_use_packaging_box WHERE date_allocation = '{$datefilter_sql}' AND shipping_id = '{$destination}'";
         $total_box_result = tep_db_query($total_box_query);
         $total_boxes = mysql_fetch_row($total_box_result);
         $result = '<ul style="margin:0 10px;padding:0;">';
         $result .= '<li>Gesamtzahl der Kartons: ' . $total_boxes[0] . '</li>';
         $result .= '<li ' . $list_gap . '>In AVC, go to next step.</li>';