$arr = explode(",", $admin_config['order_office']); $where = '('; foreach ($arr as $k => $v) { if ($k) { $where .= " OR "; } $where .= "office_id={$v}"; } $where .= ')'; $replace['office_select'] = mysql_select('office_id', "SELECT office_id, region FROM " . TABLE_OFFICE . " WHERE {$where} ORDER BY office_id", $office_id, 0, "", $office_count); } $replace['stamp_select'] = array_select('stamp', array(0 => 'Нет', 1 => 'Да'), 0); $replace['order_status'] = $admin_config['order_status']; $replace['card_vip_select'] = array_select('card_vip', array(0 => '', 1 => 'Vip'), $replace['card_vip']); $where = "h.tour<2 AND s.public AND s.hotel_id='{$hotel_id}'"; $tour_date_from = sql_date_from_form('', $replace['date_from']); if ($replace['tour_id']) { $sql1 = mysql_query("SELECT suite, date_from FROM " . TABLE_TOUR . " WHERE tour_id='{$replace['tour_id']}'") or Error(1, __FILE__, __LINE__); $t = @mysql_fetch_array($sql1); if (@$t['suite']) { $tour_date_from = $t['date_from']; $where .= " AND FIND_IN_SET(s.suite_id, '{$t['suite']}')"; } } $suite_list = array(); $sql1 = mysql_query("SELECT s.suite_id, s.name, s.ncount, z.order_id, z.paid, z.prepaid \n\t\t\t\tFROM " . TABLE_SUITE . " s \n\t\t\t\tLEFT JOIN " . TABLE_HOTEL . " h ON (h.hotel_id=s.hotel_id) \n\t\t\t\tLEFT JOIN " . TABLE_ORDER . " z ON (z.tour_id='{$replace['tour_id']}' AND z.status AND !z.basket AND \n\t\t\t\t\tz.suite_id regexp CONCAT('(^|,)',s.suite_id,'-'))\n\t\t\tWHERE {$where} \n\t\t\tGROUP BY s.suite_id\n\t\t\tORDER BY s.ord") or Error(1, __FILE__, __LINE__); while ($suite = @mysql_fetch_array($sql1)) { if ($replace['tour_id']) { $suite['status'] = $suite['order_id'] ? $suite['paid'] || $suite['prepaid'] ? 2 : 1 : 0; if (!$suite['status']) { $sql_r = mysql_query("SELECT order_id, status FROM " . TABLE_RESERVATION . " where suite_id='{$suite['suite_id']}' AND tour_id='{$replace['tour_id']}' AND status>0") or Error(1, __FILE__, __LINE__);
} mysql_query("INSERT INTO " . TABLE_TOUR . " SET ord={$ord}, hotel_id={$hotel_id} {$sql_str}") or Error(1, __FILE__, __LINE__); $id = mysql_insert_id(); Header("Location: " . ADMIN_URL . "?p={$part}&tours=1&tour_id={$id}&hotel_id={$hotel_id}&edit=1"); exit; } if (@$savetour) { $url = ADMIN_URL . "?p={$part}&tours=1&tour_id={$tour_id}&hotel_id={$hotel_id}&edit=1"; $tour_id = (int) @$tour_id; $ord = (int) @$ord; $public = (int) @$public; $name = escape_string(from_form(@$name)); $plackart = (int) @$plackart; $kupe = (int) @$kupe; $date_from = sql_date_from_form('date_from'); $date_to = sql_date_from_form('date_to'); if (is_array(@$suite)) { $suite_str = join(",", array_keys($suite)); } else { $suite_str = ''; } $sql = mysql_query("SELECT COUNT(*) FROM " . TABLE_TOUR . " WHERE hotel_id={$hotel_id}") or Error(1, __FILE__, __LINE__); $arr = @mysql_fetch_array($sql); $count = (int) @$arr[0]; $sql = mysql_query("SELECT p.ord FROM " . TABLE_TOUR . " p WHERE p.tour_id={$tour_id}") or Error(1, __FILE__, __LINE__); $arr = @mysql_fetch_array($sql); $oldord = (int) @$arr[0]; if ($ord < 1 || $ord > $count) { $_SESSION['message'] = "Неверное значение порядкового номера (от 1 до {$count})"; Header("Location: " . $url); exit;