$detailed_view = Com_pred::open_old_kp($_GET['show_old_kp']); } if(isset($_GET['show_kp_in_blank'])){ $kp_id = (int)$_GET['show_kp_in_blank']; $rows = Com_pred::create_list($client_id,array('type'=>'new','kp'=>$kp_id)); $dont_show_rows = TRUE; $detailed_view = Com_pred::open_in_blank($kp_id,$client_id,$user_id,true); //$detailed_view .= '<a href="?'.$_SERVER['QUERY_STRING'].'&show_kp_in_blank='.$kp_id.'">open_in_blank</a>'; $detailed_view .= '<br><a href="?'.$_SERVER['QUERY_STRING'].'&save_in_pdf='.$kp_id.'">сохранить на диск</a>'; } /////////////////////////////////////// end Временно /////////////////////////////////////// if(isset($_GET['delete_com_offer'])){ if($_GET['old_version']) Com_pred::delete_old_version($_GET['delete_com_offer'],intval($_GET['client_id']),$_GET['id']/* must be string*/); else Com_pred::delete($_GET['delete_com_offer']); header('Location:?'.addOrReplaceGetOnURL('client_id='.$client_id,'delete_com_offer&old_version&id')); } // Собираем ряды для таблицы коммерческих предложений if(empty($dont_show_rows)) $rows = Com_pred::create_list($client_id); // Подключаем шаблон таблицы списка коммерческих предложений include ('skins/tpl/clients/client_folder/business_offers/list_table.tpl'); if(!empty($detailed_view)) echo $detailed_view; ?>
static function save_to_tbl($json) { global $mysqli; global $user_id; //echo $json; $data_obj = json_decode($json); // print_r($data_obj); // exit; //предварительно получаем данные о контактном лице прикрепленном к запросу $query = "SELECT client_face_id FROM `" . RT_LIST . "` WHERE `query_num` = '" . $data_obj->query_num . "'"; $result = $mysqli->query($query) or die($mysqli->error); $row = $result->fetch_assoc(); $recipient_id = $row['client_face_id']; // $data->ids - это двухмерный массив первый уровеннь которого содержит id строк из таблицы RT_MAIN_ROWS // второй уровень содержит id дочерних строк из таблицы RT_DOP_DATA // проходим в цикле этот массив и поочередно копируем данные из таблиц РТ в таблицы КП // записываем данные о КП в таблицу KP_LIST $query = "INSERT INTO `" . KP_LIST . "` \n\t\t\t\t\t\t\t SET \n\t\t\t\t\t\t\t `create_time` = NOW(),\n\t\t\t\t\t\t\t `client_id` = '" . $data_obj->client_id . "',\n\t\t\t\t\t\t\t `manager_id` = '" . $user_id . "',\n\t\t\t\t\t\t\t `theme` = '" . $data_obj->query_theme . "',\n\t\t\t\t\t\t\t `query_num` = '" . $data_obj->query_num . "',\n\t\t\t\t\t\t\t `recipient_id` = '" . $recipient_id . "'\n\t\t\t\t\t\t\t "; $result = $mysqli->query($query) or die($mysqli->error); if (!$result) { return 2; } $kp_id = $mysqli->insert_id; foreach ($data_obj->ids as $key => $dop_data) { // преобразуем объект в массив $dop_data = (array) $dop_data; if (count($dop_data) == 0) { continue; } // прежде чем данные в таблицы КП сверим совпадают ли количество в расчетах и в услугах // может получиться что они не совпадают ( было что-то не досохранено в РТ) // для этого делаем предварительные запросы к таблицам RT_DOP_DATA и RT_DOP_USLUGI foreach ($dop_data as $dop_key => $dop_val) { // RT_DOP_DATA $query_dop1 = "SELECT*FROM `" . RT_DOP_DATA . "` WHERE id = '" . $dop_key . "'"; //echo $query; $result_dop1 = $mysqli->query($query_dop1) or die($mysqli->error); if ($result_dop1->num_rows > 0) { $row_dop1 = $result_dop1->fetch_assoc(); //RT_DOP_USLUGI $query_dop2 = "SELECT*FROM `" . RT_DOP_USLUGI . "` WHERE dop_row_id = '" . $row_dop1['id'] . "'"; //echo $query; $result_dop2 = $mysqli->query($query_dop2) or die($mysqli->error); if ($result_dop2->num_rows > 0) { while ($row_dop2 = $result_dop2->fetch_assoc()) { if ($row_dop2['glob_type'] == 'print' && $row_dop2['quantity'] != $row_dop1['quantity']) { $reload['flag'] = true; //echo $dop_data['quantity']; include_once ROOT . "/libs/php/classes/rt_calculators_class.php"; $json_out = rtCalculators::change_quantity_and_calculators($row_dop1['quantity'], $row_dop1['id'], 'true', 'false'); $json_out_obj = json_decode($json_out); // если расчет не может быть произведен по причине outOfLimit или needIndividCalculation // сбрасываем количество тиража и нанесения до 1шт. if (isset($json_out_obj->print->outOfLimit) || isset($json_out_obj->print->needIndividCalculation)) { rtCalculators::change_quantity_and_calculators(1, $row_dop1['id'], 'true', 'false'); $query = "UPDATE `" . RT_DOP_DATA . "` SET `quantity` = '1' WHERE `id` = '" . $row_dop1['id'] . "'"; $result = $mysqli->query($query) or die($mysqli->error); } } if ($row_dop2['glob_type'] == 'extra' && $row_dop2['quantity'] != $row_dop1['quantity']) { $query = "UPDATE `" . RT_DOP_USLUGI . "` SET `quantity` = '" . $row_dop1['quantity'] . "' WHERE `id` = '" . $row_dop2['id'] . "'"; $result = $mysqli->query($query) or die($mysqli->error); } } } } } if (isset($reload['flag']) && $reload['flag'] == true) { header('Location:' . HOST . '/?' . $_SERVER['QUERY_STRING']); exit; } // Вставляем ряд в таблицу KP_MAIN_ROWS $query = "SELECT*FROM `" . RT_MAIN_ROWS . "` WHERE id = '" . $key . "'"; //echo $query; $rt_main_row_id = $key; $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $description = $row['description'] != '' ? 'описание: ' . $row['description'] : ''; if ($row['characteristics'] != '') { $arr = json_decode($row['characteristics'], TRUE); $ch_arr = array(); foreach ($arr as $key => $data) { if ($key == 'colors') { $ch_arr[] = 'цвет: ' . implode(', ', $data); } if ($key == 'materials') { $ch_arr[] = 'материал: ' . implode(', ', $data); } } $characteristics = count($ch_arr) > 0 ? implode('<br>', $ch_arr) : ''; } else { $characteristics = ''; } $query2 = "INSERT INTO `" . KP_MAIN_ROWS . "` \n\t\t\t\t\t\t\t SET \n\t\t\t\t\t\t\t `kp_id` = '" . $kp_id . "',\n\t\t\t\t\t\t\t `sort` = '" . $row['sort'] . "',\n\t\t\t\t\t\t\t `art` = '" . $row['art'] . "',\n\t\t\t\t\t\t\t `type` = '" . $row['type'] . "',\n\t\t\t\t\t\t\t `art_id` = '" . $row['art_id'] . "',\n\t\t\t\t\t\t\t `name` = '" . $row['name'] . "',\n\t\t\t\t\t\t\t `description` = '" . $row['description'] . "',\n\t\t\t\t\t\t\t `characteristics` = '" . mysql_real_escape_string($characteristics) . "',\n\t\t\t\t\t\t\t `img_folder` = '" . ($row['img_type'] == 'g_std' ? 'img' : $row['img_folder']) . "'\t\t\t\t\t\t\t \n\t\t\t\t\t\t\t "; $result2 = $mysqli->query($query2) or die($mysqli->error); $row_id = $mysqli->insert_id; // копируем выбранные для КП изображения $query7 = "SELECT * FROM `" . RT_MAIN_ROWS_GALLERY . "` WHERE `parent_id` = '" . $rt_main_row_id . "';"; $result7 = $mysqli->query($query7) or die($mysqli->error); // echo $query7.'<br>'; // echo '<pre>'; // print_r($result7); // echo '</pre>'; $choosen_img_arr = array(); if ($result7->num_rows > 0) { while ($row7 = $result7->fetch_assoc()) { // $row7 = $result7->fetch_assoc(); $choosen_img_arr[] = $row7; } } // echo '<pre>'; // print_r($choosen_img_arr); // echo '</pre>'; foreach ($choosen_img_arr as $key => $row7) { $query8 = "INSERT INTO `" . KP_MAIN_ROWS_GALLERY . "` \n\t\t\t\t\t\t\t SET \n\t\t\t\t\t\t\t `parent_id` = '" . $row_id . "',\n\t\t\t\t\t\t\t `img_name` = '" . $row7['img_name'] . "',\n\t\t\t\t\t\t\t `folder` = '" . $row7['folder'] . "',\n\t\t\t\t\t\t\t `on` = '" . $row7['on'] . "',\n\t\t\t\t\t\t\t `sort` = '" . $row7['sort'] . "'\n\t\t\t\t\t\t\t "; // echo $query8.'<br>'; $result8 = $mysqli->query($query8) or die($mysqli->error); } // Проходим по второму уровню массива foreach ($dop_data as $dop_key => $dop_val) { //echo $dop_key.','; // Вставляем ряд в таблицу KP_DOP_DATA $query3 = "SELECT*FROM `" . RT_DOP_DATA . "` WHERE id = '" . $dop_key . "'"; //echo $query; $result3 = $mysqli->query($query3) or die($mysqli->error); if ($result3->num_rows > 0) { $row3 = $result3->fetch_assoc(); if ($row['type'] != 'cat') { include_once ROOT . "/libs/php/classes/os_form_class.php"; include_once ROOT . "/libs/php/classes/cabinet/cabinet_class.php"; //os_form_class.php $cabinet = new Cabinet(); $details = $cabinet->get_a_detailed_specifications($row['type'], $row3['no_cat_json']); $details = strip_tags($details, '<div><br><br/><br />'); $details = str_replace(array('<div>', '</div>'), array('<br>', ''), $details); $details = str_replace(array("\n", "\r", "\t"), '', $details); $details = str_replace('<br><br>', '<br>', $details); $details = preg_replace('/<div[^<]+>/', '', $details); $details = $row['name'] . '<br>' . $details; } else { $details = ''; } $query4 = "INSERT INTO `" . KP_DOP_DATA . "` \n\t\t\t\t\t\t\t\t\t SET \n\t\t\t\t\t\t\t\t\t `row_id` = '" . $row_id . "',\n\t\t\t\t\t\t\t\t\t `expel` = '" . $row3['expel'] . "',\n\t\t\t\t\t\t\t\t\t `shipping_time` = '" . $row3['shipping_time'] . "',\n\t\t\t\t\t\t\t\t\t `shipping_date` = '" . $row3['shipping_date'] . "',\n\t\t\t\t\t\t\t\t\t `quantity` = '" . $row3['quantity'] . "',\n\t\t\t\t\t\t\t\t\t `price_in` = '" . $row3['price_in'] . "',\n\t\t\t\t\t\t\t\t\t `price_out` = '" . $row3['price_out'] . "',\n\t\t\t\t\t\t\t\t\t `discount` = '" . $row3['discount'] . "',\n\t\t\t\t\t\t\t\t\t `details` = '" . $details . "',\n\t\t\t\t\t\t\t\t\t `dop_men_text_details` = '" . $row['id'] . "|" . $dop_key . "',\n\t\t\t\t\t\t\t\t\t `tirage_str` = '" . Com_pred::convertTirageJSON($row3['tirage_json']) . "' \n\t\t\t\t\t\t\t\t\t "; $result4 = $mysqli->query($query4) or die($mysqli->error); $dop_row_id = $mysqli->insert_id; // Вставляем ряд в таблицу KP_DOP_USLUGI $query5 = "SELECT*FROM `" . RT_DOP_USLUGI . "` WHERE dop_row_id = '" . $row3['id'] . "'"; //echo $query; $result5 = $mysqli->query($query5) or die($mysqli->error); if ($result5->num_rows > 0) { while ($row5 = $result5->fetch_assoc()) { $query6 = "INSERT INTO `" . KP_DOP_USLUGI . "` \n\t\t\t\t\t\t\t\t\t\t SET \n\t\t\t\t\t\t\t\t\t\t `dop_row_id` = '" . $dop_row_id . "',\n\t\t\t\t\t\t\t\t\t\t `uslugi_id` = '" . $row5['uslugi_id'] . "',\n\t\t\t\t\t\t\t\t\t\t `glob_type` = '" . $row5['glob_type'] . "',\n\t\t\t\t\t\t\t\t\t\t `type` = '" . $row5['type'] . "',\n\t\t\t\t\t\t\t\t\t\t `quantity` = '" . $row5['quantity'] . "',\n\t\t\t\t\t\t\t\t\t\t `price_in` = '" . $row5['price_in'] . "',\n\t\t\t\t\t\t\t\t\t\t `price_out` = '" . $row5['price_out'] . "',\n\t\t\t\t\t\t\t\t\t\t `discount` = '" . $row5['discount'] . "',\n\t\t\t\t\t\t\t\t\t\t `for_how` = '" . $row5['for_how'] . "',\n\t\t\t\t\t\t\t\t\t\t `other_name` = '" . $row5['other_name'] . "',\n\t\t\t\t\t\t\t\t\t\t `print_details` = '" . $row5['print_details'] . "' \n\t\t\t\t\t\t\t\t\t\t "; $result6 = $mysqli->query($query6) or die($mysqli->error); } } } } } } return '1'; }
exit; } if(isset($_GET['expel_value_from_calculation'])){ //print_r(json_decode($_GET['expel_value_from_calculation'])); RT::expel_value_from_calculation($_GET['id'],$_GET['expel_value_from_calculation']); exit; } if(isset($_GET['change_svetofor'])){ $idsArr = (isset($_GET['idsArr']))? json_decode($_GET['idsArr']):false; RT::change_svetofor(array($_GET['id']),$_GET['change_svetofor'],$idsArr); exit; } if(isset($_GET['make_com_offer'])){ include_once(ROOT."/libs/php/classes/com_pred_class.php"); echo Com_pred::save_to_tbl($_GET['make_com_offer']); /* старый вариант создания коммерческого предложения echo make_com_offer($id_arr,(int)$_GET['stock'],$_GET['order_num']/ *string* /,$_GET['client_manager_id']/ *string* /,(int)$_GET['conrtol_num']); */ exit; } if(isset($_GET['sendToSnab'])){ echo RT::sendToSnab(json_decode($_GET['sendToSnab'])); exit; } /*if(isset($_GET['makeSpecAndPreorder'])){ // RT::make_specification($_GET['make_order']);
*/ if(isset($_GET['ajax_set_samples_list'])) { $id_arr = explode(";",$_GET['data']); echo (int)$_GET['conrtol_num'].'<br>'; print_r($id_arr); exit; } if(isset($_POST['change_kp_comment_old_version'])){ $file_name = $_POST['file_name']; $file_comment = urldecode($_POST['change_kp_comment_old_version']); Com_pred::change_comment_old_version($file_name,$file_comment); exit; } if(isset($_GET['get_client_cont_faces'])) { echo Client::get_cont_faces_ajax($_GET['get_client_cont_faces']); exit; } if(isset($_GET['set_manager_for_order'])) { set_manager_for_order_ajax($_GET['row_id'],$_GET['set_manager_for_order'],$_GET['control_num']); exit; }
<?php header('Content-type: text/html; charset=utf-8'); error_reporting(E_ALL); include_once(ROOT."/libs/php/classes/art_img_class.php"); include_once(ROOT."/libs/php/classes/com_pred_class.php"); ?> <script type="text/javascript"> window.onload(window.print()); </script> <?php //echo ROOT.'/libs/php/common.php'; include(ROOT.'/libs/php/common.php'); //echo; list($version,$param) = explode('{@}',$_GET['data']); if($version == 'new'){ include(ROOT.'/libs/mysqli.php'); include(ROOT.'/libs/config.php'); list($id,$client_id,$manager_id) = explode('-',$param); echo Com_pred::open_in_blank($id,$client_id,$manager_id,false); } if($version == 'old') echo Com_pred::open_old_kp($param); exit; ?>
<?php $quick_button = '<div class="quick_button_div"><a href="#11" class="button"> </a></div>'; $view_button = '<div class="quick_view_button_div"><a href="#11" class="button"> </a></div>'; // Собираем ряды для таблицы коммерческих предложений // выборка данных из базы данных производится на основании номера зпароса для КП нового типа // и на основании client_id для КП старого типа if($create_list) $rows = Com_pred::create_list($query_num,$client_id); // Подключаем шаблон таблицы списка коммерческих предложений include ('skins/tpl/client_folder/business_offers/list_table.tpl'); if(isset($detailed_view)) include ('skins/tpl/client_folder/business_offers/detailed_view.tpl'); if(isset($in_blank_view)){ if(isset($_GET['show_old_kp'])) include ('skins/tpl/client_folder/business_offers/in_blank_view_old.tpl'); else{ $query="SELECT display_setting_2 FROM`".KP_LIST."` WHERE `id` = '".$kp_id."'"; $result = $mysqli->query($query)or die($mysqli->error); $row = $result->fetch_assoc(); $display_setting_2 = $row['display_setting_2']; include ('skins/tpl/client_folder/business_offers/in_blank_view.tpl'); } } ?>
} if(isset($_POST['saveChangesInBase'])){ Com_pred::saveKpDisplayChangesInBase($_POST['kp_id'],$_POST['dataJSON']); exit; } if(isset($_POST['saveChangesRadioInBase'])){ Com_pred::saveChangesRadioInBase($_POST['kp_id'],$_POST['val']); exit; } if(isset($_GET['delete_com_offer'])){ if(isset($_GET['old_version'])) Com_pred::delete_old_version($_GET['delete_com_offer'],intval($_GET['client_id']),$_GET['id']/* must be string*/); else Com_pred::delete($_GET['delete_com_offer']); //exit; header('Location:?'.addOrReplaceGetOnURL('client_id='.$client_id,'delete_com_offer&old_version&id')); } /////////////////////////////////////// end Временно /////////////////////////////////////// // шаблон поиска include ROOT.'/skins/tpl/common/quick_bar.tpl'; // планка клиента include_once './libs/php/classes/client_class.php'; Client::get_client__information($_GET['client_id']); include 'business_offers_controller.php';