<?php
require("../../config/config.php");
require(APP."inc/inc-functions.php");
require(APP."inc/inc-display-functions.php");
require(APP."inc/classe_xml.php");
$xml=new classe_xml(MODELE);

$action=array(
    "titre"=>"Ajouter un item",
    "action"=>"ajouter_item",
    "submit"=>"Ajouter"
);

if(isset($_GET['xml'])){
    $item=CHEMIN.DOSSIER_XML.$_GET['xml'];
    $xml->lire_xml($item);
    $action=array(
        "titre"=>"Updater un item",
        "action"=>"updater_item",
        "submit"=>"Updater",
        "delete"=>"oui");
}
$retour=$xml->traiter_formulaire(true);

//print_r($xml->messages);

if($retour=="update"){ 
    display_mosaique_item($xml);
    supprimer_cache();
}
if($retour=="insert"){
    display_mosaique_item($xml);
    supprimer_cache();
}
if($retour=="delete"){
    // header('Location: '.URL.'index.php');
    // die();
    echo "delete";
    supprimer_cache();
} 
if($retour=="none"){
    echo "<div class='px-3'>".display_buttons("",false)."</div>";
    echo $xml->deployer_formulaire($action);
}
?>