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

$svaTool = new svaTool();

//print_r($_REQUEST);


$errorCode = 0;
$opId= $userId= $username= $pwd= $userType=$profileId= $onwerId= $lang= $citizen=$firstName=$lastName=$primaryPhone= $secondaryPhone=$homePhone=$mobilePhone=$email=$primAddress=$secondAddress=$profession=$char1=$char2=$char3=$char4=$char5=$char6=$char7=$char8=$char9=$char10= $status="";

$password = NULL;
$confPasswd = NULL;
// Ajout de nouvel utilisateur

if(isset($_REQUEST['roleId']) && $_REQUEST['roleId']!= -1) {
	$roleId = $_REQUEST['roleId'] ;
}
else {
    
    $errorCode = 1; 
}


if(isset($_REQUEST['userId']) && $_REQUEST['userId']!= -1) {
	$userId = $_REQUEST['userId'] ;
}
else {
    
    $errorCode = 2; 
}


if(isset($_REQUEST['profileId']) && $_REQUEST['profileId']!= -1) {
	$profileId = $_REQUEST['profileId'] ;
}
else {
    
    $errorCode = 3; 
}




$callerId = $_REQUEST['callerId'] ;
$uid = $_REQUEST['uid'] ;
$opId = $_REQUEST['opId'] ;

//echo "Vue = ".$opId;




if($opId == 0 ){
    $label = "CREE"; 
}
else{
    $label = "MODIFIE";
    $userId = $uid;
    $errorCode = 0;
}

if ($errorCode == 0) {
  
 
 

$res = $dba->UpdateAddDelSCCUser($opId, $userId, $profileId, $callerId, 0) ;

}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"AGENT $label AVEC SUCCES !\"  }"; 
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER UN ROLE !\"  }";
        break;
    case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER UN UTILISATEUR !\"  }"; 
        break;
    case 3 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER UN PROFIL !\"  }"; 
        break;
	 
}


echo $msg ;

?>