function debit_procurement_table($d_id) { $sql = "SELECT \r\t\tPRODUCTS.PR_ID,\r\t\tITEMS.I_ID,\r\t\tDEAL_ITEMS_LIST.DIL_CUR_ID,\r\t\tCURRENCIES.CUR_NAME,\r\t\tPRODUCTS.PR_NAME,\r\t\tPRODUCTS.PR_SDESC,\r\t\tDEAL_ITEMS_LIST.DIL_PRICE\r\t\tFROM DEALS\r\t\tINNER JOIN DEAL_ITEMS_LIST ON DEAL_ITEMS_LIST.DIL_D_ID = DEALS.D_ID\r\t\tINNER JOIN ITEMS ON ITEMS.I_ID = DEAL_ITEMS_LIST.DIL_I_ID\r\t\tINNER JOIN PRODUCTS ON PRODUCTS.PR_ID = ITEMS.I_PR_ID\r\t\tINNER JOIN CURRENCIES ON CURRENCIES.CUR_ID = DEAL_ITEMS_LIST.DIL_CUR_ID\r\t\tWHERE DEALS.D_ID=" . $d_id . ";"; $result = $this->mysqli->query($sql); if ($result) { while ($row = $result->fetch_row()) { $pr_id = $row[0]; $i_id = $row[1]; $cur_id = $row[2]; $cur_name = $row[3]; $pr_name = $row[4]; $pr_sdesc = page::trim_str($row[5], 60); $dil_price = $row[6]; $sum = $sum + $row[6]; $pr_foto = basemng::get_product_foto($pr_id); $pr_foto = "<div class='prod_small_foto'>" . $pr_foto . "</div>"; //group $tab[$pr_id]['name'] = $pr_name; $tab[$pr_id]['sdesc'] = $pr_sdesc; $tab[$pr_id]['sum'] = $tab[$pr_id]['sum'] + $dil_price; $tab[$pr_id]['count']++; $tab[$pr_id]['foto'] = $pr_foto; $tab[$pr_id]['cur_name'] = $cur_name; } } if ($tab) { foreach ($tab as $pr_id => $val) { //average price per position $pr_price = (int) ($val['sum'] / $val['count']); if ($style == 'multitable2' or $style == '') { $style = 'multitable1'; } else { $style = 'multitable2'; } //curency change alert if (!isset($currency)) { $currency = $val['cur_name']; } elseif ($currency != $val['cur_name']) { $cur_alert = "Внимание Разные валюты !"; } $tbl .= "<tr class='" . $style . "' onclick=\"\"><td>" . $val['foto'] . "</td><td>" . $val['name'] . "</td><td>" . $val['sdesc'] . "</td><td>" . trade::getprice($pr_price) . " " . $val['cur_name'] . "</td><td>" . $val['count'] . "</td><td>" . trade::getprice($val['sum']) . "</td></tr>"; } $tbl .= "<tr><td></td><td></td><td><b>Сумма :</b></td><td><b>" . $summ . "</b></td></tr>"; $out .= "<div id='list_table'><table class='multitable' ><tr><th>Фото</th><th>Модель товара</th><th>Краткое описание</th><th>Цена за единицу</th><th>Кол-во</th><th>Всего</th></tr>" . $tbl . "</table></div>"; } else { $out .= "Список пуст"; } return $out; }
function show_multitable($pc_id) { $this->rec_tbl_prods_in_cat($pc_id); if ($this->cattable) { foreach ($this->cattable as $pr_id => $pr_name) { $product = $this->get_product_info($pr_id); $pr_sdesc = implode(array_slice(explode('<br>', wordwrap($product['SDESC'], 280, '<br>', false)), 0, 1)); $pr_sdesc = $pr_sdesc != $product['SDESC'] ? $pr_sdesc . '...' : $pr_sdesc; $pr_foto = basemng::get_product_foto($pr_id); $pr_foto = "<div class='prod_small_foto'>" . $pr_foto . "</div>"; if ($style == 'multitable2' or $style == '') { $style = 'multitable1'; } else { $style = 'multitable2'; } $tbl .= "<tr class='" . $style . "' onclick=\"sel_pr('" . $pr_id . "')\"><td>" . $pr_foto . "</td><td>" . $pr_name . "</td><td>" . $pr_sdesc . "</td></tr>"; } } $out = $tbl ? "<table id='multutable' class='multitable'><tr><th>Фото</th><th width=30%>Наименование</th><th>Краткое описание</th></tr>" . $tbl . "</table>" : "Каталог пуст"; return $out; }
<?
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; }