function getDisplay($pid, $spid, $amvd_provision_rate, $row_class = 'o') { global $class_jc; $result = ''; $obj_product = new Product($pid); $have_amvd_catalog = $obj_product->isAddedToSalesPartner($spid); $is_active = $obj_product->isActiveInSalesPartner($spid); $products_image = $obj_product->displayImage(IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1); $info = '<div style="margin-bottom:20px;">' . $obj_product->displayIDAndCode() . '</div>'; $info .= '<div class="w150" style="margin:0 auto;">' . $obj_product->displayRecentSoldTable() . '</div>'; $navids = array('0' => 'Please select a navigation...'); $navids_opts = retrieveNavIDs($spid, 'bn'); foreach ($navids_opts as $n_id => $n_name) { //if doesn't work in dev environment, it could be caused by umlauts //in the navigation name. Can be fixed by adding htmlspecialchars or //but we don't need it for live (sahat- 16.09.2014) $navids[$n_id] = $n_name; } $navid = $have_amvd_catalog ? $obj_product->getSalesPartnerMainNavigationID($spid) : null; $navigation = '<select class="navigation input">' . loadComboListFromArray($navids, null, $navid, false) . '</select>'; $result .= '<tr id="' . $pid . '" class="' . $row_class . '">'; $result .= '<td class="img">' . $products_image . '</td>'; $result .= '<td class="name">' . $info . '</td>'; $result .= '<td class="pb">' . $navigation . '</td>'; $btn_update_text = $is_active ? 'Update' : 'Activate'; $btn_add = '<input type="button" style="width:90px;" class="add button blue" value="Add" title="Add this product to AM.VD Catalogue"/>'; $btn_update = '<input type="button" style="width:90px;" class="update button blue" value="' . $btn_update_text . '" title="Update and activate this product on AM.VD Catalogue"/>'; $btn_ignore = '<input type="button" style="width:90px;" class="ignore button" value="Ignore" title="Ignore from list"/>'; $btn_deactivate = '<input type="button" style="width:90px;" class="deactivate button blue" value="Deactivate" title="Deactivate or remove from AM.VD catalog"/>'; $i_hidden = '<input type="hidden" name="jcid" value="' . $obj_product->getSalesPartnerCatalogID($spid) . '"/>'; if ($have_amvd_catalog) { $btn = $i_hidden . $btn_update . '<br/>' . $btn_deactivate; } else { $btn = $btn_add . '<br/>' . $btn_ignore; } $result .= '<td class="act">' . $btn; $result .= '<input type="hidden" class="pid" value="' . $pid . '"/>'; $result .= '</td>'; $result .= '</tr>'; return $result; }
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"> </div>' . '<div class="cr cr-option notice">-</div>' . '<div class="cr cr-preview"> </div>' . '<div class="cr cr-cogs">' . $cogs . '</div>' . '<div class="cr cr-profit"> </div>' . '<div class="cr cr-margin"> </div>' . '<div class="cr cr-premium"> </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"> </div>' . '<div class="cr cr-option">' . sprintf($price_options_combo, $price_option_jng) . $sp_id_jng . '</div>' . '<div class="cr cr-preview"> </div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit"> </div>' . '<div class="cr cr-margin"> </div>' . '<div class="cr cr-premium"> </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"> </div>' . '<div class="cr cr-option">' . sprintf($price_options_combo, $price_option_sp) . $sp_id . '</div>' . '<div class="cr cr-preview"> </div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit"> </div>' . '<div class="cr cr-margin"> </div>' . '<div class="cr cr-premium"> </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 = ' '; $status_disc = ' '; $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"> </div>' . '<div class="cr cr-disc notice">-</div>' . '<div class="cr cr-option notice">-</div>' . '<div class="cr cr-preview"> </div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit"> </div>' . '<div class="cr cr-margin"> </div>' . '<div class="cr cr-premium"> </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"> </div>' . '<div class="cr cr-disc"> </div>' . '<div class="cr cr-option">' . $b2b_disc_status . $sp_id . '</div>' . '<div class="cr cr-preview"> </div>' . '<div class="cr cr-cogs notice">' . $cogs . '</div>' . '<div class="cr cr-profit"> </div>' . '<div class="cr cr-margin"> </div>' . '<div class="cr cr-premium"> </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; }
$spid = strtoupper(tep_db_prepare_input($_POST['spid'])); $products_id = tep_db_prepare_input($_POST['pid']); $week_start = str_ireplace('week', '-', tep_db_prepare_input($_POST['start_week'])); $week_end = str_ireplace('week', '-', tep_db_prepare_input($_POST['end_week'])); $p = $class_pm->retrieveDetail($products_id, 'p'); $not_available_text = '<span class="notice">N/A</span>'; $result = '<div id="box-' . $products_id . '" class="float-left ui-corner-all" style="margin:10px 10px 0 0; padding:10px; border:solid 1px #ccc;">'; if ($p['p'] !== false) { //Get Product Info $product = new Product($products_id); $product_info = "{$product->id}/{$product->code}"; $result .= ' <div class="tac">'; $result .= $product->displayImage(IMAGE_SIZE_THUMBNAIL_2, IMAGE_SIZE_THUMBNAIL_2); $link_product = '<a href="?open=product-detail&hidemenu=true&products_id=' . $products_id . '" class="view_webpage"> ' . $product_info . '</a>'; $result .= ' <br/>' . $link_product; if ($product->isAddedToSalesPartner($spid) || $spid == 'ALL') { $cogs = $product->getProductCOGSValue(); //Get price selling if ($spid == 'ALL') { $price_selling = $product->getPriceDefault(); } else { $price_selling = $product->getPriceSelling($spid); } //Get total sold $total_sold = $not_available_text; if ($spid > 0 || $spid == 'ALL') { $total_sold = $class_jc->getTotalSold($products_id, $spid); } //Get net price per type of sp (B2C or B2B) if (in_array($spid, $sp_b2b_ids)) { $net_price = $price_selling;