Пример #1
0
$pdf->label_width = ($pdf->page_width - 2 * $pdf->left_margin) / $pdf->label_per_width;
$pdf->label_per_height = 5;
$pdf->label_height = ($pdf->page_height - 2 * $pdf->top_margin) / $pdf->label_per_height;
$pdf->label_per_page = $pdf->label_per_width * $pdf->label_per_height;
$order_counter = 0;
//$labelpad = 4;
$labelxpad = 55;
$labelypad = 4;
$labelxpos = 1;
$labelypos = 1;
foreach ($orders_array as $order_id) {
    $order = array();
    if ($type == 'sp') {
        //RETRIEVED DATA SP
        $order_data = $class_jo->retrieveDetail($order_id);
        $items = $class_jo->retrieveItems($order_id);
        $order['customer'] = "{$order_data['customer_shipping_firstname']} {$order_data['customer_shipping_lastname']} ";
        $order['id'] = $order_data['order_id'];
        $order['shipment_id'] = $order_data['shipment_id'];
        $order['prefix_code'] = $sp_prefix[$order_data['jng_sp_id']];
    } else {
        //RETRIEVED DATA JNG
        $order_data = $class_o->retrieveDetail($order_id);
        $items = $class_o->retrieveProducts($order_id);
        $order['id'] = $order_data['orders_no'];
        $order['customer'] = $order_data['delivery_name'];
        $order['prefix_code'] = '';
    }
    if ($order_counter % $pdf->label_per_page == 0) {
        $pdf->AddPage();
    }
    $idcode_ret = $idcr[$i];
    if ($shipment_id != '') {
        if (substr($ref, 0, 2) == 'JG') {
            $order_id = substr($ref, 2);
            $idcounter = 'JG' . $order_id;
            $items = $class_o->retrieveProducts($order_id);
            foreach ($items as $item) {
                if ($item['status'] == $REQUIRED_STATUS) {
                    $class_o->updateProductStatus($item['orders_products_id'], $UPDATED_STATUS, $username);
                }
                if ($item['status'] == $REQUIRED_STATUS || $item['status'] == $UPDATED_STATUS) {
                    $update_counter[] = $idcounter;
                }
            }
        } else {
            $items = $class_jo->retrieveItems($shipment_id, true);
            $idcounter = 'SP' . $shipment_id;
            foreach ($items as $item) {
                if ($item['status'] == $REQUIRED_STATUS) {
                    $osda = array('shipment_date' => $shipment_date, 'idcode_ship' => $idcode_ship, 'idcode_ret' => $idcode_ret);
                    tep_db_perform('jng_sp_orders', $osda, 'update', "shipment_id='{$shipment_id}'");
                    $class_jo->updateItemStatus($item['jng_sp_orders_items_id'], $UPDATED_STATUS, $username);
                }
                if ($item['status'] == $REQUIRED_STATUS || $item['status'] == $UPDATED_STATUS) {
                    $update_counter[] = $idcounter;
                }
            }
        }
    }
}
$result = array();
         $from_email_name = FROM_EMAIL_NAME;
         $from_email_address = FROM_EMAIL_ADDRESS;
         $sent = tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address);
         if ($sent) {
             $cron_result[] = "{$to_name} ({$to_email_address}) - {$oid}";
             tep_mail(EMAIL_NAME_SERVICE, EMAIL_ADDRESS_SERVICE, $email_subject, $email_text, $from_email_name, $from_email_address);
             $sent_to = array();
             $sent_to[] = $to_email_address;
             $sent_to[] = EMAIL_ADDRESS_SERVICE;
             if ($o['type'] == 'JG') {
                 $items = $class_o->retrieveProducts($o['orders_id']);
                 foreach ($items as $i) {
                     $class_o->delayInfoSent($i['orders_products_id'], $timestamp, 'auto-sent', $sent_to);
                 }
             } elseif ($o['type'] == 'SP') {
                 $items = $class_jo->retrieveItems($o['orders_id']);
                 foreach ($items as $i) {
                     $class_jo->delayInfoSent($i['jng_sp_orders_items_id'], $timestamp, 'auto-sent', $sent_to);
                 }
             }
         }
     }
 }
 $mt_finish = microtime();
 list($old_usec, $old_sec) = explode(' ', $mt_start);
 list($new_usec, $new_sec) = explode(' ', $mt_finish);
 $old_mt = (double) $old_usec + (double) $old_sec;
 $new_mt = (double) $new_usec + (double) $new_sec;
 $runtime = $new_mt - $old_mt;
 $cron_result[] = 'Run in ' . $runtime . ' seconds';
 //save result to a log file
Пример #4
0
 } else {
     //If product is found
     if (strtoupper($ean_scan) != 'SKIP' && $ean_scan != $item['products_ean']) {
         $result .= printPackageTip(EAN_MISMATCH_ERROR, $item['products_ean'], $ean_scan);
     } else {
         if ($item['status'] < intval($old_status)) {
             //If product status is not yet finish
             $errinfo = $template_error_not_finish;
             $result .= printPackageTip('E', $box_date, $errinfo, $sp_name);
         } elseif ($item['status'] == $old_status) {
             //If product status is finish
             //$order = $class_jo->retrieveDetail($item['jng_sp_orders_id']);
             $order_date = strtotime($order['order_date']);
             $box_date = date('d. M', $order_date);
             //Retrieve all products from the order
             $items = $class_jo->retrieveItems($order['jng_sp_orders_id']);
             foreach ($items as $key => $i) {
                 //Exclude any canceled products
                 $iscanceled = $class_jo->statusIsCancelled($i['status']);
                 if ($iscanceled) {
                     unset($items[$key]);
                 }
             }
             if ($item['order_item_total'] == '1' || count($items) == 1) {
                 //If order only consist of 1 product
                 $packages = $class_jp->getUsablePackages($order['jng_sp_id']);
                 if (count($packages) == 0) {
                     //If no usable package found for this SP, create 1
                     $package_id = $class_jp->createNew($order['jng_sp_id']);
                 } else {
                     //If usable package found fo this SP, use it
$col_subcol_width = array();
$col_subcol_width[1] = 13;
$col_subcol_width[2] = 25;
$col_subcol_width[3] = 20;
$col_subcol_width[4] = 30;
$col_subcol_width[5] = 100;
$col_subcol_width[6] = 50;
$col_subcol_width[7] = 25;
$col_subcol_width[8] = 13;
$col_subcol_imagepos = $col_subcol_width[1];
$col_subcol_eanpos = $col_subcol_width[1] + $col_subcol_width[2] + $col_subcol_width[3] + $col_subcol_width[4] + $col_subcol_width[5];
$colwidth = array_sum($col_subcol_width);
$colheight = $col_subcol_width[2];
$order_counter++;
$order = $class_jo->retrieveDetail($order_id);
$items = $class_jo->retrieveItems($order_id, false, "ptc.categories_id, joi.price");
foreach ($items as $key => $item) {
    if ($class_jo->statusIsCancelled($item['status'])) {
        unset($items[$key]);
    } elseif (isset($items_array) && !in_array($item['jng_sp_orders_items_id'], $items_array)) {
        unset($items[$key]);
    }
}
$pdf->AddPage();
$pdf->SetXY($margin, $pdf->ypos);
//Order Items
if (count($items) > 0) {
    //DRAW BARCODE
    $items_key = array_keys($items);
    $barcode_width = 35;
    $pdf->order_barcode = 'JR-' . $items[$items_key[0]]['jng_sp_orders_items_id'];