<?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['groupTypeId']) && $_REQUEST['groupTypeId']!= -1) {
	$groupTypeId = $_REQUEST['groupTypeId'] ;
}
else {
    
    $errorCode = 1; 
}


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


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



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


if ($errorCode == 0) {
  
 
 
//$res = $dba->UpdateAddSCCAgent(0,0, $userId, $callerId, 0);
$res = $dba->UpdateAddDelSCCGroup($opId,$itemId, $userId, $groupTypeId, $groupName) ;

}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"GROUPE $label AVEC SUCCES !\"  }"; 
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER LE TYPE DU GROUPE !\"  }";
        break;
    case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ RENSEIGNER L'IDENTIFIANT DU GROUPE ! \"  }"; 
        break;
   
	 
}


echo $msg ;

?>