<?php $back_names[] = "cl_call"; $back_names[] = "cl_call2"; $back_names[] = "cl_call3"; $back_names[] = "cl_call4"; $back_names[] = "cl_call5"; $dt_id = $this->request['deal_type']; $d_id = $this->request['deal']; $todo = $this->request['todo']; // trade class $trade = new trade(); $trade->sp = $this->sp; $trade->mysqli = $this->mysqli; $trade->user = $this->user; // vars for product margin $trade->m_basic = $trade->get_basic_margins(); $trade->margin_groups = $trade->get_margin_groups(); $trade->m_groups_basic = $trade->get_basic_groups_margin();
function sell_price_selector($pr_id, $d_id) { $deal = trade::get_deal_properties($d_id); $existance = trade::get_product_existance($pr_id); $margin = trade::get_margins_by_product($pr_id); $m_basic = trade::get_basic_margins(); $margin_groups = trade::get_margin_groups(); $m_groups_basic = trade::get_basic_groups_margin(); $product = basemng::get_product_info($pr_id); //for every mergin group ( now- partner ) $m_basic_abs = $m_basic['abs']; $m_basic_prc = $m_basic['prc']; // start price // if have a USD price if (isset($existance['maxprice'][2]['price'])) { // rate $rate = (int) $this->sp['usd_rate'] / 100; // start price $start_price = $existance['maxprice'][2]['price'] * $rate; $max_price = $start_price; $min_price = $existance['minprice'][2]['price'] * $rate; } else { $start_price = (int) $existance['maxprice'][1]['price']; $max_price = $start_price; $min_price = $existance['minprice'][1]['price']; } // incoming price if ($max_price == $min_price and $max_price != '') { $prod_price = "Закупочная цена :" . trade::getprice($max_price) . " Грн"; } if ($max_price != $min_price) { $prod_price = "Закупочная цена : от " . trade::getprice((int) $min_price) . " до " . trade::getprice((int) $max_price) . " Грн"; } if (!$max_price) { $prod_price = "Закупочная цена : неизвестна "; } $pr_fix = trade::get_absolute_prod_price($pr_id); if ($pr_fix) { $sell_price = $pr_fix; $margin_msg = "Установлена фиксированная цена"; } else { if ($start_price > 0) { // by margin group cycle foreach ($margin_groups as $mg_id => $mg_name) { $m_all_mg_abs = $m_groups_basic[$mg_id][2]['val']; $m_all_mg_prc = $m_groups_basic[$mg_id][3]['val']; $m_pr_mg_abs = $margin[$mg_id][9]['val']; $m_pr_mg_prc = $margin[$mg_id][10]['val']; $m_pr_mg_fix = $margin[$mg_id][11]['val']; if (!$m_pr_mg_fix) { // margin ! // basic margin $price = $start_price + $m_basic_abs; $price = $price + (int) ($price * $m_basic_prc) / 10000; // by margin group for all products $price1 = $price; $price = $price + $m_all_mg_abs; $price = $price + (int) ($price * $m_all_mg_prc / 10000); // by margin groups for this product $price = $price + $m_pr_mg_abs; $price = $price + (int) ($price * $m_pr_mg_prc / 10000); } else { $price = $m_pr_mg_fix; } // fixed price for product by margin group $price = (int) $price; // sell mng for current partner ( margin group ) $_2p_selection = ''; if ($mg_id == trade::get_margin_group_by_partner($deal['2p_id'])) { $sell_price = trade::getprice($price); $_2p_selection = "bgcolor='#88bbaa'"; } // generate form $m_action = "\$('#sell_price').val('" . trade::getprice($price) . "');"; $m_form_names .= "<td width=10% " . $_2p_selection . " onclick=\"" . $m_action . "\" ><div><font class='microfont'>" . $mg_name . "</font></div></td>"; $m_form_prices .= "<td width=10% " . $_2p_selection . " onclick=\"" . $m_action . "\" ><div id='mg_" . $mg_id . "_price'>" . trade::getprice($price) . "</div></td>"; } $margin_msg = "<table class='multitable'><tr>" . $m_form_names . "</tr><tr>" . $m_form_prices . "</tr></table>"; } else { $margin_msg = "Нет закупочной цены для наценки"; } } // main sell selector // product existance form $product_existance_form = "Количество всего: " . (int) $existance['exist'] . "\n\t\t<table class='multitable'><tr><td>Склад</td><td>План.</td><td>Едет</td><td>Отлож.</td></tr>\n\t\t<tr><td>" . (int) $existance['stored'] . "</td><td>" . (int) $existance['planned'] . "</td><td>" . (int) $existance['purchased'] . "</td><td>" . (int) $existance['saved'] . "</td></tr></table>"; //sell price area $selling_price_box = "<input type='text' size='7' maxlength='7' id='sell_price' class='input_text' value='" . $sell_price . "'>"; $sell_price_area = $prod_price . "<br> Продать за " . $selling_price_box; $main_sell_selector = "<table><tr valign='top'><td><div id='product_existance'>" . $product_existance_form . "</div></td><td>" . $sell_price_area . "</td></tr></table>\n\t\t"; // $product_table_sell_selector foreach ($existance['places'] as $pl_id => $val) { $place = trade::get_place_properties_by_id($pl_id); $out[$pl_id] .= "Склад '" . $place['pl_name'] . "'<br><table class='multitable' >"; foreach ($val as $i_id => $prop) { if ($style == 'multitable2' or $style == '') { $style = 'multitable1'; } else { $style = 'multitable2'; } $add_act = "onclick=\"x_cl_call5('trade','insert_item_to_list'," . $i_id . "," . $d_id . ",\$('#sell_price').val(),1," . $pr_id . ",'show_result');\""; if ($prop['is_id'] == 1 or $prop['is_id'] == 2 or $prop['is_id'] == 3) { $add_butt = "<button class='button' " . $add_act . " ><img class='menu_img' src='/img/site/add.png'></button>"; } else { $add_butt = ''; } $out[$pl_id] .= "<tr class='" . $style . "'><td width=60px>" . $prop['serial'] . "</td><td>" . $prop['desc'] . "</td><td width=130px>" . $prop['owner'] . "</td><td width=100px>" . $prop['status'] . "</td><td width=2%>" . $add_butt . "</td></tr>"; } $out[$pl_id] .= "</table>"; } $product_table_sell_selector = implode($out); $pr_foto = basemng::get_product_foto($pr_id); $pr_foto = "<div class='prod_small_foto'>" . $pr_foto . "</div>"; // full selling product form $ans = "<table width=130%>\n\t\t<tr><td><table><tr><td>" . $pr_foto . "</td><td><h3>" . $product['NAME'] . "</h3></td></tr></table></td></tr>\n\t\t<tr><td>" . $main_sell_selector . "</td></tr>\n\t\t<tr><td>" . $margin_msg . "</td></tr>\n\t\t<tr><td><div id='product_table_sell_selector'>" . $product_table_sell_selector . "</div></td></tr>\n\t\t</table>\n\t\t"; return $ans; }