$action = $_POST['action']; if ($action == 'add_season') { $number = isset($_POST['number']) ? (int) $_POST['number'] : null; $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : null; $description = isset($_POST['description']) && trim($_POST['description']) ? trim($_POST['description']) : null; if ($number && $name && $description) { $game_model->add_season($provider_id, $number, $name, $description); } } else { if ($action == 'update_season') { $season_id = isset($_POST['season_id']) ? (int) $_POST['season_id'] : null; $number = isset($_POST['number']) ? (int) $_POST['number'] : null; $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : null; $description = isset($_POST['description']) && trim($_POST['description']) ? trim($_POST['description']) : null; if ($season_id && $number && $name && $description && $game_model->is_provider_season($provider_id, $season_id)) { $game_model->update_season(null, $number, $name, $description, null, null, $season_id); } } else { if ($action == 'delete_season') { $season_id = isset($_POST['season_id']) ? (int) $_POST['season_id'] : null; // Необходимо сделать проверку, нашего ли поставщика этот сезон if ($season_id && $game_model->is_provider_season($provider_id, $season_id)) { $game_model->delete_season($season_id); } } else { if ($action == 'delete_seasons') { $seasons_id = isset($_POST['seasons_id']) ? $_POST['seasons_id'] : null; foreach ($seasons_id as $season_id) { if ($season_id && $game_model->is_provider_season($provider_id, $season_id)) { $game_model->delete_season($season_id); }