コード例 #1
0
/**
 * Get sp id which using selling point
 * @param boolean $use_amde_selling_point
 * @return Array Array of Sales Partner ID
 */
function getSalesPartnerUseSellingPoint($use_amde_selling_point = false)
{
    $result = array();
    if ($use_amde_selling_point) {
        //SP's which using amde selling points
        $result = array_keys(getSalesPartnerUseAmazonLogistic());
    } else {
        //SP's which using non-amde selling points
        $result = array('2', '8');
        //Applied to otde, zade
    }
    return $result;
}
コード例 #2
0
 function constructPIContent($pdf, $output, $order, $ignoreStockStatusDepot, $print_per_orders)
 {
     /*  NOTES!!!!!!!!!!!!!!!!
      *  if $print_per_orders == false, $order should contain "collections of orders"
      *  elseif $print_per_orders == true, $order should contain "one order only"
      */
     use_class('Product');
     use_class('ProductAttribute');
     global $class_pm, $class_pb, $product_categories_name, $DIAMOND_BRAND_IDS;
     if ($print_per_orders) {
         $orders[] = $order;
     } else {
         $orders = $order;
     }
     //echo "<pre>";var_dump($orders);die();
     $margin = 5;
     $fontsize_big = '9';
     $fontsize_med = '8';
     $fontsize_sml = '7';
     $fontsize_tny = '5';
     $barcode_width = 32;
     $barcode_pos = 210 - $margin - $barcode_width - 1;
     $element_name_max_chars = 30;
     if ($output == 'F') {
         //PRODUCE PDF FILE PER ITEM (MULTI PDF FILE PER ORDER)
         $pdf = new PDF('P', 'mm', 'A4');
         $pdf->setTitle('Production Instruction');
         $pdf->SetAuthor('JULIE GRACE / Bonofactum');
         $pdf->SetCreator('k-Auto Generated PDF');
         $pdf->SetDisplayMode('real');
         $pdf->SetAutoPageBreak(false);
         $pdf->AliasNbPages();
         $pdf->SetFillColor(191, 191, 191);
     }
     //start looping orders
     foreach ($orders as $order) {
         $o = $order['detail'];
         $is_ottob2b = $o['jng_sp_id'] == '11' || strpos(strtolower($o['customer']), 'otto b2b') !== false;
         foreach ($order['items'] as $oiid => $i) {
             if ($i['status'] < 8) {
                 $this->pi_printed[strtolower($o['type'])][] = $oiid;
             }
             $obj_product = new Product($i['products_id']);
             $is_gold_product = $obj_product->metal_stamp_code > 0 && $obj_product->metal_stamp_code != 925;
             $pdf->pi_number = $o['id'];
             if ($this->duplex_printing && isset($item_page_count) && $item_page_count % 2 != 0) {
                 $pdf->AddPage();
             }
             $pdf->AddPage();
             $item_page_count = 1;
             $product_key = $i['products_id'] . '-' . $i['articles_id'];
             $product_qty = intval($i['quantity']);
             $p = $this->products[$product_key];
             $is_elli_premium = $p['p']['products_brand_id'] == '29';
             $is_diamore = in_array($p['p']['products_brand_id'], $DIAMOND_BRAND_IDS);
             $is_pearl = $p['p']['products_brand_id'] == '7';
             $ean = $this->products_ean[$product_key];
             $product_complexity = strtoupper(productComplexityName($p['p']['complexity']));
             $order_type_code = '';
             if (strtoupper($o['type']) == 'DP') {
                 $order_type_code = strtoupper($o['type']);
                 $otc_width = 12;
             } else {
                 $order_type_code = $o['customer_type'];
                 $otc_width = 20;
             }
             $pdf->OrderBarcode($o['type'], $oiid, $barcode_pos, $margin, $barcode_width);
             $pdf->setFont('Arial', 'B', '12');
             $YPOS = $margin;
             $lineheight = 4;
             //ORDER TYPE CODE (JG,SP,DP)
             $pdf->SetXY($barcode_pos - $otc_width, 10);
             $pdf->Cell(100, $lineheight, $order_type_code);
             //PROCESS DATE
             $pdf->setFont('Arial', 'B', $fontsize_big);
             $process_date = date('d M Y', strtotime($i['prod_target_in']));
             $pdf->SetXY($barcode_pos, 22);
             $pdf->Cell($barcode_width, $lineheight, $process_date, 0, 2, 'R');
             //PRODUCT COMPLEXITY
             $pdf->setFont('Arial', 'B', '12');
             $pdf->SetXY($barcode_pos, 22 + $lineheight + 5);
             $pdf->Cell($barcode_width, $lineheight, $product_complexity, 0, 2, 'R');
             //PAGE HEADER
             $margin_orderinfo = $margin + 50;
             $pdf->SetXY($margin_orderinfo, $YPOS);
             $pdf->Cell(100, $lineheight, 'Production Instruction ' . $o['id'] . ' (' . $i['counter'] . ') - print ' . ($i['print_count'] + 1));
             $YPOS += $lineheight + 1;
             //ORDER INFORMATION
             $lineheight = 3.5;
             $orderilbl = array();
             $orderinfo = array();
             $orderilbl[] = 'Ship To (Country)';
             $orderinfo[] = ': ' . trim($o['shipto_name']) . ($o['shipto_address'] != '' ? ' (' . $o['shipto_address'] . ')' : '');
             //Show shipping window date only for order which using amazon logistic
             if (in_array($o['jng_sp_id'], array_keys(getSalesPartnerUseAmazonLogistic())) && isset($i['shipping_window_open'])) {
                 $orderilbl[] = 'Shipping Window Date';
                 $orderinfo[] = ': ' . date('d. M Y', strtotime($i['shipping_window_open']));
             }
             /* Moved to below barcode
                $orderilbl[] = 'Process Date';
                $orderinfo[] = ': '.date('d. M Y', strtotime($i['prod_target_in']));
                 */
             $orderilbl[] = 'Customer Name';
             $vip_status = $o['customer_is_vip'] ? ' ( VIP )' : '';
             if ($is_ottob2b) {
                 $orderinfo[] = ': OTTO B2B';
             } else {
                 $orderinfo[] = ': ' . $o['customer'] . $vip_status;
             }
             //$orderilbl[] = 'Order Source / Customer Name';
             //$orderinfo[] = ': '.$o['customer_type'].' / '.$o['customer'];
             //$orderilbl[] = 'Product Qty x EAN (ID / Code)';
             //$orderinfo[] = ': '.intval($i['quantity']).' x '.$ean.' ('.$p['p']['products_id'].' / '.$p['p']['products_model'].')';
             $orderilbl[] = 'Product Qty x EAN';
             $orderinfo[] = ': ' . $product_qty . ' x ' . $ean;
             $pdf->setFont('Arial', '', $fontsize_med);
             $pdf->setXY($margin_orderinfo, $YPOS);
             $pdf->MultiCell(50, $lineheight, implode("\n", $orderilbl));
             $pdf->setXY($margin_orderinfo + 30, $YPOS);
             $pdf->MultiCell(100, $lineheight, implode("\n", $orderinfo));
             $maxline = count($orderilbl);
             $YPOS += $maxline * $lineheight + 10;
             //STOCK PREPARATION
             $pdf->setFont('Arial', 'B', $fontsize_big);
             if ($i['stock_status'] == 'D' && !$ignoreStockStatusDepot) {
                 //USE DEPOT STOCK
                 $lineheight = 6;
                 $pdf->SetXY($margin + 1, $YPOS);
                 $pdf->Cell(100, $lineheight, 'Depot Stock', 1, 0, 'C', true);
                 $YPOS += $lineheight + 3;
             } elseif ($i['stock_status'] == 'P') {
                 //USE FINISH GOOD STOCK
                 $lineheight = 6;
                 $pdf->SetXY($margin + 1, $YPOS);
                 $pdf->Cell(100, $lineheight, 'Finish Good', 1, 0, 'C', true);
                 $YPOS += $lineheight + 3;
             } else {
                 //USE ELEMENTS STOCK
                 $lineheight = 4;
                 $pdf->SetXY($margin, $YPOS);
                 $pdf->Cell(100, $lineheight, 'Elements Preparation');
                 $YPOS += $lineheight + 1;
                 $pue_total = count($p['elements']);
                 $pue_rows = ceil($pue_total / 2);
                 $max_rows_el_per_page_1 = 12;
                 //MAX ROWS ELEMENT ON PAGE 1
                 $max_rows_el_per_page_n = 14;
                 //MAX ROWS ELEMENT ON NEXT PAGE
                 $max_rows_el_per_page = $max_rows_el_per_page_1;
                 $pue_counter = 0;
                 $pue_number = 0;
                 $rowpos = $YPOS;
                 $colpos = $margin + 1;
                 $colheight = 20;
                 $col_subcol_width = array();
                 $col_subcol_width[1] = 6;
                 //          $col_subcol_width[2] = $colheight;
                 $col_subcol_width[2] = 20;
                 $col_subcol_width[3] = 10;
                 $col_subcol_width[4] = 51;
                 $col_subcol_width[5] = 10;
                 $col_subcol_imgepos = $col_subcol_width[1];
                 $col_subcol_infopos = $col_subcol_width[1] + $col_subcol_width[2] + $col_subcol_width[3];
                 $colwidth = array_sum($col_subcol_width);
                 $print_header_el = false;
                 foreach ($p['elements'] as $element) {
                     if ($pue_counter == 0 || $print_header_el) {
                         $lineheight = 5;
                         $pdf->setXY($colpos, $rowpos);
                         $pdf->setFont('Arial', 'B', $fontsize_med);
                         $pdf->Cell($col_subcol_width[1], $lineheight, 'No', 1, 0, 'C', true);
                         $pdf->Cell($col_subcol_width[2], $lineheight, 'Image', 1, 0, 'C', true);
                         $pdf->Cell($col_subcol_width[3], $lineheight, 'ID', 1, 0, 'C', true);
                         $pdf->Cell($col_subcol_width[4], $lineheight, 'Info', 1, 0, 'C', true);
                         $pdf->Cell($col_subcol_width[5], $lineheight, 'Qty', 1, 0, 'C', true);
                         $rowpos += $lineheight;
                     }
                     $pue_counter++;
                     $pue_number++;
                     $e = $this->elements[$element['elements_id']];
                     $element_image = $this->getImageForPDF($e->image, '80', '80');
                     $element_info = array();
                     $element_info['n'] = substr($e->detail['name'], 0, $element_name_max_chars) . (strlen($e->detail['name']) > $element_name_max_chars ? '...' : '');
                     //var_dump($e->attributes); exit;
                     $element_info['c'] = $e->attributes['color']['name'];
                     //$element_info['s'] = $e->attributes['size']['name'];
                     $material_name = array();
                     $material_name = explode(',', $e->attributes['material']['name']);
                     $element_info['m'] = count($material_name) > 1 ? $material_name[1] : $material_name[0];
                     $element_info['sh'] = '';
                     if (!eregi('other', $e->attributes['size']['name'])) {
                         $element_info['sh'] = $e->attributes['size']['name'];
                     }
                     if (!eregi('other', $e->attributes['shape']['name'])) {
                         if ($element_info['sh'] != '') {
                             $element_info['sh'] .= '.';
                         }
                         $element_info['sh'] .= $e->attributes['shape']['name'];
                     }
                     //$element_info['h'] = $e->attributes['shape']['name'];
                     if ($this->products[$product_key]['elements'][$element['elements_id']]['finishing_hammer'] == '1') {
                         $element_info['f'][] = 'Hammered';
                     }
                     if ($this->products[$product_key]['elements'][$element['elements_id']]['finishing_brush'] == '1') {
                         $element_info['f'][] = 'Brushed';
                     }
                     if ($this->products[$product_key]['elements'][$element['elements_id']]['finishing_oxid'] == '1') {
                         $element_info['f'][] = 'Oxidized/No Antitarnish';
                     }
                     if ($this->products[$product_key]['elements'][$element['elements_id']]['finishing_goldplate'] == '1') {
                         $element_info['f'][] = 'Yellow Goldplated';
                     }
                     if ($this->products[$product_key]['elements'][$element['elements_id']]['finishing_rosegoldplate'] == '1') {
                         $element_info['f'][] = 'Rose Goldplate';
                     }
                     $element_info['f'] = count($element_info['f']) > 0 ? implode(',', $element_info['f']) : '';
                     if ($element_image != '') {
                         $pdf->Image($element_image, $colpos + $col_subcol_imgepos, $rowpos, $col_subcol_width[2]);
                     }
                     $pdf->setXY($colpos, $rowpos);
                     $pdf->setFont('Arial', '', $fontsize_med);
                     $pdf->Cell($col_subcol_width[1], $colheight, $pue_number, 1, 0, 'C', true);
                     $pdf->Cell($col_subcol_width[2], $colheight, '', 1, 0, 'C');
                     $pdf->Cell($col_subcol_width[3], $colheight, $element['elements_id'], 1, 0, 'C');
                     $pdf->Cell($col_subcol_width[4], $colheight, '', 1, 0, 'C');
                     $pdf->Cell($col_subcol_width[5], 10, $product_qty * $element['quantity'], 1, 0, 'C');
                     $pdf->setXY($colpos + $col_subcol_width[1] + $col_subcol_width[2] + $col_subcol_width[3] + $col_subcol_width[4], $rowpos + 10);
                     $pdf->SetTextColor(209, 209, 209);
                     $pdf->setFont('Arial', 'B', $fontsize_big + 2);
                     $pdf->Cell($col_subcol_width[5], 10, 'QC', 1, 0, 'C');
                     $pdf->SetTextColor(0, 0, 0);
                     $pdf->setFont('Arial', '', $fontsize_med);
                     //$pdf->setXY($colpos + $col_subcol_infopos, $rowpos);
                     //$pdf->MultiCell($col_subcol_width[4], 4, implode("\n", $element_info), 0, 'C');
                     $rowpos_incol = $rowpos + 1;
                     //TODO: make column table could wrapped for text and have flexible height, for example please find this reference : http://www.fpdf.de/downloads/addons/3/
                     $ei_labels = array('s' => 'Size: ', 'm' => 'Material: ', 'h' => 'Shape: ');
                     foreach ($element_info as $key => $ei) {
                         if ($ei != '') {
                             if ($key == 'c') {
                                 $pdf->setFont('Arial', 'B', $fontsize_big + 2);
                                 $lineheight = 4;
                             } elseif ($key == 'f') {
                                 $pdf->setFont('Arial', 'B', $fontsize_big);
                                 $lineheight = 4;
                             } else {
                                 $pdf->setFont('Arial', '', $fontsize_med);
                                 $lineheight = 3.5;
                             }
                             if (array_key_exists($key, $ei_labels)) {
                                 $ei = $ei_labels[$key] . $ei;
                             }
                             $pdf->setXY($colpos + $col_subcol_infopos, $rowpos_incol);
                             $pdf->Cell($col_subcol_width[4], $lineheight, $ei, 0, 0, 'C');
                             $rowpos_incol += $lineheight;
                         }
                     }
                     if ($pue_rows > $max_rows_el_per_page) {
                         //IF ELEMENT USED MORE THAN MAX ROWS ELEMENT COULD FIT PER PAGE
                         $n_rows = $max_rows_el_per_page;
                     } else {
                         $n_rows = $pue_rows;
                     }
                     if ($pue_counter == $n_rows) {
                         $colpos = $margin + $colwidth + 5;
                         $rowpos = $YPOS;
                         $print_header_el = true;
                     } else {
                         $print_header_el = false;
                         $rowpos += $colheight;
                         if ($pue_counter % $max_rows_el_per_page == 0 && $pue_counter / $max_rows_el_per_page > 1) {
                             //IF ELEMENT USED REACH THE END OF PAGE AND THERE STILL ELEMENT NEED TO BE PRINTED
                             $pdf->AddPage();
                             if ($pdf->PageNo() > 1) {
                                 $max_rows_el_per_page = $max_rows_el_per_page_n;
                             }
                             //SET MARGIN TO THE VERY TOP OF PAGE
                             $colpos = $margin + 1;
                             $rowpos = $margin;
                             $YPOS = $rowpos;
                             $pue_rows = ceil(($pue_total - $pue_number) / 2);
                             //RECALCULATE THE REST OF ELEMENTS THAT COULD DIVIDED INTO 2 COLUMNS
                             $pue_counter = 0;
                         }
                     }
                 }
                 $YPOS += 5 + 3 + $pue_rows * $colheight;
             }
             //PRODUCT INFORMATION
             if ($pue_rows > 9) {
                 $pdf->AddPage();
                 $item_page_count++;
                 $YPOS = $margin;
             }
             $lineheight = 4;
             $imgbig_width = 60;
             $imgsml_width = 25;
             $rowpos = $YPOS;
             $colpos = $margin + 1;
             $pdf->SetXY($margin, $YPOS);
             $pdf->setFont('Arial', 'B', $fontsize_big);
             $pdf->Cell(100, $lineheight, 'Product Information');
             $YPOS += $lineheight + 1;
             $rowpos = $YPOS;
             $imgbig = $this->getImageForPDF($p['p']['products_image'], '', '212');
             //if($imgbig!='') $pdf->Image($imgbig, $colpos, $rowpos, $imgbig_width);
             if ($imgbig != '') {
                 $colposmainimage = $colpos;
                 $image_metadata = getimagesize($imgbig);
                 //MAKE IMAGE CENTERED WHEN SIZE IS PORTRAIT
                 if ($image_metadata[0] == 147) {
                     $colposmainimage = $colpos + 9;
                 }
                 $pdf->Image($imgbig, $colposmainimage, $rowpos, 0, $imgbig_width);
             }
             $pdf->Rect($colpos, $rowpos, $imgbig_width, $imgbig_width);
             $rowpos_main_image = $YPOS + $imgbig_width + 2;
             $rowpos = $YPOS;
             $img_h_resized = 0;
             //SHOW LOGO DIAMORE AND ELLI PREMIUM FOR NON OTTO B2B ORDERS
             if ($i['products_id'] > 0 && ($is_diamore || $is_elli_premium)) {
                 $pb = $class_pb->retrieveDetail($p['p']['products_brand_id']);
                 $img_path = DIR_WS_IMAGES . $pb['brand_image'];
                 $imgsize = getimagesize($img_path);
                 $img_w = $imgsize[0];
                 $img_h = $imgsize[1];
                 $h_ratio = $img_h / $img_w;
                 $img_w_resized = 50;
                 $img_h_resized = $img_w_resized * $h_ratio;
                 $pdf->Image($img_path, 150, $YPOS, $img_w_resized, $img_h_resized);
             }
             /*USE IMAGE DIAMOND
               if($class_pm->productContainMaterials($i['products_id'], 52)) {
                   $img_path = FPDF_IMGPATH.'diamond.jpg';
                   $imgsize = getimagesize($img_path);
                   $img_w = $imgsize[0];
                   $img_h = $imgsize[1];
                   $h_ratio = $img_h/$img_w;
                   $img_w_resized = 40;
                   $img_h_resized = $img_w_resized * $h_ratio;
                   $pdf->Image($img_path,165,$YPOS,$img_w_resized,$img_h_resized);
               }
                */
             if ($is_gold_product) {
                 $lineheight = 6;
                 $leftpos = 150;
                 $rowpos = $YPOS + $img_h_resized + 2;
                 $pdf->SetFontSize($fontsize_big + 5);
                 $pdf->SetXY($leftpos, $rowpos);
                 $pdf->Cell(50, $lineheight, 'G O L D', 0, 2, 'C');
             }
             //SPECIAL TREATMENT
             $product_finishing_array_st = ProductAttribute::getOldStylesFunction()->retrieveList(ProductAttribute::GROUP_ID_PRODUCT_FINISHING);
             $finishing_product_st = ProductAttribute::displayAttributeName($i['products_id'], ProductAttribute::GROUP_ID_PRODUCT_FINISHING, '2');
             //echo "<pre>";var_dump($finishing_product_st);die();
             if (empty($finishing_product_st)) {
                 unset($finishing_product_st);
             }
             if ($finishing_product_st == NULL) {
                 $isset_product_finishing = false;
             } else {
                 $isset_product_finishing = true;
             }
             if (!$is_diamore && !$is_elli_premium) {
                 if ($isset_product_finishing) {
                     $rowpos = $YPOS + $img_h_resized;
                     $lineheight = 6;
                     $leftpos = 150;
                     //special treament
                     $pdf->SetFontSize($fontsize_big + 3);
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->Cell(50, $lineheight, 'SPECIAL TREATMENT', 0, 2, 'C');
                     if ($i['products_id'] > 0 && ($is_gold_product || $is_pearl)) {
                         if ($is_gold_product) {
                             //gold
                             $rowpos = $rowpos + 7;
                             $pdf->SetFontSize($fontsize_big + 1);
                             $pdf->SetXY($leftpos, $rowpos);
                             $pdf->Cell(50, $lineheight, 'G O L D', 0, 2, 'C');
                         }
                         /*
                                                     if ($is_elli_premium) {
                            $products_used_materials = $class_pm->retrieveProductMaterialsUsed($i['products_id']);
                            if (in_array(52, $products_used_materials)) {
                                $rowpos = $rowpos + 5;
                                $pdf->SetFontSize($fontsize_big+1);
                                $pdf->SetXY($leftpos, $rowpos);
                                $pdf->Cell(50, $lineheight, 'D I A M O N D', 0, 2, 'C');
                            }
                            if (in_array(5, $products_used_materials)) {
                                $rowpos = $rowpos + 5;
                                $pdf->SetFontSize($fontsize_big+1);
                                $pdf->SetXY($leftpos, $rowpos);
                                $pdf->Cell(50, $lineheight, 'P E A R L', 0, 2, 'C');
                            }
                                                     }
                                                     if ($is_diamore) {
                            //diamore
                            $rowpos = $rowpos + 5;
                            $pdf->SetFontSize($fontsize_big+1);
                            $pdf->SetXY($leftpos, $rowpos);
                            $pdf->Cell(50, $lineheight, 'D I A M O N D', 0, 2, 'C');
                                                     }
                         * 
                         */
                         if ($is_pearl) {
                             //pearl
                             $rowpos = $rowpos + 5;
                             $pdf->SetFontSize($fontsize_big + 1);
                             $pdf->SetXY($leftpos, $rowpos);
                             $pdf->Cell(50, $lineheight, 'P E A R L', 0, 2, 'C');
                         }
                     }
                     //$pdf->Rect(150, 120, $img_w_resized, 30);
                 }
             }
             $leftpos = $colpos + $imgbig_width + 2;
             $rowpos = $YPOS;
             $lineheight = 4;
             $linesep = 1;
             $pilbl = array();
             $pinfo = array();
             $pilbl[] = 'Product Category';
             $pinfo[] = ': ' . $product_categories_name[$p['categories_id']];
             $pilbl[] = 'Product ID';
             $pinfo[] = ': ' . $i['products_id'];
             $pilbl[] = 'Product Code';
             $pinfo[] = ': ' . $p['p']['products_model'];
             /* HIDE PRICE (REQUESTED BY CANTY & WAYAN TO PREVENT SMITH SPOTTED THE PRICE)
                $pilbl[] = 'Product Price';
                $pinfo[] = ': '.displayCurrency('EUR', $p['p']['products_price']);
                 */
             if ($p['length'] > 0) {
                 $pilbl[] = 'Product Length';
                 $pinfo[] = ': ' . textLength($p['length']);
             }
             $pilbl[] = 'Product Quantity';
             $pinfo[] = ': ' . $product_qty;
             $lbl_width = 30;
             $pdf->SetXY($leftpos, $rowpos);
             $pdf->setFont('Arial', 'B', $fontsize_big);
             $pdf->MultiCell($lbl_width, $lineheight + $linesep, implode("\n", $pilbl), 0, 'L');
             $pdf->SetXY($leftpos + $lbl_width, $rowpos);
             $pdf->MultiCell($lbl_width, $lineheight + $linesep, implode("\n", $pinfo), 0, 'L');
             $rowpos += count($pilbl) * ($lineheight + $linesep) + 2 * $linesep;
             //                $pdf->SetXY($leftpos, $rowpos);
             //                $pdf->setFont('Arial','B',$fontsize_med);
             //                $prodinfo = 'Product ID: '.$p['p']['products_id'];
             //                $pdf->Cell(100, $lineheight, $prodinfo);
             //                $rowpos += $lineheight + $linesep;
             //                $pdf->SetXY($leftpos, $rowpos);
             //                $pdf->setFont('Arial','B',$fontsize_med);
             //                $prodinfo = 'Product Code: '.$p['p']['products_model'];
             //                $pdf->Cell(100, $lineheight, $prodinfo);
             //                $rowpos += $lineheight + $linesep;
             //                if($p['length']>0) {
             //                    $pdf->SetXY($leftpos, $rowpos);
             //                    $pdf->setFont('Arial','B',$fontsize_med);
             //                    $prodinfo = 'Product Length: '.textLength($p['length']);
             //                    $pdf->Cell(100, $lineheight, $prodinfo);
             //                    $rowpos += $lineheight + $linesep;
             //                }
             $pdf->SetXY($leftpos, $rowpos);
             $pdf->setFont('Arial', 'B', $fontsize_big);
             $pdf->Cell(100, $lineheight, 'Product Name:');
             $rowpos += $lineheight;
             $pdf->SetXY($leftpos, $rowpos);
             $pdf->setFont('Arial', '', $fontsize_big);
             $pdf->Cell(100, $lineheight, $p['pd'][2]['products_name']);
             $rowpos += $lineheight + 2 * $linesep;
             if ($p['pnc']['production_instruction_id'] != '') {
                 $rowpos += $lineheight;
                 $piids = explode(",", $p['pnc']['production_instruction_id']);
                 $pdf->SetXY($leftpos, $rowpos);
                 $pdf->setFont('Arial', 'B', $fontsize_big);
                 $pdf->Cell(100, $lineheight, 'Production Instruction:');
                 $pdf->setFont('Arial', '');
                 $pims = array();
                 //MERGE ALL MANUAL PI THAT ATTACHED TO PRODUCT
                 foreach ($piids as $piid) {
                     $pim = new production_instruction_manual($piid);
                     $pi_temp = "\n" . $pim->cat_name . ' - ' . $pim->name;
                     if (trim($pim->description) != '') {
                         $pi_temp .= "\n" . $pim->description;
                     }
                     $pims[] = $pi_temp;
                 }
                 //EXPLODE EACH MANUAL PI WITH LINE FEED
                 $pi_manual = implode("\n", $pims);
                 $rowpos += $lineheight;
                 $pdf->SetXY($leftpos, $rowpos);
                 $pdf->MultiCell(0, $lineheight, trim($pi_manual), 0, 'L');
                 $manpi_rows = explode("\n", trim($pi_manual));
                 //            $rowpos += $lineheight * 3;
             } else {
                 if ($p['pnc']['products_instruction'] != '') {
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', 'B', $fontsize_big);
                     $pdf->Cell(100, $lineheight, 'Production Instruction:');
                     $pdf->setFont('Arial', '');
                     $rowpos += $lineheight;
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->MultiCell(0, $lineheight, $p['pnc']['products_instruction'], 0, 'L');
                     $manpi_rows = explode("\n", $p['pnc']['products_instruction']);
                     //$rowpos += ceil(($lineheight-1)*count($manpi_rows));
                 }
             }
             $rowpos_manpi = $pdf->GetY();
             $rowpos = $rowpos_manpi + 5;
             $leftpos = $colpos + $imgbig_width + 2;
             $rowpos_addimage = 0;
             $nei = 0;
             if (strtoupper($o['type']) == 'JG' && $i['custom_img'] != '') {
                 //$imgcus_width = 37; //150px
                 $imgcus_width = $imgsml_width;
                 //100px
                 $imgcus = $this->getImageForPDF($i['custom_img'], '100', '100');
                 if ($imgcus != '') {
                     $pdf->Image($imgcus, $leftpos, $rowpos, $imgcus_width);
                     $pdf->Rect($leftpos, $rowpos, $imgcus_width, $imgcus_width);
                 }
                 $leftpos += $imgcus_width + 2;
                 //                } elseif((count($p['pei'])>0 && ($p['categories_id']==2||$p['categories_id']==3||$p['categories_id']==30)) || (count($p['pei'])>1 && $p['categories_id']==9)) {
                 //Show Extra Images only for NL,BL,SETS OR CH that have 2 extra images (only show 1st extra_images)
             } elseif (count($p['pei']) > 0) {
                 //                    show extra images for all categories since tends now extra images is used for explain detailly of a product
                 $rowpos = $YPOS + $imgbig_width + 2;
                 $pdf->SetXY($margin, $rowpos);
                 $pdf->setFont('Arial', 'B', $fontsize_big);
                 $pdf->Cell(100, $lineheight, 'Additional Images');
                 $rowpos += $lineheight + 1;
                 foreach ($p['pei'] as $pei) {
                     $nei++;
                     //                        if($p['categories_id']==9 && $nei>1) continue;    //display only 1st extra image for CH
                     $reset_leftpos = true;
                     if ($is_diamore) {
                         //IF DIAMORE PRODUCTS
                         $print_image = false;
                         if (($p['categories_id'] == 2 || $p['categories_id'] == 30) && in_array($nei, array(1, 3))) {
                             $print_image = true;
                         }
                         if ($p['categories_id'] == 4 && in_array($nei, array(2, 3))) {
                             $print_image = true;
                         }
                         if (($p['categories_id'] == 29 || $p['categories_id'] == 3) && in_array($nei, array(1, 2))) {
                             $print_image = true;
                         }
                         if (($p['categories_id'] == 9 || $p['categories_id'] == 28) && in_array($nei, array(1))) {
                             $print_image = true;
                         }
                         if ($print_image) {
                             $leftpos = $colpos;
                             if ($rowpos > 214) {
                                 $pdf->show_footer_page_info = true;
                                 $pdf->AddPage();
                                 $YPOS = $margin + 5;
                                 $rowpos = $YPOS;
                                 $rowpos_manpi = $YPOS;
                             }
                             $imgsml = $this->getImageForPDF($pei, '212', '212');
                             if ($imgsml != '') {
                                 $pdf->Image($imgsml, $leftpos, $rowpos, $imgbig_width);
                                 $pdf->Rect($leftpos, $rowpos, $imgbig_width, $imgbig_width);
                                 $rowpos += $imgbig_width + 2;
                             }
                         }
                     } else {
                         //IF NOT DIAMORE PRODUCTS
                         $check_nei = $nei % 2;
                         if ($check_nei == 1) {
                             if ($nei != 1) {
                                 $reset_leftpos = false;
                                 //print additional image using 2 columns when manual pi is exceeded bottom of main image
                                 if ($nei > 2 && $rowpos_manpi > $rowpos_main_image) {
                                     $rowpos += $imgsml_width + 2;
                                     $reset_leftpos = true;
                                 }
                             }
                         } else {
                             $reset_leftpos = false;
                         }
                         if ($reset_leftpos) {
                             $leftpos = $colpos;
                         } else {
                             $leftpos += $imgsml_width + 2;
                         }
                         $imgsml = $this->getImageForPDF($pei, '100', '100');
                         if ($imgsml != '') {
                             $pdf->Image($imgsml, $leftpos, $rowpos, $imgsml_width);
                             $pdf->Rect($leftpos, $rowpos, $imgsml_width, $imgsml_width);
                             //$rowpos += $imgsml_width + 2;
                         }
                     }
                 }
                 if ($is_diamore) {
                     //IF DIAMORE PRODUCTS
                     $rowpos_addimage = $rowpos + 2;
                 } else {
                     $rowpos_addimage = $rowpos + $imgsml_width + 2;
                     $leftpos += $imgsml_width + 2;
                 }
             }
             //CUSTOMIZE PRODUCTS & PRINTED GIFT VOUCHER FROM JULIE & GRACE
             if (strtoupper($o['type']) == 'JG') {
                 if (strpos($p['p']['products_model'], 'GIFT-P') !== false) {
                     $gift_amount = substr($p['p']['products_model'], 7);
                     $cgq_query = "SELECT c.coupon_code, c.coupon_amount, c.coupon_expire_date FROM coupon_gv_queue cgq";
                     $cgq_query .= " LEFT JOIN coupons c ON c.coupon_id=cgq.coupon_id";
                     $cgq_query .= " WHERE cgq.order_id={$o['id']} AND cgq.amount={$gift_amount}";
                     $cgq_result = tep_db_query($cgq_query);
                     $vouchers = array();
                     while ($row = tep_db_fetch_array($cgq_result)) {
                         $vouchers[] = $row;
                     }
                     $vcounter = 0;
                     foreach ($vouchers as $v) {
                         $vcounter++;
                         $pdf->SetXY($leftpos, $rowpos);
                         $pdf->setFont('Arial', 'B', $fontsize_med);
                         $pdf->Cell(100, $lineheight, 'Voucher ' . $vcounter . ':');
                         $rowpos += $lineheight;
                         $vilbl = array();
                         $vinfo = array();
                         $vilbl[] = '- Code';
                         $vinfo[] = ': ' . $v['coupon_code'];
                         $vilbl[] = '- Amount';
                         $vinfo[] = ': ' . number_format($v['coupon_amount'], 0) . ' EUR';
                         $vilbl[] = '- Expired Date';
                         $vinfo[] = ': ' . date('d. M Y', strtotime($v['coupon_expire_date']));
                         $pdf->setFont('Arial', '', $fontsize_med);
                         $pdf->SetXY($leftpos, $rowpos);
                         $pdf->MultiCell($lbl_width, $lineheight, implode("\n", $vilbl));
                         $pdf->SetXY($leftpos + $lbl_width, $rowpos);
                         $pdf->MultiCell(100, $lineheight, implode("\n", $vinfo));
                         $rowpos += count($vilbl) * $lineheight + 2 * $linesep;
                     }
                 }
                 if ($i['custom_text'] != '') {
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', 'B', $fontsize_big);
                     $pdf->Cell(100, $lineheight, 'Custom Text:');
                     $rowpos += $lineheight;
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', '', 12);
                     $pdf->MultiCell(0, 4, $i['custom_text']);
                     $rowpos += 2 * $lineheight + 2 * $linesep;
                 }
                 if ($i['custom_img'] != '') {
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', 'B', $fontsize_big);
                     $pdf->Cell(100, $lineheight, 'Custom Image:');
                     $rowpos += $lineheight;
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', '', $fontsize_big);
                     $pdf->Cell(0, $lineheight, basename($i['custom_img']));
                     $rowpos += $lineheight + 2 * $linesep;
                 }
                 if ($i['custom_imgcm'] != '') {
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', 'B', $fontsize_big);
                     $pdf->Cell(100, $lineheight, 'Custom Image Comment:');
                     $rowpos += $lineheight;
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', '', $fontsize_big);
                     $pdf->MultiCell(0, $lineheight, basename($i['custom_imgcm']), 0, 'L');
                 }
             } else {
                 if ($p['article']['text'] != '') {
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', 'B', $fontsize_big);
                     $pdf->Cell(100, $lineheight, 'Custom Text:');
                     $rowpos += $lineheight;
                     $pdf->SetXY($leftpos, $rowpos);
                     $pdf->setFont('Arial', '', 12);
                     $pdf->MultiCell(0, 4, $p['article']['text']);
                     $rowpos += 2 * $lineheight + 2 * $linesep;
                 }
             }
             //$YPOS += (($rowpos>($YPOS+$imgbig_width)) ? $rowpos : $imgbig_width) + 10;    //CHANGE THIS TO BELOW
             //if($rowpos>($YPOS+$imgbig_width)) $YPOS = $rowpos + 5;
             //else $YPOS += $imgbig_width + 10;
             if (in_array($p['p']['products_brand_id'], $DIAMOND_BRAND_IDS)) {
                 if ($rowpos_manpi > $rowpos_addimage) {
                     $YPOS = $rowpos_manpi + 5;
                 } elseif ($rowpos_addimage > $rowpos_manpi) {
                     $YPOS = $rowpos_addimage + 15;
                 }
                 //if manual pi printed smaller than displayed additional images
                 if ($rowpos_main_image > $rowpos_manpi && $nei == 0) {
                     $YPOS = $rowpos_main_image + 5;
                 }
                 //if manual pi printed smaller than displayed main images and theres no additional images printed
                 if ($rowpos_manpi == $rowpos_addimage) {
                     $YPOS = $rowpos_manpi;
                 }
                 //if manual pi printed and additional images were the same row height
             } else {
                 if ($rowpos_manpi > $rowpos_addimage) {
                     $YPOS = $rowpos_manpi + 5;
                 } elseif ($rowpos_addimage > $rowpos_manpi) {
                     $YPOS = $rowpos_addimage + 5;
                 }
                 //if manual pi printed smaller than displayed additional images
                 if ($rowpos_main_image > $rowpos_manpi && $nei == 0) {
                     $YPOS = $rowpos_main_image + 5;
                 }
                 //if manual pi printed smaller than displayed main images and theres no additional images printed
                 if ($rowpos_manpi == $rowpos_addimage) {
                     $YPOS = $rowpos_manpi;
                 }
                 //if manual pi printed and additional images were the same row height
             }
             //PRODUCTION
             if ($YPOS > 240) {
                 $pdf->show_footer_page_info = true;
                 $pdf->AddPage();
                 $YPOS = $margin + 5;
             }
             $lineheight = 5;
             $pdf->SetXY($margin, $YPOS);
             $pdf->setFont('Arial', 'B', $fontsize_big);
             $pdf->Cell(100, $lineheight, 'Production');
             $YPOS += $lineheight + 1;
             //IF NEED NEW QC COLUMN, ONLY NEED TO ADD BELOW ARRAY
             $col = array();
             $col[1] = 'Workshop';
             $col[2] = 'Beading';
             $col[3] = 'Enamel';
             $col[4] = 'Ferido';
             $col[5] = 'Packing';
             $leftpos = $margin + 1;
             $pdf->setXY($leftpos, $YPOS);
             $qc_table_max_width = 198;
             $colwidth = number_format($qc_table_max_width / count($col), 1);
             //$colwidth = 39.6;
             foreach ($col as $cval) {
                 $pdf->Cell($colwidth, $lineheight, $cval, 1, 0, 'C', true);
             }
             $YPOS += $lineheight;
             $leftpos = $margin + 1;
             $pdf->setFont('Arial', 'B', $fontsize_big + 5);
             $pdf->SetTextColor(209, 209, 209);
             $pdf->setXY($leftpos, $YPOS);
             for ($x = 1; $x <= count($col); $x++) {
                 $pdf->Cell($colwidth, 15, 'QC', 1, 0, 'C');
             }
             //PRODUCT FINISHING
             //echo "<pre>";var_dump($finishing);die();
             $finishing = array();
             /* UPDATE: NOW WE USE PRODUCTS FINISHING IN PRODUCT ATTRIBUTES TO 
                   FLAG WHETHER THE PRODUCTS NEEDS RHODIUM OR MICRON
                */
             /* RHODIUM RULES
                   Rule1: OttoB2B, Elli Premium which Silver "without plated" and whitegold product
                   Rule2: Diamore
                */
             /*
                             $rhodium_rule1 = ( ($is_ottob2b || $is_elli_premium) 
                    && ($obj_product->metal_stamp_code == Product::METAL_STAMP_CODE_925 
                        || $obj_product->metal_stamp_info == Product::METAL_STAMP_INFO_WHITEGOLD) );
                             $rhodium_rule2 = $is_diamore;
             */
             //$rhodium_and_micron_rule = in_array_r($finishing_product, $product_finishing_array);
             //if ($rhodium_rule1 || $rhodium_rule2) {
             //if ($rhodium_and_micron_rule) {
             //$finishing[] = 'Rhodium';
             //}
             $is_partial_plated = $p['p']['is_partial_plated'] == '1';
             $is_goldplated = false;
             foreach ($p['finishing'] as $ftext => $fval) {
                 if ($fval) {
                     $is_goldplated = $fval == 'Goldplated' || $fval == 'Rose Goldplate';
                     if ($is_partial_plated) {
                         if ($fval == 'Goldplated' || $fval == 'Rose Goldplate') {
                             continue;
                         }
                     }
                     //OttoB2B and Elli Premium goldplated products need to be added with 1.5 micron
                     /*
                     if (($is_ottob2b || $is_elli_premium) 
                             && ($fval == 'Goldplated' || $fval == 'Rose Goldplate')) {
                         $ftext .= ' 1.5 micron';
                     }
                     */
                     $finishing[] = $ftext;
                 }
             }
             if ($is_partial_plated) {
                 //OttoB2B and Elli Premium goldplated products need to be added with 1.5 micron
                 //if (($is_ottob2b || $is_elli_premium)
                 //$finishing_micron_key = array_search('micron', $finishing);
                 //if ($finishing_micron_key !== false
                 //&& ($fval == 'Goldplated' || $fval == 'Rose Goldplate')) {
                 //$finishing[] = 'Partial Plated 1.5 micron';
                 //} else {
                 $finishing[] = 'Partial Plated';
                 //}
             }
             $product_finishing_array = ProductAttribute::getOldStylesFunction()->retrieveList(ProductAttribute::GROUP_ID_PRODUCT_FINISHING);
             $finishing_product = ProductAttribute::displayAttributeName($i['products_id'], ProductAttribute::GROUP_ID_PRODUCT_FINISHING, '2');
             if (!empty($finishing_product)) {
                 $finishing[] = $finishing_product;
             }
             /*
             if ($is_goldplated || $is_partial_plated) {
                 //If using plating, removed finishing Rhodium since it will antitarnished as standard for plated products
                 $finishing_rhodium_key = array_search('Rhodium', $finishing);
                 if ($finishing_rhodium_key !== false) {
                     unset($finishing[$finishing_rhodium_key]);
                 }
             }
             */
             //echo "<pre>";var_dump($finishing);die();
             if (count($finishing) > 0) {
                 if ($YPOS > 250) {
                     $pdf->show_footer_page_info = true;
                     $pdf->AddPage();
                     $YPOS = $margin + 5;
                 }
                 $finishing = implode(', ', $finishing);
                 $pdf->SetTextColor(0, 0, 0);
                 $YPOS += $lineheight + 15;
                 $lineheight = 4;
                 $pdf->SetXY($margin, $YPOS);
                 $pdf->setFont('Arial', 'B', $fontsize_big);
                 $pdf->Cell(100, $lineheight, 'Product Finishing');
                 $YPOS += $lineheight + 1;
                 $lineheight = 15;
                 $colwidth = array();
                 $colwidth[1] = 178;
                 $colwidth[2] = 20;
                 $leftpos = $margin + 1;
                 $pdf->setXY($leftpos, $YPOS);
                 $pdf->setFont('Arial', 'B', $fontsize_big + 5);
                 $pdf->Cell($colwidth[1], $lineheight, $finishing, 1, 2, 'C');
                 $leftpos += $colwidth[1];
                 $pdf->setXY($leftpos, $YPOS);
                 $pdf->SetTextColor(209, 209, 209);
                 $pdf->Cell($colwidth[2], $lineheight, 'QC', 1, 2, 'C');
             }
             $pdf->SetTextColor(0, 0, 0);
             //PRODUCT GOLD WEIGHT CHECK (PGWC)
             if ($is_gold_product) {
                 if ($YPOS > 220) {
                     $pdf->show_footer_page_info = true;
                     $pdf->AddPage();
                     $YPOS = $margin + 5;
                 }
                 $YPOS += $lineheight + 15;
                 $lineheight = 5;
                 $pdf->SetXY($margin, $YPOS);
                 $pdf->setFont('Arial', 'B', $fontsize_big);
                 $pdf->Cell(100, $lineheight, 'Product Gold Weight Check');
                 $YPOS += $lineheight + 1;
                 $gold_weight_check_process = array();
                 $gold_weight_check_process["Safe-WH"] = 'Safe to WH';
                 $gold_weight_check_process["WH-QC"] = 'WH to QC';
                 $gold_weight_check_process["QC-GS"] = 'QC to Goldsmith';
                 $gold_weight_check_process["GS-QC"] = 'Goldsmith to QC';
                 $leftpos = $margin + 1;
                 $pdf->SetXY($leftpos, $YPOS);
                 $gwc_table_max_width = $qc_table_max_width;
                 $n_col_weight_check = 8;
                 $colwidth = number_format($gwc_table_max_width / $n_col_weight_check, 1);
                 foreach ($gold_weight_check_process as $key => $val) {
                     if ($key == "QC-GS" || $key == "GS-QC") {
                         $pdf->Cell($colwidth * 3, $lineheight, $val, 1, 0, 'C', true);
                     } else {
                         $pdf->Cell($colwidth, $lineheight, $val, 1, 0, 'C', true);
                     }
                 }
                 //Draw PGWC Total Weight Box
                 $YPOS += $lineheight;
                 $leftpos = $margin + 1;
                 $pdf->setFont('Arial', 'B', $fontsize_sml);
                 $pdf->SetTextColor(209, 209, 209);
                 $pdf->SetXY($leftpos, $YPOS);
                 $gw_colheight_big = 10;
                 $gw_colheight_sml = number_format($gw_colheight_big / 2, 1);
                 for ($x = 1; $x <= $n_col_weight_check; $x++) {
                     if ($x == 1) {
                         $pdf->Cell($colwidth, $gw_colheight_sml, 'GW:', 1, 2, 'L');
                         $pdf->SetX($leftpos);
                         $pdf->Cell($colwidth, $gw_colheight_sml, 'NW:', 1, 0, 'L');
                     } else {
                         if ($x == 2) {
                             $pdf->SetXY($leftpos + $colwidth, $YPOS);
                         }
                         $box_start = $x == $n_col_weight_check ? 2 : 0;
                         $pdf->Cell($colwidth, $gw_colheight_sml, "Total Weight", 'LR', $box_start, 'C');
                     }
                 }
                 $pdf->SetX($leftpos + $colwidth);
                 for ($x = 2; $x <= $n_col_weight_check; $x++) {
                     $box_start = $x == $n_col_weight_check ? 2 : 0;
                     $pdf->Cell($colwidth, $gw_colheight_sml, '', 'LR', $box_start, 'C');
                 }
                 //Draw PGWC Total Signature Box
                 $colwidth_signature = number_format($colwidth / 2, 1);
                 $pdf->SetX($leftpos);
                 $pdf->SetFontSize($fontsize_med);
                 foreach ($gold_weight_check_process as $key => $val) {
                     if ($key == "QC-GS" || $key == "GS-QC") {
                         $loop = 3;
                     } else {
                         $loop = 1;
                     }
                     list($lsign, $rsign) = explode("-", $key);
                     for ($x = 1; $x <= $loop; $x++) {
                         $pdf->Cell($colwidth_signature, $gw_colheight_big, $lsign, 1, 0, 'C');
                         $pdf->Cell($colwidth_signature, $gw_colheight_big, $rsign, 1, 0, 'C');
                     }
                 }
                 $YPOS += $lineheight - 2 + $gw_colheight_big * 2;
                 $pdf->setFont('Arial', '', $fontsize_sml);
                 $pdf->Text($leftpos, $YPOS, 'GW: Total Weight of Gold Elements');
                 $YPOS += $lineheight - 2;
                 $pdf->Text($leftpos, $YPOS, 'NW: Total Weight of Non-Gold Elements');
                 //Draw PGWC Dust Box
                 if ($YPOS > 250) {
                     $pdf->show_footer_page_info = true;
                     $pdf->AddPage();
                     $YPOS = $margin + 5;
                 }
                 $YPOS += $lineheight;
                 $pdf->SetXY($leftpos, $YPOS);
                 $pdf->setFont('Arial', 'B', $fontsize_big);
                 $pdf->SetTextColor(0, 0, 0);
                 $pdf->Cell($colwidth, $lineheight, 'Dust', 1, 2, 'C', true);
                 $pdf->SetFontSize($fontsize_sml);
                 $pdf->SetTextColor(209, 209, 209);
                 $pdf->Cell($colwidth, $gw_colheight_sml, 'Total Weight', 'LR', 2, 'C');
                 $pdf->Cell($colwidth, $gw_colheight_sml, '', 'LR', 2, 'C');
                 $pdf->Cell($colwidth_signature, $gw_colheight_big, 'QC', 1, 0, 'C');
                 $pdf->Cell($colwidth_signature, $gw_colheight_big, 'GS', 1, 0, 'C');
             }
             $pdf->SetTextColor(0, 0, 0);
             //ENGRAVING ORDER SLIP
             global $ENGRAVED_PRODUCTS;
             if (strtoupper($o['type']) == 'JG' && in_array($i['products_id'], $ENGRAVED_PRODUCTS)) {
                 if ($this->duplex_printing && $item_page_count % 2 != 0) {
                     $pdf->AddPage();
                     $item_page_count++;
                 }
                 $pdf->AddPage();
                 $item_page_count++;
                 $lineheight = 4;
                 $midpage = 148.5;
                 $rowpos = $margin + 10;
                 //repeat 2 times
                 for ($s = 1; $s <= 2; $s++) {
                     if ($s == 2) {
                         $rowpos = $midpage + 10;
                         $slipinfo = 'Face2Face';
                     } else {
                         $slipinfo = 'Bonofactum';
                     }
                     $colpos = $margin + 1;
                     $pdf->OrderBarcode($o['type'], $oiid, $barcode_pos, $rowpos, $barcode_width);
                     $pdf->SetXY($margin, $rowpos);
                     $pdf->setFont('Arial', 'B', '12');
                     $pdf->Cell(100, $lineheight, 'Engraving Order Slip (' . $slipinfo . ')');
                     $rowpos += $lineheight + 5;
                     $rowpos_fixed = $rowpos;
                     if ($imgbig != '') {
                         $pdf->Image($imgbig, $colpos, $rowpos, $imgbig_width);
                     }
                     $pdf->Rect($colpos, $rowpos, $imgbig_width, $imgbig_width);
                     $colpos += $imgbig_width + 5;
                     $es_ilbl_width = 30;
                     $es_ilbl = array();
                     $es_info = array();
                     $es_ilbl[] = 'Order By';
                     $es_info[] = ': Bonofactum';
                     $es_ilbl[] = 'Order Date';
                     $es_info[] = ': ' . date('d. M Y');
                     $es_ilbl[] = 'Order Quantity';
                     $es_info[] = ': ' . $product_qty;
                     $pdf->setFont('Arial', 'B', $fontsize_med);
                     $pdf->SetXY($colpos, $rowpos);
                     $pdf->MultiCell($es_ilbl_width, $lineheight, implode("\n", $es_ilbl));
                     $pdf->SetXY($colpos + $es_ilbl_width, $rowpos);
                     $pdf->MultiCell($es_ilbl_width * 2, $lineheight, implode("\n", $es_info));
                     $rowpos += (count($es_ilbl) + 1) * $lineheight + 1;
                     $pdf->SetXY($colpos, $rowpos);
                     $pdf->Cell(100, $lineheight, 'Custom Text');
                     $rowpos += $lineheight + 1;
                     $pdf->SetDrawColor(128, 128, 128);
                     $pdf->Rect($colpos + 1, $rowpos, 132, 30);
                     $pdf->SetDrawColor(0, 0, 0);
                     if ($i['custom_text'] != '') {
                         $pdf->SetXY($colpos + 3, $rowpos + 3);
                         $pdf->setFont('Arial', 'B', '12');
                         $pdf->MultiCell(100, $lineheight, $i['custom_text']);
                     }
                     $rowpos = $rowpos_fixed + $imgbig_width + 5;
                     if ($i['custom_img'] != '') {
                         $leftpos = $margin + 1;
                         if ($imgcus != '') {
                             $pdf->Image($imgcus, $leftpos, $rowpos, $imgcus_width);
                             $pdf->Rect($leftpos, $rowpos, $imgcus_width, $imgcus_width);
                         }
                         $leftpos += $imgcus_width + 2;
                         $pdf->setXY($leftpos, $rowpos);
                         $pdf->setFont('Arial', 'B', $fontsize_med);
                         $pdf->Cell(100, $lineheight, 'Custom Image:');
                         $rowpos += $lineheight;
                         $pdf->setXY($leftpos, $rowpos);
                         $pdf->setFont('Arial', '', $fontsize_med);
                         $pdf->Cell(100, $lineheight, basename($i['custom_img']));
                         $rowpos += $lineheight + 1;
                         $pdf->setXY($leftpos, $rowpos);
                         $pdf->setFont('Arial', 'B', $fontsize_med);
                         $pdf->Cell(100, $lineheight, 'Graving Request:');
                         $rowpos += $lineheight;
                         $engraving_options_pos = $leftpos + $lineheight + 1;
                         $engraving_options = array();
                         $engraving_options[] = 'Full (gravir penuh)';
                         $engraving_options[] = 'Centered (gravir tengah, atas dan bawah kosong)';
                         $engraving_options[] = 'Bottom (gravir bawah penuh, atas kosong)';
                         $pdf->setXY($engraving_options_pos, $rowpos);
                         $pdf->setFont('Arial', '', $fontsize_med);
                         $pdf->MultiCell(100, $lineheight, implode("\n", $engraving_options));
                         $cb_sep = 0.5;
                         $cbsize = $lineheight - $cb_sep;
                         $leftpos += 1;
                         $pdf->SetDrawColor(128, 128, 128);
                         foreach ($engraving_options as $eo) {
                             $pdf->Rect($leftpos, $rowpos, $cbsize, $cbsize);
                             $rowpos += $lineheight;
                         }
                         $pdf->SetDrawColor(0, 0, 0);
                     }
                 }
                 $pdf->Line($margin, $midpage, 210 - $margin, $midpage);
             }
             if ($i['print_count'] == '0' || $i['print_count'] == '') {
                 $this->qty_total_first_printed++;
             }
         }
         //end looping items
     }
     //end looping orders
     if ($output == 'F') {
         $filename = $this->filename != '' ? $this->filename : DIR_FS_MINIERP . DIR_WS_GATEWAY . "ready_orders/" . strtoupper($o['type']) . '/' . strtoupper($o['type']) . '-' . $oiid;
         //            $priority_rule_1 = in_array($o['jng_sp_id'], $sp_using_red_paper);
         //            $priority_rule_2 = $o['customer_is_vip'];
         $priority_rule_1 = $o['priority'] == '1';
         //            if($priority_rule_1 || $priority_rule_2 || $priority_rule_3) $filename .= '-RED';
         if ($priority_rule_1 && $this->filename == '') {
             $filename .= '-RED';
         }
         $pdf->Output($filename . '.pdf', $output);
     }
 }
コード例 #3
0
 function getEANReturnResult($partner_type, $products_data, $sp_id = '0')
 {
     use_class('jng_sp');
     use_class('orders');
     use_class('jng_sp_orders');
     use_class('Product');
     use_class('products_ean');
     use_class('products_minierp');
     use_class('products_articles');
     use_class('products_brand');
     $class_sp = new jng_sp();
     $class_orders = new orders();
     $class_jo = new jng_sp_orders();
     $class_pean = new products_ean();
     $class_pm = new products_minierp();
     $class_pa = new products_articles();
     $class_pb = new products_brand();
     $result = "no data";
     $product_id = $products_data["products_id"];
     $product_article_id = $products_data["products_articles_id"];
     if ($product_article_id > 0) {
         $articles_data = $class_pa->retrieveDetail($product_article_id);
     }
     $p_ean = $class_pean->getEAN($product_id, $product_article_id);
     $p = $class_pm->retrieveDetail($product_id, 'p,pd,cat,pnc');
     //GETTING BRAND NAME
     $p_brand_id = $p['p']['products_brand_id'];
     $brand_data = $class_pb->retrieveDetail($p_brand_id);
     $brand_name = strtoupper(trim($brand_data['brand_name']));
     $p_brand = $brand_name == '' ? 'JULIE & GRACE' : $brand_name;
     $p_code = $p['p']['products_model'];
     $p_category = mb_strtoupper($class_pm->retrieveCategoryName($p['categories_id'], 2));
     //$p_shortname = "925 SILBER";  //it was $label_material
     //$p_shortname = ($sp_id=='5') ? strtoupper($p['pd']['2']['products_short_name']) : "925 SILBER";
     $sp_used_am_logistic = array_keys(getSalesPartnerUseAmazonLogistic());
     if (in_array($sp_id, $sp_used_am_logistic)) {
         $p_shortname = strtoupper($p['pd']['2']['products_short_name']);
     } else {
         $obj_product = new product($product_id);
         $metal_stamp_code = $obj_product->metal_stamp_code;
         $metal_stamp_info = $metal_stamp_code == 925 ? 'SILBER' : $obj_product->metal_stamp_info;
         $metal_stamp_info = $this->convertToGermanHex($metal_stamp_info);
         $p_shortname = strtoupper("{$metal_stamp_code} {$metal_stamp_info}");
     }
     $p_length = $product_article_id > 0 ? $articles_data['length'] : $p['pnc']['products_length'];
     $p_length = $p_length > 0 ? strtoupper(str_replace(' ', '', textLength($p_length))) : '';
     $p_targetaudience = strtoupper(LABEL_TARGET_AUDIENCE);
     //FOR TEMPORARY WE USING ONLY DAMEN
     if ($partner_type == 'sp') {
         $order_qty = intval($products_data["order_quantity"]);
         $p_price = $products_data['price'];
     } elseif ($partner_type == 'jg') {
         $order_qty = $products_data["products_quantity"];
         $p_price = $products_data['final_price'];
     } elseif ($partner_type == 'dp') {
         $order_qty = $products_data["quantity"];
         $p_price = '0';
     } else {
         $order_qty = '';
         $p_price = '';
     }
     if ($p_ean != '') {
         $return_label = $p_ean . ";" . $p_category . ";" . $p_shortname . ";" . $p_price . " EUR;{$order_qty};{$sp_id};{$p_code};{$p_brand};{$p_length};{$p_targetaudience};{$p_brand_id}";
         $result = $return_label;
     }
     return $result;
 }
コード例 #4
0
    if ($default_length != '-') {
        //        foreach($pa as $a) $products_options[] = $a['products_ean'].','.textLength($a['length']);
        foreach ($pa as $a) {
            $products_options[] = $a['products_articles_id'] . ';' . $a['products_ean'] . ',' . textLength($a['length']);
        }
    }
    $bestgood_status = $class_pm->retrieveBestGoodStatus($pid);
    $result['status'] = 'FOUND';
    $result['products_id'] = $pid;
    $result['products_code'] = $p['p']['products_model'];
    $result['products_image'] = $products_image;
    $result['products_option'] = $aid;
    $result['products_options'] = implode('|', $products_options);
    $result['bestgood_status'] = $bestgood_status;
    $result['scanned_ean'] = $ean;
    $result['orders_qty'] = $qty;
    $result['sp_id'] = $spid;
    $result['use_am_logistic'] = in_array($spid, array_keys(getSalesPartnerUseAmazonLogistic()));
    $result['ean_printed'] = $ean_printed;
    $result['multiple_scan_error_msg'] = '';
    if ($ean_printed != '' && !$counter_on) {
        $now = time();
        $last_ean_scanned = $ean_printed;
        $manobo_date_format = date('d-m-Y h:i:s', strtotime($ean_printed));
        $time_duration = abs($now - strtotime($last_ean_scanned));
        $time_duration = trim(displayDuration($time_duration, 1, 0));
        $result['multiple_scan_error_msg'] = "PI {$barcode_id} already scanned for EAN on {$manobo_date_format} ({$time_duration} ago)";
    }
    $result['barcode_id'] = $barcode_id;
}
$logger->close();
コード例 #5
0
 if ($sellingpointslaid != '') {
     if ($sellingpoints == '' && $languages_id == 3) {
         $sellingpoints = $sellingpointslaid;
     }
 }
 $promoname = tep_db_prepare_input($_POST['promoname']);
 $shortname = tep_db_prepare_input($_POST['shortname']);
 $topicname = tep_db_prepare_input($_POST['topicname']);
 $colname = tep_db_prepare_input($_POST['colname']);
 $keywords = $class_pm->keywordsParseRule($keywords);
 $class_pm->saveDescription($products_id, $languages_id, $name, $description, $keywords, $shortname, $sellingpoints, $promoname, $topicname, $colname, $sellingpointsamde);
 $q = tep_db_query("SELECT jc.jng_sp_id, jc.jng_sp_catalog_id, sp.languages_id FROM jng_sp_catalog jc LEFT JOIN jng_sp sp ON sp.jng_sp_id=jc.jng_sp_id WHERE jc.products_id={$products_id}");
 $sp_list = array();
 $sp_list_amazon = array();
 $sp_list_spid = array();
 $sp_used_selling_points_amde = array_keys(getSalesPartnerUseAmazonLogistic());
 while ($row = tep_db_fetch_array($q)) {
     if (in_array($row['jng_sp_id'], $sp_used_selling_points_amde)) {
         $sp_list_amazon[$row['jng_sp_catalog_id']] = $row['languages_id'];
     } else {
         $sp_list[$row['jng_sp_catalog_id']] = $row['languages_id'];
     }
     $sp_list_spid[$row['jng_sp_catalog_id']] = $row['jng_sp_id'];
 }
 //Update selling points which use non-amazon Selling Points
 foreach ($sp_list as $catalog_id => $sp_languages_id) {
     if ($sp_languages_id == $languages_id) {
         $sda = array();
         $sda['name'] = $name;
         $sda['description'] = $description;
         $sda['products_selling_points'] = $sellingpoints;