Inheritance: extends AppModel
function generateKeywords($product_id)
{
    use_class('styles');
    use_class('Product');
    use_class('ProductAttribute');
    $class_s = new styles();
    $keywords = array();
    $product = new Product($product_id);
    $language_id = 2;
    //Step 1 (Brand)
    if ($product->brand_id == 24) {
        $keywords = array(strtolower($product->brand_name), 'eli', 'silberschmuck', '925', 'junger', 'modischer', 'trendy', 'fashion');
    } elseif ($product->brand_id == 3) {
        $keywords = array(strtolower($product->brand_name), 'vergoldet', 'golden', 'gold', 'vermeil');
    } elseif ($product->brand_id == 7) {
        $keywords = array(strtolower($product->brand_name), 'perlenschmuck', 'brautschmuck', 'hochzeit');
    }
    //Step 2 (Symbol)
    $symbol = $class_s->getProductStyle($product_id);
    if ($symbol['Symbol'] > 0) {
        $style = new ProductAttribute($symbol['Symbol']);
        if ($symbol['Symbol'] != '') {
            array_push($keywords, strtolower($style->displayAttributeName($product_id, ProductAttribute::GROUP_ID_SYMBOL, $language_id)));
        }
    }
    //Step 3 (Basic)
    array_push($keywords, 'günstiger', 'frau', 'freundin', 'geschenk', 'juwelier');
    //Step 4 (Material)
    $materials = array();
    $q = "SELECT ptpm.products_materials_id AS id" . " , material_name AS name" . " FROM products_to_products_materials ptpm" . " INNER JOIN products_materials pm" . " ON pm.products_materials_id = ptpm.products_materials_id" . " WHERE ptpm.products_id = {$product_id}";
    $r = tep_db_query($q);
    while ($row = tep_db_fetch_array($r)) {
        $materials[$row['id']] = $row['name'];
    }
    foreach ($materials as $key => $value) {
        if ($key == 4 || $key == 2) {
            list($material_name2, $material_name1, $material_name3) = split(",", $value);
            array_push($keywords, strtolower($material_name2), 'glamourös', 'funkelnd', 'glitzernd', 'strass', 'festlich', 'elegant');
        } else {
            list($material_name2, $material_name1, $material_name3) = split(",", $value);
            array_push($keywords, strtolower($material_name2));
        }
    }
    //Step 5 (Color)
    $color = $product->getColors($language_id);
    array_push($keywords, strtolower($color));
    //Step 6 (Rest of the products)
    array_push($keywords, 'basic', 'klassik', 'klassisch', 'schlicht', 'elegant', 'zeitlos', 'sportlich', 'dezent', 'filigran', 'zart', 'schlicht');
    $final_k = implode(',', $keywords);
    //echo $pid." = ".$final_k;
    $sda = array();
    $sda['products_head_keywords_tag'] = $final_k;
    tep_db_perform('products_description', $sda, 'update', "products_id={$product_id} AND language_id={$language_id}");
}
 public function loadModel($id)
 {
     $model = ProductAttribute::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #3
0
 /**
  * Get ebay name suggestion for this product
  * @param Int $language_id
  * @return String
  */
 public function getEbayNameSuggestion($language_id)
 {
     $ebay_name = array();
     $ebay_name[] = $this->brand_name;
     $ebay_name[] = $this->category_name;
     foreach ($this->materials as $id => $name) {
         $ebay_name[] = Material::getName($name, $language_id);
     }
     $attributes = ProductAttribute::getOldStylesFunction()->retrieveList(ProductAttribute::GROUP_ID_SYMBOL, "shp.products_id = {$this->id}");
     foreach ($attributes as $attr) {
         $ebay_name[] = $attr['name'];
     }
     $ebay_name[] = ucfirst($this->getTargetGroup($language_id));
     return implode(' ', $ebay_name);
 }
Example #4
0
 /**
  * Get the full standard product name based on language
  * @param Int $language_id
  * @param Boolean $use_brand_name
  * @return String
  */
 public function getName($language_id, $use_brand_name = true)
 {
     if ($language_id == '3') {
         $pmat_chars = ProductAttribute::displayAttributeName($this->id, ProductAttribute::GROUP_ID_MATERIAL, $language_id, ' ');
         $pshape = ProductAttribute::displayAttributeName($this->id, ProductAttribute::GROUP_ID_SHAPE, $language_id, ' ');
         $subcat = ProductAttribute::displayAttributeName($this->id, $this->getTopCategory()->getSubCategoryGroup(), $language_id, ' ');
         $name = $pmat_chars . ' ' . $pshape . ' ' . $subcat;
         $name = trim(str_replace('  ', ' ', $name));
     } else {
         $name = ($use_brand_name ? $this->brand_name . ' ' : '') . $this->getCategory()->getName($language_id) . ' ' . $this->getNameRaw($language_id);
     }
     return $name;
 }
Example #5
0
 public function afterDelete()
 {
     // delete dependencies
     ProductAttribute::model()->deleteAll("product_id={$this->cacheId}");
     ProductDescription::model()->deleteAll("product_id={$this->cacheId}");
     ProductDiscount::model()->deleteAll("product_id={$this->cacheId}");
     ProductFilter::model()->deleteAll("product_id={$this->cacheId}");
     ProductImage::model()->deleteAll("product_id={$this->cacheId}");
     ProductOption::model()->deleteAll("product_id={$this->cacheId}");
     ProductOptionValue::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("product_id={$this->cacheId}");
     ProductRelated::model()->deleteAll("related_id={$this->cacheId}");
     ProductReward::model()->deleteAll("product_id={$this->cacheId}");
     ProductSpecial::model()->deleteAll("product_id={$this->cacheId}");
     ProductToCategory::model()->deleteAll("product_id={$this->cacheId}");
     ProductToDownload::model()->deleteAll("product_id={$this->cacheId}");
     ProductToLayout::model()->deleteAll("product_id={$this->cacheId}");
     ProductToStore::model()->deleteAll("product_id={$this->cacheId}");
     Review::model()->deleteAll("product_id={$this->cacheId}");
     UrlAlias::model()->deleteAll("query='product_id={$this->cacheId}'");
     parent::afterDelete();
 }
 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);
     }
 }
Example #7
0
 protected function create($id)
 {
     $a = new ProductAttribute($id, $this->variationId);
     return $a->isNull() ? new ProductAttribute($id, $this->productId) : $a;
 }
     echo utf8_encode($result);
     exit;
 } elseif ($_POST['me_action'] == 'LOADCATS') {
     $param_code = 'V';
     $category_top_id = tep_db_prepare_input($_POST['ctid']);
     $genders = Product::getOldProductFunction()->productGenderName();
     unset($genders[0]);
     //none
     unset($genders[3]);
     //unisex
     $obj_ct = new CategoryTop($category_top_id);
     $cats = array();
     while ($cat = $obj_ct->getCategoriesOneByOneAsObject()) {
         $cats[$cat->id] = $cat->getName(LANGUAGEID);
     }
     ProductAttribute::getOldStylesFunction()->retrieveList($obj_ct->getSubCategoryGroup());
     if (in_array($jng_sp_id, array(1005))) {
         //get from Primary Navigation (Navigation for this SP separated between Primary and Secondary)
         $navids = retrieveNavIDs($jng_sp_id, 'c');
     } else {
         //Navigation are used for both Primary and Additional
         $navids = retrieveNavIDs($jng_sp_id, '');
     }
     $params = $class_jpc->loadAsMapper($jng_sp_id, $param_code);
     if (count($cats) == 0) {
         $result = '<h3 class="red">No Categories found</h3>';
     } else {
         $result = '<div><table class="form" border="0" cellpadding="0" cellspacing="0">';
         foreach ($genders as $gkey => $gval) {
             $gender_color = $gkey == '1' ? 'green' : 'blue';
             foreach ($cats as $param_id => $param_name) {
        $javascript .= $obj_pa->getAttachmentsAsObject()->drawAttachmentJSAction('');
    }
    $javascript .= '
        $("#product-style").tabs();
        $("#style-desc-tabs").tabs();
        $("#style-desc-tabs").tabs("select", 1);
        $("input[name=back]").click(function() {
            top.window.closePopup();
        });
        ' . ($reloadlist ? 'top.window.reloadList();' : '') . '
    ';
} else {
    //START TEMPLATE for LIST
    $sgoptions = '<div>';
    $sgoptions .= '<strong>Attributes Group </strong> <select id="style_group">';
    foreach (ProductAttribute::getOldStylesFunction()->groups as $gk => $gv) {
        $sgoptions .= '<option value="' . $gk . '"' . ($STYLEGROUP == $gk ? 'selected="selected"' : '') . '>' . $gv . '</option>';
    }
    $sgoptions .= '</select>';
    $sgoptions .= '<select id="default_language">';
    foreach ($languages as $lid => $lang) {
        $sel = $lid == '2' ? ' selected="selected"' : '';
        $sgoptions .= '<option value="' . $lid . '"' . $sel . '>' . $lang['name'] . '</option>';
    }
    $sgoptions .= '</select>';
    $sgoptions .= '</div>';
    $pagetype = 'Products Attributes - <span id="groupname"></span>';
    $content .= '<div><table border="0" cellpadding="0" cellspacing="0"><tr>';
    $content .= '<td style="vertical-align:middle;padding-right:10px;">' . $sgoptions . '</td>';
    $content .= '<td style="vertical-align:middle;">';
    $content .= '<a href="?open=products-styles&amp;id=0&amp;hidemenu=true" class="view_webpage"></a>';
            $obj_product = Product::loadObjectFromEAN($product_entry);
        } else {
            $obj_product = Product::loadObjectFromProductCode($product_entry);
            if ($obj_product === false) {
                $obj_product = new Product($product_entry);
            }
        }
        $result = '';
        if ($obj_product === false) {
            $result .= '<h3 class="red">Product <strong>' . $product_entry . '</strong> not found!</h3>';
        } else {
            $result .= '<div style="float:left;">' . $obj_product->displayImage(IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1_PORTRAIT) . '</div><div style="margin-left:120px;">';
            $attributes = ProductAttribute::getOldStylesFunction()->getProductStyles($obj_product->id);
            $total_images = 0;
            foreach ($attributes[ProductAttribute::GROUP_ID_PACKAGING] as $attribute_id => $attribute_name) {
                $obj_pa = new ProductAttribute($attribute_id);
                foreach ($obj_pa->getAttachmentsAsObject()->getFilesAsArray() as $img_index => $img_file) {
                    $total_images++;
                    $result .= '<div style="margin-bottom:10px;">' . $obj_pa->getAttachmentsAsObject()->displayImageFile($img_index, $imgwidth, $imgheight) . '</div>';
                }
            }
            if ($total_images == 0) {
                $result .= ERROR_MESSAGE_NOIMAGE;
            }
            $result .= '</div>';
        }
        echo utf8_encode($result);
        exit;
    }
}
if (USERAGENTISMANOBOCLIENT && $hidemenuscript != '') {
Example #11
0
 function __construct()
 {
     $this->groups = ProductAttribute::getAttributeGroups();
 }
 public function validateProductAttribute()
 {
     if (isset($_POST['ProductAttribute'])) {
         $valid = true;
         $this->_productattribute = array();
         /*Yii::log( "ProductCreateAction: ".CVarDumper::dumpAsString( $_POST['ProductOption'] ),
         			CLogger::LEVEL_ERROR, "product.actions.create" 
         		);*/
         foreach ($_POST['ProductAttribute'] as $i => $attribute) {
             if (isset($_POST['ProductAttribute'][$i])) {
                 $attribute = new ProductAttribute();
                 $attribute->product_id = 0;
                 $attribute->locale_code = Yii::app()->getLanguage();
                 $attribute->attributes = $_POST['ProductAttribute'][$i];
                 $valid = $attribute->validate() && $valid;
                 $this->_productattribute[] = $attribute;
             }
         }
         if (!$valid) {
             return false;
         }
     }
     return true;
 }
Example #13
0
 public function importProductManufacturers()
 {
     $productAttributes = ProductAttribute::getAllByCriteria('code = ? and isFromB2B = 1 and mageId <> 0', array('manufacturer'), true, 1, 1, array("id" => "desc"));
     if (count($productAttributes) === 0) {
         return;
     }
     $productAttribute = $productAttributes[0];
     try {
         $transStarted = false;
         try {
             Dao::beginTransaction();
         } catch (Exception $e) {
             $transStarted = true;
         }
         foreach ($this->getProductAttributeOptions($productAttribute->getMageId()) as $productAttributeOption) {
             $label = isset($productAttributeOption->label) ? trim($productAttributeOption->label) : '';
             $value = isset($productAttributeOption->value) ? trim($productAttributeOption->value) : '';
             // mageId
             if ($label === '' || $value === '') {
                 echo "ingore product manufacturer options due to empty label or value (" . 'label="' . $label . '", value="' . $value . '")' . "\n";
                 continue;
             }
             $manufacturer = Manufacturer::create($label, '', true, $value);
             echo 'Imported manufacture (name="' . $label . '", mageId=' . $value . ')' . "\n";
         }
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
     } catch (Exception $e) {
         if ($transStarted === false) {
             Dao::commitTransaction();
         }
         throw $e;
     }
     return $this;
 }
/**
 * Get cell value for Matahari catalog cell
 * @global Int $jng_sp_id
 * @global Array $sp_detail
 * @param String $column_key
 * @param Product $product
 * @param Int $aid
 * @return String
 */
function getMatahariCatalogCellValue($column_key, $product, $aid)
{
    global $class_pb, $jng_sp_id, $sp_detail, $sp_values_brand, $sp_values_colors, $sp_values_navcat, $sp_values_navsubcat, $category_top_id;
    $lid = $sp_detail['languages_id'];
    if (!isset($sp_values_brand[$product->brand_id])) {
        $sp_brands = $class_pb->getSPbrands($product->brand_id);
        $sp_values_brand[$product->brand_id] = $sp_brands[$jng_sp_id];
    }
    $product_old_function = $product->getOldProductFunction()->retrieveDetail($product->id, 'p,pd,pd2,pc,pnc,cat,pei,pci');
    if ($category_top_id == '1') {
        if ($product_old_function['pci']['products_clear_image'] != '') {
            $main_image = substr($product_old_function['pci']['products_clear_image'], 23);
        } else {
            $main_image = substr($product_old_function['p']['products_image'], 23);
        }
    } else {
        $main_image = substr($product_old_function['p']['products_image'], 23);
    }
    $additional_images = array_values($product_old_function['pei']);
    $category_id = $product->category_id;
    $selling_points = $product->getSellingPointsAsArray($lid);
    switch ($column_key) {
        case 'Title*':
            if ($category_top_id == '1') {
                //JEWELRY
                $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
                //                $value = 'VON LORENZ' . ' ' .
                //                    $product_old_function['pd'][3]['products_name'] . ' ' . $product->getColors($lid);
            } else {
                $value = ucwords(strtolower($sp_values_brand[$product->brand_id])) . ' ' . $product->getName($lid) . ' ' . $product->getColors($lid);
            }
            break;
        case 'Brand':
            $value = $sp_values_brand[$product->brand_id];
            //            $value = 'VON LORENZ';
            break;
        case 'Model':
            $value = '';
            break;
        case 'Color*':
            $value = $product->getColors($lid);
            break;
        case 'Sale Price (Amount)*':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                //show blank if its not discounted
                $price = '';
            }
            $value = $price;
            break;
        case 'Price (Amount)*':
            $price = $product->getPriceSelling($jng_sp_id);
            $price_old = $product->getPriceSellingOld($jng_sp_id);
            if ($price_old <= $price) {
                $price_old = $price;
            }
            $value = $price_old;
            break;
        case 'SKU*':
            $value = $product->getSKU($aid);
            break;
        case 'Size':
            //todo: translate ring sizes
            if ($category_top_id == '1') {
                if ($category_id == '29') {
                    $value = $product->convertRingSizeToJapaneseSize($product->getLengthOrSizeAsText($aid));
                } else {
                    $value = 'One Size';
                }
            } else {
                $value = $product->getLengthOrSizeAsText($aid);
            }
            break;
        case 'Model Number':
            $value = $product->getEAN($aid);
            break;
        case 'Stock':
            $value = $product->retrieveStockQuantity($aid);
            break;
        case 'Product Line':
            $value = 'Wanita';
            break;
        case 'Normal Price (Amount)*':
            $value = $product->getPriceDefault();
            break;
        case 'Normal Price (Currency)*':
            $value = 'IDR';
            break;
        case 'Main Material':
            $value = '';
            break;
        case 'Description*':
            $value = $product->getDescription($lid);
            break;
        case 'Youtube URL':
            $value = '';
            break;
        case 'Highlight 1':
            $value = $selling_points[0];
            break;
        case 'Highlight 2':
            $value = $selling_points[1];
            break;
        case 'Highlight 3':
            $value = $selling_points[2];
            break;
        case 'Highlight 4':
            $value = $selling_points[3];
            break;
        case 'Highlight 5':
            $value = $selling_points[4];
            break;
        case 'Highlight 6':
            $value = '';
            break;
        case 'Highlight 7':
            $value = '';
            break;
        case 'Highlight 8':
            $value = '';
            break;
        case 'Highlight 9':
            $value = '';
            break;
        case 'Highlight 10':
            $value = '';
            break;
        case 'Highlight 11':
            $value = '';
            break;
        case 'Highlight 12':
            $value = '';
            break;
        case 'Insurance option':
            $value = '1';
            break;
        case 'Handling fee (IDR)':
            $value = '0';
            break;
        case 'Product Dimension':
            //Measurements is from Zalora Template
            $value = $product->displayMeasurement($lid);
            break;
        case 'Product Weight':
            $value = $product->displayWeight($lid);
            break;
        case 'Package Dimension (L x W x H cm)':
            //todo: use dynamic data
            $value = '40 x 35 x 3 cm';
            break;
        case 'Certification':
            $value = '';
            break;
        case 'Product Country':
            $value = ProductAttribute::displayAttributeName($product->id, ProductAttribute::GROUP_ID_ORIGIN, $lid);
            break;
        case 'Item Condition*':
            $value = 'new';
            break;
        case 'Product Waranty':
            $value = '';
            break;
        case 'Image 1*':
            //Currently Kristel will copy the link to this field manually.
            $value = $main_image;
            break;
        case 'Image 2':
            $value = $additional_images[0] == '' ? '' : substr($additional_images[0], 23);
            break;
        case 'Image 3':
            $value = $additional_images[1] == '' ? '' : substr($additional_images[1], 23);
            break;
        case 'Image 4':
            $value = $additional_images[2] == '' ? '' : substr($additional_images[2], 23);
            break;
        case 'Image 5':
            $value = $additional_images[3] == '' ? '' : substr($additional_images[3], 23);
            break;
        case 'Product Line':
            $value = ucfirst($product->getProductGender('1'));
            break;
        case 'Price (Currency)*':
            $value = 'IDR';
            break;
        case 'Type':
            $value = '';
            break;
        case 'Package Weight (Kg)':
            $value = 0.4;
            break;
        case 'product_id(MUST BE DELETED BEFORE UPLOAD)':
            $value = $product->id;
            break;
        default:
            $value = '';
    }
    return $value;
}