function deal_list_table($d_id, $nds) { $deal = $this->get_deal_properties($d_id); // get deal properties $sql = "SELECT \n\t\tPRODUCTS.PR_ID,\n\t\tPRODUCTS.PR_NAME,\n\t\tPRODUCTS.PR_SDESC,\n\t\tDEAL_ITEMS_LIST.DIL_PRICE,\n\t\tDEAL_ITEMS_LIST.DIL_PRI\n\t\tFROM DEALS\n\t\tINNER JOIN DEAL_ITEMS_LIST ON DEAL_ITEMS_LIST.DIL_D_ID = DEALS.D_ID\n\t\tINNER JOIN PRODUCTS ON PRODUCTS.PR_ID = DEAL_ITEMS_LIST.DIL_PR_ID\n\t\tWHERE DEAL_ITEMS_LIST.DIL_D_ID=" . $d_id . " ORDER BY DEAL_ITEMS_LIST.DIL_PRI , DEAL_ITEMS_LIST.DIL_ID;"; $result = $this->mysqli->query($sql); if ($result) { while ($row = $result->fetch_row()) { $pr_id = $row[0]; $pr_name = $row[1]; $pr_sdesc = $row[2]; $dil_price = $row[3]; $dil_pri = $row[4]; $sum = $sum + $row[3]; //group $tab[$pr_id]['name'] = $pr_name; $tab[$pr_id]['sdesc'] = $pr_sdesc; //$tab[$pr_id]['sdesc']=$this->trim_str($pr_sdesc,60); $tab[$pr_id]['sum'] = $tab[$pr_id]['sum'] + $dil_price; $tab[$pr_id]['count']++; $tab[$pr_id]['pri'] = $dil_pri; } } if ($tab) { foreach ($tab as $pr_id => $val) { //average price per position $pr_price = (int) ($val['sum'] / $val['count']); $tbl .= "\n<tr class='printtable_row'><td>" . $val['pri'] . "</td><td>" . $val['name'] . "</td><td><div class='prod_desc'>" . $val['sdesc'] . "</div></td><td>" . $this->getprice($pr_price) . " " . $val['cur_name'] . "</td><td>" . $val['count'] . "</td><td>" . trade::getprice($val['sum']) . "</td></tr>"; $all_sum = $all_sum + $val['sum']; } $sum = $all_sum; $sum_show = $this->getprice($sum); $ndss = $sum * $this->sp['nds_percent'] / 100; $nds_round = (int) $ndss; $nds_show = $this->getprice($nds_round); $total = $sum + $ndss; $total_round = (int) $total; $total_show = $this->getprice($total_round); $tbl .= "\n<tr><td colspan='5' align=right>Сумма :</td><td align='right'>" . $sum_show . " Грн</td></tr>"; $ans['sum_str'] = $this->num2str($sum_show); if ($nds) { $tbl .= "\n<tr><td colspan='5'align=right >НДС " . $this->sp['nds_percent'] . "%:</td><td align='right'>" . $nds_show . " Грн</td></tr>"; $tbl .= "\n<tr><td colspan='5' align=right><b>Итого :</b></td><td align='right'><b>" . $total_show . " Грн</b></td></tr>"; $ans['sum_str'] = $this->num2str($total_show); } $table = "\n<div id='list_table'><table class='printtable' ><tr><th width=20px>№</th><th width=130px>Модель</th><th width=420px>Краткое описание</th><th>Цена за единицу</th><th width=20px>Кол-во</th><th width=110px>Всего</th></tr>" . $tbl . "</table></div>"; } $ans['table'] = $table; return $ans; }
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 basic_margin_form() { $abs_margin_abs_val_box = "<input type='text' size='7' maxlength='7' id='abs_margin_abs_val' class='input_text' onchange=\"x_cl_call2('trade','save_basic_margin',\$('#abs_margin_abs_val').val(),1,'show_result');\" value='" . trade::getprice(trade::get_margin_by_id(1)) . "'>"; $abs_margin_prc_val_box = "<input type='text' size='7' maxlength='7' id='abs_margin_prc_val' class='input_text' onchange=\"x_cl_call2('trade','save_basic_margin',\$('#abs_margin_prc_val').val(),2,'show_result');\" value='" . trade::getprice(trade::get_margin_by_id(2)) . "'>"; $abs_margin_form = "Базовая абсолютная :" . $abs_margin_abs_val_box . "Грн + Процентная :" . $abs_margin_prc_val_box . "%"; $partners_margin_form = $this->margin_by_partners_table(); // check direct url if ($this->request['marginproduct'] != '') { $this->a('margin_management.php'); $prod_margin = $this->margin_by_product_form($this->request['marginproduct']); } $prod_margin = $prod_margin ? $prod_margin : "<div align=center>товар не выбран</div>"; $ans .= "<table>\r\t\t<tr></td><div class='headpost'>Наценки на все товары</div></td></tr>\r\t\t<tr></td>" . $abs_margin_form . "</td></tr>\r\t\t<tr></td>" . $partners_margin_form . "</td></tr>\r\t\t<tr></td><hr></td></tr>\r\t\t<tr></td><div class='headpost'>Наценка на выбранный товар:</div></td></tr>\r\t\t<tr></td><div id='product_margin'>" . $prod_margin . "</td></tr></table>"; return $ans; }
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; }