WebService Netisse - CA Nord de France | GS3
Date : ".date('Y-m-d');
$GLOBALS['LOG'] .= "Date : ".date('Y-m-d')."\r\n";
$timestart=microtime(true);
require_once("../../inc/confNetisse.php");
ini_set('memory_limit','-1');
ini_set('max_execution_time', 0);
$DATATYPE = "JSON";
$s = "";
// ###############################################################
function getData($FILE, $DATATYPE) {
if ($DATATYPE == "JSON") {
$q0 = "UPDATE ca_conseillers SET gs3_check=0";
$r0 = excuteQuery($q0);
// ACQUISITIION DES DONNEES VIA WEBSERVICE - FORMAT JSON
$json = json_decode(file_get_contents($FILE));
$jsonCount = count($json);
echo "Total : ".$jsonCount."
";
$advisors = array();
for($i=0;$i<$jsonCount;$i++) {
$matricule = $json[$i]->Matricule;
$nom = $json[$i]->Nom;
$prenom = $json[$i]->Prenom;
$email = $json[$i]->email;
$civ = $json[$i]->Civilite;
if ($civ == 'M') {
$civ = "M.";
} else if ($civ == 'F') {
$civ = "Mme";
}
$eds = str_pad($json[$i]->AgenceRattachement, 5, "0", STR_PAD_LEFT);
//$agence = loadAgence($eds);
$profil = '';
$gs3 = $json[$i]->Fct;
if ($fct == "DAG" || $fct == "DAE" || $fct == "DAP" || $fct == "DDB" || $fct == "RAG" || $fct == "RPO" || $fct == "DCA") {
$fct = '1';
$profil = 6;
} else if ($fct == "AAG") {
$fct = '2';
} else {
$fct = '3';
}
$DATA = array(
"matricule" => $matricule,
"initiales" => $eds,
"eds" => $eds,
"nom" => $nom,
"prenom" => $prenom,
"email" => $email,
"civ" => $civ,
"pro" => null,
"gs3" => $fct,
"profil" => $profil,
"aid" => $agence->id_agence,
"agenceCode" => $eds,
"nom_agence" => $json[$i]->Libelle_AgenceRattachement,
"code" => $eds,
"statut" => 0,
"groupe" => "(SELECT id_entite FROM ca_entites WHERE id_agence=".intval($agence->id_agence)." LIMIT 1)",
"orientation" => "(SELECT id_orientation FROM ca_orientations WHERE id_entite=(SELECT id_entite FROM ca_entites WHERE id_agence=".intval($agence->id_agence)." LIMIT 1) AND orientation=2 LIMIT 1)",
);
$q1 = "SELECT id_conseiller, id_agent from ca_conseillers WHERE id_agent='".$matricule."' AND supp=0";
$r1 = excuteQuery($q1);
while ($o = $r1['stmt']->fetchObject()) {
$idc = $o->id_conseiller;
$q2 = "UPDATE ca_conseillers SET gs3='".$gs3."', gs3_check=1 WHERE id_conseiller=".intval($idc);
$s .= "".$o->id_agent." => ".$q2;
$r2 = excuteQuery($q2);
}
}
echo $s;
$GLOBALS['LOG'] .= $i. " conseillers traites.\r\n";
} else if ($DATATYPE == "CSV") {
// ACQUISITIION DES DONNEES VIA UN FICHIER - FORMAT CSV
}
}
// ###############################################################
// ###############################################################
// ###############################################################
// TIMERS
$timeend=microtime(true);
$time=$timeend-$timestart;
$page_load_time = number_format($time, 3);
$scriptStart = date("H:i:s", $timestart);
$scriptEnd = date("H:i:s", $timeend);
$timeLoad = $page_load_time;
//echo "DUREE = ".$timeLoad." s\r\n";
echo "Debut : ".date("H:i:s", $timestart);
echo "Fin : ".date("H:i:s", $timeend);
$GLOBALS['LOG'] .= "Start : ".date("H:i:s", $timestart)."\r\n";
$GLOBALS['LOG'] .= "End : ".date("H:i:s", $timeend)."\r\n";
//echo "Script execute en " . $page_load_time . " sec";
// REMISE A ZERO DES CONSEILLERS :
$q = 'UPDATE ca_conseillers SET chk=0';
$r = excuteQuery($q);
// RECUPERATION DU FLUX
// getData("https://democandf.welcometouchscreen.com/admin/outils/CANDF_20190729_WebService.json.txt", $DATATYPE);
getData("http://nfp10-iucrdevintra.ca-technologies.fr/Dotnet/Web_Services/WS_Netisse/Services/Get_Netisse_Data.ashx", $DATATYPE);
// CANDF_20190201_WebService.json.txt
file_put_contents('./logs/CANDF_WS_'.date("YmdHis").'.txt', $GLOBALS['LOG'], FILE_APPEND);
?>