Ajout du service Gestion (clients, utilisateurs)

This commit is contained in:
Michael RICOIS 2011-10-12 12:39:11 +00:00
parent de8fa78378
commit facbd2ed88
5 changed files with 1445 additions and 1 deletions

View File

@ -0,0 +1,3 @@
[0.1]
actif = true;
defaut = true;

View File

@ -0,0 +1,21 @@
Type[] = "ErrorType"
Type[] = "InfosLoginReturn"
Type[] = "InfosLogin"
Type[] = "InfosLoginData"
Type[] = "SetInfosLoginReturn"
Type[] = "NextLoginReturn"
Type[] = "NextLoginResult"
Type[] = "ClientFiltre";
Type[] = "ListeClientsReturn"
Type[] = "Client"
Type[] = "ListeDroitsReturn"
Type[] = "ListePrefsReturn"
Type[] = "ListeUtilisateursReturn"
Type[] = "Utilisateur"
Type[] = "LogsClientsReturn"
Type[] = "LogsClients"
Type[] = "ClientReturn"
Type[] = "SetUtilisateurs"
Type[] = "UtilisateursReturn"
Type[] = "ModeleUtilisateurReturn"
Type[] = "ModeleUtilisateur"

View File

@ -0,0 +1,955 @@
<?php
require_once 'WsScore/WsScore.php';
require_once realpath(dirname(__FILE__)).'/Types.php';
class Gestion extends WsScore
{
/**
* Récupère les informations du profil connecté
* @param string $login
* @param string $ipUtilisateur
* @return InfosLoginReturn
*/
public function getInfosLogin($login, $ipUtilisateur = '')
{
$this->authenticate();
//Initialisation
if (empty($ipUtilisateur)) $ipUtilisateur = $_SERVER['REMOTE_ADDR'];
$error = new ErrorType();
debugLog('I',"getInfosLogin pour $login (IP=$ipUtilisateur)",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
//L'utilisateur qui demande les informations est différent
if ($this->tabInfoUser['login']<>$login &&
( $this->tabInfoUser['profil']=='Administrateur' ||
$this->tabInfoUser['profil']=='SuperAdministrateur') )
{
//debugLog('I',"getInfosLogin - Un administrateur veut il des infos sur un login",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
/** Un administrateur veut il des infos sur un login ? **/
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->select(
'utilisateurs u, clients c',
'u.login, u.id, u.email, u.password, u.idClient, u.typeCompte, u.actif, u.filtre_ip, u.civilite, u.nom, u.prenom, u.tel, u.fax, u.mobile, u.profil, u.raisonSociale, u.siret, u.adrNum, u.adrIndRep, u.adrTypeVoie, u.adrLibVoie, u.adrCp, u.adrVille, u.adrComp, u.tel, u.fax, u.mobile, u.pref, u.profil, u.dateInscription, u.dateValidation, u.nombreConnexions, u.dateDerniereConnexion, u.droits, u.referenceParDefaut, u.nbReponses, u.formatMail, u.dateDebutCompte, u.dateFinCompte, u.maxFicheId, c.droits AS droitsClients, c.timeout',
"u.login='$login' AND u.idClient=c.id AND u.deleted=0",
false, MYSQL_ASSOC
);
$tabRep = $rep[0];
if (count($rep)>0)
{
$timeOutSec=$tabRep['timeout']*60;
if ($timeOutSec==0) $timeOutSec=1800;
$rep = array(
'login'=> $login,
'id'=> $tabRep['id'],
'email'=> $tabRep['email'],
'typeCompte'=> $tabRep['typeCompte'],
'idClient'=> $tabRep['idClient'],
'filtre_ip'=> $tabRep['filtre_ip'],
'civilite'=> $tabRep['civilite'],
'nom'=> $tabRep['nom'],
'prenom'=> $tabRep['prenom'],
'raisonSociale'=> $tabRep['raisonSociale'],
'siret'=> $tabRep['siret'],
'adrNum'=> $tabRep['adrNum'],
'adrIndRep'=> $tabRep['adrIndRep'],
'adrTypeVoie'=> $tabRep['adrTypeVoie'],
'adrLibVoie'=> $tabRep['adrLibVoie'],
'adrCp'=> $tabRep['adrCp'],
'adrVille'=> $tabRep['adrVille'],
'adrComp'=> $tabRep['adrComp'],
'tel'=> $tabRep['tel'],
'fax'=> $tabRep['fax'],
'mobile'=> $tabRep['mobile'],
'pref'=> $tabRep['pref'],
'profil'=> $tabRep['profil'],
'dateInscription'=> $tabRep['dateInscription'],
'dateValidation'=> $tabRep['dateValidation'],
'nombreConnexions'=> $tabRep['nombreConnexions'],
'dateDerniereConnexion'=> $tabRep['dateDerniereConnexion'],
'droits'=> $tabRep['droits'],
'droitsClients'=> $tabRep['droitsClients'],
'timeout'=> $timeOutSec,
'nbReponses'=> $tabRep['nbReponses'],
'formatMail'=> $tabRep['formatMail'],
'reference'=> $tabRep['referenceParDefaut'],
'dateDebutCompte'=> $tabRep['dateDebutCompte'],
'dateFinCompte'=> $tabRep['dateFinCompte'],
'maxFicheId'=> $tabRep['maxFicheId'],
);
$tabTmp = $iDbCrm->select('clients', 'typeScore', 'id='.$tabRep['idClient'], false, MYSQL_ASSOC);
$tabRep = $tabTmp[0];
$rep['typeScore'] = $tabRep['typeScore'];
}
}
else
{
//Identification utilisateur
$connected = true;
if (trim($this->tabInfoUser['filtre_ip'])<>'')
{
//debugLog('I',"getInfosLogin test filtre IP",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$connected = checkPlagesIp($this->tabInfoUser['filtre_ip'], $ipUtilisateur);
if (!$connected)
{
debugLog('I',"getInfosLogin Adresse IP $ipUtilisateur non declaree pour le compte $login",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
$error->errnum = 10818;
$error->errmsg = "Adresse IP $ipUtilisateur non declaree pour ce compte. Contactez votre administrateur !";
}
}
$rep = array(
'connected'=> $connected,
'login'=> $this->tabInfoUser['login'],
'id'=> $this->tabInfoUser['id'],
'idClient'=> $this->tabInfoUser['idClient'],
'email'=> $this->tabInfoUser['email'],
'typeCompte'=> $this->tabInfoUser['typeCompte'],
'filtre_ip'=> $this->tabInfoUser['filtre_ip'],
'ipPasserelle'=> $this->tabInfoUser['ipConnexion'],
'ipConnexion'=> $ipUtilisateur,
'civilite'=> $this->tabInfoUser['civilite'],
'nom'=> $this->tabInfoUser['nom'],
'prenom'=> $this->tabInfoUser['prenom'],
'raisonSociale'=> $this->tabInfoUser['raisonSociale'],
'siret'=> $this->tabInfoUser['siret'],
'adrNum'=> $this->tabInfoUser['adrNum'],
'adrIndRep'=> $this->tabInfoUser['adrIndRep'],
'adrTypeVoie'=> $this->tabInfoUser['adrTypeVoie'],
'adrLibVoie'=> $this->tabInfoUser['adrLibVoie'],
'adrCp'=> $this->tabInfoUser['adrCp'],
'adrVille'=> $this->tabInfoUser['adrVille'],
'adrComp'=> $this->tabInfoUser['adrComp'],
'tel'=> $this->tabInfoUser['tel'],
'fax'=> $this->tabInfoUser['fax'],
'mobile'=> $this->tabInfoUser['mobile'],
'pref'=> $this->tabInfoUser['pref'],
'profil'=> $this->tabInfoUser['profil'],
'dateInscription'=> $this->tabInfoUser['dateInscription'],
'dateValidation'=> $this->tabInfoUser['dateValidation'],
'nombreConnexions'=> $this->tabInfoUser['nombreConnexions'],
'dateDerniereConnexion'=> $this->tabInfoUser['dateDerniereConnexion'],
'droits'=> $this->tabInfoUser['droits'],
'droitsClients'=> $this->tabInfoUser['droitsClients'],
'timeout'=> $this->tabInfoUser['timeout'],
'nbReponses'=> $this->tabInfoUser['nbReponses'],
'formatMail'=> $this->tabInfoUser['formatMail'],
'reference'=> $this->tabInfoUser['referenceParDefaut'],
'dateDebutCompte'=> $this->tabInfoUser['dateDebutCompte'],
'dateFinCompte'=> $this->tabInfoUser['dateFinCompte'],
'maxFicheId'=> $this->tabInfoUser['maxFicheId'],
'typeScore'=> $this->tabInfoUser['typeScore'],
);
//debugLog('I',"getInfosLogin fin ".print_r($rep,true),__LINE__,__FILE__, __FUNCTION__, __CLASS__);
}
$result = new InfosLogin();
$result = arrayToClass($rep, 'InfosLogin');
$output = new InfosLoginReturn();
$output->error = $error;
$output->result = $result;
return $output;
}
/**
* Mise à jour des informations du profil connecté
* @param string $login
* @param string $action (delete|actif|desactif|changepwd|new|update)
* @param InfosLoginData $infos
* @return SetInfosLoginReturn
*/
public function setInfosLogin($login, $action, $infos = null)
{
$this->authenticate();
//Initialisation
$error = new ErrorType();
$result = false;
switch($action)
{
case 'delete':
if ($this->tabInfoUser['profil']=='Administrateur' ||
$this->tabInfoUser['profil']=='SuperAdministrateur') {
$tabUpdate = array( 'deleted' => 1 );
$iDbCrm = new WDB('sdv1');
if ($iDbCrm->update('utilisateurs', $tabUpdate, "login='$login'")){
$result = true;
} else {
$error->errnum = 1;
$error->errmsg = 'Mise a jour impossible';
}
}
break;
case 'actif':
case 'desactif':
if ($this->tabInfoUser['profil']=='Administrateur' ||
$this->tabInfoUser['profil']=='SuperAdministrateur'){
if ($action=='actif') $actif = 1;
if ($action=='desactif') $actif = 0;
$tabUpdate = array( 'actif' => $actif );
$iDbCrm = new WDB('sdv1');
if ($iDbCrm->update('utilisateurs', $tabUpdate, "login='$login'")){
$result = true;
} else {
$error->errnum = 1;
$error->errmsg = 'Mise a jour impossible';
}
}
break;
case 'changepwd':
$tabUpdate = array(
'password' => stripslashes($infos->password),
);
$iDbCrm = new WDB('sdv1');
if ($iDbCrm->update('utilisateurs', $tabUpdate, "login='$login'", true)){
$result = true;
} else {
$error->errnum = 1;
$error->errmsg = 'Mise a jour impossible';
}
break;
case 'new':
if ($this->tabInfoUser['profil']=='Administrateur' ||
$this->tabInfoUser['profil']=='SuperAdministrateur') {
$tabUpdate = array(
'idClient' => $infos->idClient,
'login' => $login,
'password' => stripslashes($infos->password),
'nom' => stripslashes($infos->nom),
'prenom' => stripslashes($infos->prenom),
'referenceParDefaut' => stripslashes($infos->reference),
'email' => stripslashes($infos->email),
'tel' => stripslashes($infos->tel_fix),
'fax' => stripslashes($infos->tel_fax),
'mobile' => stripslashes($infos->tel_mob),
'nbReponses' => $infos->rech_nbrep,
'formatMail' => $infos->formatMail,
'profil' => (isset($infos->profil) || !in_array($infos->profil, array('SuperAdministrateur','Administrateur', 'Utilisateur')) ) ? $infos->profil : 'Utilisateur',
'pref' => implode(' ',$infos->pref->item),
'droits' => implode(' ', $infos->droits->item),
);
$iDbCrm = new WDB('sdv1');
if ($iDbCrm->insert('utilisateurs', $tabUpdate)){
$result = true;
} else {
$error->errnum = 1;
$error->errmsg = 'Création impossible';
}
}
break;
case 'update':
if (!empty($infos->password)){
$tabUpdate['password'] = stripslashes($infos->password);
}
$tabUpdate['email'] = stripslashes($infos->email);
$tabUpdate['tel'] = stripslashes($infos->tel_fix);
$tabUpdate['fax'] = stripslashes($infos->tel_fax);
$tabUpdate['mobile'] = stripslashes($infos->tel_mb);
$tabUpdate['nbReponses'] = $infos->rech_nbrep;
$tabUpdate['formatMail'] = $infos->formatMail;
$tabUpdate['pref'] = implode(' ',$infos->pref->item);
if ($this->tabInfoUser['profil']=='Administrateur' ||
$this->tabInfoUser['profil']=='SuperAdministrateur') {
$tabUpdate['droits'] = implode(' ', $infos->droits->item);
$tabUpdate['nom'] = stripslashes($infos->nom);
$tabUpdate['prenom'] = stripslashes($infos->prenom);
$tabUpdate['referenceParDefaut'] = stripslashes($infos->reference);
$tabUpdate['profil'] = isset($infos->profil) ? $infos->profil : 'Utilisateur';
}
$iDbCrm = new WDB('sdv1');
if ($iDbCrm->update('utilisateurs', $tabUpdate, "login='$login'", true)){
$result = true;
} else {
$error->errnum = 1;
$error->errmsg = 'Mise a jour impossible';
}
break;
default;
$result = false;
break;
}
$output = new SetInfosLoginReturn();
$output->error = $error;
$output->result = $result;
return $output;
}
/**
* Obtention automatique d'un nouveau login pour un client
* @param string $login
* @return NextLoginReturn
*/
public function getNextLogin( $login )
{
$this->authenticate();
//Initialisation
$error = new ErrorType();
if ($this->tabInfoUser['profil']=='Administrateur' ||
$this->tabInfoUser['profil']=='SuperAdministrateur') {
/** Un administrateur veut créer un nouveau login **/
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->select('utilisateurs u, clients c', 'u.idClient, c.racineLogin, c.droits', "u.login='$login' AND u.idClient=c.id");
$racine = $rep[0]['racineLogin'];
$idClient = $rep[0]['idClient'];
$droitsClients = $rep[0]['droits'];
$rep = $iDbCrm->select('utilisateurs', 'login, length(login) as taille', "login like '$racine%' group by login order by taille desc, login desc LIMIT 0,1");
if (count($rep)==0) {
$racine.='1';
} else {
$last_i = preg_replace("/\D/", '',$rep[0]['login'])*1;
$racine.= $last_i+1;
}
$result = new NextLoginResult();
$result->racine = $racine;
$result->idClient = $idClient;
$result->droitsClients = $droitsClients;
} else {
$error->errnum = 0;
$error->errmsg = 'Acces non authorisé!';
}
$output = new NextLoginReturn();
$output->error = $error;
$output->result = $result;
return $output;
}
/**
* Récupère la liste des clients ou les informations d'un client
* @param integer|boolean $idClient
* @param ClientFiltre $filtre
* @return ListeClientsReturn
*/
public function getListeClients($idClient=false, $filtre=null)
{
$this->authenticate();
//Initialisation
$error = new ErrorType();
if (empty($idClient)) $idClient = false;
$isAuthorized = false;
if ($this->tabInfoUser['profil']=='Administrateur' &&
($idClient=='false' || $idClient==$this->tabInfoUser['idClient'])){
$idClient = $this->tabInfoUser['idClient'];
$isAuthorized = true;
}
if ($this->tabInfoUser['profil']<>'SuperAdministrateur'){
$error->errnum = 1;
$error->errmsg = 'Profil non administrateur';
} else {
$isAuthorized = true;
}
if ($isAuthorized)
{
$strClient = '';
if (is_numeric($idClient)) $strClient.=" AND id='$idClient' ";
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->select('clients',
'id, nom, actif, test, racineLogin, siren, nic, tva, editerFacture, fact_detail, fac_dest, fac_adr1, fac_adr2, fac_adr3, fac_email, fac_tel, fact_rib, liv_dest, liv_adr1, liv_adr2, liv_adr3, liv_email, liv_tel, droits, filtres_ip, dateInsert, dateUpdate, respComSD, typeContrat, dateSignature, typeAcces, typeScore, timeout, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance, forfaitExtranetPeriode, forfaitExtranetMontant, reconductionAuto, remarque, forfaitPiecesNb, forfaitPiecesMt, forfaitPiecesDep, forfaitInvestigNb, forfaitInvestigMt, forfaitInvestigDep, tarifIndiscore',
"1 $strClient",
false,
MYSQL_ASSOC);
$tabRet = array();
foreach ($rep as $uti)
{
$client = new Client();
$client->idClient = $uti['id'];
$client->nom = $uti['nom'];
$client->actif = $uti['actif'];
$client->test = $uti['test'];
$client->racineLogin = $uti['racineLogin'];
$client->siren = $uti['siren'];
$client->nic = $uti['nic'];
$client->tva = $uti['tva'];
$client->editerFacture = $uti['editerFacture'];
$client->fact_detail = $uti['fact_detail'];
$client->fac_dest = $uti['fac_dest'];
$client->fac_adr1 = $uti['fac_adr1'];
$client->fac_adr2 = $uti['fac_adr2'];
$client->fac_adr3 = $uti['fac_adr3'];
$client->fac_email = $uti['fac_email'];
$client->fac_tel = $uti['fac_tel'];
$client->fact_rib = $uti['fact_rib'];
$client->liv_dest = $uti['liv_dest'];
$client->liv_adr1 = $uti['liv_adr1'];
$client->liv_adr2 = $uti['liv_adr2'];
$client->liv_adr3 = $uti['liv_adr3'];
$client->liv_email = $uti['liv_email'];
$client->liv_tel = $uti['liv_tel'];
$client->droits = strtolower($uti['droits']);
$client->timeout = $uti['timeout'];
$client->filtres_ip = $uti['filtres_ip'];
$client->dateInsert = $uti['dateInsert'];
$client->dateUpdate = $uti['dateUpdate'];
$client->respComSD = $uti['respComSD'];
$client->typeContrat = $uti['typeContrat'];
$client->dateSignature = $uti['dateSignature'];
$client->typeAcces = $uti['typeAcces'];
$client->typeScore = $uti['typeScore'];
$client->accesPieces = $uti['accesPieces'];
$client->accesKbis = $uti['accesKbis'];
$client->accesInvestigations = $uti['accesInvestigations'];
$client->accesInternationnal = $uti['accesInternationnal'];
$client->accesEnquetes = $uti['accesEnquetes'];
$client->miseSousSurveillance = $uti['miseSousSurveillance'];
$client->forfaitExtranetPeriode = $uti['forfaitExtranetPeriode'];
$client->forfaitExtranetMontant = $uti['forfaitExtranetMontant'];
$client->reconductionAuto = $uti['reconductionAuto'];
$client->remarque = $uti['remarque'];
$client->forfaitPiecesNb = $uti['forfaitPiecesNb'];
$client->forfaitPiecesMt = $uti['forfaitPiecesMt'];
$client->forfaitPiecesDep = $uti['forfaitPiecesDep'];
$client->forfaitInvestigNb = $uti['forfaitInvestigNb'];
$client->forfaitInvestigMt = $uti['forfaitInvestigMt'];
$client->forfaitInvestigDep = $uti['forfaitInvestigDep'];
$client->tarifIndiscore = $uti['tarifIndiscore'];
$tabRet[] = $client;
}
}
$output = new ListeClientsReturn();
$output->error = $error;
$output->result = $tabRet;
return $output;
}
/**
* Retourne la liste des droits
* @return ListeDroitsReturn[]
*/
public function getListeDroits()
{
$tabRet = array();
foreach($this->listeDroits as $code => $desc){
$droit = new ListeDroitsReturn();
$droit->code = $code;
$droit->desc = $desc;
$tabRet[] = $droit;
}
return $tabRet;
}
/**
* Retourne la liste des préférences
* @return ListePrefsReturn[]
*/
public function getListePrefs()
{
$tabRet = array();
foreach($this->listePrefs as $code => $desc){
$pref = new ListePrefsReturn();
$pref->code = $code;
$pref->desc = $desc;
$tabRet[] = $pref;
}
return $tabRet;
}
/**
* Récupère les informations du profil connecté
* @param string $login
* @param int $idClient
* @return ListeUtilisateursReturn
*/
public function getListeUtilisateurs($login, $idClient=-1)
{
$this->authenticate();
//Initialisation
if (empty($idClient)) $idClient = -1;
$error = new ErrorType();
$tabRet = array();
if ($this->tabInfoUser['profil']<>'Administrateur' &&
$this->tabInfoUser['profil']<>'SuperAdministrateur')
{
$error->errnum = 1;
$error->errmsg = 'Profil non administrateur';
} else {
$iDbCrm = new WDB('sdv1');
if ($idClient==-1){
$rep = $iDbCrm->select('utilisateurs', 'idClient', "login='$login'");
$idClient = $rep[0][0];
}
if ($idClient==-1){
$error->errnum = 1;
$error->errmsg = 'idClient=0';
} else {
$rep = $iDbCrm->select('utilisateurs', 'id, idClient, login, email, actif, nom, prenom, referenceParDefaut', "idClient='$idClient' AND deleted=0 ORDER BY login ASC", false, MYSQL_ASSOC);
foreach ($rep as $uti){
$utilisateur = new Utilisateur();
$utilisateur->idUti = $uti['id'];
$utilisateur->idClient= $uti['idClient'];
$utilisateur->login = $uti['login'];
$utilisateur->email = $uti['email'];
$utilisateur->actif= $uti['actif'];
$utilisateur->nom = $uti['nom'];
$utilisateur->prenom = $uti['prenom'];
$utilisateur->reference = $uti['referenceParDefaut'];
$tabRet[]= $utilisateur;
}
}
}
$output = new ListeUtilisateursReturn();
$output->error = $error;
$output->result = $tabRet;
return $output;
}
/**
* getLogsClients
* @param string $mois (Format : AAAA-MM ou AAAA/MM)
* @param int $detail
* @param int $idClient
* @param string $login
* @param int $all
* @return LogsClientsReturn
*/
public function getLogsClients($mois, $detail=0, $idClient=0, $login='', $all=0)
{
$this->authenticate();
//Initialisation
$error = new ErrorType();
if (empty($detail)) $detail = 0;
if (empty($idClient)) $idClient = 0;
if (empty($login)) $login = '';
if (empty($all)) $all = 0;
$strDetail = $strClient = $strLogin='';
// Vue détaillée ou uniquement les infos payantes
if ($detail==0) {
$detail='Non';
$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page LIKE 'indiscore%' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page LIKE 'indiscore%' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
} elseif($detail==1) {
$detail='Oui';
}
// On veut uniquement le client précis
if ($all && $this->tabInfoUser['profil']=='SuperAdministrateur') {
$all = 'Oui';
} else {
$all = 'Non';
}
// Pas d'idClient mentionné ou tentative sur autre client et non SAD
if ($idClient==0 || ($idClient!=$this->tabInfoUser['idClient'] && $this->tabInfoUser['profil']!='SuperAdministrateur') ){
$idClient = $this->tabInfoUser['idClient'];
}
$strClient = " AND u.idClient=$idClient ";
// On veut uniquement le login précis
if ($login!='') {
$strLogin=" AND l.login='$login' ";
} else {
$login='Non';
}
// Dates de début et de fin
$mois = strtr($mois, array('-'=>'','/'=>''));
$annee = substr($mois,0,4);
$mois = substr($mois,4,2);
$dateDeb=date('Y-m-d', mktime(0,0,0,$mois,1,$annee));
$dateFin=date('Y-m-t', mktime(0,0,0,$mois,15,$annee));
$fichierCsv=DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
if (file_exists($fichierCsv) &&
date('Ymd', filemtime($fichierCsv))==date('Ymd') &&
filesize($fichierCsv)>60 ) {
$size=filesize($fichierCsv);
$erreur=false;
$tabNom=array();
$cache=1;
} else {
@unlink($fichierCsv);
$sql="SELECT LOWER(l.login) as loginUti, page, l.siren, l.nic, l.params, l.dateHeure, u.idClient, c.nom, u.referenceParDefaut AS refUti
FROM `logs` l, utilisateurs u, clients c
WHERE 1 $strDetail $strClient $strLogin AND dateHeure BETWEEN '$dateDeb 00:00:00' AND '$dateFin 23:59:59' AND l.login=u.login AND u.idClient=c.id
GROUP BY l.login, l.siren, page, date(dateHeure), params
ORDER BY l.login ASC, dateHeure ASC";
$fp = fopen(DOC_WEB_LOCAL."/csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql", 'w');
fwrite($fp, $sql.EOL);
fclose($fp);
exec("php ".APPLICATION_PATH."/../batch/sql2csv.php sdv1 ".DOC_WEB_LOCAL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.sql $fichierCsv > /dev/null &");
$size = $cache = 0;
}
$hostname = 'http://'.$_SERVER['SERVER_NAME'];
if ($_SERVER['SERVER_PORT']!='80'){
$hostname.= ':'.$_SERVER['SERVER_PORT'];
}
$result = new LogsClients();
$result->Url = $hostname.DOC_WEB_URL."csv/logs-$annee-$mois-$detail-$idClient-$login-$all.csv";
$result->Taille = $size;
$result->Cache = $cache;
$output = new LogsClientsReturn();
$output->error = $error;
$output->result = $result;
return $output;
}
/**
* Création/Modification d'un client
* @param string $infos
* @return ClientReturn
*/
public function setClient($infos)
{
$this->authenticate();
$result = false;
//Pas SuperAdministrateur
if ($this->tabInfoUser['profil']!='SuperAdministrateur') {
throw new SoapFault(1, 'Profil insuffisant pour cette méthode');
} else {
$infos = json_decode($infos);
/**
* - Protégé les chaines de caractères
* - Gérer les champs select
*/
$idClient = null;
$tabInfos = array();
foreach($infos as $nom => $value)
{
switch($nom)
{
case 'idClient':
$idClient = $value;
break;
case 'nom':
$tabInfos['nom'] = $value;
break;
case 'actif':
$tabInfos['actif'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'test':
$tabInfos['test'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'racineLogin':
$tabInfos['racineLogin'] = $infos->racineLogin;
break;
case 'siren':
$tabInfos['siren'] = (int) $value;
break;
case 'nic':
$tabInfos['nic'] = (int) $value;
break;
case 'tva':
$tabInfos['tva'] = $value;
break;
case 'idClientFacture':
$tabInfos['idClientFacture'] = $value;
break;
case 'editerFacture':
$tabInfos['editerFacture'] = ($value=='Non') ? 'Non' : 'Oui';
break;
case 'fact_detail':
$tabInfos['fact_detail'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'fac_dest':
$tabInfos['fac_dest'] = $value;
break;
case 'fac_adr1':
$tabInfos['fac_adr1'] = $value;
break;
case 'fac_adr2':
$tabInfos['fac_adr2'] = $value;
break;
case 'fac_adr3':
$tabInfos['fac_adr3'] = $value;
break;
case 'fac_email':
$tabInfos['fac_email'] = $value;
break;
case 'fac_tel':
$tabInfos['fac_tel'] = $value;
break;
case 'fact_rib':
if (in_array($value, array('BPOSTALE','CCOOP', 'CDNORD'))){
$tabInfos['fact_rib'] = $value;
}
break;
case 'liv_dest':
$tabInfos['liv_dest'] = $value;
break;
case 'liv_adr1':
$tabInfos['liv_adr1'] = $value;
break;
case 'liv_adr2':
$tabInfos['liv_adr2'] = $value;
break;
case 'liv_adr3':
$tabInfos['liv_adr3'] = $value;
break;
case 'liv_email':
$tabInfos['liv_email'] = $value;
break;
case 'liv_tel':
$tabInfos['liv_tel'] = $value;
break;
case 'droits':
if (count($value)>0){
$tabInfos['droits'] = strtolower(implode(' ',$value));
} else {
$tabInfos['droits'] = array();
}
break;
case 'filtres_ip':
$tabInfos['filtres_ip'] = $value;
break;
case 'typeContrat':
if (in_array($value, array('Contrat','Marché'))){
$tabInfos['typeContrat'] = $value;
}
break;
case 'typeAcces':
if (in_array($value, array('userPassword','userPasswordIP', 'IP'))){
$tabInfos['typeAcces'] = $value;
}
break;
case 'typeScore':
if (in_array($value, array('20','100'))){
$tabInfos['typeScore'] = $value;
}
break;
case 'timeout':
if (!empty($value)){
$tabInfos['timeout'] = $value;
}
break;
case 'accesPieces':
$tabInfos['accesPieces'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'accesKbis':
$tabInfos['accesKbis'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'accesInvestigations':
$tabInfos['value'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'accesInternationnal':
$tabInfos['accesInternationnal'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'accesEnquetes':
$tabInfos['accesEnquetes'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'miseSousSurveillance':
$tabInfos['miseSousSurveillance'] = ($value=='Oui') ? 'Oui' : 'Non' ;
break;
case 'forfaitExtranetPeriode':
if (in_array($value, array('Mensuel','Trimestriel','Semestriel', 'Annuel'))){
$tabInfos['forfaitExtranetPeriode'] = $value;
}
break;
case 'forfaitExtranetMontant':
$tabInfos['forfaitExtranetMontant'] = $value;
break;
case 'reconductionAuto':
if ($value=='Non') {
$tabInfos['reconductionAuto'] = 'Non';
}
break;
case 'remarque':
$tabInfos['remarque'] = $value;
break;
case 'forfaitPiecesNb':
$tabInfos['forfaitPiecesNb'] = $value;
break;
case 'forfaitPiecesMt':
$tabInfos['forfaitPiecesMt'] = $value;
break;
case 'forfaitPiecesDep':
$tabInfos['forfaitPiecesDep'] = $value;
break;
case 'forfaitInvestigNb':
$tabInfos['forfaitInvestigNb'] = $value;
break;
case 'forfaitInvestigMt':
$tabInfos['forfaitInvestigMt'] = $value;
break;
case 'forfaitInvestigDep':
$tabInfos['forfaitInvestigDep'] = $value;
break;
case 'tarifIndiscore':
$tabInfos['tarifIndiscore'] = $value;
break;
case 'InterSudLogin':
$tabInfos['InterSudLogin'] = $value;
break;
case 'InterSudPass':
$tabInfos['InterSudPass'] = $value;
break;
}
}
$iDbCrm = new WDB('sdv1');
if (empty($idClient)){
//Ajout
//$tabInfos['dateInsert'] = now();
$result = $iDbCrm->insert('clients', $tabInfos, true);
} else {
//Droits client actuel avant modification
if (isset($tabInfos['droits'])){
$rep = $iDbCrm->select('clients', 'droits', "id='$idClient'", false, MYSQL_ASSOC);
$droitsPre = explode(' ', $rep[0]['droits']);
$droitsSui = explode(' ', $tabInfos['droits']);
//Détection suppression d'un droit client
if (count($droitsSui)<count($droitsPre)){
$droitsDiff = array_diff($droitsPre, $droitsSui);
//Modification sur les droits utilisateurs
$update = array();
foreach($droitsDiff as $droit){
$update[] = array('droits' => "TRIM(REPLACE(droits, '$droit', ''))");
}
$iDbCrm->update('utilisateurs', $update, "idClient='$idClient'");
}
}
//Modification
if ($iDbCrm->update('clients', $tabInfos, "id='$idClient'", true)){
$result = true;
}
}
}
$output = new ClientReturn();
$output->error = $error;
$output->result = $result;
return $output;
}
/**
* Création d'un modele pour le préremplisage des données utilisateurs
* @param integer $idClient
* @param string $nom
* @param ModeleUtilisateur $infos
* @return ModeleUtilisateurReturn
*/
protected function setModeleUtilisateur($idClient, $nom, $infos)
{
$this->authenticate();
}
/**
* Création/Modification d'utilisateurs
* @param integer $idClient
* @param SetUtilisateurs[] $users
* @return UtilisateursReturn
*/
protected function setUtilisateurs($idClient, $users)
{
$this->authenticate();
$error = new ErrorType();
$result = false;
//idClient existe
$iDbCrm = new WDB('sdv1');
$rep = $iDbCrm->select('clients', 'id, nom, actif, test, racineLogin, siren, nic, droits, filtres_ip, typeAcces, typeScore, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance', "1 AND id='$idClient'", false, MYSQL_ASSOC);
if (count($rep)>0){
$client = $rep[0];
$idClient = $client['id'];
if (count($users)>0){
foreach($users as $user){
$tabInfos = array();
$tabInfos['idClient'] = $idClient;
$tabInfos['login'] = $user->login;
$tabInfos['email'] = '';
$tabInfos['password'] = $user->password;
$tabInfos['actif'] = '';
//$tabInfos['deleted'] = '';
if (in_array($user->typeCompte, array('TEST', 'PROD'))){
$tabInfos['typeCompte'] = $user->typeCompte;
} else {
$tabInfos['typeCompte'] = 'PROD';
}
//$tabInfos['filtre_ip'] = '';
//SetInfosLogin
$tabInfos['civilite'] = '';
$tabInfos['nom'] = '';
$tabInfos['prenom'] = '';
//Identique au client
$tabInfos['raisonSociale'] = '';
$tabInfos['siret'] = '';
$tabInfos['adrNum'] = '';
$tabInfos['adrInRep'] = '';
$tabInfos['adrTypeVoie'] = '';
$tabInfos['adrLibVoie'] = '';
$tabInfos['adrCp'] = '';
$tabInfos['adrVille'] = '';
$tabInfos['adrComp'] = '';
$tabInfos['tel'] = '';
$tabInfos['fax'] = '';
$tabInfos['mobile'] = '';
$tabInfos['pref'] = '';
if (in_array($user->typeCompte, array('Administrateur', 'Utilisateur'))){
$tabInfos['profil'] = $user->profil;
} else {
$tabInfos['profil'] = 'Utilisateur';
}
/*
$tabInfos['dateInscription'] = '';
$tabInfos['dateValidation'] = '';
*/
if (empty($user->droits)){
$tabInfos['droits'] = $client->droits;
} else {
$tabInfos['droits'] = $user->droits;
}
$tabInfos['referenceParDefaut'] = '';
$tabInfos['nbReponses'] = '';
$tabInfos['listeEven'] = '';
$tabInfos['maxFicheId'] = $user->maxFicheId;
//$tabInfos['dateInsert'] = '';
if (empty($user->id)){
$iDbCrm->insert('utilisateurs', $tabInfos);
} else {
$iDbCrm->update('utilisateurs', $tabInfos, "id='$user->id'");
}
}
} else {
$error->errnum = 1;
$error->errmsg = 'Aucun utiliateur';
}
} else {
$error->errnum = 1;
$error->errmsg = 'Identifiant client inconnu!';
}
$output = new UtilisateursReturn();
$output->error = $error;
$output->result = $result;
return $output;
}
}

View File

@ -0,0 +1,461 @@
<?php
class ErrorType
{
/**
* Numéro d'erreur
* @var int
*/
public $errnum = 0;
/**
* Message d'erreur
* @var string
*/
public $errmsg = '';
}
class InfosLoginReturn
{
/** @var ErrorType */
public $error;
/** @var InfosLogin */
public $result;
}
class InfosLogin
{
/** @var bool */
public $connected;
/** @var string */
public $login;
/** @var int */
public $id;
/** @var int */
public $idClient;
/** @var string */
public $email;
/** @var string */
public $typeCompte;
/** @var string */
public $filtre_ip;
/** @var string */
public $ipPasserelle;
/** @var string */
public $ipConnexion;
/** @var string */
public $civilite;
/** @var string */
public $nom;
/** @var string */
public $prenom;
/** @var string */
public $raisonSociale;
/** @var string */
public $siret;
/** @var string */
public $adrNum;
/** @var string */
public $adrIndRep;
/** @var string */
public $adrTypeVoie;
/** @var string */
public $adrLibVoie;
/** @var string */
public $adrCp;
/** @var string */
public $adrVille;
/** @var string */
public $adrComp;
/** @var string */
public $tel;
/** @var string */
public $fax;
/** @var string */
public $mobile;
/** @var string */
public $pref;
/** @var string */
public $profil;
/** @var string */
public $dateInscription;
/** @var string */
public $dateValidation;
/** @var int */
public $nombreConnexions;
/** @var string */
public $dateDerniereConnexion;
/** @var string */
public $droits;
/** @var string */
public $droitsClients;
/** @var int */
public $timeout;
/** @var int */
public $nbReponses;
/** @var string */
public $formatMail;
/** @var string */
public $reference;
/** @var string */
public $dateDebutCompte;
/** @var string */
public $dateFinCompte;
/** @var int */
public $maxFicheId;
/** @var string */
public $typeScore;
}
class InfosLoginData
{
/** @var int */
public $idClient;
/** @var string */
public $nom;
/** @var string */
public $prenom;
/** @var string */
public $reference;
/** @var string */
public $email;
/** @var string */
public $tel_fix;
/** @var string */
public $tel_fax;
/** @var string */
public $tel_mob;
/** @var int */
public $rech_nbrep;
/** @var string */
public $formatMail;
/** @var string */
public $password = '';
/**
* Profil de l'utilisateur Utilisateur, Administrateur
* @var string
*/
public $profil = 'Utilisateur';
/** @var string[] */
public $droits;
/** @var string[] */
public $pref;
}
class SetInfosLoginReturn
{
/** @var ErrorType */
public $error;
/** @var boolean */
public $result;
}
class NextLoginReturn
{
/** @var ErrorType */
public $error;
/** @var NextLoginResult */
public $result;
}
class NextLoginResult
{
/** @var string */
public $racine;
/** @var int */
public $idClient;
/** @var string */
public $droitsClients;
}
class ClientFiltre
{
/** @var int */
public $page = 0;
}
class ListeClientsReturn
{
/** @var ErrorType */
public $error;
/** @var Client[] */
public $result;
}
class Client
{
/** @var int */
public $idClient;
/** @var string */
public $nom;
/** @var string */
public $actif;
/** @var string */
public $test;
/** @var string */
public $racineLogin;
/** @var string */
public $siren;
/** @var string */
public $nic;
/** @var string */
public $tva;
/** @var string */
public $editerFacture;
/** @var string */
public $fact_detail;
/** @var string */
public $fac_dest;
/** @var string */
public $fac_adr1;
/** @var string */
public $fac_adr2;
/** @var string */
public $fac_adr3;
/** @var string */
public $fac_email;
/** @var string */
public $fac_tel;
/** @var string */
public $fact_rib;
/** @var string */
public $liv_dest;
/** @var string */
public $liv_adr1;
/** @var string */
public $liv_adr2;
/** @var string */
public $liv_adr3;
/** @var string */
public $liv_email;
/** @var string */
public $liv_tel;
/** @var string */
public $droits;
/** @var string */
public $filtres_ip;
/** @var string */
public $typeContrat;
/** @var string */
public $dateSignature;
/** @var string */
public $typeAccess;
/** @var string */
public $typeScore;
/** @var string */
public $timeout;
/** @var string */
public $accesPieces;
/** @var string */
public $accesKbis;
/** @var string */
public $accesInvestigations;
/** @var string */
public $accesInternationnal;
/** @var string */
public $accesEnquetes;
/** @var string */
public $miseSousSurveillance;
/** @var string */
public $forfaitExtranetPeriode;
/** @var string */
public $forfaitExtranetMontant;
/** @var string */
public $reconductionAuto;
/** @var string */
public $remarque;
/** @var string */
public $forfaitPiecesNb;
/** @var string */
public $forfaitPiecesMt;
/** @var string */
public $forfaitPiecesDep;
/** @var string */
public $forfaitInvestigNb;
/** @var string */
public $forfaitInvestigMt;
/** @var string */
public $forfaitInvestigDep;
/** @var string */
public $tarifIndiscore;
/** @var string */
public $InterSudLogin;
/** @var string */
public $InterSudPass;
}
class ListeDroitsReturn
{
/** @var string */
public $code;
/** @var string */
public $desc;
}
class ListePrefsReturn
{
/** @var string */
public $code;
/** @var string */
public $desc;
}
class ListeUtilisateursReturn
{
/** @var ErrorType */
public $error;
/** @var Utilisateur[] */
public $result;
}
class Utilisateur
{
/** @var int */
public $idUti;
/** @var int */
public $idClient;
/** @var string */
public $login;
/** @var string */
public $email;
/** @var int */
public $actif;
/** @var string */
public $nom;
/** @var string */
public $prenom;
/** @var string */
public $reference;
}
class LogsClientsReturn
{
/** @var ErrorType */
public $error;
/** @var LogsClients */
public $result;
}
class LogsClients
{
/** @var string */
public $Url;
/** @var string */
public $Taille;
/** @var int */
public $Cache;
}
class ClientReturn
{
/** @var ErrorType */
public $error;
/** @var mixed */
public $result;
}
class SetUtilisateurs
{
/** @var int */
public $id = null;
/** @var string */
public $login;
/** @var string */
public $email;
/** @var string */
public $password;
/** @var bool */
public $actif;
/**
* TEST/PROD
* @var string
*/
public $typeCompte;
/**
* @var string
*/
public $filtre_ip;
/**
* M/Mme/Mlle
* @var string
*/
public $civilite;
/** @var string */
public $nom;
/** @var string */
public $prenom;
/** @var string */
public $raisonSociale;
/** @var string */
public $siret;
/** @var string */
public $adrNum;
/** @var string */
public $adrIndRep;
/** @var string */
public $adrTypeVoie;
/** @var string */
public $adrLibVoie;
/** @var string */
public $adrCp;
/** @var string */
public $adrVille;
/** @var string */
public $adrComp;
/** @var string */
public $tel;
/** @var string */
public $fax;
/** @var string */
public $mobile;
/** @var string */
public $pref;
/** @var string */
public $profil;
/** @var string */
public $dateInscription;
/** @var string */
public $dateValidation;
/** @var string */
public $droits;
/** @var string */
public $referenceParDefaut;
/** @var int */
public $nbReponses;
/** @var string */
public $listeEven;
/** @var int */
public $maxFicheId;
}
class UtilisateursReturn
{
/** @var ErrorType */
public $error;
/** @var boolean */
public $result;
}
class ModeleUtilisateurReturn
{
/** @var ErrorType */
public $error;
/** @var boolean */
public $result;
}
class ModeleUtilisateur
{
/** @var string */
public $actif;
/** @var string */
public $typeCompte;
/** @var string */
public $pref;
/** @var string */
public $profil;
/** @var string */
public $droits;
}

View File

@ -3,4 +3,8 @@ actif = true;
[interne]
actif = true;
idClient = 1;
idClient = 1;
[gestion]
actif = true;
idClient = 1;