$obj_excel_draw->setWorksheet($obj_ws);
             $obj_excel_draw->setPath($img_path);
             $obj_excel_draw->setCoordinates(chr($column_ai[$ai]) . $row_products_images);
             $obj_excel_draw->setOffsetX($offset_ai[$ai]);
             $obj_excel_draw->setOffsetY($img_offset);
         }
     }
 }
 $row_total = $row_products_images;
 foreach ($p->articles as $aid => $a) {
     if ($p->isArticleKilled($aid)) {
         continue;
     }
     $article_counter++;
     //ELEMENTS!
     $ean = $p->getEAN($aid);
     $size = $p->getLengthOrSizeAsText($aid);
     $cell_ean = 'A' . ($row_total + 2);
     $element_rowstart = $row_total + 3;
     $obj_ws->getStyle($cell_ean)->getFont()->setBold(true);
     $obj_ws->setCellValue($cell_ean, "EAN Code: {$ean} ({$size})");
     $range_elements_header = $obj_ws->getStyle('A' . $element_rowstart . ':I' . $element_rowstart);
     $range_elements_header->getFont()->setBold(true);
     $range_elements_header->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB($table_header_bgcolor);
     $obj_ws->setCellValue('A' . $element_rowstart, 'Element');
     $obj_ws->setCellValue('B' . $element_rowstart, 'ID');
     $obj_ws->setCellValue('C' . $element_rowstart, 'Description');
     $obj_ws->setCellValue('D' . $element_rowstart, 'Material');
     $obj_ws->setCellValue('E' . $element_rowstart, 'Finishing');
     $obj_ws->setCellValue('F' . $element_rowstart, 'Qty');
     $obj_ws->setCellValue('G' . $element_rowstart, 'Weight (gram)');
 private static function queryStock($warehouse_id)
 {
     $archive_table = self::$archive_query_in_excel;
     $stock_list = Product::getOldProductFunction()->stockRetrieveDetailAll($warehouse_id);
     if ($archive_table) {
         //Create new excel object
         $excel_row = 1;
         $obj_excel = new PHPExcel();
         $obj_sheet = $obj_excel->getActiveSheet();
         $obj_sheet->getColumnDimension('A')->setWidth(15);
         $obj_sheet->getColumnDimension('B')->setWidth(15);
         $obj_sheet->getColumnDimension('C')->setWidth(15);
         $obj_sheet->getColumnDimension('D')->setWidth(15);
         $obj_sheet->getColumnDimension('E')->setWidth(15);
         $obj_sheet->getColumnDimension('F')->setWidth(15);
         $obj_sheet->getColumnDimension('G')->setWidth(15);
         //Set Header Row
         $obj_sheet->setCellValue('A1', 'Product ID');
         $obj_sheet->setCellValue('B1', 'EAN');
         $obj_sheet->setCellValue('C1', 'Purchase Price');
         $obj_sheet->setCellValue('D1', 'Stock Qty');
         $obj_sheet->setCellValue('E1', 'Stock Value');
         $obj_sheet->setCellValue('F1', 'Last Order Date');
     }
     $stock_qty_total = 0;
     $stock_value_total = 0;
     foreach ($stock_list as $stock_detail) {
         $pid = $stock_detail['products_id'];
         $aid = $stock_detail['articles_id'];
         $stock_available = $stock_detail['stock'];
         if (!isset($obj_product) || $obj_product->id != $pid) {
             $obj_product = new Product($pid);
         }
         $stock_booked = $obj_product->getStockBookedByRealOrderQuantity($aid, WAREHOUSE_ID_FOR_HANDLING_ORDERS);
         $stock_qty = $stock_available + $stock_booked;
         if ($stock_qty > 0) {
             $purchase_price = $obj_product->getCOGSObject()->purchase_price;
             $stock_value = $stock_qty * $purchase_price;
             $stock_qty_total += $stock_qty;
             $stock_value_total += $stock_value;
             if ($archive_table) {
                 $excel_row++;
                 $ean = $obj_product->getEAN($aid);
                 $last_order_date = $obj_product->getLastOrderDate($aid);
                 //Set Data Row
                 $obj_sheet->setCellValue('A' . $excel_row, $pid);
                 $obj_sheet->setCellValue('B' . $excel_row, $ean);
                 $obj_sheet->setCellValue('C' . $excel_row, $purchase_price);
                 $obj_sheet->setCellValue('D' . $excel_row, $stock_qty);
                 $obj_sheet->setCellValue('E' . $excel_row, $stock_value);
                 $obj_sheet->setCellValue('F' . $excel_row, $last_order_date);
             }
         }
     }
     if ($archive_table) {
         $period = date(self::PERIOD_DATE_FORMAT, strtotime('-1 day'));
         self::saveArchiveFile($obj_excel, $period, self::ARCHIVE_FILENAME_STOCK);
     }
     self::$current_stock_qty = $stock_qty_total;
     self::$current_stock_value = $stock_value_total;
 }
Example #3
0
 /**
  * Load an item as an object by using Order object and the item id
  * @param Order $order An Order object to load an item from
  * @param Int $item_id Item ID to be loaded
  */
 public function __construct($order, $item_id)
 {
     $this->order = $order;
     if ($order->isOrderFromSalesPartner()) {
         $table = 'jng_sp_orders_items';
         $colname_id = self::COLNAME_ID_SP;
         $colname_qty = self::COLNAME_QTY_SP;
         $colname_price = self::COLNAME_PRICE_SP;
         $colname_product_name = self::COLNAME_NAME_SP;
         $colname_article_no = self::COLNAME_CODE_SP;
     } elseif ($order->isOrderFromJulieGrace()) {
         $table = 'orders_products';
         $colname_id = self::COLNAME_ID_JG;
         $colname_qty = self::COLNAME_QTY_JG;
         $colname_price = self::COLNAME_PRICE_JG;
         $colname_product_name = self::COLNAME_NAME_JG;
         $colname_article_no = self::COLNAME_CODE_JG;
     }
     $q = "SELECT * FROM {$table} WHERE {$colname_id} = '{$item_id}'";
     $r = tep_db_query($q);
     $row = tep_db_fetch_array($r);
     $this->item_id = $item_id;
     $this->item_detail = $row;
     $this->product_id = $row['products_id'];
     $this->product_name = $row[$colname_product_name];
     $this->article_id = $row['products_articles_id'];
     $this->article_no = $row[$colname_article_no];
     $this->ean = $row['products_ean'];
     if (is_null($this->ean)) {
         $product = new Product($this->product_id);
         $product->getEAN($this->article_id);
     }
     $this->ordered_quantity = $row[$colname_qty];
     $this->price = $row[$colname_price];
     $this->item_count = $row['order_item_count'];
     $this->item_total = $row['order_item_total'];
     $this->status = $row['status'];
     $this->stock_status = $row['stock_status'];
 }
 function generateLabelHSE($product_id, $article_id, $ean = '')
 {
     $result = array();
     if ($ean != '') {
         $obj_product = Product::loadObjectFromEAN($ean);
         $article_id = $obj_product->getArticleIDFromEAN($ean);
     } else {
         $obj_product = new Product($product_id);
         $ean = $obj_product->getEAN($article_id);
     }
     $sales_partner_id = '12';
     //Use product code from SP (HSE)
     //SP is not yet created, maybe will have a different ID
     $code = $obj_product->getSalesPartnerProductCode($sales_partner_id);
     if ($code == '') {
         $code = 'N/A';
     }
     $name = $obj_product->getSalesPartnerProductName($sales_partner_id);
     if ($name == '') {
         $name = 'No SP Name';
     }
     $length = $obj_product->getLengthOrSizeAsText($article_id);
     //Set label size (in dots)
     $label_width = '340';
     $text_block_width = '300';
     //Set default x and y position
     $posx_start = 20;
     $posy_start = 35;
     //Start setting x and y position to be used and changed dynamically
     //can be set to default size again when needed
     $posx = $posx_start;
     $posy = $posy_start;
     //CONSTRUCT label
     //==> START COMMAND ^XA
     $label = "^XA";
     //==> Change International Font/Encoding ^CI
     //6 = German Character Set
     $label .= "^CI6";
     //==> Media Type
     //^MT
     //D for Direct Thermal (need special media)
     //T for Thermal Transfer (need ribbon)
     $label .= "^MTD";
     //==> Media Darkness
     //^MD
     //0 : 0 (-30 to 30)
     $label .= "^MD0";
     //==> Print Mode
     //^MM
     //T = Tear-off
     $label .= "^MMT";
     //==> Measurement Unit
     //^MU
     //d = dots
     //300 = dpi format
     //300 = dpi conversion
     $label .= "^MUd,300,300";
     //==> Label Home
     //^LH
     //0,0 = x,y axis position (0 - 32000)
     $label .= "^LH0,0";
     //==> Media Tracking
     //^MN
     //Y = non-continues web sensing
     //N = continues
     $label .= "^MNY";
     //$label .= "^MNN";
     //==> Label Length
     //^LL
     //only needed for continues media
     //$label .= "^LL384.5";
     //==> Print Width
     //^PW
     //Specify label width in dots
     $label .= "^PW" . $label_width;
     //==> Set Dots per Milimiter
     //^JM
     //will affect sizes of result that will be printed on label
     //A = 24 dots/mm, 12 dots/mm, 8 dots/mm or 6 dots/mm
     //B = 12 dots/mm,  6 dots/mm, 4 dots/mm or 3 dots/mm
     $label .= "^JMA";
     //==> Field Origin
     //^FO
     //x axis in dots
     //y axis in dots
     //z = justification (0 = left, 1 = right, 2 = auto)
     $label .= "^FO{$posx},{$posy}";
     //==> Set Scalable/Bitmapped Font
     //^A
     //font name : A-Z, 0-9 (saved in printer memory)
     //orientation : N = normal, R = 90CW, I = 180, B = 270
     //character height in dots
     //width in dots
     $label .= "^A0N,35,35";
     //==> Field Block
     //^FB
     //set field data to be printed as a block which can be aligned
     //width in dots
     //maximum lines : 1 to 9999
     //line spaces : -9999 to 9999
     //alignment : L = Left, C = Center, R = Right, J = Justified
     //hanging indent : 0 to 9999
     $label .= '^FB' . $text_block_width . ',1,0,C,0';
     //==> Field Data (set barcode value)
     //^FD ... ^FS
     //Data to print (in this case Product Code)
     $label .= '^FD' . 'HSE 24' . '^FS';
     $posy += 38;
     //==> Field Origin
     //^FO
     //x axis in dots
     //y axis in dots
     //z = justification (0 = left, 1 = right, 2 = auto)
     $label .= "^FO{$posx},{$posy}";
     //==> Set Scalable/Bitmapped Font
     //^A
     //font name : A-Z, 0-9 (saved in printer memory)
     //orientation : N = normal, R = 90CW, I = 180, B = 270
     //character height in dots
     //width in dots
     $label .= "^A0N,60,60";
     //==> Field Block
     //^FB
     //set field data to be printed as a block which can be aligned
     //width in dots
     //maximum lines : 1 to 9999
     //line spaces : -9999 to 9999
     //alignment : L = Left, C = Center, R = Right, J = Justified
     //hanging indent : 0 to 9999
     $label .= '^FB' . $text_block_width . ',1,0,C,0';
     //==> Field Data (set barcode value)
     //^FD ... ^FS
     //Data to print (in this case Product Code)
     $label .= '^FD' . $code . '^FS';
     $posy += 50;
     $posx_barcode = 35;
     //==> Bar Code Field Default
     //^BY
     //could make barcode on smallest size
     //width : 1 - 10
     //ratio : 2.0 - 3.0
     //height : in dots
     $label .= "^BY2";
     //==> Field Origin
     //^FO
     //x axis in dots
     //y axis in dots
     //z = justification (0 = left, 1 = right, 2 = auto)
     $label .= "^FO\${$posx_barcode},{$posy}";
     //==> Set Barcode Type and Format
     //^B
     //C = Code 128
     //orientation : N = normal, R = 90CW, I = 180, B = 270
     //height in dots
     //print interpretation : Y = Yes, N = No
     //print interpretation above : Y = Yes, N = No (print below)
     $label .= "^BCN,80,N,N";
     //==> Field Data (set barcode value)
     //^FD ... ^FS
     //Data to print (in this case EAN Code)
     $label .= '^FD' . $code . '^FS';
     $posy += 85;
     //==> Field Origin
     //^FO
     //x axis in dots
     //y axis in dots
     //z = justification (0 = left, 1 = right, 2 = auto)
     $label .= "^FO{$posx},{$posy}";
     //==> Set Scalable/Bitmapped Font
     //^A
     //font name : A-Z, 0-9 (saved in printer memory)
     //orientation : N = normal, R = 90CW, I = 180, B = 270
     //character height in dots
     //width in dots
     $label .= "^A0N,30,30";
     //==> Field Block
     //^FB
     //set field data to be printed as a block which can be aligned
     //width in dots
     //maximum lines : 1 to 9999
     //line spaces : -9999 to 9999
     //alignment : L = Left, C = Center, R = Right, J = Justified
     //hanging indent : 0 to 9999
     $label .= '^FB' . $text_block_width . ',2,0,C,0';
     //==> Field Data (set barcode value)
     //^FD ... ^FS
     //Data to print (in this case the Article Length)
     $label .= '^FH^FD' . $this->convertToGermanHex($name) . '^FS';
     //$label .= '^FD' . $name . ' ' . $length . '^FS';
     //END COMMAND ^XZ
     $label .= "^XZ";
     $result['barcode_type'] = 'label_product_hse';
     $result['label'] = $label;
     $result['label_name'] = "{$ean}.data";
     return $result;
 }
/**
 * 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;
}