//$content .= '<br /><span class="smallText red">* we disable update because we need the original value for generating reports</span>';
 $content .= '</td>';
 $content .= '</tr><tr>';
 $content .= '<td>Date Last Modified</td>';
 $content .= '<td>' . date('d.m.Y H:i:s', strtotime($products['products_last_modified']));
 //$content .= '<td><input type=text" value="'.date('d.m.Y H:i:s', strtotime($products['products_last_modified'])).'" class="input" readonly="readonly" />';
 //$content .= ' <input type="text" class="date_picker" name="products_last_modified" value="'.$last_modified.'" readonly="readonly" />';
 //$content .= ' <input type="text" class="time" name="products_last_modified_time" value="'.$last_modified_time.'" readonly="readonly" />';
 //$content .= ' <small>(YYYY-MM-DD Hour:Min:Sec)</small>';
 //$content .= '<br /><span class="smallText red">* value will be updated automatically when this tab is saved</span>';
 $content .= '</td>';
 $content .= '</tr>';
 $content .= '<tr><td colspan="2"><hr /></td></tr>';
 $content .= '<tr>';
 $content .= '<td>Default Price (UVP)</td>';
 $content .= '<td>' . displayCurrency(CURRENCY_DEFAULT, $obj_product->getPriceUVP());
 $content .= '</td>';
 //$content .= '<td><input type="text" name="products_price_uvp" value="'.$products['products_price_uvp'].'" class="input" readonly="readonly" /> <span class="info">EUR</span></td>';
 $content .= '</tr>';
 $content .= '<tr>';
 $content .= '<td>Default Selling Price</td>';
 $content .= '<td>' . displayCurrency(CURRENCY_DEFAULT, $obj_product->getPriceDefault()) . '</td>';
 //$content .= '<td><input type="text" name="products_price_default" value="'.$products['products_price_default'].'" class="input" readonly="readonly" /> <span class="info">EUR</span></td>';
 $content .= '</tr>';
 if ($products['products_price_uvp'] > $products['products_price_default']) {
     $des_discount = ($products['products_price_uvp'] - $products['products_price_default']) / $products['products_price_uvp'];
     $content .= '<tr>';
     $content .= '<td>Default Discount</td>';
     $content .= '<td>' . round($des_discount * 100, 0) . '%</td>';
     $content .= '</tr>';
 }
Example #2
0
function sp_addProductToCatalog($jng_sp_id, $product_id)
{
    use_class('Product');
    use_class('jng_sp');
    use_class('products_minierp');
    use_class('jng_sp_catalog');
    use_class('jng_sp_catalog_params');
    $class_sp = new jng_sp();
    $class_pm = new products_minierp();
    $class_jc = new jng_sp_catalog();
    $class_jcp = new jng_sp_catalog_params();
    $sp_detail = $class_sp->retrieveDetail($jng_sp_id);
    $sp_used_selling_points = getSalesPartnerUseSellingPoint();
    $sp_used_selling_points_amde = getSalesPartnerUseSellingPoint(true);
    if (!is_array($product_id)) {
        $product_id = explode(',', $product_id);
    }
    $new_id = array();
    foreach ($product_id as $pid) {
        $check_exist = $class_jc->retrieveDetail(null, $jng_sp_id, $pid);
        if ($check_exist === false) {
            $obj_product = new Product($pid);
            $product_data_raw = $class_pm->retrieveDetail($pid);
            $products_selling_points = '';
            $psp = $product_data_raw['pd'][2]['products_selling_points'];
            $pspa = $product_data_raw['pd'][2]['products_selling_points_amde'];
            if (in_array($jng_sp_id, $sp_used_selling_points)) {
                $products_selling_points = $psp;
            } elseif (in_array($jng_sp_id, $sp_used_selling_points_amde)) {
                $products_selling_points = $pspa;
            }
            if (!is_null($obj_product->id)) {
                $desc = $product_data_raw['pd'][$sp_detail['languages_id']];
                $product = array();
                $product['products_length'] = $product_data_raw['pnc']['products_length'];
                $product['products_name'] = $desc['products_name'];
                $product['products_description'] = $desc['products_description'];
                $product['products_head_keywords_tag'] = $desc['products_head_keywords_tag'];
                $article_number = str_replace('-', '_', $obj_product->code);
                $price_uvp = $obj_product->getPriceUVP();
                $price_default = $obj_product->getPriceDefault();
                //TODO: USE B2B FLAG
                if ($jng_sp_id == '5') {
                    $product_price = $obj_product->getPriceSellingDefaultB2B($price_uvp, $jng_sp_id);
                    $product_price_old = 0;
                    $product_price_new = 0;
                    $active_status = '1';
                } else {
                    $product_price = $price_default;
                    $product_price_old = $price_uvp > $price_default ? $price_uvp : 0;
                    $product_price_new = 0;
                    $active_status = '0';
                }
                $product_name = $product['products_name'];
                $product_desc = $product['products_description'];
                $keywords_ok = array();
                $keywords_temp = str_replace('|||', ',', $product['products_head_keywords_tag']);
                $keywords_split = explode(',', $keywords_temp);
                foreach ($keywords_split as $kws) {
                    $kws = trim($kws);
                    if ($kws != '') {
                        $rule1 = strpos($product_name, $kws) === false;
                        $rule2 = strpos($product_desc, $kws) === false;
                        $rule3 = strpos($kws, 'cm') === false;
                        if ($rule1 && $rule2 && $rule3) {
                            $keywords_ok[] = $kws;
                        }
                    }
                }
                $product_keywords = count($keywords_ok) > 0 ? implode(', ', $keywords_ok) : '';
                $product_length = $product['products_length'] == '' ? '0' : $product['products_length'];
                //Retrieve Products Color and connect it with SP Colors
                $color_pattern_id = $class_pm->loadColorPattern($obj_product->id);
                $sp_params_raw = $class_jcp->load($jng_sp_id, 'C');
                $sp_params = array();
                foreach ($sp_params_raw as $spr) {
                    if (in_array($spr['param_id'], $color_pattern_id)) {
                        $sp_params[] = $spr['param_value'];
                    }
                }
                $product_color = implode(', ', $sp_params);
                //Retrieve Products Materials and connect it with SP Materials
                $products_materials_id = $class_pm->loadProductMaterials($obj_product->id);
                $sp_params_raw = $class_jcp->load($jng_sp_id, 'M');
                $sp_params = array();
                foreach ($sp_params_raw as $spr) {
                    if (in_array($spr['param_id'], $products_materials_id)) {
                        $sp_params[] = $spr['param_value'];
                    }
                }
                $product_material = implode(', ', $sp_params);
                $date_added = date('Y-m-d H:i:s');
                //Retrieve Max Resourcing Days
                $elmax_rd_query = "SELECT pe.products_id, MAX(es.resourcing_day) AS max_res_day";
                $elmax_rd_query .= " FROM products_use_elements pe";
                $elmax_rd_query .= " LEFT JOIN elements_stock es ON es.elements_id=pe.elements_id";
                $elmax_rd_query .= " WHERE pe.products_id = {$obj_product->id}";
                $elmax_rd_query .= " GROUP BY pe.products_id";
                $elmax_rd_result = tep_db_query($elmax_rd_query);
                $elmax_rd = tep_db_fetch_array($elmax_rd_result);
                $resplacement_days = $elmax_rd['max_res_day'] == '' ? '0' : $elmax_rd['max_res_day'];
                //INSERT DATA
                $sda = array('jng_sp_id' => $jng_sp_id, 'products_id' => $obj_product->id, 'article_number' => $article_number, 'price' => $product_price, 'price_old' => $product_price_old, 'price_new' => $product_price_new, 'name' => $product_name, 'description' => $product_desc, 'keywords' => $product_keywords, 'length' => $product_length, 'color' => $product_color, 'material' => $product_material, 'use_logo' => '1', 'status_image' => '0', 'date_added' => $date_added, 'replacement_days' => $resplacement_days, 'products_selling_points' => $products_selling_points, 'active_status' => $active_status);
                tep_db_perform('jng_sp_catalog', $sda);
                $new_id[] = tep_db_insert_id();
            }
        }
    }
    return $new_id;
}
function shopifyTemplate($is_article, $product_id, $var_ean, $var_length, $add_images)
{
    global $class_pm, $class_pmat, $class_pa, $r;
    $product_materials_name = '';
    //    $product = $class_pm->retrieveDetail($product_id, 'p,pd,pd2,pc,pnc,cat,pei,pci');
    $product = Product::getOldProductFunction()->retrieveDetail($product_id, 'p,pd,pd2,pc,pnc,cat,pei,pci');
    $product_name = $product['pd'][3]['products_name'];
    $product_name_handle = strtolower(str_replace(' ', '-', $product_name));
    $product_articles = $class_pa->retrieveList($product_id);
    $product_articles_total = count($product_articles);
    //    $product_stock = $class_pm->stockRetrieve(WAREHOUSE_ID_PRODUCTS_HAMBURG, $product_id, '*');
    $product_stock = Product::getOldProductFunction()->stockRetrieve(WAREHOUSE_ID_PRODUCTS_HAMBURG, $product_id, '*');
    $product_obj = new Product($product_id);
    //$product_price_uvp = $product['p']['products_price_uvp'];
    $product_price_uvp = $product_obj->getPriceUVP();
    //    $product_price_default = $product['p']['products_price_default'];
    $product_price_default = $product_obj->getPriceDefault();
    $main_image = webImageSource($product['p']['products_image']);
    //    $product_gender = $class_pm->productGenderName($product['p']['products_gender']);
    $product_gender_id = $product['p']['products_gender'];
    if ($product_gender_id == 1) {
        $product_gender = 'Pria';
    } elseif ($product_gender_id == 2) {
        $product_gender = 'Wanita';
    }
    //$product_gender = Product::getOldProductFunction()->productGenderName($product['p']['products_gender']);
    //    $product_agegroup = $class_pm->productAgeGroupName($product['p']['products_agegroup']);
    $product_agegroup = Product::getOldProductFunction()->productAgeGroupName($product['p']['products_agegroup']);
    $cat_for_fashion = new Category($product['categories_id']);
    if ($product['categories_id'] < 36) {
        $product_categories = translateCategoriesToIndonesian($product['categories_id']);
    } else {
        $product_categories = $cat_for_fashion->getName('3');
    }
    //    $productLength = ($product['pc']['products_length'] !== false) ? $product['pc']['products_length']/10 : $product['pnc']['products_length']/10;
    if ($product['pc'] !== false) {
        $product_length = number_format($product['pc']['products_length'], 0);
        $length_code = '_' . number_format($product_length, 0);
        //        $product_length_for_var = 'One size'; //FOR NOW WE ALWAYS USE One Size for every Categories except ring
        if ($product['categories_id'] == 29) {
            $product_lenght_code = $product_length;
            $product_length = $product_length * 10;
            $length_code = '_' . $product_length;
        }
    } else {
        //if ($product['categories_id'] < 36) {
        //} else {
        $product_length = number_format($product['pnc']['products_length'], 0);
        $length_code = '_' . number_format($product_length, 0);
        //        $product_length_for_var = 'One size'; //FOR NOW WE ALWAYS USE One Size for every Categories except ring
        if ($product['categories_id'] == 29) {
            $product_lenght_code = $product_length;
            $product_length = $product_length * 10;
            $length_code = '_' . $product_length;
        }
        //}
    }
    if ($product_length == '0.00') {
        $length_code = '';
    }
    //    $productLength = ($product['pc'] !== false) ? $product['pc']['products_length'] : $product['pnc']['products_length'];
    if ($product['pd2']['width'] == '0.00') {
        $product_width = '';
    } else {
        $product_width = $product['pd2']['width'] / 10;
    }
    if ($product['pd2']['height'] == '0.00') {
        $product_height = '';
    } else {
        $product_height = $product['pd2']['height'] / 10;
    }
    if ($product['pd2']['weight'] == '0.00') {
        $product_weight = '';
    } else {
        $product_weight = $product['pd2']['weight'];
    }
    if ($product['pd2']['diameter'] == '0') {
        $product_diameter = '';
    } else {
        $product_diameter = $product['pd2']['diameter'] / 10;
    }
    $product_ean = $product['p']['products_ean'];
    $product_keywords = $product['pd'][3]['products_head_keywords_tag'];
    $product_description = $product['pd'][3]['products_description'];
    $product_brand = $product['p']['products_brand_name'];
    $product_selling_points = explode(';', $product['pd'][3]['products_selling_points']);
    $materials = $class_pmat->retrieveList('', 'material_name');
    //    $product_materials = $class_pm->loadProductMaterials($product_id);
    $product_materials = Product::getOldProductFunction()->loadProductMaterials($product_id);
    $separator = '';
    foreach ($materials as $mat) {
        if (in_array($mat['products_materials_id'], $product_materials)) {
            $materials_name = explode(',', $mat['material_name']);
            $product_materials_name .= $separator;
            $product_materials_name .= $materials_name[2];
            if (!$separator) {
                $separator = ',';
            }
        }
    }
    $query_color = "SELECT ptcp.products_id, ptcp.color_pattern_id, cpd.name FROM products_to_color_pattern ptcp";
    $query_color .= " LEFT JOIN color_pattern_description cpd ON cpd.color_pattern_id = ptcp.color_pattern_id";
    $query_color .= " WHERE ptcp.products_id = {$product_id} AND languages_id = 1";
    $query_color_result = tep_db_query($query_color);
    $product_color_row = mysql_fetch_row($query_color_result);
    $product_color = translateColorToIndonesian($product_color_row[1]);
    if ($is_article) {
        if ($product_articles_total > 0) {
            $product_ean = $var_ean;
            $product_length = $var_length * 10;
            $length_code = '_' . $var_length;
            if ($product['categories_id'] == 29) {
                $length_code = '_' . $var_length * 10;
            }
        }
    }
    if ($is_article || $add_images != '') {
        $product_name = '';
        $product_description = '';
        $product_brand = '';
    }
    $add_images != '' ? $main_image = webImageSource($add_images) : $main_image;
    $product_code = $product['p']['products_model'];
    $x = array();
    /*A - Handle     */
    $x[0][0] = $product_name_handle;
    /*B - Title */
    $x[0][1] = $add_images == '' ? $product_name : '';
    /*C - Body (HTML) */
    $x[0][2] = $add_images == '' ? $product_description : '';
    /*D - Vendor */
    $x[0][3] = $add_images == '' ? 'Bellinda Germany' : '';
    /*E - Type  */
    $x[0][4] = $add_images == '' ? $product_categories : '';
    /*F - Tags  */
    $x[0][5] = $add_images == '' ? $product_materials_name . ', ' . $product_color . ', ' . $product_gender : '';
    /*G - Published   */
    $x[0][6] = $add_images == '' ? 'TRUE' : '';
    /*H - Option1 Name    */
    $x[0][7] = $add_images == '' ? 'Product Length/Size' : '';
    /*I - Option1 Value  */
    $x[0][8] = $add_images == '' ? $product_length : '';
    /*J - Option2 Name  */
    $x[0][9] = $add_images == '' ? 'Color' : '';
    /*K - Option2 Value    */
    $x[0][10] = $add_images == '' ? $product_color : '';
    /*L - Option3 Name   */
    $x[0][11] = $add_images == '' ? 'Material' : '';
    /*M - Option3 Value    */
    $x[0][12] = $add_images == '' ? $product_materials_name : '';
    /*N - Variant SKU    */
    $x[0][13] = $add_images == '' ? $product_code . $length_code : '';
    /*O - Variant Gram    */
    $x[0][14] = $add_images == '' ? $product_weight : '';
    /*P - Variant Inventory Tracker*/
    $x[0][15] = $add_images == '' ? 'shopify' : '';
    /*Q - Variant Inventory Qty    */
    $x[0][16] = $add_images == '' ? '10' : '';
    /*R - Variant Inventory Policy  */
    $x[0][17] = $add_images == '' ? 'deny' : '';
    /*S - Variant Fulfillment Service    */
    $x[0][18] = $add_images == '' ? 'manual' : '';
    /*T - Variant Price    */
    $x[0][19] = $add_images == '' ? $product_price_default : '';
    /*U - Variant Compare At Price    */
    $x[0][20] = $add_images == '' ? $product_price_uvp : '';
    /*V - Variant Requires Shipping*/
    $x[0][21] = $add_images == '' ? 'TRUE' : '';
    /*W - Variant Taxable*/
    $x[0][22] = $add_images == '' ? 'TRUE' : '';
    /*X - Variant Barcode    */
    $x[0][23] = $add_images == '' ? $product_ean : '';
    /*Y - Image Src */
    $x[0][24] = $main_image;
    /*Z - Image Alt Text */
    $x[0][25] = $add_images == '' ? $product_name : '';
    /*AA - Gift Card */
    $x[0][26] = $add_images == '' ? 'FALSE' : '';
    /*AB - Google Shopping / MPN */
    $x[0][27] = '';
    /*AC - Google Shopping / Age Group */
    $x[0][28] = $add_images == '' ? $product_agegroup : '';
    /*AD - Google Shopping / Gender */
    $x[0][29] = $add_images == '' ? $product_gender : '';
    /*AE - Google Shopping / Google Product Category */
    $x[0][30] = '';
    /*AF - SEO Title */
    $x[0][31] = $add_images == '' ? $product_name : '';
    /*AG - SEO Description */
    $x[0][32] = $add_images == '' ? $product_keywords : '';
    /*AH - Google Shopping / AdWords Grouping*/
    $x[0][33] = '';
    /*AI - Google Shopping / AdWords Labels */
    $x[0][34] = '';
    /*AJ - Google Shopping / Condition */
    $x[0][35] = $add_images == '' ? 'new' : '';
    /*AK - Google Shopping / Custom Product */
    $x[0][36] = '';
    /*AL - Google Shopping / Custom Label 0 */
    $x[0][37] = '';
    /*AM - Google Shopping / Custom Label 1 */
    $x[0][38] = '';
    /*AN - Google Shopping / Custom Label 2 */
    $x[0][39] = '';
    /*AO - Google Shopping / Custom Label 3 */
    $x[0][40] = '';
    /*AP - Google Shopping / Custom Label 4 */
    $x[0][41] = '';
    /*AQ - Variant Image */
    $x[0][42] = $add_images == '' ? $main_image : '';
    /*AR - Variant Weight Unit */
    $x[0][43] = $add_images == '' ? 'g' : '';
    $csv_row = array();
    $csv_row['data'] = $x;
    //    $csv_row['temp_images'] = (!$is_article) ? $temp_images : '';
    return $csv_row;
}
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;
}
$range_products_header->getFont()->setBold(true);
$range_products_header->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB($table_header_bgcolor);
$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);
Example #6
0
 $row[] = $pdata['categories_name'];
 $row[] = $class_pm->displayProductName($pid);
 $row[] = '';
 //Serie
 $row[] = '';
 //Color Numbers
 $row[] = implode(', ', $colors);
 $row[] = implode(',', $materials);
 $row[] = $length > 0 ? textLength($length) : '';
 $row[] = '';
 //Special Size
 $row[] = 'DAMEN';
 //Gender
 $row[] = displayCurrency('EUR', $cost_price, false);
 //Cost Price
 $row[] = displayCurrency('EUR', $obj_product->getPriceUVP(), false);
 //UVP
 $row[] = '';
 //Saison
 $row[] = '';
 //Gefahrgut
 $row[] = '';
 //Gewicht der Batterie
 $row[] = '';
 //Packing (Height)
 $row[] = '';
 //Packing (Length)
 $row[] = '';
 //Packing (Width)
 $row[] = '';
 //Packing (Weight)
                 $class_jc->updateField($amvdcatid, $sda);
             }
         }
         $class_pm->saveDescription($pid, $languages_id, $pname, $pdesc, $pkeys, $pshortname, null, null, $topicname, $colname, null, null);
         $pda['name'] = $pname;
         $pda['description'] = $pdesc;
         $pda['keywords'] = $pkeys;
         $pda['status_price'] = '1';
         //$pda['products_selling_points'] = $pspoint;
         $pda['short_name'] = $pshortname;
         tep_db_perform('jng_sp_catalog', $pda, 'update', "products_id={$pid}");
     }
     $class_pm->updateFlagContentImproved($products_id, $improved_content);
     $class_pm->updateFlagImageImproved($products_id, $improved_image);
     $product = new Product($products_id);
     $price_uvp = $product->getPriceUVP();
     $price_default = $product->getPriceDefault();
     $is_finalized = $pname != '' && $pdesc != '' && $price_uvp > 0 && $price_default > 0;
     if ($is_finalized) {
         $draft->finalizeProduct($products_id, $session_userinfo['username']);
     } else {
         $draft->unfinalizeProduct($products_id);
     }
     echo utf8_encode($result);
     exit;
 } elseif ($_POST['me_action'] == "REASSIGNSELLINGPOINTS") {
     $products_id = tep_db_prepare_input($_POST['products_id']);
     $spoint_result = $class_pm->setSellingPointToProducts($products_id, null, true);
     $product = $class_pm->retrieveDetail($products_id, 'pd');
     $product_selling_points = explode(';', $product['pd']['2']['products_selling_points']);
     $product_selling_points_amde = explode(';', $product['pd']['2']['products_selling_points_amde']);