<?php
session_start();
$currentBaseDir = dirname($_SERVER['PHP_SELF']);
include($_SESSION['basedir']."core.php");

$svaTool = new svaTool();


$errorCode = 0;
if (isset($_REQUEST['ivrName']) && strlen($_REQUEST['ivrName']) > 0) {
    $ivrName = addslashes($_REQUEST['ivrName']);
} else {
    $errorCode = 1;
}


if (isset($_REQUEST['ivrData']) && strlen($_REQUEST['ivrData']) > 0) {
    $ivrData = addslashes($_REQUEST['ivrData']);
} else {
    $errorCode = 2;
}



$description = addslashes($_REQUEST['description']);

$opId = $_REQUEST['opId'];
$id = $_REQUEST['itemId'];
$userId = $_SESSION['ownerId'];

if($opId == 0 ){
    $label = "CREEE"; 
}
else {
    
    $label = "MODIFIEE";
}



if ($errorCode == 0) {


$res = $dba->UpdateAddDelIVR($opId, $id, $ivrName, $description, $ivrData , $_SESSION['ownerId']);

   //$errorCode = 10;
}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"SVI $label AVEC SUCCES !\"  }"; 
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VERIFIEZ L'IDENTIFIANT DE LA FICHE !\"  }";
        break;
   case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SAISIR LE DETAIL !\"  }";
        break;
    case 13 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! IMPOSSIBLE DE CREER LE COMPTE. VEUILLEZ RE-ESSAYER ULTERIEUREMENT!\"  }";  break;
	
}

echo $msg ;


?>