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

$svaTool = new svaTool();


$errorCode = 0;

$password = NULL;
$confPasswd = NULL;
// Ajout de nouvel utilisateur
if (isset($_REQUEST['campaignName']) && strlen($_REQUEST['campaignName']) > 0)
    $campaignName = addslashes($_REQUEST['campaignName']);
else
    $errorCode = 1;
	
	
if (isset($_REQUEST['subjectName']) && strlen($_REQUEST['subjectName']) > 0)
    $subjectName = addslashes($_REQUEST['subjectName']);
else
    $errorCode = 2;
	

if (isset($_REQUEST['toUserList']) && strlen($_REQUEST['toUserList']) > 0)
    $toUserList = addslashes($_REQUEST['toUserList']);
else
    $errorCode = 3;
	

 $ccUserList = addslashes($_REQUEST['ccUserList']);
 
 
 if (isset($_REQUEST['mailText']) && strlen($_REQUEST['mailText']) > 0)
    $mailText = addslashes($_REQUEST['mailText']);
else
    $errorCode = 4;

	$actionType = addslashes($_REQUEST['actionType']);
	
	
	//echo "Text " . $mailText  ." T";

//print_r($_FILES);
//print_r($_REQUEST);



if ($errorCode == 0) {
$id = 0;
$count = 1;

//$res = $dba->UpdateAddCallReason(0,$id, $callReasonName,$callReasonDesc) ;

$res = $dba->UpdateAddMailCampaign(0, $id, $campaignName, $_SESSION['ownerId'], $mailText, $subjectName, $count ,$actionType);

   //$errorCode = 10;
}




switch ($errorCode) {

    case 0 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"CAMPAGNE CREE AVEC SUCCES  $res .\"  }"; 
        break;
    case 1 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! NOM DE CAMPAGNE INVALIDE.\"  }";
        break;
    case 2 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! SUJET INVALIDE.\"  }"; 
        break;
    case 3 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! LISTE DE DIFFUSION INVALIDE.\"  }"; 
        break;
    case 4 : $msg = "{ \"errorCode\": $errorCode,\"errorMessage\" :\"ERREUR ! CORPS DE TEXTE INVALIDE.\"  }";
        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 ;


?>