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

$svaTool = new svaTool();

//print_r($_REQUEST);


$errorCode = 0;

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

if (isset($_REQUEST['commentType']) && $_REQUEST['commentType'] != "-1")
    $commentType = addslashes($_REQUEST['commentType']);
else
    $errorCode = 1;

/*
if (isset($_FILES['name']['attachFile']) && strlen($_REQUEST['attachFile'])>0 )
    $csrDetails = addslashes($_REQUEST['csrDetails']);
else
    $errorCode = 2;
*/

if (isset($_REQUEST['csrComment']) && strlen($_REQUEST['csrComment'])>0 )
    $csrComment = addslashes($_REQUEST['csrComment']);
else
    $errorCode = 3;
/*	
if (isset($_REQUEST['emailId']) && strlen($_REQUEST['csrComment'])>0 )
    $csrDetails = addslashes($_REQUEST['csrComment']);
else
    $errorCode = 4;
	*/


$csrId = addslashes($_REQUEST['csrId']);
$customerName = addslashes($_REQUEST['customerName']);
$userId = $_SESSION['ownerId'];


/*
$callerId = addslashes($_REQUEST['callerId']);
$firstName = addslashes($_REQUEST['firstName']); 
$lastName = addslashes($_REQUEST['lastName']);

$address = addslashes($_REQUEST['address']);
$mobileNumber = addslashes($_REQUEST['mobileNumber']);
$emailId = addslashes($_REQUEST['emailId']);
$callId = addslashes($_REQUEST['callId']);

$statut = addslashes($_REQUEST['operationId']);
$actionType = addslashes($_REQUEST['actionType']);
*/

if ($errorCode == 0) {
$id = 0;
$field[0] = date('Y-m-d H:i:s');
$field[1] = '';
$field[2] = '';
$field[3] = '';
$field[4] = '';
$dba->UpdateAddComment($id, $userId, $csrId, $csrComment, $commentType, $customerName,0 );


   //$errorCode = 10;
}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"COMMENTAIRE AJOUTE AVEC SUCCES !\"  }"; 
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER LE TYPE DU COMMENTAIRE !\"  }";
        break;
    case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ DETAILLER LA REQUETE DU CLIENT !\"  }"; 
        break;
    case 3 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SAISIR UN COMMENTAIRE.\"  }"; 
        break;
 /*   case 4 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER LA STRATEGIE DES APPELS ENTRANTS.\"  }";
        break;
   /* case 5 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LE LOGIN EST INVALIDE.\"  }"; 
        break;
    case 6 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! L'EMAIL EST INVALIDE.\"  }";
        break;
    /*case 7 : $msg =  "ERREUR ! LE MOT DE PASSE EST INVALIDE.";
        break;
    case 8 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LE MOT DE PASSE DE CONFIRMATION EST INVALIDE .!\"  }"; 
        break;
    case 9 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LES MOTS DE PASSE NE CONCORDENT PAS.\"  }";
        break; */
    case 13 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! IMPOSSIBLE DE CREER LE COMPTE. VEUILLEZ RE-ESSAYER ULTERIEUREMENT!\"  }";  break;
	/*
		case 14 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! VEUILLEZ SELECTIONNER LE PLAN TARIFAIRE ASSOCIE AU COMPTE !\"  }";   break; */
   
	 
}


echo $msg ;


?>