<?php

session_start();
include './core.php';

$svaTool = new svaTool();

$ids = $_REQUEST['ids'];
$ids = rtrim($ids, ",");
$idsList = explode(",", $ids);
$found = false;
$errorCode = 0;


for ($i = 0; $i < count($idsList); $i++) {

    $roleId = trim($idsList[$i]);
    $Id .= "'" . $roleId . "',";
    if ($dba->checkRoleInUse($roleId) > 0) {
        $found = true;
        $errorCode = 1;
    }
}

$Id = rtrim($Id, ',');




if ($errorCode == 0) {
    $qosCode = "";
    $dba->UpdateAddDelRoles(3, $Id, NULL, NULL, NULL, NULL);
    $dba->UpdateAddDelRolesDetails(3, $Id, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ROLE(S) SUPPRIME(S) AVEC SUCCES !\"  }";
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! IMPOSSIBLE DE SUPPRIMER - ROLE EN COURS D'UTILISATION !\"  }";
        break;
    case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SAISIR UNE VALEUR POUR CE PARAMETRE. !\"  }";
        break;
}


echo $msg;
?>