static function open_in_blank($kp_id, $client_id, $user_id, $save_on_disk = false) { global $mysqli; // Здесь делаем то что в старой версии делали при сохранении КП в файл // Данные из РТ $multi_dim_arr = self::fetch_kp_rows($kp_id); // echo '<pre>';print_r($multi_dim_arr);echo '</pre>';//exit; /*if(@$_SESSION['access']['user_id']==18){ echo '<pre>';print_r($multi_dim_arr);echo '</pre>'; } */ // Настройки отображения состовляющих КП $display_setting = $multi_dim_arr[key($multi_dim_arr)]['display_setting']; $display_setting_2 = $multi_dim_arr[key($multi_dim_arr)]['display_setting_2']; $dispSetObj = json_decode($display_setting); $itogo = $itogo_print_uslugi = $itogo_extra_uslugi = 0; $itogo_print_uslugi1 = $itogo_print_uslugi2 = $itogo_print_uslugi3 = 0; $itogo_extra_uslugi1 = $itogo_extra_uslugi2 = $itogo_extra_uslugi3 = 0; // echo '<pre>'; // print_r($multi_dim_arr); // echo '</pre>'; // Разворачиваем массив foreach ($multi_dim_arr as $pos_key => $pos_level) { // РАБОТАЕМ С ПЕРВОЙ ЯЧЕЙКОЙ РЯДА ТАБЛИЦЫ КП // в этой ячейке подразумевается отображение картинки товарной позиции // соответсвенное если есть что показывать, то добавляем тег img, если нет то добавляем пустую строку $img_src = 'http://www.apelburg.ru/img/no_image.jpg'; $img_cell = '<img src="' . $img_src . '" height="180" width="180">'; $art_img = new Art_Img_development($pos_key, $pos_level['img_folder'], $pos_level['img'], $pos_level['art']); // $img_src = $art_img->big; // echo '<pre>'; // print_r($art_img); // echo '</pre>'; // меняем размер изображения $img_cell = ''; foreach ($art_img->big as $key => $img_src) { $size_arr = transform_img_size($img_src, 230, 300); // $size_arr = array(230,300); $img_cell .= '<img src="' . $img_src . '" height="' . $size_arr[0] . '" width="' . $size_arr[1] . '">'; } // $img_cell .= '<img src="'.$img_src.'" height="'.$size_arr[0].'" width="'.$size_arr[1].'">'; // $img_cell .= '<img src="'.$img_src.'" height="'.$size_arr[0].'" width="'.$size_arr[1].'">'; // if($pos_level['row_type']=='cat'){ // если позиция из каталога получаем картинку из базы данных каталога // $art_img = new Art_Img($pos_level['art']); // // проверяем наличие изображения // $img_path = 'http://www.apelburg.ru/img/'.$art_img->big; // if($img_src = checkImgExists($img_path)){ // // меняем размер изображения // $size_arr = transform_img_size($img_src,230,300); // // $size_arr = array(230,300); // $img_cell = '<img src="'.$img_src.'" height="'.$size_arr[0].'" width="'.$size_arr[1].'">'; // } // } // РАБОТАЕМ СО ВТОРОЙ ЯЧЕЙКОЙ РЯДА ТАБЛИЦЫ КП // наименование товарной позиции // форматируем вывод, разбиваем строки на куски определенной длины и вставляем перед каждым отступ $str_len = 40; $pos_name = $pos_level['name']; $pos_name = nl2br($pos_name); if ($save_on_disk && isset($dispSetObj->art)) { $article = ''; } else { if ($pos_level['row_type'] != 'cat') { $article = ''; } else { $article = '<managedDisplay name="art" style="display:' . (isset($dispSetObj->art) ? 'none' : 'inline-block') . '">арт.: <a href="/description/' . @$pos_level['art_id'] . '/" target="_blank">' . @$pos_level['art'] . '</a></managedDisplay>'; } } // НАЧИНАЕМ ПЕРЕБИРАТЬ ДАННЫЕ РАСЧЕТОВ // примечание - у позиции может быть любое количество расчетов( а каждый расчет в свою очередь может содержать // любое количество нанесений и доп услуг) foreach ($pos_level['dop_data'] as $r_key => $r_level) { if ($pos_level['row_type'] != 'cat' && isset($r_level['details'])) { $pos_name = $r_level['details']; } $all_print_summ = $all_extra_summ = 0; //$r_ - сокращение обозначающее - уровень Расчёта позиции // стоимост артикула в данном расчете (без нанесения и услуг) // чтобы в дальнейшем не было проблем с делением преобразуем $quantity в 1 если оно равно 0 $quantity = $r_level['quantity'] == 0 ? 1 : $r_level['quantity']; // стоимость $price = $r_level['discount'] != 0 ? round($r_level['price_out'] / 100 * (100 + $r_level['discount']), 2) : $r_level['price_out']; $summ = $quantity * $price; $itogo += $summ; // добавляем данные в содержимое ячейки<td><div contenteditable="true" class="saveKpPosDescription" pos_id="'.$pos_key.'">'.$pos_name.'</div></td> $description_cell = '<div style="margin-top:5px;"><b>Сувенир:</b></div> <table border="0" style="font-family:arial;font-size:13px;" tbl="managed"> <tr> <td style="width:6px;"></td> <td style="width:400px;" managed="text" bd_row_id="' . ($pos_level['row_type'] == 'cat' ? $pos_key : $r_key) . '" bd_field="' . ($pos_level['row_type'] == 'cat' ? 'name' : 'details') . '" action="changeKpPosDescription">' . $pos_name . '</td> </tr> <tr> <td style="width:6px;"></td> <td>' . $article . '</td> </tr> </table>'; if (!($save_on_disk && isset($dispSetObj->sizes))) { $description_cell .= '<managedDisplay name="sizes" style="display:' . (!isset($dispSetObj->sizes) && $r_level['tirage_str'] != '' ? 'inline-block' : 'none') . '"> <table border="0" style="font-family:arial;font-size:13px;" tbl="managed"> <tr> <td style="width:6px;"></td> <td style="width:400px;" managed="text" bd_row_id="' . $r_key . '" action="changeKpPosDescription" bd_field="tirage_str">' . $r_level['tirage_str'] . '</td> </tr> </table> </managedDisplay>'; } if (!($save_on_disk && isset($dispSetObj->characteristics))) { $description_cell .= '<managedDisplay name="characteristics" style="display:' . (!isset($dispSetObj->characteristics) && $pos_level['characteristics'] != '' ? 'inline-block' : 'none') . '"> <table border="0" style="font-family:arial;font-size:13px;" tbl="managed"> <tr> <td style="width:6px;"></td> <td style="width:400px;" managed="text" bd_row_id="' . $pos_key . '" action="changeKpRepresentedData" bd_field="characteristics">' . $pos_level['characteristics'] . '</td> </tr> </table> </managedDisplay>'; } if (!($save_on_disk && isset($dispSetObj->description))) { $description_cell .= '<managedDisplay name="description" style="display:' . (!isset($dispSetObj->description) && $pos_level['description'] != '' ? 'inline-block' : 'none') . '"> <table border="0" style="font-family:arial;font-size:13px;" tbl="managed"> <tr> <td style="width:6px;"></td> <td style="width:400px;" managed="text" bd_row_id="' . $pos_key . '" action="changeKpRepresentedData" bd_field="description">' . $pos_level['description'] . '</td> </tr> </table> </managedDisplay>'; } $description_cell .= '<table style="font-family:arial;font-size:13px;margin-top:10px;width:100%;border-collapse:collapse;width:350px;table-layout:_fixed;" border="0"> <tr> <td align="right" style="width:250px;color:#888;">1шт.</td> <td align="right" style="width:70px;padding:0 5px;"><nobr>' . number_format($price, 2, '.', ' ') . '</nobr></td> <td align="left" style="width:30px;">руб.</td> </tr> <tr> <td align="right" style="color:#888;">тираж: ' . $quantity . ' шт. </td> <td align="right" style="padding:0 5px;"><nobr>' . number_format($summ, 2, '.', ' ') . '</nobr></td> <td align="left">руб.</td> </tr> </table>'; // РАБОТАЕМ С НАНЕСЕНИЯМИ И ДОП УСЛУГАМИ СОБИРАЕМ В ЕДИННЫЕ БЛОКИ ДЛЯ ПОСЛЕДУЮЩЕЙ СБОРКИ $print_block = $details_block = array(); $counter = 0; // если есть нанесение if (isset($r_level['dop_uslugi']['print'])) { $show_count = count($r_level['dop_uslugi']['print']) > 1 ? true : false; $counter2 = 0; foreach ($r_level['dop_uslugi']['print'] as $u_key => $u_level) { if ($u_level['print_details'] == '') { continue; } $print_details_obj = json_decode($u_level['print_details']); if ($print_details_obj == NULL) { continue; } $print_details_arr = json_decode($u_level['print_details'], TRUE); /*if(@$_SESSION['access']['user_id']==18){ echo '<pre>';print_r($print_details_arr);echo '</pre>'; } */ if (isset($print_details_arr['dop_params']['sizes'])) { if ($print_details_arr['dop_params']['sizes'][0]['type'] == 'coeff') { $size_coeff = isset($print_details_arr['dop_params']['sizes'][0]['val']) && $print_details_arr['dop_params']['sizes'][0]['val'] != 0 ? $print_details_arr['dop_params']['sizes'][0]['val'] : 1; } if ($print_details_arr['dop_params']['sizes'][0]['type'] == 'addition') { $size_coeff = isset($print_details_arr['dop_params']['sizes'][0]['val']) ? $print_details_arr['dop_params']['sizes'][0]['val'] : 0; $size_coeff = $print_details_arr['dop_params']['sizes'][0]['target'] == 'summ' ? round($size_coeff / $quantity, 2) : $size_coeff; } } else { $size_coeff = false; } $new_price_arr['price_in'] = $u_level['discount'] != 0 ? $u_level['price_in'] / 100 * (100 + $u_level['discount']) : $u_level['price_in']; $new_price_arr['price_out'] = $u_level['discount'] != 0 ? $u_level['price_out'] / 100 * (100 + $u_level['discount']) : $u_level['price_out']; //$new_price_arr['price_in'] = $u_level['price_in']; //$new_price_arr['price_out'] = $u_level['price_out']; include_once ROOT . "/libs/php/classes/rt_calculators_class.php"; $calculations = rtCalculators::make_calculations($quantity, $new_price_arr, $print_details_obj->dop_params); // echo '<pre>'; print_r($new_price_arr); echo '</pre>'; // /*if(@$_SESSION['access']['user_id']==18){ echo '<pre>';print_r($calculations);echo '</pre>'; } */ // наименование нанесения include_once ROOT . "/libs/php/classes/print_calculators_class.php"; $print_data = printCalculator::convert_print_details_for_kp($u_level['print_details']); /*if(@$_SESSION['access']['user_id']==18){ echo '<pre>';print_r($print_data);echo '</pre>'; } */ // Собираем данные для print_block (Печать логотипа) $print_block[] = '<table border="0" style="font-family:arial;font-size:13px;right;margin:15px 0 0 11px;width:100%;border-collapse:collapse;width:350px;table-layout:fixed;">'; $print_block[] = '<tr><td valign="top" style="width:90px;">метод ' . ($show_count ? ++$counter2 . ': ' : '') . ' </td><td style="width:170px;">' . $print_data['block1']['print_type'] . '</td></tr>'; $print_block[] = '<tr><td valign="top">Место нанесения: </td><td>' . $print_data['block1']['place_type'] . '</td></tr>'; if (isset($print_data['block1']['price_data']['y_params'])) { $print_block[] = '<tr><td valign="top">' . $print_data['block1']['price_data']['cap'] . ': </td><td>' . count($print_data['block1']['price_data']['y_params']) . ' (' . implode(', ', $print_data['block1']['price_data']['y_params']) . ')</td></tr>'; $y_params_count = count($print_data['block1']['price_data']['y_params']); $y_params_coeff = 0; foreach ($print_details_arr['dop_params']['YPriceParam'] as $y_data) { if ($y_data['coeff'] == 0) { $y_data['coeff'] = 1; } $y_params_coeff += $y_data['coeff'] - 1; } } if (isset($print_data['block1']['print_size'])) { // если тип нанесения Тампопечать ( id =18 ) - то тогда не отображаем площать печати if ($u_level['usluga_id'] != 18) { $print_block[] = '<tr><td valign="top">Площадь печати: </td><td>' . $print_data['block1']['print_size'] . '</td></tr>'; } //echo '<pre>--2--'; print_r($print_details_arr['dop_params']); echo '</pre>'; } if (isset($print_data['block2']['data'])) { foreach ($print_data['block2']['data'] as $block2_data) { $print_block[] = '<tr><td valign="top" colspan="2">' . $block2_data['name'] . '</td></tr>'; } } $print_block[] = '</table>'; $print_block_price = $new_price_arr['price_out']; $print_block_price1 = $new_price_arr['price_out']; if ($display_setting_2 == 0) { // вариант 1 // коэффициент площади /*if($size_coeff!==false){ if($print_details_arr['dop_params']['sizes'][0]['type'] == 'coeff'){ $print_block_price = $new_price_arr['price_out']*$size_coeff; } if($print_details_arr['dop_params']['sizes'][0]['type'] == 'addition'){ $print_block_price = $new_price_arr['price_out']+$size_coeff; } } // добавить коэфф цвета если есть if(isset($y_params_count) && $y_params_count>0){ $y_params_coeff = (isset($y_params_coeff))?$y_params_coeff:1; $print_block_price += ($new_price_arr['price_out']/$y_params_count)*$y_params_coeff; }*/ $print_block_summ = $quantity * $print_block_price; $all_print_summ += $quantity * $new_price_arr['price_out']; $itogo_print_uslugi += $print_block_summ; //$itogo_extra_uslugi += $calculations['new_summs']['summ_out'] - $print_block_summ; } else { if ($display_setting_2 == 1) { // вариант 2 $print_block_price = $new_price_arr['price_out']; $print_block_summ = $quantity * $new_price_arr['price_out']; $all_print_summ += $calculations['new_summs']['summ_out']; $itogo_print_uslugi += $print_block_summ; //$itogo_extra_uslugi += $calculations['new_summs']['summ_out'] - $print_block_summ; } else { if ($display_setting_2 == 2) { // вариант 3 $print_block_price = $new_price_arr['price_out']; $print_block_summ = $quantity * $new_price_arr['price_out']; $all_print_summ += $calculations['new_summs']['summ_out']; $itogo_print_uslugi += $calculations['new_summs']['summ_out']; } } } ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // коэффициент площади /*if($size_coeff!==false){ if($print_details_arr['dop_params']['sizes'][0]['type'] == 'coeff'){ $print_block_price1 = $new_price_arr['price_out']*$size_coeff; } if($print_details_arr['dop_params']['sizes'][0]['type'] == 'addition'){ $print_block_price1 = $new_price_arr['price_out']+$size_coeff; } } //$size_coeff = (isset($size_coeff))?$size_coeff:1; //$print_block_price1 = $new_price_arr['price_out']*$size_coeff; // добавить коэфф цвета если есть if(isset($y_params_count) && $y_params_count>0){ $y_params_coeff = (isset($y_params_coeff))?$y_params_coeff:1; $print_block_price1 += ($new_price_arr['price_out']/$y_params_count)*$y_params_coeff; }*/ $print_block_summ1 = $quantity * $print_block_price1; $itogo_print_uslugi1 += $quantity * $print_block_price1; //$itogo_extra_uslugi1 += $calculations['new_summs']['summ_out'] - $print_block_summ1; $print_block_price2 = $new_price_arr['price_out']; $print_block_summ2 = $quantity * $new_price_arr['price_out']; $itogo_print_uslugi2 += $quantity * $new_price_arr['price_out']; // $itogo_extra_uslugi2 += $calculations['new_summs']['summ_out'] - $quantity*$new_price_arr['price_out']; $print_block_price3 = $new_price_arr['price_out']; $print_block_summ3 = $quantity * $new_price_arr['price_out']; //$itogo_print_uslugi3 += $calculations['new_summs']['summ_out']; ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// unset($size_coeff); unset($y_params_coeff); unset($y_params_count); if ($save_on_disk && isset($dispSetObj->full_summ)) { $print_block[] = '<table style="font-family:arial;font-size:13px;right;margin:0 0 5px 0;width:100%;border-collapse:collapse;width:350px;table-layout:_fixed;" border="0"> <tr> <td align="right" style="width:250px;color:#888;">1шт.</td> <td align="right" style="width:70px;padding:0 5px;"><nobr>' . number_format($print_block_price, 2, '.', ' ') . '</nobr></td> <td align="left" style="width:30px;">руб.</td> </tr> <tr> <td align="right" style="color:#888;">тираж: ' . $quantity . ' шт. </td> <td align="right" style="padding:0 5px;"><nobr>' . number_format($print_block_summ, 2, '.', ' ') . '</nobr></td> <td align="left">руб.</td> </tr> </table>'; } else { $print_block[] = '<table style="font-family:arial;font-size:13px;right;margin:0 0 5px 0;width:100%;border-collapse:collapse;width:350px;table-layout:_fixed;" border="0"> <tr> <td align="right" style="width:250px;color:#888;">1шт.</td> <td align="right" style="width:70px;padding:0 5px;"><nobr><span id="metod_display_setting_' . $counter2 . '1_0" style="display:' . ($display_setting_2 == 0 ? 'inline-block' : 'none') . '">' . number_format($print_block_price1, 2, ',', ' ') . '</span><span id="metod_display_setting_' . $counter2 . '1_1" style="display:' . ($display_setting_2 == 1 ? 'inline-block' : 'none') . '">' . number_format($print_block_price2, 2, ',', ' ') . '</span><span id="metod_display_setting_' . $counter2 . '1_2" style="display:' . ($display_setting_2 == 2 ? 'inline-block' : 'none') . '">' . number_format($print_block_price3, 2, ',', ' ') . '</span></nobr></td> <td align="left" style="width:30px;">руб.</td> </tr> <tr> <td align="right" style="color:#888;">тираж: ' . $quantity . ' шт. </td> <td align="right" style="padding:0 5px;"><nobr><span id="metod_display_setting_' . $counter2 . '2_0" style="display:' . ($display_setting_2 == 0 ? 'inline-block' : 'none') . '">' . number_format($print_block_summ1, 2, ',', ' ') . '</span><span id="metod_display_setting_' . $counter2 . '2_1" style="display:' . ($display_setting_2 == 1 ? 'inline-block' : 'none') . '">' . number_format($print_block_summ2, 2, ',', ' ') . '</span><span id="metod_display_setting_' . $counter2 . '2_2" style="display:' . ($display_setting_2 == 2 ? 'inline-block' : 'none') . '">' . number_format($print_block_summ3, 2, ',', ' ') . '</span></nobr></td> <td align="left">руб.</td> </tr> </table>'; } unset($print_block_summ); unset($print_block_price); unset($print_block_price3); // Собираем данные для details_block (деталировка по нанесению) $square_coeff = 1; //echo '<pre>--1--'; print_r( $print_data['block1']['price_data']['y_params']); echo '</pre>'; //echo '<pre>--2--'; print_r( $print_details_arr['dop_params']); echo '</pre>'; foreach ($print_details_arr['dop_params'] as $type => $data) { $price_addition = $summ_addition = 0; // if ($type == 'sizes' && isset($data[0]['val'])) { // в итгое не выводится первым потому что в исходном массиве не на первом месте if ($data[0]['val'] == 0) { $data[0]['val'] = 1; } if ($data[0]['target'] == 'price') { $square_coeff = $data[0]['val']; } //!!if($data->target == 'summ') $summ_coeff += (float)$data->val-1; if ($square_coeff == 1) { continue; } $print_summ = $quantity * ($new_price_arr['price_out'] * ($square_coeff - 1)); if ($save_on_disk && $display_setting_2 != 0) { $rows_2[] = '<tr><td align="left" style="width:230px;padding:0 5px 0 15px;">+ ' . ($square_coeff - 1) * 100 . '% за увелич. площади печати</td>'; $rows_2[] = '<td align="right" style="width:90px;">' . number_format($print_summ, 2, '.', ' ') . '</td>'; $rows_2[] = '<td align="left" style="width:30px;">руб. </td></tr>'; /**/ } else { if (!$save_on_disk) { $rows_2[] = '<tr id="metod_display_setting_' . $counter2 . '3" style="display:' . ($display_setting_2 != 0 ? 'table-row' : 'none') . '"><td align="left" style="width:230px;padding:0 5px 0 15px;">+ ' . ($square_coeff - 1) * 100 . '% за увелич. площади печати</td>'; $rows_2[] = '<td align="right" style="width:90px;">' . number_format($print_summ, 2, '.', ' ') . '</td>'; $rows_2[] = '<td align="left" style="width:30px;">руб. </td></tr>'; /**/ } } } if ($type == 'YPriceParam') { $price_tblYindex = count($data) == 0 ? 1 : count($data); $base_price_for_Y = $new_price_arr['price_out'] / $price_tblYindex; foreach ($data as $index => $Y_data) { if ($Y_data['coeff'] == 1) { continue; } $Y_coeff = (double) $Y_data['coeff'] - 1; $print_summ = $quantity * ($base_price_for_Y * $Y_coeff); if ($save_on_disk && $display_setting_2 != 0) { $rows_2[] = '<tr><td align="left" style="width:230px;padding:0 5px 0 15px;">+ ' . ($Y_data['coeff'] - 1) * 100 . '% за металлик (' . $print_data['block1']['price_data']['y_params_ids'][$Y_data['id']] . ')</td>'; $rows_2[] = '<td align="right" style="width:90px;">' . number_format($print_summ, 2, '.', ' ') . '</td>'; $rows_2[] = '<td align="left" style="width:30px;">руб. </td></tr>'; } else { if (!$save_on_disk) { $rows_2[] = '<tr id="metod_display_setting_' . $counter2 . $index . '4" style="display:' . ($display_setting_2 != 0 ? 'table-row' : 'none') . '"><td align="left" style="width:230px;padding:0 5px 0 15px;">+ ' . ($Y_data['coeff'] - 1) * 100 . '% за металлик (' . $print_data['block1']['price_data']['y_params_ids'][$Y_data['id']] . ')</td>'; $rows_2[] = '<td align="right" style="width:90px;">' . number_format($print_summ, 2, '.', ' ') . '</td>'; $rows_2[] = '<td align="left" style="width:30px;">руб. </td></tr>'; } } } } } $base_price2 = $new_price_arr['price_out'] * $square_coeff; $spechial_summ = 100; foreach ($print_data['block2'] as $data) { foreach ($data as $data2) { if ($data2['type'] == 'coeff') { if ($data2['value'] == 1) { continue; } $spechial_summ = 1; $coeff = $data2['value'] - 1; $print_summ = $data2['target'] == 'price' ? $quantity * ($base_price2 * $coeff) : $spechial_summ / 100 * $data2['value']; } if ($data2['type'] == 'addition') { if ($data2['value'] == 0) { continue; } $print_summ = $data2['target'] == 'price' ? $quantity * $data2['value'] : $data2['value']; } $rows_2[] = '<tr><td align="left" style="width:230px;padding:0 5px 0 15px;">' . $data2['name'] . '</td>'; $rows_2[] = '<td align="right" style="width:90px;">' . number_format($print_summ, 2, '.', ' ') . '</td>'; $rows_2[] = '<td align="left" style="width:30px;">руб. </td></tr>'; } } if (isset($rows_2)) { //$details_block11[$counter]['cap'] = 'для метода печати '.(($show_count)? $counter2.': ':''); //$details_block11[$counter]['data'] = $rows_2; } $counter++; // echo '<pre>'; print_r($rows_2); echo '</pre>'; unset($rows_2); // //echo '<table style="margin-top:5px;border-collapse:collapse;" border="1">'.implode('',$rows_2).'</table>'; } } // перебор доп услуг if (isset($r_level['dop_uslugi']['extra'])) { foreach ($r_level['dop_uslugi']['extra'] as $u_key => $u_level) { if ($u_level['price_out'] == 0) { continue; } include_once ROOT . "/libs/php/classes/agreement_class.php"; // если альтернативное название отсутствует (вводится при заведении услуги "НЕТ В СПИСКЕ") if (trim($u_level['other_name']) == "") { $extra_usluga_details = Agreement::get_usluga_details($u_level['usluga_id']); $u_level['name'] = $extra_usluga_details ? $extra_usluga_details['name'] : 'Неопределено'; } else { $u_level['name'] = $u_level['other_name']; } $print_summ = $u_level['for_how'] == 'for_all' ? $u_level['price_out'] : $quantity * $u_level['price_out']; $all_extra_summ += $print_summ; $itogo_extra_uslugi += $print_summ; $itogo_extra_uslugi1 += $print_summ; $itogo_extra_uslugi2 += $print_summ; $itogo_extra_uslugi3 += $print_summ; $rows_2[] = '<tr><td align="left" style="width:230px;height:10px;line-height:10px;padding:0 5px 0 15px;">' . $u_level['name'] . '</td>'; $rows_2[] = '<td align="right" style="width:90px;">' . number_format($print_summ, 2, '.', ' ') . '</td>'; $rows_2[] = '<td align="left" style="width:30px;">руб. </td></tr>'; } if (isset($rows_2)) { $details_block11[$counter]['cap'] = 'для сувенира '; $details_block11[$counter]['data'] = $rows_2; } unset($rows_2); } // Вставляем блоки в тело КП if (isset($print_block) && count($print_block) > 0) { $description_cell .= '<hr style="border:none;border-top:#888 solid 1px;"><div style="margin-top:5px;"><b>Печать логотипа:</b></div>'; $description_cell .= '<div style="">' . implode('<div></div>', $print_block) . '</div>'; } if (isset($details_block11) && count($details_block11) > 0) { /*if(true!($save_on_disk && isset($dispSetObj->dop_uslugi))){ //style="display:'.(isset($dispSetObj->dop_uslugi)?'none':'block').'}"*/ $description_cell .= '<managedDisplay name="dop_uslugi" style="display:' . (isset($dispSetObj->dop_uslugi) ? 'none' : 'block') . '"><hr style="border:none;border-top:#888 solid 1px;"><div><b>Дополнительные услуги:</b></div>'; $description_cell .= '<table style="margin-top:5px;border-collapse:collapse; font-family:arial;font-size:13px;" border="0">'; foreach ($details_block11 as $key => $rows) { //$description_cell .= '<tr><td align="left" height="25" colspan="3" style="padding:0 5px 0 15px;color:#888">'.$rows['cap'].'</td>'; $description_cell .= implode('', $rows['data']); } $description_cell .= '</table></managedDisplay>'; } $description_cell .= '<table style="margin:5px 0 10px 0;border-collapse:collapse;" border="0"><tr><td align="left" style="width:220px;"><b>Итого</b></td>'; /*if(@$_SESSION['access']['user_id']==18){ echo '---'.$summ.'--'.$all_print_summ.'--'.$all_extra_summ.'---'; } */ $description_cell .= '<td align="right" style="width:100px;"><b>' . number_format($summ + $all_print_summ + $all_extra_summ, 2, '.', ' ') . '</b></td>'; $description_cell .= '<td align="left" style="width:30px;"><b>руб.</b></td></tr></table>'; $tbl_rows[] = '<tr><td style="border-bottom:#91B73F solid 2px; border-top:#91B73F solid 2px;" width="300" valign="middle" align="center">' . $img_cell . '</td><td style="border-bottom:#91B73F solid 2px; border-top:#91B73F solid 2px;padding:6px;" width="325" valign="top">' . $description_cell . '</td></tr>'; $description_cell = $print_description = ''; unset($details_block11); unset($print_details); unset($extra_details); unset($pos_and_print_cost); } } /******************** ++++++++++++++ *********************/ // КОНЕЧНАЯ СБОРКА КП // Данные для шапки $cont_face_data_arr = get_client_cont_face_by_id($client_id, $user_id, true); $client_data_arr = select_all_client_data($client_id); // получаем данные о получателе КП, сначала вычисляем его id // потом передаем его в метод Client::get_cont_face_details($recipient_id); reset($multi_dim_arr); $recipient_id = $multi_dim_arr[key($multi_dim_arr)]['recipient_id']; include_once ROOT . "/libs/php/classes/client_class.php"; $cont_face_data = Client::get_cont_face_details($recipient_id); //print_r($cont_face_data_arr);//exit;625 $kp_content = '<div id="kpBlankConteiner" style="width:675px;background-color:#FFFFFF;border:#91B73F solid 0px;"><table width="675" style="border-collapse:collapse;background-color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;" valign="top"><tr><td colspan="2" style="text-align:right;"> <input type="hidden" style="width:90px;" id="kpDisplaySettings" value=' . $display_setting . '><input type="hidden" id="kpDisplaySettings_kpId" value=' . $kp_id . '>'; if (!($save_on_disk && isset($dispSetObj->header))) { $kp_content .= '<div style="text-align:right;font-family:verdana;font-size:12px;font-weight:bold;line-height:16px;"><managedDisplay name="header" style="display:' . (isset($dispSetObj->header) ? 'none' : 'block') . '">В компанию: ' . Client::get_client_name($client_id) . '<br />Кому: ' . $cont_face_data['last_name'] . ' ' . $cont_face_data['name'] . ' ' . $cont_face_data['surname'] . '</managedDisplay></div>'; } //s$kp_content .= '<div style="font-family:verdana;font-size:18px;padding:10px;color:#10B050;text-align:center;border:#91B73F solid 1px;width:675px;">Презентация</div>'; $kp_content .= '</td></tr> <tr><td colspan="2" style="text-align:center;"> <div style="font-family:verdana; font-size:18px;padding:10px;color:#10B050;">Презентация</div></td></tr>'; $kp_content .= '</td></tr>' . implode('', $tbl_rows) . '<tr><td colspan="2" style="text-align:right;">'; // <div style="border-top:#91B73F solid 2px;width:675px;"></div> /******************** ++++++++++++++ *********************/ if ($save_on_disk && !isset($dispSetObj->full_summ)) { if ($itogo != 0) { $full_itog = $itogo + $itogo_print_uslugi + $itogo_extra_uslugi; $kp_content .= '<div style="text-align:right;"> <managedDisplay name="full_summ" style="text-align:right;display:' . (isset($dispSetObj->full_summ) ? 'none' : 'inline-block') . '"> <table align="right" style="margin:15px 0px 10px 0;font-family:arial" border="0">'; if ($itogo_print_uslugi + $itogo_extra_uslugi != 0) { $kp_content .= '<tr> <td width="230" height="20" align="right" valign="top" style="padding-right:2px;" >Общая стоимость сувениров:</td><td width="150" align="right" valign="top">' . number_format($itogo, 2, ',', ' ') . 'руб.</td> </tr>'; } if ($itogo_print_uslugi != 0) { $kp_content .= '<tr> <td align="right" height="20" valign="top">Общая стоимость нанесения:</td><td align="right" valign="top">' . number_format($itogo_print_uslugi, 2, ',', ' ') . 'руб.</td> </tr>'; } if ($itogo_extra_uslugi != 0) { $kp_content .= '<tr> <td align="right" height="30" valign="top">Общая стоимость доп услуг:</td><td align="right" valign="top">' . number_format($itogo_extra_uslugi, 2, ',', ' ') . 'руб.</td> </tr>'; } $kp_content .= '<tr> <td align="right" valign="top" style="font-family:verdana;font-size:14px;font-weight:bold;">Итоговая сумма:</td><td align="right" valign="top" style="font-family:verdana;font-size:14px;font-weight:bold;white-space: nowrap">' . number_format($full_itog, 2, ',', ' ') . 'руб.</td> </tr> </table> </managedDisplay>'; } } else { if (!$save_on_disk) { if ($itogo != 0) { $full_itog = $itogo + $itogo_print_uslugi + $itogo_extra_uslugi; $kp_content .= '<div style="text-align:right;"> <managedDisplay name="full_summ" style="text-align:right;display:' . (isset($dispSetObj->full_summ) ? 'none' : 'inline-block') . '"> <table align="right" style="margin:15px 0px 10px 0;font-family:arial" border="0">'; if ($itogo_print_uslugi + $itogo_extra_uslugi != 0) { $kp_content .= '<tr> <td width="230" height="20" align="right" valign="top" style="padding-right:2px;" >Общая стоимость сувениров:</td><td width="150" align="right" valign="top">' . number_format($itogo, 2, ',', ' ') . 'руб.</td> </tr>'; } if ($itogo_print_uslugi != 0) { $kp_content .= '<tr> <td align="right" height="20" valign="top">Общая стоимость нанесения:</td><td align="right" valign="top"><span id="itogo_display_setting_1_0" style="display:' . ($display_setting_2 == 0 ? 'inline-block' : 'none') . '">' . number_format($itogo_print_uslugi1, 2, ',', ' ') . '</span><span id="itogo_display_setting_1_1" style="display:' . ($display_setting_2 == 1 ? 'inline-block' : 'none') . '">' . number_format($itogo_print_uslugi2, 2, ',', ' ') . '</span><span id="itogo_display_setting_1_2" style="display:' . ($display_setting_2 == 2 ? 'inline-block' : 'none') . '">' . number_format($itogo_print_uslugi3, 2, ',', ' ') . '</span>руб.</td> </tr>'; } if ($itogo_extra_uslugi != 0) { $kp_content .= '<tr> <td align="right" height="30" valign="top">Общая стоимость доп услуг:</td><td align="right" valign="top"><span id="itogo_display_setting_2_0" style="display:' . ($display_setting_2 == 0 ? 'inline-block' : 'none') . '">' . number_format($itogo_extra_uslugi1, 2, ',', ' ') . '</span><span id="itogo_display_setting_2_1" style="display:' . ($display_setting_2 == 1 ? 'inline-block' : 'none') . '">' . number_format($itogo_extra_uslugi2, 2, ',', ' ') . '</span><span id="itogo_display_setting_2_2" style="display:' . ($display_setting_2 == 2 ? 'inline-block' : 'none') . '">' . number_format($itogo_extra_uslugi3, 2, ',', ' ') . '</span>руб.</td> </tr>'; } $kp_content .= '<tr style="font-family:verdana;font-size:14px;font-weight:bold;"> <td align="right" valign="top">Итоговая сумма:</td><td align="right" valign="top" style="white-space: nowrap">' . number_format($full_itog, 2, ',', ' ') . 'руб.</td> </tr> </table> </managedDisplay>'; } } } $kp_content .= '<div style="text-align:right;font-family:arial;font-size:12px;line-height:20px;"><br>' . convert_bb_tags(mysql_result(select_manager_data($user_id), 0, 'mail_signature')) . '<br><br><br></div>'; $kp_content .= '<div style="text-align:justify;font-family:verdana;font-size:10px;line-height:11px;padding:0 20px;"><br>Данная презентация носит исключительно информационный характер и никакая информация, опубликованная в ней, ни при каких условиях не является офертой или публичной офертой, определяемой положениями пункта 2 статьи 437 и статьи 435 Гражданского кодекса Российской Федерации. Для получения подробной информации о реализуемых товарах, работах и услугах и их цене необходимо обращаться к менеджерам компании Апельбург<br><br><br></div></td></tr></table></div>'; return $kp_content; }
protected function get_dop_inputs_for_services($id, $dop_usluga_id, $enable_edit = 0) { global $mysqli; // допуски на редактирование $enable_edit = isset($_POST['order_status']) && $_POST['order_status'] != 'in_work' && $_POST['order_status'] != 'paused' && $_POST['order_status'] != 'cancelled' && $_POST['order_status'] != 'shipped' ? 1 : 0; if ($this->user_access != 5) { $enable_edit = 1; } // запрет для буха if ($this->user_access == 2) { $enable_edit = 0; } $readonly = $enable_edit == 0 ? ' disabled' : ''; include_once ROOT . "/libs/php/classes/print_calculators_class.php"; // запрашиваем информацию по ТЗ и , если нужно if (!isset($this->Service)) { // если нам ничего не известно по строке из CAB_DOP_USLUGI $query = "SELECT * FROM " . CAB_DOP_USLUGI . " WHERE `id` = '" . $dop_usluga_id . "'"; $result = $mysqli->query($query) or die($mysqli->error); $this->Service = array(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $this->Service = $row; } } } // если у нас есть информация в поле $this->Service['print_details'] - декодируем её в читабельный вид if (trim($this->Service['print_details']) != '') { include_once './libs/php/classes/agreement_class.php'; $this->Service['print_details_read'] = '<div><span>Данные из калькулятора:</span><br><div class="calculator_info">' . printCalculator::convert_print_details($this->Service['print_details']) . '</div></div>'; } else { $this->Service['print_details_read'] = ''; } // получаем инфу и настройки по данной услуге if (!isset($this->All_Services_arr)) { $this->All_Services_arr = $this->get_all_services_names_Database(); } $this->iputs_id_Str = isset($this->All_Services_arr[$id]['uslugi_dop_inputs_id']) ? $this->All_Services_arr[$id]['uslugi_dop_inputs_id'] : ''; $this->Service_logotip_on = isset($this->All_Services_arr[$id]['logotip_on']) ? $this->All_Services_arr[$id]['logotip_on'] : ''; $this->Service_show_status_film_photos = isset($this->All_Services_arr[$id]['show_status_film_photos']) ? $this->All_Services_arr[$id]['show_status_film_photos'] : ''; $this->maket_old_true_for_Service = isset($this->All_Services_arr[$id]['maket_old_true']) ? $this->All_Services_arr[$id]['maket_old_true'] : ''; // echo $row['logotip_on']; ////////////////////////// // СЛЕДУЮЩИЕ 2 запроса В БЛИЖАЙШЕМ БУДУЩЕМ нужно сократить до одного !!!!!!!!!!!! ////////////////////////// // запрашиваем список полей предназначенных для этой услуги $query = "SELECT * FROM `" . CAB_DOP_USLUGI_DOP_INPUTS . "` WHERE `id` IN (" . $this->iputs_id_Str . ")"; $this->iputs_arr = array(); if (trim($this->iputs_id_Str) != '') { $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $this->iputs_arr[] = $row; } } } // получаем список всех полей $query = "SELECT * FROM `" . CAB_DOP_USLUGI_DOP_INPUTS . "`"; $result = $mysqli->query($query) or die($mysqli->error); $iputs_all_arr = array(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $iputs_all_arr[] = $row; } } // получаем json $this->print_details_dop_Json = trim($this->Service['print_details_dop']) == "" ? '{}' : $this->Service['print_details_dop']; // декодируем json в массив $this->print_details_dop = json_decode($this->print_details_dop_Json, true); // перебор полей указанных в услуге $html = ''; // добавляем скрытую json строку для обработке в JS $html = '<div id="dop_input_json">' . $this->print_details_dop_Json . '</div>'; //$html .= $this->print_arr($this->print_details_dop); // добавляем информацию из калькулятора.... если есть $html .= $this->Service['print_details_read']; foreach ($this->iputs_arr as $key => $input) { //echo $input['name_ru']; $html .= $input['name_ru'] . ':<br>'; //if($input['name_en'] == "tip_pechati"){$html .= '<div>'.$this->print_details_dop[$input['name_en']].'</div>';} if ($input['type'] == "text") { if (isset($this->print_details_dop[$input['name_en']])) { $text = $this->print_details_dop[$input['name_en']]; $text = htmlspecialchars(base64_decode($text), ENT_QUOTES); } else { // $html .= '!= '.$input['name_en']; $text = ''; } $html .= '<div><input class="dop_inputs" data-dop_usluga_id="' . $dop_usluga_id . '" type="' . $input['type'] . '" name="' . $input['name_en'] . '" placeholder="" value=\'' . $text . '\'" ' . $readonly . '></div>'; } else { $html .= 'данный тип поля пока что не предусмотрен'; } // удаляем $this->print_details_dop[$input['name_en']] unset($this->print_details_dop[$input['name_en']]); } //перебираем оставшиеся значения из json .... они могут остаться, // если админы что-то наменяли и открепили доп поля от услуги foreach ($iputs_all_arr as $key => $input) { if (isset($this->print_details_dop[$input['name_en']])) { $html .= $input['name_ru'] . ' * <span class="delete_dop_input_for_admin">(было удалено Админом из списка обязательных полей для услуги)</span><br>'; if ($input['type'] == "text") { $text = isset($this->print_details_dop[$input['name_en']]) ? $this->print_details_dop[$input['name_en']] : ''; $text = htmlspecialchars(base64_decode($text), ENT_QUOTES); $html .= '<div><input class="dop_inputs" data-dop_usluga_id="' . $dop_usluga_id . '" type="' . $input['type'] . '" name="' . $input['name_en'] . '" placeholder="" value="' . $text . '" ' . $readonly . '></div>'; } else { $html .= 'данный тип поля пока что не предусмотрен'; } } } // подключаем поле логотип, если оно включено в админке или уже что-то содержит if ($this->Service['logotip'] != '' || trim($this->Service_logotip_on) == "on") { $html .= '<div>Логотип<br><input type="text" class="save_logotip" name="logotip" value="' . addslashes($this->Service['logotip']) . '" ' . $readonly . '></div>'; } // подключаем поле плёнки, если оно включено в админке if (trim($this->Service_show_status_film_photos) == "on") { $html .= '<div>Плёнки/Клише<br>'; $html .= $this->get_statuslist_film_photos($this->Service['film_photos_status'], $this->Service['id']); // $html .='<textarea class="save_logotip" name="logotip">'.$this->Service['logotip'].'</textarea>'; $html .= '</div>'; } // подключаем поле путь к макету if (trim($this->maket_old_true_for_Service) == "on") { $html .= '<div>Путь к макету (к старому):<br>'; $html .= '<div><input type="text" name="the_url_for_layout" placeholder="заполнить при необходимости" class="save_the_url_for_layout" value="' . base64_decode($this->Service['the_url_for_layout']) . '" ' . $readonly . '></div>'; // $html .='<textarea class="save_logotip" name="logotip">'.$this->Service['logotip'].'</textarea>'; $html .= '</div>'; } $html .= '<div>Комментарии для исполнителя ' . (isset($this->performer[$this->Service['performer']]) ? '"' . $this->performer[$this->Service['performer']] . '"' : '') . '<br><textarea class="save_tz" name="tz" ' . $readonly . '>' . str_replace('<br>', "", base64_decode($this->Service['tz'])) . '</textarea></div>'; return $html; }
public function uslugi_template_cat_Html($arr, $NO_show_head = 0, $status_snab = '', $pause = 0, $edit_true = true) { // определяем редакторов для полей (html тегов) $this->edit_admin = $this->user_access == 1 ? ' contenteditable="true" class="edit_span"' : ''; $this->edit_men = $this->user_access == 5 ? ' contenteditable="true" class="edit_span"' : ''; $this->edit_snab = $this->user_access == 8 ? ' contenteditable="true" class="edit_span"' : ''; // '.$this->edit_admin.$this->edit_snab.$this->edit_men.' // если работает снаб, ограничиваем права мена и наоборот if ($status_snab == 'in_calculation' || $status_snab == 'in_recalculation') { $this->edit_snab = $this->user_access == 8 && !$pause ? ' contenteditable="true" class="edit_span"' : ''; $this->edit_men = ''; } else { $this->edit_men = $this->user_access == 5 && !$pause ? ' contenteditable="true" class="edit_span"' : ''; $this->edit_snab = ''; } // обнуляем все права при $edit_true == false if ($edit_true == false) { $this->edit_men = ''; $this->edit_snab = ''; $this->edit_admin = ''; $pause = 1; } $html = ''; // если массив услуг пуст возвращаем пустое значение if (!count($arr)) { return $html; } // сохраняем id услуг $id_s = array(); foreach ($arr as $key => $value) { $id_s[] = $value['uslugi_id']; } $id_s = implode(', ', $id_s); // делаем запрос по услугам global $mysqli; $query = "SELECT `" . OUR_USLUGI_LIST . "`.`parent_id`,\n\t\t`" . OUR_USLUGI_LIST . "`.`tz`,\n\t\t`" . OUR_USLUGI_LIST . "`.`edit_pr_in`,\n\t\t`" . OUR_USLUGI_LIST . "`.`price_out`,\n\t\t`" . OUR_USLUGI_LIST . "`.`for_how`,\n\t\t`" . OUR_USLUGI_LIST . "`.`id`,\n\t\t`" . OUR_USLUGI_LIST . "`.`name`,\n\t\t`" . OUR_USLUGI_LIST . "_par`.`name` AS 'parent_name' \n\t\tFROM " . OUR_USLUGI_LIST . "\ninner join `" . OUR_USLUGI_LIST . "` AS `" . OUR_USLUGI_LIST . "_par` ON `" . OUR_USLUGI_LIST . "`.`parent_id`=`" . OUR_USLUGI_LIST . "_par`.`id` WHERE `" . OUR_USLUGI_LIST . "`.`id` IN (" . $id_s . ") ORDER BY `os__our_uslugi_par`.`name` ASC "; // $query = "SELECT * FROM `".OUR_USLUGI_LIST."` WHERE `id` IN (".$id_s.")"; // echo $query; $result = $mysqli->query($query) or die($mysqli->error); $services_arr = array(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { foreach ($arr as $key => $value) { $services_arr[$row['id']] = $row; } } } include_once ROOT . "/libs/php/classes/print_calculators_class.php"; $uslname = ''; foreach ($services_arr as $key => $service) { // $NO_show_head добавлен как необязательная переменная для отключения вывода // названия группы услуги if ($uslname != $service['parent_name'] && !$NO_show_head) { $html .= '<tr class="group_usl_name" data-usl_id="' . $service['parent_id'] . '"> <th colspan="7">' . $service['parent_name'] . '</th> </tr>'; $uslname = $service['parent_name']; } foreach ($arr as $key2 => $value2) { if ($value2['uslugi_id'] == $key) { $price_in = $value2['for_how'] == "for_all" ? $value2['price_in'] : $value2['price_in'] * $value2['quantity']; $price_out_men = $value2['for_how'] == "for_all" ? $value2['price_out'] : $value2['price_out'] * $value2['quantity']; $pribl = $value2['for_how'] == "for_all" ? $value2['price_out'] - $value2['price_in'] : $value2['price_out'] * $value2['quantity'] - $value2['price_in'] * $value2['quantity']; $dop_inf = $value2['for_how'] == "for_one" ? '(за тираж ' . $value2['quantity'] . ' шт.)' : ''; // информация из калькулятора $calc_info = ''; $calc_class = ''; if ($service['parent_id'] == 6) { $calc_class = ' service-calculator'; $calc_info = '<span class="calc_info">/ ' . printCalculator::convert_print_details($value2['print_details']) . ' /</span>'; } $price_out_snab = $value2['for_how'] == "for_all" ? $value2['price_out_snab'] : $value2['price_out_snab'] * $value2['quantity']; $real_price_out = $service['for_how'] == "for_all" ? $service['price_out'] : $service['price_out'] * $value2['quantity']; // ТЗ кнопки $buttons_tz = trim($value2['tz']) == '' ? '<span class="tz_text_new"></span>' : '<span class="tz_text_edit"></span>'; $html .= '<tr class="calculate calculate_usl " data-dop_uslugi_id="' . $value2['id'] . '" data-our_uslugi_id="' . $service['id'] . '" data-our_uslugi_parent_id="' . trim($service['parent_id']) . '" data-for_how="' . trim($service['for_how']) . '"> <td><div class="' . $calc_class . '">' . $service['name'] . ' ' . $dop_inf . ' <br> ' . $calc_info . '</div></td> <td class="row_tirage_in_gen uslugi_class price_in"><span ' . ($service['edit_pr_in'] == '1' ? $this->edit_admin . $this->edit_snab . $this->edit_men : '') . '>' . $this->round_money($price_in) . '</span></td> <td class="row_tirage_in_gen uslugi_class percent_usl"><span ' . $this->edit_admin . $this->edit_snab . $this->edit_men . '>' . $this->get_percent_Int($value2['price_in'], $value2['price_out']) . '</span></td> <td class="row_price_out_gen uslugi_class price_out_men"><span ' . $this->edit_admin . $this->edit_men . '>' . $this->round_money($price_out_men) . '</span></td> <td class="row_pribl_out_gen uslugi_class pribl"><span>' . $this->round_money($pribl) . '</span></td> <td class="usl_tz">' . $buttons_tz . '<span class="tz_text">' . base64_decode($value2['tz']) . '</span><span class="tz_text_shablon">' . $service['tz'] . '</span></td>'; $html .= $this->user_id == $value2['creator_id'] || $this->user_access == 1 ? '<td class="usl_del"><span class="del_row_variants"></span></td>' : ''; // $html .= $value2['creator_id']; $html .= '</tr>'; } } } return $html; }
static function add_items_for_specification($dateDataObj, $specification_num, $rows_data, $client_id, $agreement_id, $agreement_date, $our_firm_acting_manegement_face, $client_firm_acting_manegement_face, $date, $short_description, $address, $prepayment) { global $mysqli; // print_r($dateDataObj); // exit; if (!$specification_num) { $query = "SELECT MAX(specification_num) specification_num FROM `" . GENERATED_SPECIFICATIONS_TBL . "` WHERE agreement_id = '" . $agreement_id . "'"; $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $specification_num = $row['specification_num'] + 1; } else { $specification_num = 1; } } $date_arr = explode('.', $date); $date = $date_arr[2] . '-' . $date_arr[1] . '-' . $date_arr[0]; $rows_data_arr = json_decode($rows_data); // echo $specification_num.'<pre>'; print_r($rows_data_arr); echo '</pre>';// // exit; // настройки в завасимости от типа спецификации $dates_data = self::date_terms_convert($dateDataObj); $shipping = '0000-00-00 00:00:00'; foreach ($rows_data_arr as $data_arr) { if (count($data_arr) == 0) { continue; } $summ_out = 0; $uslugi_summ_out = 0; $main_id = $data_arr->pos_id; $dop_id = $data_arr->row_id; $query = "SELECT*FROM `" . RT_MAIN_ROWS . "` WHERE `id` = '" . $main_id . "'"; // echo $query."\r\n"; $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { // 1). main_data $main_data = $result->fetch_assoc(); $query2 = "SELECT*FROM `" . RT_DOP_DATA . "` WHERE `id` = '" . $dop_id . "'"; // echo $query."\r\n"; $result2 = $mysqli->query($query2) or die($mysqli->error); if ($result2->num_rows > 0) { // 2). dop_data $dop_data = $result2->fetch_assoc(); $expel = array("main" => 0, "print" => 0, "dop" => 0); if (@$dop_data['expel'] != '') { $obj = @json_decode($dop_data['expel']); foreach ($obj as $expel_key => $expel_val) { $expel[$expel_key] = $expel_val; } } $summ_out = $dop_data['quantity'] * $dop_data['price_out']; $name = ($main_data['art'] != '' ? 'арт.' . $main_data['art'] : '') . " " . $main_data['name']; $price = $dop_data['price_out']; // прежде чем записать ряд в спецификацию сверим совпадает ли количество в расчете и в услугах // для этого делаем дополнительный запрос к таблице RT_DOP_USLUGI, далее после добавления ряда // будет такойже запрос к таблице RT_DOP_USLUGI но уже чтобы добавить доп услуги в спецификацию $query2_dop = "SELECT*FROM `" . RT_DOP_USLUGI . "` WHERE `dop_row_id` = '" . $dop_id . "' ORDER BY glob_type"; // echo $query."\r\n"; $result2_dop = $mysqli->query($query2_dop) or die($mysqli->error); if ($result2_dop->num_rows > 0) { while ($uslugi_data = $result2_dop->fetch_assoc()) { if ($uslugi_data['glob_type'] == 'print' && $uslugi_data['quantity'] != $dop_data['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($dop_data['quantity'], $dop_data['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, $dop_data['id'], 'true', 'false'); $query = "UPDATE `" . RT_DOP_DATA . "` SET `quantity` = '1' WHERE `id` = '" . $dop_data['id'] . "'"; $result = $mysqli->query($query) or die($mysqli->error); } } /**/ if ($uslugi_data['glob_type'] == 'extra' && $uslugi_data['quantity'] != $dop_data['quantity']) { $query = "UPDATE `" . RT_DOP_USLUGI . "` SET `quantity` = '" . $dop_data['quantity'] . "' WHERE `id` = '" . $uslugi_data['id'] . "'"; $result = $mysqli->query($query) or die($mysqli->error); $uslugi_data['quantity'] = $dop_data['quantity']; } } } if (isset($reload['flag']) && $reload['flag'] == true) { header('Location:' . HOST . '/?' . $_SERVER['QUERY_STRING']); exit; } if ($main_data['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($main_data['type'], $dop_data['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); $name .= $details; } // записываем ряд $specIdsArr[] = Agreement::insert_row($client_id, $agreement_id, $our_firm_acting_manegement_face, $client_firm_acting_manegement_face, $specification_num, $short_description, $address, $prepayment, $name, $dop_data['quantity'], $price, $dop_data['discount'], $date, $dateDataObj, $dates_data); $query3 = "SELECT*FROM `" . RT_DOP_USLUGI . "` WHERE `dop_row_id` = '" . $dop_id . "' ORDER BY glob_type DESC"; // echo $query."\r\n"; $result3 = $mysqli->query($query3) or die($mysqli->error); if ($result3->num_rows > 0) { while ($uslugi_data = $result3->fetch_assoc()) { // 3). uslugi_data if ($uslugi_data['glob_type'] == 'print' && !!!$expel["print"]) { include_once ROOT . "/libs/php/classes/print_calculators_class.php"; $name = printCalculator::convert_print_details($uslugi_data['print_details']); // записываем ряд $specIdsArr[] = Agreement::insert_row($client_id, $agreement_id, $our_firm_acting_manegement_face, $client_firm_acting_manegement_face, $specification_num, $short_description, $address, $prepayment, $name, $uslugi_data['quantity'], $uslugi_data['price_out'], $uslugi_data['discount'], $date, $dateDataObj, $dates_data); } if ($uslugi_data['glob_type'] == 'extra' && !!!$expel["dop"]) { // если альтернативное название отсутствует (вводится при заведении услуги "НЕТ В СПИСКЕ") if (trim($uslugi_data['other_name']) == "") { $extra_usluga_details = self::get_usluga_details($uslugi_data['uslugi_id']); $name = $extra_usluga_details ? $extra_usluga_details['name'] : 'Неопределено'; } else { $name = $uslugi_data['other_name']; } // меняем количество на 1(еденицу) если это надбавка на всю стоимость $uslugi_data['quantity'] = $uslugi_data['for_how'] == 'for_all' ? 1 : $uslugi_data['quantity']; // записываем ряд $specIdsArr[] = Agreement::insert_row($client_id, $agreement_id, $our_firm_acting_manegement_face, $client_firm_acting_manegement_face, $specification_num, $short_description, $address, $prepayment, $name, $uslugi_data['quantity'], $uslugi_data['price_out'], $uslugi_data['discount'], $date, $dateDataObj, $dates_data); } /**/ } } } } } // exit; // этап создания отдельного файла Спецификации и сохраниения его на диск // проверяем существует ли папка данного клиента если нет создаем её // если происходит ошибка выводим отчет // проверяем есть папка данного клента, если её нет то создаем её $client_dir_name = $_SERVER['DOCUMENT_ROOT'] . '/admin/order_manager/data/agreements/' . strval($client_id); //chmod("data/com_offers/", 0775); if (!file_exists($client_dir_name)) { if (!mkdir($client_dir_name, 0775)) { echo 'ошибка создания папки клиента (4)' . $client_dir_name; exit; } } // папка обозначающая год (название папки - название года) $agreement_date = explode('-', $agreement_date); $year_dir_name = $client_dir_name . '/' . $agreement_date[0]; if (!file_exists($year_dir_name)) { if (!mkdir($year_dir_name, 0775)) { echo 'ошибка создания папки с именем года' . $year_dir_name; exit; } } // папка для типа договора $type_dir_name = $year_dir_name . '/long_term'; if (!file_exists($type_dir_name)) { if (!mkdir($type_dir_name, 0775)) { echo 'ошибка создания папки с именем года' . $type_dir_name; exit; } } $our_requisit_id = fetchOneValFromGeneratedAgreementTbl(array('retrieve' => 'our_requisit_id', 'coll' => 'id', 'val' => $agreement_id)); $client_requisit_id = fetchOneValFromGeneratedAgreementTbl(array('retrieve' => 'client_requisit_id', 'coll' => 'id', 'val' => $agreement_id)); // папка для выбранных сторон $full_dir_name = $type_dir_name . '/' . $our_requisit_id . '_' . $client_requisit_id; if (!file_exists($full_dir_name)) { if (!mkdir($full_dir_name, 0775)) { echo 'ошибка создания папки с именем года' . $full_dir_name; exit; } } // папка для выбранных спецификаций $full_dir_name = $full_dir_name . '/specifications'; if (!file_exists($full_dir_name)) { if (!mkdir($full_dir_name, 0775)) { echo 'ошибка создания папки с именем года' . $full_dir_name; exit; } } // записываем файл $file_name = $full_dir_name . '/' . $specification_num . '.tpl'; //echo $file_name; //$file_name = $dir_name_full.'/com_pred_1_1.doc'; //if(file_exists($file_name)){ //echo 'файл с таким именем уже существует (232)'; //exit; //} if ($dateDataObj->data_type == 'days') { $origin_file_name = ROOT . '/modules/agreement/agreements_templates/specification.tpl'; } if ($dateDataObj->data_type == 'date') { $origin_file_name = ROOT . '/modules/agreement/agreements_templates/specification_type2_by_date.tpl'; } $fd_origin = fopen($origin_file_name, 'r'); $file_content = fread($fd_origin, filesize($origin_file_name)); fclose($fd_origin); $fd = fopen($file_name, 'w'); $write_result = fwrite($fd, $file_content); //\r\n fclose($fd); /* // создаем предзаказ include_once(ROOT."/libs/php/classes/rt_class.php"); RT::make_order($rows_data,$client_id,$_GET['query_num'],$specification_num,$agreement_id,$dateDataObj->doc_type,$dateDataObj->data_type,$dates_data['shipping_date_time'],$dates_data['item_production_term'],$dates_data['final_date_time']); */ return $specification_num; }
static function make_order($rows_data, $client_id, $query_num, $doc_num, $doc_id, $doc_type, $date_type, $shipping_date = '', $work_days = 0, $limit = '0000-00-00') { echo '<br><br><strong>$limit = </strong>' . $limit . '<br>'; // подключаем класс для информации из калькулятора include_once ROOT . "/libs/php/classes/print_calculators_class.php"; global $mysqli; $user_id = $_SESSION['access']['user_id']; // убиваем пустые позиции foreach (json_decode($rows_data, true) as $key => $value) { if (!empty($value)) { $positions_arr[] = $value; } } ///////////////////////////// // СОЗДАНИЕ СТРОКИ с информацией по группе товаров в спецификации -- START ///////////////////////////// // КОПИРУЕМ СТРОКУ ЗАКАЗА из таблицы запросов $query = "INSERT INTO `" . CAB_BILL_AND_SPEC_TBL . "` (`manager_id`, `client_id`, `snab_id`, `query_num` )\n SELECT `manager_id`, `client_id`, `snab_id`, `query_num`\n FROM `" . RT_LIST . "` \n WHERE `query_num` = '" . $query_num . "';\n "; echo $query; // выполняем запрос $result = $mysqli->query($query) or die($mysqli->error); // получаем id нового заказа... он же номер $the_bill_id = $mysqli->insert_id; ///////////////////////////// // СОЗДАНИЕ СТРОКИ с информацией по группе товаров в спецификации -- start ///////////////////////////// ////////////////////////// // Запрашиваем информацию по спецификацииии или оферте-- start ////////////////////////// if ($doc_type == 'spec') { $query = "SELECT * FROM `" . GENERATED_SPECIFICATIONS_TBL . "` WHERE `agreement_id` = '" . $doc_id . "' AND `specification_num` = '" . $doc_num . "'"; echo $query; $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $prepayment = $row['prepayment']; } } if ($doc_type == 'oferta') { $query = "SELECT * FROM `" . OFFERTS_TBL . "` WHERE `id` = '" . $doc_id . "'"; echo $query; $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $prepayment = $row['prepayment']; } } ////////////////////////// // Запрашиваем информацию по спец-ии или оферте -- end ////////////////////////// //////////////////////////////////// // Сохраняем данные о спецификации или оферте -- start //////////////////////////////////// $query = "UPDATE `" . CAB_BILL_AND_SPEC_TBL . "` SET "; $query .= " `specification_num` = '" . (int) $doc_num . "'"; $query .= ", `create_time` = '" . date('Y-m-d', time()) . "' "; $query .= ", `doc_num` = '" . (int) $doc_num . "'"; $query .= ", `doc_type` = '" . $doc_type . "'"; $query .= ", `date_type` = '" . $date_type . "'"; $query .= ", `doc_id` = '" . (int) $doc_id . "'"; $query .= ", `shipping_date` = '" . $shipping_date . "'"; // дата сдачи $query .= ", `work_days` = '" . (int) $work_days . "'"; // рабочие дни указываются в случае сроков по Р/Д $query .= ", `prepayment` = '" . (int) $prepayment . "'"; // % предоплаты для запуска заказа $query .= ", `shipping_date_limit` = '" . $limit . "'"; $query .= " WHERE `id` = '" . $the_bill_id . "'"; // выполняем запрос $result = $mysqli->query($query) or die($mysqli->error); //////////////////// // test query //////////////////// // echo '<br><br>'.$query; // exit; //////////////////////////////////// // Сохраняем данные о спецификации или оферте -- end //////////////////////////////////// // echo '<br>'.$order_num.'<br>'; // перебираем принятые данные по позициям foreach ($positions_arr as $position) { ////////////////////////// // заведение позиций ////////////////////////// $query = "INSERT INTO `" . CAB_ORDER_MAIN . "` (`master_btn`,`type`,`art`,`art_id`,`name`,`number_rezerv`)\n\t SELECT `master_btn`,`type`,`art`,`art_id`,`name`,`number_rezerv`\n\t FROM `" . RT_MAIN_ROWS . "` \n\t WHERE `query_num` = '" . $query_num . "' \n\t AND `id` = '" . $position['pos_id'] . "';\n\t "; // выполняем запрос $result = $mysqli->query($query) or die($mysqli->error); // id новой позиции $main_row_id = $mysqli->insert_id; // выбираем id строки расчёта // КОПИРУЕМ СТРОКУ РАСЧЁТА (В ЗАКАЗЕ ОНА У НАС ДЛЯ КАЖДОГО ЗАКАЗА ТОЛЬКО 1) $query = "INSERT INTO `" . CAB_ORDER_DOP_DATA . "` (\n\t `row_id`,`expel`,`quantity`,`zapas`,`price_in`,`price_out`,`discount`,`tirage_json`,\n\t `print_z`,`shipping_time`,`shipping_date`,`no_cat_json`,`suppliers_name`,`suppliers_id`\n\t )\n\t SELECT `row_id`,`expel`,`quantity`,`zapas`,`price_in`,`price_out`,`discount`,`tirage_json`,\n\t `print_z`,`shipping_time`,`shipping_date`,`no_cat_json`,`suppliers_name`,`suppliers_id`\n\t FROM `" . RT_DOP_DATA . "` \n\t WHERE `id` = '" . $position['row_id'] . "'\n\t "; $result = $mysqli->query($query) or die($mysqli->error); $dop_data_row_id = $mysqli->insert_id; // id нового расчёта... он же номер // правим row_id на полученный из созданной строки позиции $query = "UPDATE `" . CAB_ORDER_DOP_DATA . "` \n SET `row_id` = '" . $main_row_id . "' \n WHERE `id` ='" . $dop_data_row_id . "';"; $result = $mysqli->query($query) or die($mysqli->error); // правим order_num на новый номер заказа $query = "UPDATE `" . CAB_ORDER_MAIN . "` \n SET `the_bill_id` = '" . $the_bill_id . "' \n WHERE `id` ='" . $main_row_id . "';"; $result = $mysqli->query($query) or die($mysqli->error); ////////////////////////////////////////////////////// // КОПИРУЕМ ДОП УСЛУГИ И УСЛУГИ ПЕЧАТИ -- start // ////////////////////////////////////////////////////// // думаю в данном случае копировать не стоит, // лучше сначала выбрать , преобразовать в PHP и вставить // в противном случае при одновременном обращении нескольких менеджеров к данному скрипту // данные о доп услугах для заказа могут быть потеряны /* данный вопрос решается в любом случае двумя запросами: Вар. 1) копируем данные, замораживаем таблицу доп услуг и апдейтим родительский id Вар. 2) выгружаем данные о доп услугах в PHP, и записывае в новую таблицу */ $query = "SELECT * FROM `" . RT_DOP_USLUGI . "` \n WHERE `dop_row_id` = '" . $position['row_id'] . "'"; // echo $position['row_id'].'<br><br><br><br>'; $arr_dop_uslugi = array(); $result = $mysqli->query($query) or die($mysqli->error); if ($result->num_rows > 0) { // echo $row.'<br><br><br>'; while ($row = $result->fetch_assoc()) { $query2 = "INSERT INTO `" . CAB_DOP_USLUGI . "` SET\n\t\t\t\t\t\t`dop_row_id` = '" . $dop_data_row_id . "',\n\t\t\t\t\t\t`date_ready` = '0000-00-00',\n\t\t\t\t\t\t`date_send_out` = '0000-00-00',\n\t\t\t\t\t\t`uslugi_id` = '" . $row['uslugi_id'] . "',\n\t\t\t\t\t\t`glob_type` = '" . $row['glob_type'] . "',\n\t\t\t\t\t\t`type` = '" . $row['type'] . "',\n\t\t\t\t\t\t`quantity` = '" . $row['quantity'] . "',\n\t\t\t\t\t\t`price_in` = '" . $row['price_in'] . "',\n\t\t\t\t\t\t`price_out` = '" . $row['price_out'] . "',\n\t\t\t\t\t\t`for_how` = '" . $row['for_how'] . "',\n\t\t\t\t\t\t`print_details_dop` = '" . printCalculator::convert_print_details_to_dop_tech_info($row['print_details']) . "',\n\t\t\t\t\t\t`tz` = '" . $row['tz'] . "',\t\t\t\t\n\t\t\t\t\t\t`performer` = '" . $row['performer'] . "',\n\t\t\t\t\t\t`print_details` = '" . $row['print_details'] . "';"; // echo $query2.'<br><br>';exit; $mysqli->query($query2) or die($mysqli->error); } } ////////////////////////////////////////////////////// // КОПИРУЕМ ДОП УСЛУГИ И УСЛУГИ ПЕЧАТИ -- end // ////////////////////////////////////////////////////// } }
} //print_r( $multi_dim_arr[$row['main_id']]['dop_data'][$row['dop_data_id']]['print_data']); echo "<br>"; $rows[]= '<tr><td>'.implode('</td><td>',$row).'</td></tr>'; } return array($multi_dim_arr,$rows); } $rows = fetch_rows_from_rt($query_num); // получаем информацию по площадям нанесения для калькуляторов require_once(ROOT."/libs/php/classes/print_calculators_class.php"); $print_sizes = printCalculator::get_sizes(); $uslugi_arr = printCalculator::get_uslugi(); $test_data = FALSE; // TRUE // Построение таблицы РТ // основой для рядов таблицы (тегов <tr>) является второй уровень массива $rows[0], тоесть это те данные которые лежат в $row['dop_data'] // каждый элемент этого массива выводится как отдельный ряд (в ходе обработки вывода могут быть добавлены дополнительные вспомагательные // элементы или изменен их порядок) // Тоесть таблица, количество (тегов <tr>), формируется на основе уровня $row['dop_data'], остальные уровни только влияют на результирующий // вид таблицы // элементы первого уровня выводятся один раз на весь блок элементов $row['dop_data'] // элементы третьего уровня $dop_row['dop_uslugi'] выводятся в виде ссылки внутри существующего ряда, если $dop_row['dop_uslugi'] существует // draft - РЕАЛИЗАЦИЯ ФУНКЦИОНАЛА "ДРАФТ" оказалась не востребованной поле draft можно удалить из таблицы в базе данных // если что реализация сохранена, закомментирована внизу скрипта // echo '<pre>'; print_r($rows[0]); echo '</pre>';