<?php
require_once 'application/class/class_ManageSession.php';

global $connecteur;

$action = getValue('action');
$mode = getValue('mode');
$ancrage = getValue('ancrage');
$no_ao = getValue('no_ao');
$type_soc_gs = getValue('type_soc_gs');
$code_ste = getValue('code_ste');
$id_modele = getValue('id_modele');

switch ($action) {
    case 'AffichePopup':
        $objImport = new AO_ImportModele($no_ao);
        $array = $objImport->buildXml($type_soc_gs, $code_ste, $mode, $ancrage);
        $genXsl = new GenXslt(true);
        echo $genXsl->XslHtml(AO_ImportModele::fichierXsl, $array);
        break;
    
    case 'Importer':
        $objImport = new AO_ImportModele($no_ao);
        $resultat = $objImport->importModele($id_modele);
        if ('O' != $resultat['Statut'])
            Affichage::messageJS($resultat['MsgErreur']);
        else {
            echo 'setTimeout(function() {window.closePopup();}, 0);';
            echo 'setTimeout(function() {parent.CallUrl("', AO_Questionnaire::fichierPhp, '?action=rafraichirAffichage&no_ao=', $no_ao, '&mode=', $mode, '&ancrage=', $ancrage, '");}, 0);';
        }
        break;
}

$connecteur->disconnect();