// This is ajax //header("Content-Type: application/json"); // Get info (post only) $action = isset($_POST['action']) ? $_POST['action'] : NULL; // Must be logged in to use tasks below this section if (!$user->user_exists) { //echo json_encode(array('result' => FALSE, 'err' => 1)); //exit(); } // Create city object $city_model = new se_city(); // Модель поставщиков $provider_model = new se_provider(); if ($action == 'get_regions') { $area_id = isset($_POST['area_id']) ? $_POST['area_id'] : null; $regions = $city_model->get_regions($area_id); foreach ($regions as $region) { echo '<option value="' . $region['region_id'] . '">' . $region['name'] . '</option>'; } die; } else { if ($action == 'get_provider') { $prefix_table = isset($_POST['prefix_table']) ? $_POST['prefix_table'] : null; $provider_id = isset($_POST['provider_id']) ? $_POST['provider_id'] : null; if ($prefix_table && $provider_id) { $provider = $provider_model->get_provider($prefix_table, $provider_id); $subcategory = $provider_model->get_subcategory_by_prefix_table($prefix_table); if ($prefix_table == 'game') { include 'include/providers/class_game.php'; $game_model = new se_game(); $offers = $game_model->get_future_games($provider_id);
$city_name = isset($_POST['city']) ? trim($_POST['city']) : NULL; if ($area_id && $region) { $region_id = $city->add_region($region, $area_id); } if ($region_id && $city_name) { $city_id = $city->add_city($city_name, $region_id); } else { $error = 'Незаполнено название города'; } } // Города-миллионники $main_cities = $city->get_main_cities(); // Округа $areas = $city->get_areas(); // Регионы и города // Структура массива - $regions[area][$i][fields] $regions = array(); // Структура массива - $cities[region][$i][fields] $cities = array(); foreach ($areas as $area) { $regions[$area['area_id']] = $city->get_regions($area['area_id']); foreach ($regions[$area['area_id']] as $region) { $cities[$region['region_id']] = $city->get_cities($region['region_id']); } } $smarty->assign_by_ref('main_cities', $main_cities); $smarty->assign_by_ref('areas', $areas); $smarty->assign_by_ref('regions', $regions); $smarty->assign_by_ref('cities', $cities); $smarty->assign_by_ref('error', $error); include "footer.php";