function drawProductPriceTable(Product $product, $message = '')
{
    global $class_sp;
    //$supported_sp = array('2', '5', '7', '8');
    //$sp_filer = 'jng_sp_id IN ('.implode(',', $supported_sp).') AND ';
    $show_jng = !SERVER_IS_LOCAL;
    $sp_b2c = $class_sp->retrieveList('use_amvd_logistic = 0');
    $sp_b2b = $class_sp->retrieveList('use_amvd_logistic = 1');
    $total_sp_b2c = count($sp_b2c);
    if ($show_jng) {
        $total_sp_b2c += 1;
    }
    $total_sp_b2b = count($sp_b2b);
    $result = '<div id="price-pid-' . $product->id . '" class="product" ' . 'style="clear:left;float:left;margin-bottom:20px;">' . '<div class="draw-table">' . '<table border="0" cellpadding="0" cellspacing="0">' . '<tr>' . '<th rowspan="2">Product</th>' . '<th colspan="2">Info</th>' . '<th colspan="' . $total_sp_b2c . '">B2C</th>';
    foreach ($sp_b2b as $sp) {
        if ($product->isAddedToSalesPartner($sp['jng_sp_id'])) {
            $btn_addto_catalog = '';
        } else {
            $btn_addto_catalog = '<div style="float:right;"><input ' . 'type="button" class="addtocat" value="add" /></div>';
        }
        $result .= '<th colspan="2">B2B - ' . $sp['package_prefix'] . '</th>';
        /*
        $result .= '<th colspan="2"><div>B2B - ' . 
            $sp['package_prefix'].'</div>' . $btn_addto_catalog . '</th>';
        */
    }
    $result .= $b2b . '</tr>' . '<tr>' . '<th>Name</th>' . '<th class="bold">DEFAULT</th>';
    if ($show_jng) {
        $result .= '<th>JG.DE</th>';
    }
    foreach ($sp_b2c as $sp) {
        $result .= '<th>' . $sp['package_prefix'] . '</th>';
    }
    foreach ($sp_b2b as $sp) {
        $result .= '<th>No Discount</th>';
        $result .= '<th>Discount</th>';
    }
    $jng_id = '0';
    $cogs = $product->getProductCOGSValue();
    $price_uvp = $product->getPriceUVP();
    $price_uvp_text = displayCurrency(CURRENCY_DEFAULT, $price_uvp, false, 2);
    $price_default = $product->getPriceDefault();
    $price_default_text = displayCurrency(CURRENCY_DEFAULT, $price_default, false, 2);
    $price_jng = $product->getPriceSelling($jng_id);
    $price_options = array('Show Discount', 'Hide Discount');
    //, 'No Discount');
    $price_options_combo = '<select name="price_option" style="display:none;">' . '%s</select><span class="notice price_option_none" style="display:none;">' . 'No Discount</span>';
    $price_option_jng = loadComboListFromArray($price_options, null, $product->isPriceSellingUsingDiscount($jng_id) ? 0 : 1, false);
    $sp_type_default = '<input type="hidden" name="sp_type" value="DEF" />';
    $sp_type_b2c = '<input type="hidden" name="sp_type" value="B2C" />';
    $sp_type_b2b_nodisc = '<input type="hidden" name="sp_type" value="B2B-ND" />';
    $sp_type_b2b_disc = '<input type="hidden" name="sp_type" value="B2B-D" />';
    $sp_id_jng = '<input type="hidden" name="sp_id" value="0" />';
    if (SERVER_IS_LOCAL) {
        $class_add = ' readonly';
        $editable = ' readonly="readonly"';
    } else {
        $class_add = '';
        $editable = '';
    }
    $result .= '</tr>' . '<tr class="o">' . '<td class="w200 tac"><div>' . $product->displayImage(IMAGE_SIZE_THUMBNAIL_2, IMAGE_SIZE_THUMBNAIL_2_PORTRAIT) . '</div>' . '<div>' . $product->displayIDAndCode() . '</div>' . '</td>' . '<td class="w150">' . '<div class="cr cr-status">Status</div>' . '<div class="cr cr-uvp">UVP</div>' . '<div class="cr cr-sp">Selling Price</div>' . '<div class="cr cr-factor">Factor</div>' . '<div class="cr cr-disc">Discount</div>' . '<div class="cr cr-option">Price Option</div>' . '<div class="cr cr-preview">Price Preview</div>' . '<div class="cr cr-cogs">COGS</div>' . '<div class="cr cr-profit">Profit</div>' . '<div class="cr cr-margin">Margin</div>' . '<div class="cr cr-premium">Premium</div>' . '</td>' . '<td class="w100 tac">' . '<input type="hidden" name="cogs" value="' . $cogs . '" />' . '<div class="cr cr-status notice">-</div>' . '<div class="cr cr-uvp"><input type="text" name="price-uvp-default" class="w080 tac' . $class_add . '" value="' . $price_uvp . '"' . $editable . ' /></div>' . '<div class="cr cr-sp"><input type="text" name="price-default" class="w080 tac' . $class_add . '" value="' . $price_default . '"' . $editable . ' />' . $sp_type_default . '</div>' . '<div class="cr cr-factor notice">-</div>' . '<div class="cr cr-disc">&nbsp;</div>' . '<div class="cr cr-option notice">-</div>' . '<div class="cr cr-preview">&nbsp;</div>' . '<div class="cr cr-cogs">' . $cogs . '</div>' . '<div class="cr cr-profit">&nbsp;</div>' . '<div class="cr cr-margin">&nbsp;</div>' . '<div class="cr cr-premium">&nbsp;</div>' . '</td>';
    if ($show_jng) {
        //COLUMN J&G
        $result .= '<td class="w100 tac">' . '<div class="cr cr-status">' . $product->displayActiveStatusIcon($jng_id) . '</div>' . '<div class="cr cr-uvp"><input type="text" name="price-uvp" class="w080 tac b2c readonly" value="' . $price_uvp . '" readonly="readonly" />' . $sp_type_b2c . $sp_id_jng . '</div>' . '<div class="cr cr-sp"><input type="text" name="price-selling" class="w080 tac b2c" value="' . $price_jng . '" />' . $sp_type_b2c . $sp_id_jng . '</div>' . '<div class="cr cr-factor notice">-</div>' . '<div class="cr cr-disc">&nbsp;</div>' . '<div class="cr cr-option">' . sprintf($price_options_combo, $price_option_jng) . $sp_id_jng . '</div>' . '<div class="cr cr-preview">&nbsp;</div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit">&nbsp;</div>' . '<div class="cr cr-margin">&nbsp;</div>' . '<div class="cr cr-premium">&nbsp;</div>' . '</td>';
    }
    //COLUMN PER SP (B2C)
    foreach ($sp_b2c as $sp) {
        $result .= '<td class="w100 tac">';
        $result .= '<div class="cr cr-status">' . $product->displayActiveStatusIcon($sp['jng_sp_id']) . '</div>';
        if ($product->isAddedToSalesPartner($sp['jng_sp_id'])) {
            $sp_id = '<input type="hidden" name="sp_id" value="' . $sp['jng_sp_id'] . '" />';
            $price_selling_old = $product->getPriceSellingOld($sp['jng_sp_id']);
            $price_selling = $product->getPriceSelling($sp['jng_sp_id']);
            $price_option_sp = loadComboListFromArray($price_options, null, $product->isPriceSellingUsingDiscount($sp['jng_sp_id']) ? 0 : 1, false);
            if (SERVER_IS_LOCAL) {
                $price_uvp_sp = $price_selling_old > 0 ? $price_selling_old : $price_selling;
                $sp_uvp_class = '';
                $sp_uvp_dis = '';
            } else {
                $price_uvp_sp = $price_uvp;
                $sp_uvp_class = ' readonly';
                $sp_uvp_dis = ' readonly="readonly"';
            }
            $result .= '<div class="cr cr-uvp">' . '<input type="text" name="price-uvp" class="w080 tac b2c' . $sp_uvp_class . '"' . ' value="' . $price_uvp_sp . '" ' . $sp_uvp_dis . ' />' . $sp_id . '</div>';
            $result .= '<div class="cr cr-sp"><input type="text" name="price-selling" class="w080 tac b2c" value="' . $price_selling . '" />' . $sp_type_b2c . $sp_id . '</div>' . '<div class="cr cr-factor notice">-</div>' . '<div class="cr cr-disc">&nbsp;</div>' . '<div class="cr cr-option">' . sprintf($price_options_combo, $price_option_sp) . $sp_id . '</div>' . '<div class="cr cr-preview">&nbsp;</div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit">&nbsp;</div>' . '<div class="cr cr-margin">&nbsp;</div>' . '<div class="cr cr-premium">&nbsp;</div>';
        } else {
            //                $result .= '<span class="red">Not<br />added<br />yet to' .
            //                    '<br />catalog</span><br /><br /><input type="button" ' .
            //                    'value="Add Now" title="Click here to add product now '.
            //                    'to this Sales Partner Catalog" />';
            $result .= '<div class="cr cr-uvp notice">-</div>' . '<div class="cr cr-sp notice">-</div>' . '<div class="cr cr-factor notice">-</div>' . '<div class="cr cr-disc notice">-</div>' . '<div class="cr cr-option notice">-</div>' . '<div class="cr cr-preview notice">Not Added to Catalog</div>' . '<div class="cr cr-cogs notice">-</div>' . '<div class="cr cr-profit notice">-</div>' . '<div class="cr cr-margin notice">-</div>' . '<div class="cr cr-premium notice">-</div>';
        }
        $result .= '</td>';
    }
    //2 COLUMNS PER SP (B2B)
    foreach ($sp_b2b as $sp) {
        $status = $product->displayActiveStatusIcon($sp['jng_sp_id']);
        $status_nodisc = '&nbsp;';
        $status_disc = '&nbsp;';
        $sp_id = '<input type="hidden" name="sp_id" value="' . $sp['jng_sp_id'] . '" />';
        $b2b_disc_status_checked = '';
        $b2b_disc_disabled = '';
        $default_discount = 0.5;
        $selling_price_notsaved_title = '';
        $selling_price_notsaved_class = '';
        if ($product->isAddedToSalesPartner($sp['jng_sp_id'])) {
            $price_selling = $product->getPriceSelling($sp['jng_sp_id']);
            $price_selling_old = $product->getPriceSellingOld($sp['jng_sp_id']);
            if ($price_selling_old == 0) {
                $status_nodisc = $status;
                $price_selling_old = $price_selling;
                $price_selling = round((1 - $default_discount) * $price_selling_old, 2);
            } else {
                $status_disc = $status;
                $b2b_disc_status_checked = ' checked="checked"';
            }
        } else {
            $status_nodisc = $status;
            $status_disc = $status;
            $price_selling_old = $product->getPriceSellingDefaultB2B($price_uvp, $sp['jng_sp_id']);
            $price_selling = round((1 - $default_discount) * $price_selling_old, 2);
            $b2b_disc_disabled = ' disabled="disabled"';
            $selling_price_notsaved_title = ' title="Value is for simulation only and can not be saved because this product is not added to SP catalog"';
            $selling_price_notsaved_class = ' notice';
        }
        $b2b_ds_cb_id = 'po-' . $product->id . '-' . $sp['jng_sp_id'];
        $b2b_disc_status = '<input id="' . $b2b_ds_cb_id . '" type="checkbox" name="price_option"' . $b2b_disc_status_checked . $b2b_disc_disabled . ' /> <label for="' . $b2b_ds_cb_id . '">Active</label>';
        $price_selling_id = 'ps-' . $product->id . '-' . $sp['jng_sp_id'];
        $result .= '<td class="w100 tac">' . '<div class="cr cr-status">' . $status_nodisc . '</div>' . '<div class="cr cr-uvp">' . '<input type="text" name="price-uvp" class="w080 tac b2c readonly"' . ' value="' . $price_uvp . '" readonly="readonly" />' . $sp_id . '</div>' . '<div class="cr cr-sp"><input id="' . $price_selling_id . '-old" type="text" name="price-selling" class="w080 tac b2b-nd' . $selling_price_notsaved_class . '"' . $selling_price_notsaved_title . ' value="' . $price_selling_old . '" />' . $sp_type_b2b_nodisc . $sp_id . '</div>' . '<div class="cr cr-factor">&nbsp;</div>' . '<div class="cr cr-disc notice">-</div>' . '<div class="cr cr-option notice">-</div>' . '<div class="cr cr-preview">&nbsp;</div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit">&nbsp;</div>' . '<div class="cr cr-margin">&nbsp;</div>' . '<div class="cr cr-premium">&nbsp;</div>' . '</td>' . '<td class="w100 tac">' . '<div class="cr cr-status">' . $status_disc . '</div>' . '<div class="cr cr-uvp">' . '<input type="text" name="price-uvp" class="w080 tac b2c readonly"' . ' value="' . $price_uvp . '" readonly="readonly" />' . $sp_id . '</div>' . '<div class="cr cr-sp"><input id="' . $price_selling_id . '" type="text" name="price-selling" class="w080 tac b2b-d' . $selling_price_notsaved_class . '"' . $selling_price_notsaved_title . ' value="' . $price_selling . '" />' . $sp_type_b2b_disc . $sp_id . '</div>' . '<div class="cr cr-factor">&nbsp;</div>' . '<div class="cr cr-disc">&nbsp;</div>' . '<div class="cr cr-option">' . $b2b_disc_status . $sp_id . '</div>' . '<div class="cr cr-preview">&nbsp;</div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit">&nbsp;</div>' . '<div class="cr cr-margin">&nbsp;</div>' . '<div class="cr cr-premium">&nbsp;</div>' . '</td>';
    }
    $result .= '</tr></table></div>';
    $message_block = '';
    $button_style = '';
    if ($message != '') {
        $button_style = ' style="display:none;"';
        $message_block .= '<h3 class="green">' . $message . '</h3>';
    }
    $result .= '<div class="tar" style="margin-top:5px;"><input type="button"' . ' class="w400 button" name="save-price" value="Save Product Price" ' . $button_style . '/>' . $message_block . '</div>' . '</div>';
    return $result;
}
$product_counter = 0;
$article_counter = 0;
foreach ($pids as $pid) {
    $product_counter++;
    $p = new Product($pid);
    if ($show_minimum_data) {
        $price_uvp = 'N/A';
        $price_default = 'N/A';
        $price_selling_old_amazon = 'N/A';
        $price_selling_amazon = 'N/A';
        $mat_exp = $p->material_expense;
        $cogs = 'N/A';
    } else {
        $price_uvp = $p->getPriceUVP();
        $price_default = $p->getPriceDefault();
        $price_selling_old_amazon = $p->getPriceSellingOld($sp_id_amazon);
        $price_selling_amazon = $p->getPriceSelling($sp_id_amazon);
        $mat_exp = $p->material_expense;
        $cogs = $p->getProductCOGSValue();
        $report_cogs_lastyear = ReportCOGS::retrieveSummaryByArticles($pids, '*', $last_year_start, $last_year_end);
        $report_cogs_thisyear = ReportCOGS::retrieveSummaryByArticles($pids, '*', $this_year_start, $this_year_end);
    }
    foreach ($p->articles as $aid => $a) {
        if ($p->isArticleKilled($aid)) {
            continue;
        }
        $article_counter++;
        $ean = $p->getEAN($aid);
        $size = $p->getLengthOrSizeAsText($aid);
        if ($show_minimum_data) {
            $stock_available = 'N/A';
Example #3
0
     $e = new element($pue['elements_id']);
     if ($e->attributes['category']['id'] == '5') {
         $matname = explode(', ', $e->attributes['material']['name']);
         $stones_mats[$matname[0]] += $pue['quantity'];
         $stones_sizes[$e->attributes['size']['name']] += $pue['quantity'];
     }
 }
 if (count($stones_mats) > 0) {
     $stones_bq = max($stones_mats);
     $materials_stone = array_search($stones_bq, $stones_mats);
 }
 if (count($stones_sizes) > 0) {
     $stones_bq = max($stones_sizes);
     $materials_stone_size = array_search($stones_bq, $stones_sizes);
 }
 $cost_price = $obj_product->isPriceSellingUsingDiscount($jng_sp_id) ? $obj_product->getPriceSelling($jng_sp_id) : $obj_product->getPriceSellingOld($jng_sp_id);
 $row = array();
 $row[] = 'X';
 $row[] = $ean;
 $row[] = '';
 //EAN rule checker
 $row[] = $pdata['p']['products_brand_name'];
 $row[] = $pdata['p']['products_model'] . ($length > 0 ? '_' . textLength($length, false) : '');
 $row[] = $pdata['categories_name'];
 $row[] = $class_pm->displayProductName($pid);
 $row[] = '';
 //Serie
 $row[] = '';
 //Color Numbers
 $row[] = implode(', ', $colors);
 $row[] = implode(',', $materials);
 }
 //Quantity
 if ($category_top_id == '1') {
     if ($category_id == '29') {
         if ($a['length'] > 4.6 && $a['length'] < 6.0) {
             $row[] = $p->retrieveStockQuantity($aid);
         }
     } else {
         $row[] = $p->retrieveStockQuantity(0);
     }
 } else {
     $row[] = $p->retrieveStockQuantity($aid);
 }
 //Price
 $price = $p->getPriceSelling($jng_sp_id);
 $price_old = $p->getPriceSellingOld($jng_sp_id);
 if ($price_old <= $price) {
     $row[] = $price;
 } else {
     $row[] = $price_old;
 }
 //SalePrice
 if ($price_old <= $price) {
     //show blank if its not discounted
     $row[] = '';
 } else {
     $row[] = $price;
 }
 //SaleStartDate
 if ($price_old <= $price) {
     $row[] = '';
/**
 * 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;
}