<?php

require_once __DIR__ . "/../auth.php";
require_once __DIR__ . "/../../fonctions/divers.php";
if (!est_autorise("acces_configuration")) {
    exit;
}
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
if ($request->isXmlHttpRequest() === false) {
    redirige("../accueil.php");
}
header('Content-Type: text/html; charset=utf-8');
if ($request->query->get('action') == "supprimer" && $request->query->get('zone', "") != "") {
    $transzone = new Transzone();
    $transzone->charger_id($request->query->get('zone'));
    $transzone->delete();
    echo 1;
} else {
    if ($request->query->get('action') == "ajouter" && $request->query->get('id', "") != "" && $request->query->get('zone', "") != "") {
        $transzone = new Transzone();
        $transzone->zone = $request->query->get('zone');
        $transzone->transport = $request->query->get('id');
        $id = $transzone->add();
        echo json_encode(array("res" => 1, "id" => $id));
    }
}
/*                                                                                   */
/*      This program is distributed in the hope that it will be useful,              */
/*      but WITHOUT ANY WARRANTY; without even the implied warranty of               */
/*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
/*      GNU General Public License for more details.                                 */
/*                                                                                   */
/*      You should have received a copy of the GNU General Public License            */
/*	    along with this program. If not, see <http://www.gnu.org/licenses/>.         */
/*                                                                                   */
/*************************************************************************************/
require_once __DIR__ . "/../pre.php";
require_once __DIR__ . "/../auth.php";
require_once __DIR__ . "/../../fonctions/divers.php";
if (!est_autorise("acces_configuration")) {
    exit;
}
require_once "../liste/transport.php";
header('Content-Type: text/html; charset=utf-8');
if ($_GET['action'] == "supprimer" && $_GET['zone'] != "") {
    $transzone = new Transzone();
    $transzone->charger_id($_GET['zone']);
    $transzone->delete();
} else {
    if ($_GET['action'] == "ajouter" && $_GET['id'] != "" && $_GET['zone'] != "") {
        $transzone = new Transzone();
        $transzone->zone = $_GET['zone'];
        $transzone->transport = $_GET['id'];
        $transzone->add();
    }
}
modifier_transports($_GET['id']);