2010-10-18 13:51:58 +00:00
< ? php
2011-02-04 11:32:55 +00:00
require_once 'WsScore/WsScore.php' ;
require_once 'WsScore/functions.php' ;
require_once realpath ( dirname ( __FILE__ )) . '/Types.php' ;
2010-10-20 13:32:33 +00:00
2011-02-04 11:32:55 +00:00
class Interne extends WsScore
2010-10-18 13:51:58 +00:00
{
2011-05-20 14:38:01 +00:00
/**
*
* Enter description here ...
* @ param string $siren
* @ param array $tabTypes
* @ return PrivilegesDetailReturn
*/
public function getPrivilegesDetail ( $siren , $tabTypes = array ( '03' , '04' ))
{
$this -> authenticate ();
//Initialisation
if ( empty ( $tabTypes )) $tabTypes = array ( '03' , '04' );
debugLog ( 'I' , " Liste des privilèges detail sur $siren " . print_r ( $tabTypes , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iPriv = new MPrivileges ();
$ret = $iPriv -> getPrivilegesDetail ( $siren , $tabTypes ); //@todo : date
$tabRet = array ();
if ( count ( $tabRet ) > 0 ) {
foreach ( $ret as $item ) {
$privileges = new PrivilegesDetail ();
2011-06-15 12:49:35 +00:00
$privileges -> numDebiteur = $item [ 'numDebiteur' ];
$privileges -> greffe = $item [ 'greffe' ];
$privileges -> greffeLib = $item [ 'greffeLib' ];
$privileges -> dateEven = $item [ 'dateEven' ];
$privileges -> dateFraiche = $item [ 'dateFraiche' ];
$privileges -> dateSD = $item [ 'dateSD' ];
$privileges -> insType = $item [ 'insType' ];
$privileges -> insTypeLib = $item [ 'insTypeLib' ];
$privileges -> insNum = $item [ 'insNum' ];
$privileges -> insDate = $item [ 'insDate' ];
$privileges -> insDateEch = $item [ 'insDateEch' ];
$privileges -> insObjet = $item [ 'insObjet' ];
$privileges -> insMontant = $item [ 'insMontant' ];
$privileges -> insDev = $item [ 'insDev' ];
$privileges -> insDateFin = $item [ 'insDateFin' ];
$privileges -> radDate = $item [ 'radDate' ];
$privileges -> radMention = $item [ 'radMention' ];
$privileges -> radPartiel = $item [ 'radPartiel' ];
$privileges -> radPartMt = $item [ 'radPartMt' ];
$privileges -> radDev = $item [ 'radDev' ];
$privileges -> creNom = $item [ 'creNom' ];
$privileges -> creAdresse1 = $item [ 'creAdresse1' ];
$privileges -> creAdresse2 = $item [ 'creAdresse2' ];
$privileges -> creAdresse3 = $item [ 'creAdresse3' ];
$privileges -> creCP = $item [ 'creCP' ];
$privileges -> creVille = $item [ 'creVille' ];
$privileges -> crePays = $item [ 'crePays' ];
$privileges -> creAutres = $item [ 'creAutres' ];
2011-05-20 14:38:01 +00:00
$tabRet [] = $privileges ;
}
}
$this -> wsLog ( 'privdetail' , $siren , join ( ',' , $tabTypes ));
$output = new PrivilegesDetailReturn ();
$output -> result = $tabRet ;
return $output ;
}
/**
*
* Enter description here ...
* @ param string $siren
* @ param array $tabTypes
* @ return PrivilegesCumulReturn
*/
public function getPrivilegesCumul ( $siren , $tabTypes = array ( '03' , '04' ))
{
$this -> authenticate ();
//Initialisation
if ( empty ( $tabTypes )) $tabTypes = array ( '03' , '04' );
debugLog ( 'I' , " Liste des privilèges cumul sur $siren " . print_r ( $tabTypes , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iPriv = new MPrivileges ();
$ret = $iPriv -> getPrivilegesCumul ( $siren , $tabTypes );
$tabRet = array ();
if ( isset ( $ret [ '03' ]) && count ( $ret [ '03' ] > 0 )){
$value = $ret [ '03' ];
$priv = new PrivilegesCumul ();
$priv -> insType = '03' ;
$priv -> nb = $value [ 'nb' ];
$priv -> insTypeLib = $value [ 'insTypeLib' ];
$priv -> dateFraiche = $value [ 'dateFraiche' ]; //@todo : date
$priv -> dateDerInsc = $value [ 'dateDerInsc' ]; //@todo : date
$priv -> nomDerCre = $value [ 'nomDerCre' ];
$priv -> numDebiteur = $value [ 'numDebiteur' ];
$priv -> greffeLib = $value [ 'greffeLib' ];
$priv -> dateMajSD = $value [ 'dateMajSD' ]; //@todo : date
$priv -> insCumul = $value [ 'insCumul' ];
$tabRet [] = $priv ;
}
if ( isset ( $ret [ '04' ]) && count ( $ret [ '04' ] > 0 )){
$value = $ret [ '04' ];
$priv = new PrivilegesCumul ();
$priv -> insType = '04' ;
$priv -> nb = $value [ 'nb' ];
$priv -> insTypeLib = $value [ 'insTypeLib' ];
$priv -> dateFraiche = $value [ 'dateFraiche' ]; //@todo : date
$priv -> dateDerInsc = $value [ 'dateDerInsc' ]; //@todo : date
$priv -> nomDerCre = $value [ 'nomDerCre' ];
$priv -> numDebiteur = $value [ 'numDebiteur' ];
$priv -> greffeLib = $value [ 'greffeLib' ];
$priv -> dateMajSD = $value [ 'dateMajSD' ]; //@todo : date
$priv -> insCumul = $value [ 'insCumul' ];
$tabRet [] = $priv ;
}
$this -> wsLog ( 'privcumul' , $siren , print_r ( $tabTypes , 1 ));
$output = new PrivilegesCumulReturn ();
$output -> result = $tabRet ;
return $output ;
}
/**
* Liste les mandataires correspondant à un nom donné
*
* @ param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d 'Identifiants numériques des cours d' appel
* @ param array $type Type de mandataire ( A ) dministrateur , ( M ) andataire , ( O ) ppositions , ( N ) otaires , a ( V ) ocat
* @ param int $cpDep Code postal ou département du mandataire
2011-05-20 14:54:30 +00:00
* @ return SearchMandatairesReturn
2011-05-20 14:38:01 +00:00
*/
public function searchMandataires ( $nom , $type = array ( 'A' , 'M' ), $cpDep = 0 )
{
$this -> authenticate ();
//Initialisation
if ( empty ( $type )) $type = array ( 'A' , 'M' );
if ( empty ( $cpDep )) $cpDep = 0 ;
$tabRet = array ();
debugLog ( 'I' , " Recherche de Mandataires ' $nom ' (Dep= $cpDep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$tabTmp = $iInsee -> searchMandataires ( $nom , true , $type , $cpDep );
foreach ( $tabTmp as $i => $mand )
{
2011-05-20 14:54:30 +00:00
$mandataire = new SearchMandataire ();
2011-05-20 14:38:01 +00:00
$mandataire -> id = 'm' . $i ;
$mandataire -> mand = utf8_encode ( $mand );
$tabRet [] = $mandataire ;
}
2011-05-20 14:54:30 +00:00
$output = new SearchMandatairesReturn ();
2011-05-20 14:38:01 +00:00
$output -> result = $tabRet ;
return $output ;
}
/**
* Retourne la liste des tribunaux ou Compétences demandées
* @ param array | string $tabTypes Tableau des types de Compétences demandés 'C' : Commerce , 'I' : Instance , 'G' : TGI , 'A' : Préfectures , 'B' : Sous - préf , 'D' : Tribunal Administratif , 'H' : Prud 'hommes, ' L ': Cour d' Appel , 'M' : Tribunal Mixte , 'O' : CCI , 'V' : Cour Administrative d ' Appel
* @ return TribunauxReturn
**/
public function getTribunaux ( $tabTypes )
{
$this -> authenticate ();
//Initialisation
if ( empty ( $tabTypes )) $tabTypes = array ();
if ( is_string ( $tabTypes )) $tabTypes = ( array ) $tabTypes ;
$iBodacc = new MBodacc ();
debugLog ( 'I' , " Liste des tribunaux demandées " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabTmp = $iBodacc -> getListeTribunaux ();
//@todo : Retourner liste en ordre alphabétique
$tabRet = array ();
if ( count ( $tabTypes ) == 0 ) {
foreach ( $tabTmp as $i => $tribunal ){
$tri = new Tribunal ();
$tri -> code = $i ;
$tri -> nom = $tribunal [ 'nom' ];
$tabRet [] = $tri ;
}
} else {
foreach ( $tabTmp as $i => $tribunal ){
$type = substr ( $i , - 1 );
if ( in_array ( $type , $tabTypes ) ){
$tri = new Tribunal ();
$tri -> code = $i ;
$tri -> nom = $tribunal [ 'nom' ];
$tabRet [] = $tri ;
}
}
}
$this -> wsLog ( 'tribunaux' , '' , print_r ( $tabTypes , 1 ));
$output = new TribunauxReturn ();
$output -> result = $tabRet ;
return $output ;
}
2010-10-18 13:51:58 +00:00
/**
* Enregistrement des informations saisie manuellement
* @ param string $siret
* @ param int $idEntreprise
2011-01-31 17:07:24 +00:00
* @ param SetInfosEntrepInfos $tabInfos
2010-11-23 15:12:32 +00:00
* @ return SetInfosEntrepReturn
2010-10-18 13:51:58 +00:00
*/
2010-11-23 15:12:32 +00:00
public function setInfosEntrep ( $siret , $idEntreprise , $tabInfos )
2010-10-18 13:51:58 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2011-01-31 17:07:24 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( __FUNCTION__ . ' : ' .
print_r ( $tabInfos , 1 ));
2010-11-23 14:27:11 +00:00
//Initialisation
2011-01-31 17:07:24 +00:00
$tabRet = array ();
$iBodacc = new MBodacc ();
$iInsee = new MInsee ();
$result = false ;
2011-01-25 16:32:49 +00:00
2010-12-03 13:24:15 +00:00
if ( $this -> tabInfoUser [ 'idClient' ] <> 1 ){
2011-01-25 16:32:49 +00:00
2010-11-23 15:12:32 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Code Client Incorrect' ;
2011-01-25 16:32:49 +00:00
2010-12-03 13:24:15 +00:00
} else {
2011-01-31 17:07:24 +00:00
$siren = substr ( $siret , 0 , 9 );
2010-11-23 15:12:32 +00:00
$iDb = new WDB ();
2011-08-24 10:30:21 +00:00
2011-01-31 17:07:24 +00:00
$tabIdentite = $tabInfos -> identite ;
$tabJugement = $tabInfos -> jugement ;
$tabActio = $tabInfos -> actionnaire ;
$tabParti = $tabInfos -> participation ;
$tabScores = $tabInfos -> score ;
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
// Mise à jour de l'identité
if ( trim ( strtolower ( $tabIdentite -> web )) == 'http://' ){
$web = '' ;
2010-12-03 13:24:15 +00:00
} else {
2011-01-31 17:07:24 +00:00
$web = trim ( $tabIdentite -> web );
2010-12-03 13:24:15 +00:00
}
2011-06-15 12:49:35 +00:00
$tabUpdate = array (
'isin' => trim ( $tabIdentite -> isin ),
'tel' => trim ( $tabIdentite -> tel ),
'fax' => trim ( $tabIdentite -> fax ),
'web' => $web ,
'mail' => trim ( $tabIdentite -> mail ),
'activite' => stripslashes ( trim ( $tabIdentite -> activite )),
'sirenDoublon' => substr ( str_replace ( ' ' , '' , strtr ( $tabIdentite -> sirenDoublon , '"\'./- ,\*#()' , ' ' )), 0 , 9 ),
'waldec' => trim ( str_replace ( ' ' , '' , strtr ( $tabIdentite -> waldec , '"\'./- ,\*#()' , ' ' ))),
2010-12-03 13:24:15 +00:00
);
2010-11-23 10:24:44 +00:00
2010-11-23 15:12:32 +00:00
/** @todo non traitées : [capital_mt] => 335400, [capital_dev] => EUR **/
if ( ! $iDb -> update ( 'infos_entrep' , $tabUpdate , " siren=' $siren ' " )){
if ( ! $iDb -> insert ( 'infos_entrep' , array_merge ( array ( 'siren' => $siren ), $tabUpdate ))){
$error -> errnum = 1 ;
$error -> errmsg = 'Mise a jour impossible' ;
$output = new SetInfosEntrepReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
exit ;
}
2010-11-23 10:24:44 +00:00
}
2011-01-31 17:07:24 +00:00
// Fin mise à jour identité
// Opposition INSEE
if ( $tabIdentite -> moisOppositionInsee > 0 &&
$tabIdentite -> moisOppositionInsee <= ( date ( 'Ym' ) * 1 ) ){
2010-11-23 15:12:32 +00:00
$iDb2 = new WDB ( 'insee' );
2011-01-31 17:07:24 +00:00
if ( ! $iDb2 -> insert ( 'insee_nondiff' , array ( 'siren' => $siren , 'mois' => $tabIdentite -> moisOppositionInsee )) ){
if ( $iDb2 -> getLastErrorNum () <> 1062 )
2010-11-23 15:12:32 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , " Erreur lors de l'inscription à la liste des oppositions de la sphère commerciale INSEE pour $siren au mois de " . $tabIdentite [ 'moisOppositionInsee' ] . " : " . EOL . print_r ( $tabIdentite , true ) . EOL . $iDb2 -> getLastError ());
2010-12-03 13:24:15 +00:00
}
2011-01-31 17:07:24 +00:00
2010-11-23 10:24:44 +00:00
}
2011-01-31 17:07:24 +00:00
// Fin opposition INSEE
2011-06-10 10:08:21 +00:00
2011-01-31 17:07:24 +00:00
// Domiciliataire
2011-06-10 10:08:21 +00:00
if ( ! empty ( $tabIdentite -> domiciliataire ) && $siren > 1000 ) {
if ( $tabIdentite -> domiciliataire == 'oui' || $tabIdentite -> domiciliataire == 'non' ) {
// L'entreprise et ces établissements seront mis à jour automatiquement ce soir
$iDb -> query ( " INSERT IGNORE INTO jo.tabAdrDom (siren,nic,siege, etActif, nom, sigle, enseigne, adrNum, adrBtq, adrTypVoie, adrLibVoie, ville, cp, depComEt, adrComp, cj, apen,apet, dateInsert)
SELECT siren , nic , siege , actif AS etActif , raisonSociale AS nom , sigle , enseigne , adr_num as adrNum , adr_btq AS adrBtq , adr_typeVoie AS adrTypVoie , adr_libVoie AS adrLibVoie , adr_ville AS ville , adr_cp AS cp , CONCAT ( adr_dep , adr_com ) AS depComEt , adr_comp AS adrComp , cj , ape_entrep AS apen , ape_etab AS apet , DATE ( NOW ()) as dateInsert
FROM jo . etablissements WHERE siren = $siren ; " , false);
}
// Si demande de suppression, on force l'indicateur ""
if ( $tabIdentite -> domiciliataire == 'non' ) {
$tabUpdate = array ( 'pasEntrepDom' => 1 );
if ( ! $iDb -> update ( 'tabAdrDom' , $tabUpdate , " siren= $siren " ))
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , " Erreur lors de la suppression du marqueur de domiciliation pour $siren : " . EOL . print_r ( $tabUpdate , true ) . EOL . $iDb -> getLastError ());
}
2010-11-23 10:24:44 +00:00
}
2011-01-31 17:07:24 +00:00
// Fin domiciliataire
2011-06-10 10:08:21 +00:00
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
// Insertion des scores
$tabUpdate = array ();
$setScore = false ;
if ( $tabScores -> encours != '' || $tabScores -> encours != null ){
$tabUpdate [ 'encours' ] = $tabScores -> encours ;
$setScore = true ;
}
if ( $tabScores -> scoreSolv != '' ){
$tabUpdate [ 'scoreSolv' ] = $tabScores -> scoreSolv ;
$setScore = true ;
}
if ( $tabScores -> scoreDir != '' ){
$tabUpdate [ 'scoreDir' ] = $tabScores -> scoreDir ;
$setScore = true ;
}
if ( $tabScores -> scoreConf != '' ){
$tabUpdate [ 'scoreConf' ] = $tabScores -> scoreConf ;
$setScore = true ;
}
if ( $setScore ){
2010-11-23 15:12:32 +00:00
// Mise à jour des Cute Offs
2011-01-31 17:07:24 +00:00
if ( ! $iDb -> update ( 'scores_cutoff' , $tabUpdate , " siren= $siren " ) ){
if ( ! $iDb -> insert ( 'scores_cutoff' , array_merge ( array (
'siren' => $siren ,
'dateInsert' => date ( 'Ymd' )
), $tabUpdate )) ){
2010-11-23 15:12:32 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , print_r ( $tabScores , true ) . EOL . $iDb -> getLastError ());
2011-01-31 17:07:24 +00:00
}
}
2010-11-23 10:24:44 +00:00
}
2011-01-31 17:07:24 +00:00
// Fin insertion des scores
// Insertion du jugement
2011-08-24 10:30:21 +00:00
$tabEven = array ();
if ( is_array ( $tabJugement -> even -> item ) && count ( $tabJugement -> even -> item ) > 0 ){
foreach ( $tabJugement -> even -> item as $even ){
$tabEven [] = $even -> code ;
}
} else {
$tabEven [] = $tabJugement -> even -> item -> code ;
}
$nic = $tabJugement -> nic * 1 ;
$entrep = $iInsee -> getIdentiteLight ( $siren , $nic );
if ( $nic > 0 && $tebEven [ 0 ] -> code == 6700 && $entrep [ 'Siege' ] == 0 ){
// Radiation d'un établissement
$tabEven [ 0 ] -> code = 6600 ;
}
if ( count ( $tabEven ) > 0 ){
2011-01-31 17:07:24 +00:00
$idAdmin = str_replace ( 'm' , '' , trim ( $tabJugement -> admin ));
$idMand = str_replace ( 'm' , '' , trim ( $tabJugement -> mand ));
$idOppo = str_replace ( 'm' , '' , trim ( $tabJugement -> oppo ));
2010-11-23 10:24:44 +00:00
2010-11-23 15:12:32 +00:00
/** Nom et Identifiant de l'opérateur de saisie **/
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2010-11-23 15:12:32 +00:00
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id' , " login=' " . $this -> tabInfoUser [ 'login' ] . " ' " );
$idUser = $rep [ 0 ][ 0 ];
2010-10-18 13:51:58 +00:00
2011-01-31 17:07:24 +00:00
$tabSource = explode ( '_' , $tabJugement -> source );
2010-11-23 15:12:32 +00:00
$source =@ $tabSource [ 0 ];
$numJal =@ $tabSource [ 1 ];
2011-01-31 17:07:24 +00:00
$dateSource = WDate :: dateT ( 'd/m/Y' , 'Ymd' , trim ( $tabJugement -> dateParution )) * 1 ;
2010-11-23 15:12:32 +00:00
if ( $dateSource < 20000101 )
$dateSource = date ( 'YmdHis' );
2011-01-31 17:07:24 +00:00
$montant = trim ( preg_replace ( '/[^0-9]/' , '' , $tabJugement -> montant )) * 1 ;
$actionsMt = trim ( preg_replace ( '/[^0-9]/' , '' , $tabJugement -> actionsMt )) * 1 ;
$actionsNb = trim ( preg_replace ( '/[^0-9]/' , '' , $tabJugement -> actionsNb )) * 1 ;
2010-11-23 15:12:32 +00:00
if ( $montant > 0 && ( $actionsNb > 0 || $actionsMt > 0 )) {
if ( $actionsNb > 0 ) $actionsMt = $montant / $actionsNb ;
elseif ( $actionsMt > 0 ) $actionsNb = $montant / $actionsMt ;
}
2011-01-31 17:07:24 +00:00
2011-08-24 10:30:21 +00:00
//@todo : ça ne va pas marcher ici
2010-11-23 15:12:32 +00:00
$strDir = '' ;
2011-01-31 17:07:24 +00:00
if ( count ( $tabJugement -> nouvDir ) > 0 ){
foreach ( $tabJugement -> nouvDir as $dir ){
if ( intval ( $dir -> Fonc ) > 0 ){
$strDir .= $iBodacc -> getFctDir (
$dir -> Fonc . ' : ' .
$dir -> Genre . ' ' .
ucwords ( strtolower ( $dir -> Pre )) . ' ' .
strtoupper ( $dir -> Nom )
);
$strDir .= ', domicilié à ' . $dir -> Dom . '. ' ;
}
}
2010-11-23 15:12:32 +00:00
}
2011-01-31 17:07:24 +00:00
if ( trim ( $tabJugement -> nouvAdrCp ) <> '' ){
$strAdr = stripslashes ( trim ( $tabJugement -> nouvAdr ) . ', ' .
trim ( $tabJugement -> nouvAdrCp ) . ' ' .
trim ( $tabJugement -> nouvAdrVille ));
} else {
2010-11-23 15:12:32 +00:00
$strAdr = '' ;
2011-01-31 17:07:24 +00:00
}
2010-11-23 15:12:32 +00:00
2011-08-24 10:30:21 +00:00
if ( count ( $tabEven ) > 1 ){
$strEven = implode ( ';' , array_slice ( $tabEven , 1 ));
} else {
$strEven = '' ;
2011-07-08 07:18:41 +00:00
}
2011-01-31 17:07:24 +00:00
$tabUpdate = array (
'strEven' => $strEven ,
'sirenValide' => $iInsee -> valideSiren ( $siren ),
2011-08-24 10:30:21 +00:00
'dateCessationPaiement' => empty ( $tabJugement -> datePaie ) ? '' :
WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement -> datePaie )),
'dateEffetFinP' => empty ( $tabJugement -> dateFinPeriode ) ? '' :
WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement -> dateFinPeriode )),
2011-01-31 17:07:24 +00:00
'tribunal' => trim ( $tabJugement -> tribunal ),
'montant' => $montant ,
'actionsNb' => $actionsNb ,
'inter1type' => 'A' ,
'inter1id' => $idAdmin ,
'inter1nom' => $iInsee -> getMandatairesParId ( $idAdmin ),
'inter2type' => 'M' ,
'inter2id' => $idMand ,
'inter2nom' => $iInsee -> getMandatairesParId ( $idMand ),
'inter3type' => 'O' ,
'inter3id' => $idOppo ,
'inter3nom' => $iInsee -> getMandatairesParId ( $idOppo ),
'complement' => stripslashes ( trim ( $tabJugement -> comp )),
'nouvActivite' => stripslashes ( trim ( $tabJugement -> nouvActivite )),
'nouvDir' => stripslashes ( trim ( $strDir )),
'nouvAdr' => $strAdr ,
'nouvFJ' => trim ( $tabJugement -> nouvFJ ),
'raisonSociale' => $entrep [ 'Nom' ],
'adresse' => $entrep [ 'Adresse' ],
'codePostal' => $entrep [ 'CP' ],
'ville' => $entrep [ 'Ville' ],
'source' => $source ,
'idSaisie' => $idUser ,
'parutionIdJal' => $numJal ,
'parutionNum' => $tabJugement -> numParution ,
2010-11-23 15:12:32 +00:00
);
2011-01-31 17:07:24 +00:00
$dateJuge = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement -> dateJuge ));
2011-08-24 10:30:21 +00:00
$tabInsert = array_merge ( $tabUpdate , array (
2011-01-31 17:07:24 +00:00
'siren' => $siren ,
'dateJugement' => $dateJuge ,
2011-08-24 10:30:21 +00:00
'typeEven' => $tabEven [ 0 ],
2011-01-31 17:07:24 +00:00
'dateSource' => $dateSource ,
));
if ( ! $iDb -> insert ( 'annonces' , array_merge ( $tabInsert , array ( 'dateInsert' => date ( 'YmdHis' ))), true ) ){
2011-08-24 10:30:21 +00:00
if ( ! $iDb -> update ( 'annonces' , $tabUpdate , " siren= $siren AND dateJugement=' $dateJuge ' AND typeEven= " . $tabEven [ 0 ], true )){
2010-11-23 15:12:32 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Mise a jour impossible' ;
$output = new SetInfosEntrepReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
}
2010-11-23 10:24:44 +00:00
}
2011-01-31 17:07:24 +00:00
// Insertion actionnaire
if ( trim ( $tabActio -> siren ) != '' ) {
$nom = $pays = $dateMAJ = '' ;
$ppPm = 'P' ;
$pct = trim ( str_replace ( ',' , '.' , $tabActio -> pct )) * 1 ;
$siren2 = preg_replace ( '/[^0-9]/' , '' , $tabActio -> siren );
$entrep2 = $iInsee -> getIdentiteEntreprise ( $siren );
$nom2 = $entrep2 [ 'Nom' ];
$pays2 = $entrep2 [ 'Pays' ];
2010-11-23 15:12:32 +00:00
if ( $pays2 == '' ) $pays2 = 'FRA' ;
if ( substr ( $entrep2 [ 'FJ' ], 0 , 1 ) * 1 <> 1 ) $ppPm = 'M' ;
2011-01-31 17:07:24 +00:00
$entrep = $iInsee -> getIdentiteEntreprise ( $siren2 );
$nom = $entrep [ 'Nom' ];
$pays = trim ( $entrep [ 'Pays' ]);
2010-11-23 15:12:32 +00:00
if ( $pays == '' ) $pays = 'FRA' ;
2011-01-31 17:07:24 +00:00
if ( trim ( $tabActio -> nom ) != '' ) $nom = $tabActio -> nom ;
if ( $tabActio -> pays != 'XXX' ) $pays = $tabActio -> pays ;
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
if ( trim ( $tabActio -> dateMAJ ) != 'JJ/MM/AAAA' && trim ( $tabActio -> dateMAJ ) != '' ){
$dateMAJ = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabActio -> dateMAJ ));
}
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
if ( $tabActio -> majMin == 'maj' ) $majMin = '+' ;
elseif ( $tabActio -> majMin == 'min' ) $majMin = '-' ;
else $majMin = '' ;
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
$tabUpdate = array (
2011-02-15 11:27:45 +00:00
//'Siren1'=> $siren,
2011-01-31 17:07:24 +00:00
'Pmin' => $pct ,
'Pmax' => $pct ,
'MajMin' => $majMin ,
'PpPm' => $ppPm ,
2011-02-15 11:27:45 +00:00
//'Siren2'=> $siren2,
2011-01-31 17:07:24 +00:00
//'RaisonSociale'=> $nom,
//'Pays'=> $pays,
'dateLien' => $dateMAJ ,
);
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
$tabInsert1 = array_merge ( $tabUpdate , array ( 'ActionPart' => 1 ),
array (
'Siren1' => $siren ,
'Siren2' => $siren2 ,
'RaisonSociale' => $nom ,
'Pays' => $pays ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' ))
);
$res = $iDb -> select ( 'liens' , 'count(*)' ,
" Siren1= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " );
2010-11-23 15:12:32 +00:00
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 1 )), " siren= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " , true ))
$errMaj = 1016166 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert1 , true ))
$errMaj = 1016167 ;
}
2011-01-31 17:07:24 +00:00
$tabInsert2 = array_merge ( $tabUpdate , array ( 'ActionPart' => 2 ),
array ( 'Siren1' => $siren2 ,
'Siren2' => $siren ,
'RaisonSociale' => $nom2 ,
'Pays' => $pays2 ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' ))
);
2010-11-23 15:12:32 +00:00
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 2 )), " siren= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " , true ))
$errMaj = 1016168 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert2 , true ))
$errMaj = 1016169 ;
}
2010-11-23 10:24:44 +00:00
}
2011-01-31 17:07:24 +00:00
// Fin insertion actionnaire
2010-11-23 10:24:44 +00:00
2011-01-31 17:07:24 +00:00
//Insertion participation
if ( trim ( $tabParti -> siren ) <> '' ) {
$nom = $pays = $dateMAJ = '' ;
$ppPm = 'P' ;
$pct = trim ( str_replace ( ',' , '.' , $tabParti -> pct )) * 1 ;
$siren2 = preg_replace ( '/[^0-9]/' , '' , $tabParti -> siren );
$entrep2 = $iInsee -> getIdentiteEntreprise ( $siren );
$nom2 = $entrep2 [ 'Nom' ];
$pays2 = $entrep2 [ 'Pays' ];
2010-11-23 15:12:32 +00:00
if ( $pays2 == '' ) $pays2 = 'FRA' ;
if ( substr ( $entrep2 [ 'FJ' ], 0 , 1 ) * 1 <> 1 ) $ppPm = 'M' ;
2011-01-31 17:07:24 +00:00
$entrep = $iInsee -> getIdentiteEntreprise ( $siren2 );
$nom = $entrep [ 'Nom' ];
$pays = trim ( $entrep [ 'Pays' ]);
if ( $pays == '' ) $pays = 'FRA' ;
if ( trim ( $tabParti -> nom ) <> '' ) $nom = $tabParti -> nom ;
if ( $tabParti -> pays <> 'XXX' ) $pays = $tabParti -> pays ;
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
if ( trim ( $tabParti -> dateMAJ ) <> 'JJ/MM/AAAA' && trim ( $tabParti -> dateMAJ ) <> '' )
$dateMAJ = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabParti -> dateMAJ ));
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
if ( $tabParti -> majMin == 'maj' ) $majMin = '+' ;
elseif ( $tabParti -> majMin == 'min' ) $majMin = '-' ;
2010-11-23 15:12:32 +00:00
else $majMin = '' ;
2011-01-31 17:07:24 +00:00
$tabUpdate = array (
'Pmin' => $pct ,
'Pmax' => $pct ,
'MajMin' => $majMin ,
'PpPm' => $ppPm ,
'dateLien' => $dateMAJ ,
);
2010-11-23 15:12:32 +00:00
2011-01-31 17:07:24 +00:00
$tabInsert1 = array_merge ( $tabUpdate , array ( 'ActionPart' => 2 ),
array ( 'Siren1' => $siren ,
'Siren2' => $siren2 ,
'RaisonSociale' => $nom ,
'Pays' => $pays ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' ))
);
2010-11-23 15:12:32 +00:00
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 2 )), " siren= $siren AND (Siren2= $siren2 OR (RaisonSociale=' $nom ' AND Pays=' $pays ')) " , true ))
$errMaj = 10168 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert1 , true ))
$errMaj = 10169 ;
}
2011-01-31 17:07:24 +00:00
$tabInsert2 = array_merge ( $tabUpdate , array ( 'ActionPart' => 1 ),
array ( 'Siren1' => $siren2 ,
'Siren2' => $siren ,
'RaisonSociale' => $nom2 ,
'Pays' => $pays2 ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' ))
);
2010-11-23 15:12:32 +00:00
$res = $iDb -> select ( 'liens' , 'count(*)' , " Siren1= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " );
if ( $res [ 0 ][ 0 ] > 0 ) {
if ( ! $iDb -> update ( 'liens' , array_merge ( $tabUpdate , array ( 'ActionPart' => 1 )), " siren= $siren2 AND (Siren2= $siren OR (RaisonSociale=' $nom2 ' AND Pays=' $pays2 ')) " , true ))
$errMaj = 10170 ;
} else {
if ( ! $iDb -> insert ( 'liens' , $tabInsert2 , true ))
$errMaj = 10171 ;
}
}
2011-01-31 17:07:24 +00:00
// Fin insertion participation
2010-11-23 15:12:32 +00:00
if ( $errMaj > 0 ){
$error -> errnum = 1 ;
$error -> errmsg = 'Mise a jour impossible' ;
2010-11-23 10:24:44 +00:00
} else {
2010-11-23 15:12:32 +00:00
$result = true ;
2010-11-23 10:24:44 +00:00
}
}
2010-11-23 15:12:32 +00:00
$output = new SetInfosEntrepReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-10-18 13:51:58 +00:00
}
2010-10-20 13:32:33 +00:00
/**
* Commande de bilan
* @ param InfoCommandeBilan $infoCommande
2011-02-01 17:27:03 +00:00
* @ param InfosDemandeur $infosDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdBilanReturn
2010-10-20 13:32:33 +00:00
*/
2011-02-01 17:27:03 +00:00
public function setCmdBilan ( InfoCommandeBilan $infoCommande , InfosDemandeur $infosDemandeur )
2010-10-20 13:32:33 +00:00
{
2010-11-08 11:27:04 +00:00
2010-10-20 13:32:33 +00:00
}
2010-10-25 07:33:43 +00:00
/**
* Renvoi des informations sur une commande de bilan
* @ param string $reference
2010-11-08 11:27:04 +00:00
* @ return CmdBilanReturn
2010-10-25 07:33:43 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getCmdBilan ( $reference )
2010-10-25 07:33:43 +00:00
{
}
2010-10-20 13:32:33 +00:00
/**
* Commande d ' acte
* @ param InfoCommandeActe $infoCommande
2011-02-01 17:27:03 +00:00
* @ param InfosDemandeur $infosDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdActeReturn
2010-10-20 13:32:33 +00:00
*/
2011-02-01 17:27:03 +00:00
public function setCmdActe ( $infoCommande , $infosDemandeur )
2010-10-20 13:32:33 +00:00
{
}
2010-10-25 07:33:43 +00:00
/**
* Renvoi des informations sur une commande d ' acte
* @ param string $reference
2010-11-08 11:27:04 +00:00
* @ return CmdActeReturn
2010-10-25 07:33:43 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getCmdActe ( $reference ){}
2010-10-25 07:33:43 +00:00
2010-10-20 13:32:33 +00:00
/**
* Commande de kbis
* @ param InfoCommandeKbis $infoCommande
2011-02-01 17:27:03 +00:00
* @ param InfosDemandeur $infosDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdKbisReturn
2010-10-20 13:32:33 +00:00
*/
2011-02-01 17:27:03 +00:00
public function setCmdKbis ( InfoCommandeKbis $infoCommande , InfosDemandeur $infosDemandeur )
2010-10-28 16:23:51 +00:00
{
2010-11-29 10:35:36 +00:00
$this -> authenticate ();
2010-10-28 16:23:51 +00:00
$error = new ErrorType ();
$ref = new RefCommande ();
//Vérifier les informations
switch ( $infoCommande -> mode )
{
case 'courrier' : break ;
case 'mail' : break ;
2010-11-08 11:27:04 +00:00
default :
exit ; break ;
2010-10-28 16:23:51 +00:00
}
if ( empty ( $infoCommande -> siren ))
{
$error -> errnum = 0 ;
$error -> errmsg = 'Erreur SIREN invalide' ;
}
else
{
$login = $_SERVER [ 'PHP_AUTH_USER' ];
// Insertion des données commande
$dataCommandes = array (
'user_login' => $login ,
2010-11-29 10:35:36 +00:00
'user_email' => $this -> tabInfoUser [ 'email' ],
2010-10-28 16:23:51 +00:00
'type' => 'kbis' ,
2011-02-01 17:27:03 +00:00
'demandeurReference' => $infosDemandeur -> reference ,
'demandeurEmail' => $infosDemandeur -> email ,
'demandeurTel' => $infosDemandeur -> tel ,
'demandeurNom' => $infosDemandeur -> nom ,
'demandeurService' => $infosDemandeur -> service ,
'demandeurSociete' => $infosDemandeur -> societe ,
'demandeurAdresse' => $infosDemandeur -> adresse ,
'demandeurCp' => $infosDemandeur -> cp ,
'demandeurVille' => $infosDemandeur -> ville ,
2010-10-28 16:23:51 +00:00
'infoCommande' => serialize ( $infoCommande )
);
try {
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
$commande = new Application_Model_Commandes ();
$commande_id = $commande -> insert ( $dataCommandes );
} catch ( Zend_Exception $e ) {
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-28 16:23:51 +00:00
}
if ( $commande_id )
{
//Enregistrement des détails de commande
$dataCommandesKbis = array (
'commande_id' => $commande_id ,
'siren' => $infoCommande -> siren ,
'raisonSociale' => '' ,
2010-11-08 11:27:04 +00:00
'fichier' => '' ,
2010-10-28 16:23:51 +00:00
'partenaireRequete' => '' ,
'partenaireReponse' => '' ,
);
try {
$commandeKbisTable = new Application_Model_CommandesPieces ();
$commandeKbisTable -> insert ( $dataCommandesKbis );
} catch ( Zend_Exception $e ) {
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-28 16:23:51 +00:00
}
try {
$row = $commande -> find ( $commande_id );
$data = $row -> current ();
$ref -> reference = $data -> id ;
$ref -> dateCommande = $data -> date_added ;
$ref -> dateMaj = $data -> date_updated ;
$ref -> dateReception = $data -> date_closed ;
} catch ( Zend_Exception $e ) {
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-28 16:23:51 +00:00
$error -> errnum = 0 ;
$error -> errmsg = " Commande Introuvable " ;
}
}
else
{
$error -> errnum = 0 ;
$error -> errmsg = " Erreur enregistrement commande " ;
}
}
2010-11-08 11:27:04 +00:00
$output = new CmdKbisReturn ();
$cmd = new CmdKbisDetail ();
$cmd -> infoCommande = $infoCommande ;
2011-02-01 17:27:03 +00:00
$cmd -> infosDemandeur = $infosDemandeur ;
2010-11-08 11:30:49 +00:00
$cmd -> refCommande = $ref ;
2010-11-08 11:27:04 +00:00
$output -> commande = $cmd ;
2010-10-28 16:23:51 +00:00
$output -> error = $error ;
return $output ;
}
2010-10-20 13:32:33 +00:00
2010-10-25 07:33:43 +00:00
/**
* Renvoi des informations sur une commande de Kbis
* @ param string $reference
2010-11-08 11:27:04 +00:00
* @ return CmdKbisReturn
2010-10-25 07:33:43 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getCmdKbis ( $reference ){}
2010-10-20 13:32:33 +00:00
/**
2010-10-25 07:33:43 +00:00
* Commande de privilèges et nantissements par email
* @ param InfoCommandePieces $infoCommande
2011-02-01 17:27:03 +00:00
* @ param InfosDemandeur $infosDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdPiecesReturn
2010-10-20 13:32:33 +00:00
*/
2011-02-01 17:27:03 +00:00
public function setCmdPieces ( $infoCommande , $infosDemandeur )
2010-10-25 07:33:43 +00:00
{
2010-11-29 10:35:36 +00:00
$this -> authenticate ();
2010-10-25 07:33:43 +00:00
$error = new ErrorType ();
$ref = new RefCommande ();
2010-12-03 13:24:15 +00:00
if ( ! empty ( $infoCommande -> siren )){
2010-10-25 07:33:43 +00:00
//Vérification SIREN
// Insertion des données commande
$dataCommandes = array (
2010-11-29 10:35:36 +00:00
'user_login' => $this -> tabInfoUser [ 'login' ],
'user_email' => $this -> tabInfoUser [ 'email' ],
2010-10-25 07:33:43 +00:00
'type' => 'pieces' ,
2011-02-01 17:27:03 +00:00
'demandeurReference' => $infosDemandeur -> reference ,
'demandeurEmail' => $infosDemandeur -> email ,
'demandeurTel' => $infosDemandeur -> tel ,
'demandeurNom' => $infosDemandeur -> nom ,
'demandeurService' => $infosDemandeur -> service ,
'demandeurSociete' => $infosDemandeur -> societe ,
'demandeurAdresse' => $infosDemandeur -> adresse ,
'demandeurCp' => $infosDemandeur -> cp ,
'demandeurVille' => $infosDemandeur -> ville ,
2010-10-26 15:42:18 +00:00
'infoCommande' => serialize ( $infoCommande )
2010-10-25 07:33:43 +00:00
);
try {
2010-10-26 15:42:18 +00:00
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
$commande = new Application_Model_Commandes ();
2010-10-28 16:23:51 +00:00
$commande_id = $commande -> insert ( $dataCommandes );
2010-10-25 07:33:43 +00:00
} catch ( Zend_Exception $e ) {
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-25 07:33:43 +00:00
}
2010-12-03 13:24:15 +00:00
if ( $commande_id ){
2010-10-25 07:33:43 +00:00
//Enregistrement des détails de commande
$dataCommandesPieces = array (
2010-10-28 16:23:51 +00:00
'commande_id' => $commande_id ,
2010-10-25 07:33:43 +00:00
'siren' => $infoCommande -> siren ,
'raisonSociale' => '' ,
2010-10-26 15:42:18 +00:00
'fichier' => '' ,
2010-10-25 07:33:43 +00:00
);
try {
2010-10-26 15:42:18 +00:00
$commandePieces = new Application_Model_CommandesPieces ();
$commandePieces -> insert ( $dataCommandesPieces );
} catch ( Zend_Exception $e ) {
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-26 15:42:18 +00:00
}
try {
2010-10-28 16:23:51 +00:00
$row = $commande -> find ( $commande_id );
2010-10-26 15:42:18 +00:00
$data = $row -> current ();
$ref -> reference = $data -> id ;
$ref -> dateCommande = $data -> date_added ;
$ref -> dateMaj = $data -> date_updated ;
$ref -> dateReception = $data -> date_closed ;
2010-10-25 07:33:43 +00:00
} catch ( Zend_Exception $e ) {
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-26 15:42:18 +00:00
$error -> errnum = 0 ;
$error -> errmsg = " Commande Introuvable " ;
2010-10-25 07:33:43 +00:00
}
2010-12-03 13:24:15 +00:00
} else {
2010-10-25 07:33:43 +00:00
$error -> errnum = 0 ;
$error -> errmsg = " Erreur enregistrement commande " ;
}
2010-12-03 13:24:15 +00:00
} else {
2010-10-25 07:33:43 +00:00
$error -> errnum = 0 ;
$error -> errmsg = 'Erreur SIREN invalide' ;
}
2010-11-08 11:27:04 +00:00
$output = new CmdPiecesReturn ();
$cmd = new CmdPiecesDetail ();
$cmd -> infoCommande = $infoCommande ;
2011-02-01 17:27:03 +00:00
$cmd -> infosDemandeur = $infosDemandeur ;
2010-11-08 11:30:49 +00:00
$cmd -> refCommande = $ref ;
2010-10-25 07:33:43 +00:00
$output -> error = $error ;
return $output ;
}
2010-10-20 13:32:33 +00:00
/**
2010-10-25 07:33:43 +00:00
* Renvoi des informations sur une commande pièces
2010-10-20 13:32:33 +00:00
* @ param string $reference
2010-11-08 11:27:04 +00:00
* @ return CmdPiecesReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getCmdPieces ( $reference )
{
list ( $typeCommande , $idCommande ) = explode ( '-' , $reference );
try {
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
$commandeTable = new Application_Model_Commandes ();
$select = $commandeTable -> select ()
-> where ( 'type = ?' , 'pieces' )
-> where ( 'id = ?' , $idCommande );
$commandeRowset = $commandeTable -> fetchAll ( $select );
}
catch ( Zend_Db_Adapter_Exception $e )
{
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
}
$error = new ErrorType ();
$ref = new RefCommande ();
$infoCommande = new InfoCommandePieces ();
2011-02-01 17:27:03 +00:00
$infosDemandeur = new InfosDemandeur ();
2010-11-08 11:27:04 +00:00
if ( $commandeRowset -> count () > 0 )
{
$commande = $commandeRowset -> current ();
$selectEven = $commandeTable -> select ()
-> order ( 'date_added DESC' ) -> limit ( 1 );
$evenRowset = $commande -> findDependentRowset (
'Application_Model_CommandesEven' , null , $selectEven );
$info = '' ;
if ( $evenRowset -> count () > 0 ){
$even = $evenRowset -> current ();
$info = $even -> commentaire ;
}
$ref -> reference = strtoupper ( $commande -> type ) . '-' . $commande -> id ;
$ref -> dateCommande = $commande -> date_added ;
$ref -> dateMaj = $commande -> date_updated ;
$ref -> dateReception = $commande -> date_closed ;
$ref -> info = $info ;
$ref -> fichier = '' ; // @todo : Détecter le fichier
$ref -> login = $commande -> user_login ;
$infoCommande = unserialize ( $commande -> infoCommande );
2011-02-01 17:27:03 +00:00
$infosDemandeur -> reference = $commande -> demandeurReference ;
$infosDemandeur -> email = $commande -> demandeurEmail ;
$infosDemandeur -> tel = $commande -> demandeurTel ;
$infosDemandeur -> nom = $commande -> demandeurNom ;
$infosDemandeur -> service = $commande -> demandeurService ;
$infosDemandeur -> societe = $commande -> demandeurSociete ;
$infosDemandeur -> adresse = $commande -> demandeurAdresse ;
$infosDemandeur -> cp = $commande -> demandeurCp ;
$infosDemandeur -> ville = $commande -> demandeurVille ;
2010-11-08 11:27:04 +00:00
}
else
{
$error -> errnum = 0 ;
$error -> errmsg = 'Référence inconnue' ;
}
$output = new CmdPiecesReturn ();
$cmd = new CmdPiecesDetail ();
2010-11-08 11:30:49 +00:00
$cmd -> refCommande = $ref ;
2010-11-08 11:27:04 +00:00
$cmd -> infoCommande = $infoCommande ;
2011-02-01 17:27:03 +00:00
$cmd -> infosDemandeur = $infosDemandeur ;
2010-11-08 11:27:04 +00:00
$output -> commande = $cmd ;
$output -> error = $error ;
return $output ;
}
2010-10-20 13:32:33 +00:00
/**
2010-11-08 11:27:04 +00:00
* Retourne la liste des commandes de pièces ainsi que leur détails
* @ param CmdFiltrePieces $filtre
2010-10-25 07:33:43 +00:00
* @ param int $position
* @ param int $nbRep
2010-11-08 11:27:04 +00:00
* @ return ListeCmdPiecesReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getListeCmdPieces ( $filtre , $position = 0 , $nbRep = 20 )
2010-10-26 15:42:18 +00:00
{
$error = new ErrorType ();
2010-11-08 11:27:04 +00:00
//Traitements des filtres pour générer la requête SQL
//Selection
$nbCommandes = 0 ;
try
{
2010-10-26 15:42:18 +00:00
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
2010-11-08 11:27:04 +00:00
$commandeTable = new Application_Model_Commandes ();
$select = $commandeTable -> select () -> where ( 'type = ?' , 'pieces' );
$countRowset = $commandeTable -> fetchAll ( $select );
$nbCommandes = $countRowset -> count ();
$select -> order ( 'date_added DESC' ) -> limit ( $nbRep , $position );
$commandeRowset = $commandeTable -> fetchAll ( $select );
2010-10-26 15:42:18 +00:00
}
catch ( Zend_Db_Adapter_Exception $e )
{
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
$error -> errnum = 1 ;
$error -> errmsg = 'Erreur' ;
2010-10-26 15:42:18 +00:00
}
2010-11-08 11:27:04 +00:00
if ( $commandeRowset -> count () > 0 )
2010-10-26 15:42:18 +00:00
{
2010-11-08 11:27:04 +00:00
$liste = array ();
foreach ( $commandeRowset as $commande )
{
$selectEven = $commandeTable -> select ()
2010-10-28 16:23:51 +00:00
-> order ( 'date_added DESC' ) -> limit ( 1 );
2010-11-08 11:27:04 +00:00
$evenRowset = $commande -> findDependentRowset (
'Application_Model_CommandesEven' , null , $selectEven );
2010-10-26 15:42:18 +00:00
$info = '' ;
2010-11-08 11:27:04 +00:00
if ( $evenRowset -> count () > 0 ){
$even = $evenRowset -> current ();
$info = $even -> commentaire ;
2010-10-26 15:42:18 +00:00
}
2010-11-08 11:27:04 +00:00
2010-10-26 15:42:18 +00:00
$ref = new RefCommande ();
2010-11-08 11:27:04 +00:00
$ref -> reference = strtoupper ( $commande -> type ) . '-' . $commande -> id ;
$ref -> dateCommande = $commande -> date_added ;
$ref -> dateMaj = $commande -> date_updated ;
$ref -> dateReception = $commande -> date_closed ;
2010-10-26 15:42:18 +00:00
$ref -> info = $info ;
2010-11-08 11:27:04 +00:00
$ref -> fichier = '' ; // @todo : Détecter le fichier
$ref -> login = $commande -> user_login ;
$infoCommande = new InfoCommandePieces ();
$infoCommande = unserialize ( $commande -> infoCommande );
2011-02-01 17:27:03 +00:00
$infosDemandeur = new InfosDemandeur ();
$infosDemandeur -> reference = $commande -> demandeurReference ;
$infosDemandeur -> email = $commande -> demandeurEmail ;
$infosDemandeur -> tel = $commande -> demandeurTel ;
$infosDemandeur -> nom = $commande -> demandeurNom ;
$infosDemandeur -> service = $commande -> demandeurService ;
$infosDemandeur -> societe = $commande -> demandeurSociete ;
$infosDemandeur -> adresse = $commande -> demandeurAdresse ;
$infosDemandeur -> cp = $commande -> demandeurCp ;
$infosDemandeur -> ville = $commande -> demandeurVille ;
2010-11-08 11:27:04 +00:00
$cmd = new CmdPiecesDetail ();
$cmd -> refCommande = $ref ;
$cmd -> infoCommande = $infoCommande ;
2011-02-01 17:27:03 +00:00
$cmd -> infosDemandeur = $infosDemandeur ;
2010-11-08 11:27:04 +00:00
$liste [] = $cmd ;
2010-10-26 15:42:18 +00:00
}
}
2010-11-08 11:27:04 +00:00
$output = new ListeCmdPiecesReturn ();
2010-10-26 15:42:18 +00:00
$output -> error = $error ;
2010-11-08 11:27:04 +00:00
$output -> nbCommandes = $nbCommandes ;
$output -> liste = $liste ;
2010-10-26 15:42:18 +00:00
return $output ;
}
2010-10-20 13:32:33 +00:00
2010-10-25 07:33:43 +00:00
/**
* Retourne la liste des statuts de commande
* @ param string $type
2010-11-08 11:27:04 +00:00
* @ return CmdStatut []
2010-10-25 07:33:43 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getListeCmdStatut ( $type )
2010-10-25 07:33:43 +00:00
{
Zend_Registry :: get ( 'WsLogger' ) -> info ( " getListeStatut - " . $type );
try {
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
2010-10-26 15:42:18 +00:00
$dbStatut = new Application_Model_CommandesStatut ();
2010-10-25 07:33:43 +00:00
$result = $dbStatut -> fetchAll ( array ( " commande_type = ' $type ' " ));
}
catch ( Zend_Db_Adapter_Exception $e )
{
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-25 07:33:43 +00:00
}
$listeStatut = array ();
if ( count ( $result ) > 0 )
{
foreach ( $result as $r )
{
2010-11-08 11:27:04 +00:00
$statut = new CmdStatut ();
2010-10-25 07:33:43 +00:00
$statut -> code = $r [ 'code' ];
$statut -> lib = $r [ 'libelle' ];
$listeStatut [] = $statut ;
}
}
return $listeStatut ;
}
/**
2010-11-08 11:27:04 +00:00
* Spécifier un état défini pour une commande
2010-10-28 16:23:51 +00:00
* ( avec déclenchement d ' une action )
* @ param int $reference
2010-10-26 15:42:18 +00:00
* @ param int $statutCode
* @ return bool
*/
2010-11-08 11:27:04 +00:00
public function setCmdStatut ( $reference , $statutCode )
2010-10-26 15:42:18 +00:00
{
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
$dbStatut = new Application_Model_CommandesStatut ();
2010-10-28 16:23:51 +00:00
$row = $dbStatut -> fetchRow ( array ( " code = ' $statutCode ' " ));
if ( count ( $row ) > 0 && $this -> setCommandeEven ( $reference , $row [ 'lib' ]) )
2010-10-26 15:42:18 +00:00
{
2010-10-28 16:23:51 +00:00
if ( ! empty ( $row [ 'action' ])){
switch ( $row [ 'action' ]){
2010-10-26 15:42:18 +00:00
case 'CLOSE' :
//date_closed
break ;
}
}
return true ;
} else {
return false ;
}
}
/**
* Spécifier un état pour une commande
2010-10-28 16:23:51 +00:00
* @ param int $reference
2010-10-25 07:33:43 +00:00
* @ param string $comment
* @ return bool
*/
2010-11-08 11:27:04 +00:00
public function setCmdEven ( $reference , $comment )
2010-10-25 07:33:43 +00:00
{
2010-11-29 10:35:36 +00:00
$this -> authenticate ();
2010-10-28 16:23:51 +00:00
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
2010-10-25 07:33:43 +00:00
try {
2010-10-28 16:23:51 +00:00
//Vérifier que la commande existe avec la référence fournie
$commandeTable = new Application_Model_Commandes ();
$commandeRowset = $commandeTable -> find ( $reference );
if ( $commandeRowset -> count () > 0 )
{
$commande = $commandeRowset -> current ();
//Enregistrer l'événement
$commandeEvenTable = new Application_Model_CommandesEven ();
$insert = $commandeEvenTable -> createRow ();
$insert -> commande_id = $commande -> id ;
$insert -> commentaire = $comment ;
2010-11-29 10:35:36 +00:00
$insert -> user_login = $this -> tabInfoUser [ 'login' ];
2010-10-28 16:23:51 +00:00
$insert -> save ();
//Mettre à jour la commande
$commande -> date_updated = date ( 'Y-m-d H:i:s' );
$commande -> save ();
return true ;
} else {
return false ;
}
2010-10-25 07:33:43 +00:00
}
catch ( Zend_Db_Adapter_Exception $e )
{
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-25 07:33:43 +00:00
return false ;
}
}
/**
* Ajout du nom de fichier liée à la commande
2010-10-28 16:23:51 +00:00
* @ param int $reference
2010-10-25 07:33:43 +00:00
* @ param string $filename
2010-10-28 16:23:51 +00:00
* @ return bool
2010-10-25 07:33:43 +00:00
*/
2010-11-08 11:27:04 +00:00
public function setCmdDocument ( $reference , $filename )
2010-10-20 13:32:33 +00:00
{
2010-11-29 10:35:36 +00:00
$this -> authenticate ();
2010-10-28 16:23:51 +00:00
$db = Zend_Db :: factory ( $this -> dbConfig -> Commandes );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
try {
//Vérifier que la commande existe avec la référence fournie
$commandeTable = new Application_Model_Commandes ();
$commandeRowset = $commandeTable -> find ( $reference );
if ( $commandeRowset -> count () > 0 )
{
$commande = $commandeRowset -> current ();
switch ( $commande -> type )
{
case 'pieces' :
$infoCommandePieces = $commande -> findDependentRowset ( 'Application_Model_CommandesPieces' );
if ( $infoCommandePieces -> count () > 0 )
{
//Update informations pieces
$commandePieces = $infoCommandePieces -> current ();
$commandePieces -> fichier = $filename ;
$commandePieces -> save ();
//Mettre à jour la commande
$commande -> date_updated = date ( 'Y-m-d H:i:s' );
$commande -> save ();
2010-11-29 10:35:36 +00:00
//Mettre à jour les évenements de commande
//@todo
2010-10-28 16:23:51 +00:00
return true ;
}
break ;
case 'default' :
return false ;
break ;
}
} else {
return false ;
}
}
catch ( Zend_Db_Adapter_Exception $e )
{
2010-11-08 11:27:04 +00:00
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
2010-10-28 16:23:51 +00:00
return false ;
}
2010-10-20 13:32:33 +00:00
}
2010-11-15 14:17:19 +00:00
/**
* Récupère les informations du profil connecté
* @ param string $login
* @ param string $ipUtilisateur
* @ return InfosLoginReturn
*/
public function getInfosLogin ( $login , $ipUtilisateur = '' )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2011-01-06 16:26:46 +00:00
2010-11-15 14:17:19 +00:00
//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 ? **/
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
$rep = $iDbCrm -> select (
2010-11-15 14:17:19 +00:00
'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 " ,
2011-08-24 10:30:21 +00:00
false , MYSQL_ASSOC
2010-11-15 14:17:19 +00:00
);
$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' ],
);
2011-08-24 10:30:21 +00:00
$tabTmp = $iDbCrm -> select ( 'clients' , 'typeScore' , 'id=' . $tabRep [ 'idClient' ], false , MYSQL_ASSOC );
2010-11-15 14:17:19 +00:00
$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 ;
}
2010-11-23 10:24:44 +00:00
/**
* Mise à jour des informations du profil connecté
2010-11-23 14:27:11 +00:00
* @ param string $login
2011-05-09 08:26:03 +00:00
* @ param string $action ( delete | actif | desactif | changepwd | new | update )
2011-01-20 11:15:32 +00:00
* @ param InfosLoginData $infos
2010-11-23 14:27:11 +00:00
* @ return SetInfosLoginReturn
2010-11-23 10:24:44 +00:00
*/
2011-01-20 11:15:32 +00:00
public function setInfosLogin ( $login , $action , $infos = null )
2010-11-23 10:24:44 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 14:27:11 +00:00
//Initialisation
$error = new ErrorType ();
$result = false ;
2011-01-20 11:15:32 +00:00
switch ( $action )
2010-11-23 14:27:11 +00:00
{
2011-01-20 11:15:32 +00:00
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 ,
2011-08-08 12:19:33 +00:00
'profil' => ( isset ( $infos -> profil ) || ! in_array ( $infos -> profil , array ( 'SuperAdministrateur' , 'Administrateur' , 'Utilisateur' )) ) ? $infos -> profil : 'Utilisateur' ,
2011-01-20 11:15:32 +00:00
'pref' => implode ( ' ' , $infos -> pref -> item ),
'droits' => implode ( ' ' , $infos -> droits -> item ),
);
2011-08-05 14:30:22 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2011-01-20 11:15:32 +00:00
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 );
2011-08-08 08:34:52 +00:00
$tabUpdate [ 'profil' ] = isset ( $infos -> profil ) ? $infos -> profil : 'Utilisateur' ;
2011-01-20 11:15:32 +00:00
}
$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 ;
2010-11-23 14:27:11 +00:00
}
2011-01-20 11:15:32 +00:00
2010-11-23 14:27:11 +00:00
$output = new SetInfosLoginReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-18 16:42:01 +00:00
/**
* Obtention automatique d ' un nouveau login pour un client
* @ param string $login
* @ return NextLoginReturn
*/
public function getNextLogin ( $login )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-18 16:42:01 +00:00
//Initialisation
$error = new ErrorType ();
if ( $this -> tabInfoUser [ 'profil' ] == 'Administrateur' ||
2011-02-01 17:27:03 +00:00
$this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) {
2010-11-18 16:42:01 +00:00
/** Un administrateur veut créer un nouveau login **/
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2010-11-18 16:42:01 +00:00
$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' ;
2011-02-01 17:27:03 +00:00
} else {
2010-11-18 16:42:01 +00:00
$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 ;
2011-02-01 17:27:03 +00:00
} else {
2010-11-18 16:42:01 +00:00
$error -> errnum = 0 ;
$error -> errmsg = 'Acces non authorisé!' ;
}
$output = new NextLoginReturn ();
2011-01-20 11:30:16 +00:00
$output -> error = $error ;
$output -> result = $result ;
2010-11-18 16:42:01 +00:00
return $output ;
}
2010-11-23 10:24:44 +00:00
/**
* Enregistre une action utilisateur pour la facturation
* @ param string $page
* @ param string $siret
* @ param int $id
* @ param string $ref
* @ return void
*/
public function setLog ( $page , $siret , $id = 0 , $ref = '' )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 10:24:44 +00:00
//Initialisation
if ( empty ( $id )) $id = 0 ;
if ( empty ( $ref )) $ref = '' ;
2011-01-26 17:23:14 +00:00
if ( $id != 0 ) {
$ref2 = '' . $id . '/' . $ref ;
} else {
$ref2 = $ref ;
}
2011-01-13 16:52:27 +00:00
$this -> wsLog ( $page , $siret , $ref2 );
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Insertion d'un log pour la page $page $siret $ref2 " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
2010-11-23 11:38:19 +00:00
/**
* Met a jour les informations sur un mandataire
2011-02-15 11:27:45 +00:00
* @ param SetInfosMandataire $infos Informations sur le mandataire à créer ou à ajouter ( ajout si id absent )
2010-11-23 11:38:19 +00:00
* @ return SetMandataireReturn
2010-11-23 10:24:44 +00:00
**/
2011-02-15 11:27:45 +00:00
public function setMandataire ( SetInfosMandataire $infos )
2010-11-23 11:38:19 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 11:38:19 +00:00
//Initialisation
$error = new ErrorType ();
$result = true ;
2010-11-23 10:24:44 +00:00
2010-11-23 11:38:19 +00:00
$iDb = new WDB ();
2010-11-23 10:24:44 +00:00
/** Nom et Identifiant de l'opérateur de saisie **/
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id' , " login=' " . $this -> tabInfoUser [ 'login' ] . " ' " );
2010-11-23 11:38:19 +00:00
$idUser = $rep [ 0 ][ 0 ];
2010-11-23 10:24:44 +00:00
2010-11-23 11:38:19 +00:00
$infos = serialize ( $tabInfos );
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Ajout/MAJ de mandaitaire $infos demandée " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-02-15 11:27:45 +00:00
$type = substr ( strtoupper ( $infos -> type ), 0 , 1 );
$stag = substr ( strtoupper ( $infos -> type ), 1 , 1 );
2010-11-23 11:38:19 +00:00
if ( $stag == 'S' ) { $stag = 1 ; } else { $stag = 0 ; }
if ( $type == 'A' || $type == 'H' || $type == 'M' || $type == 'V' ||
$type == 'N' || $type == 'T' )
{
$tabUpdate = array (
2011-02-15 11:27:45 +00:00
'sirenGrp' => substr ( $infos -> sirenGrp , 0 , 9 ) * 1 ,
'nicGrp' => substr ( $infos -> sirenGrp , 9 , 5 ) * 1 ,
'sirenMand' => substr ( $infos -> sirenMand , 0 , 9 ) * 1 ,
'nicMand' => substr ( $infos -> sirenMand , 9 , 5 ) * 1 ,
'Nom' => ucwords ( strtolower ( $infos -> Nom )),
'Prenom' => ucwords ( strtolower ( $infos -> Prenom )),
2010-11-23 11:38:19 +00:00
'type' => $type ,
'stagiaire' => $stag ,
2011-02-15 11:27:45 +00:00
'coursAppel' => intval ( $infos -> coursAppel ),
'coursAppel2' => intval ( $infos -> coursAppel2 ),
'tribunal' => $infos -> tribunal ,
'Statut' => strtoupper ( $infos -> Statut ),
'adresse' => ucwords ( $infos -> adresse ),
'adresseComp' => strtoupper ( $infos -> adresseComp ),
'cp' => intval ( $infos -> cp ),
'ville' => strtoupper ( $infos -> ville ),
'tel' => $infos -> tel ,
'fax' => $infos -> fax ,
'email' => $infos -> email ,
'web' => $infos -> web ,
'contact' => $infos -> contact ,
2010-11-23 11:38:19 +00:00
'idUser' => $idUser ,
);
2010-11-23 10:24:44 +00:00
}
2011-02-15 11:27:45 +00:00
$id = str_replace ( 'm' , '' , '' . $infos -> id ) * 1 ;
if ( intval ( $id ) != 0 ) {
2010-11-23 10:24:44 +00:00
// MAJ
2011-02-15 11:27:45 +00:00
if ( ! $iDb -> update ( 'tabMandataires' , $tabUpdate , " id= $id " , true )) {
2010-11-23 11:38:19 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Mise a jour impossible' ;
$result = false ;
}
2011-02-15 11:27:45 +00:00
} else {
2010-11-23 10:24:44 +00:00
// Insertion
2011-02-15 11:27:45 +00:00
if ( ! $iDb -> insert ( 'tabMandataires' , array_merge ( $tabUpdate , array ( 'dateInsert' => date ( 'YmdHis' ))), true )) {
2010-11-23 11:38:19 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Insertion impossible' ;
$result = false ;
}
2010-11-23 10:24:44 +00:00
}
2010-11-23 11:38:19 +00:00
$output = new SetMandataireReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
/**
* Supprime une annonce issue de la collecte
2010-11-23 14:09:39 +00:00
* @ param string $idAnn
* @ param string $siret
* @ return SupprAnnonceCollecteReturn
2010-11-23 10:24:44 +00:00
*/
2010-11-23 14:09:39 +00:00
public function supprAnnonceCollecte ( $idAnn , $siret = null )
2010-11-23 10:24:44 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 14:09:39 +00:00
//Initialisation
if ( empty ( $siret )) $siret = 0 ;
$error = new ErrorType ();
$result = false ;
2010-11-23 10:24:44 +00:00
2010-11-23 14:09:39 +00:00
if ( $this -> tabInfoUser [ 'idClient' ] <> 1 )
{
$error -> errnum = 1 ;
$error -> errmsg = 'Code Client Incorrect' ;
2010-11-23 10:24:44 +00:00
}
2010-11-23 14:09:39 +00:00
else
{
$siren = substr ( $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
if ( $idAnn > 0 )
{
if ( $iDb -> update ( 'annonces' , array (
'dateSuppr' => date ( 'YmdHis' ),
2010-11-29 10:45:03 +00:00
'idSuppr' => $this -> tabInfoUser [ 'id' ]),
2010-11-23 14:09:39 +00:00
" id= $idAnn " , false ))
{
debugLog ( 'I' , " Suppression de l'annonce collectée n° $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$result = true ;
}
else
{
$error -> errnum = 1 ;
$error -> errmsg = 'Suppression de l\'annonce impossible' ;
debugLog ( 'I' , " Suppression impossible de l'annonce collectée n° $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
}
else
{
$error -> errnum = 1 ;
$error -> errmsg = 'idAnn incorrect' ;
}
}
$output = new SupprAnnonceCollecte ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-18 16:42:01 +00:00
2010-11-23 15:45:07 +00:00
/**
* Récupère le mandataire par son id
* @ param int $idMand Identifiant du mandataire
* @ return MandataireReturn
*/
public function getMandataire ( $idMand )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 15:45:07 +00:00
//Initialisation
$error = new ErrorType ();
2010-11-23 10:24:44 +00:00
2010-11-23 15:45:07 +00:00
debugLog ( 'I' , " Donne le Mandataires correspondant à $idMand " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new classMInsee ();
$tabRet = $iInsee -> getMandataire ( $idMand );
$mandataire = new MandataireDetail ();
$mandataire -> Nom = $tabRet [ 'Nom' ];
$mandataire -> Prenom = $tabRet [ 'Prenom' ];
$mandataire -> tribunal = $tabRet [ 'tribunal' ];
$mandataire -> adresse = $tabRet [ 'adresse' ];
$mandataire -> adresseComp = $tabRet [ 'adresseComp' ];
$mandataire -> ville = $tabRet [ 'ville' ];
$mandataire -> email = $tabRet [ 'email' ];
$mandataire -> web = $tabRet [ 'web' ];
$mandataire -> contact = $tabRet [ 'contact' ];
$output = new MandataireReturn ();
$output -> error = $error ;
$output -> result = $mandataire ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-23 15:29:01 +00:00
/**
* Liste les mandataires compétentes pour une cours d ' appel donnée
*
* @ param mixed $codeTribunal Identifiants BODACC du tribunal ou tableau d 'Identifiants numériques des cours d' appel
* @ param array $type Type de mandataire ( A ) dministrateur , ( M ) andataire , ( O ) ppositions , ( N ) otaires , a ( V ) ocat
* @ return MandatairesReturn
*/
public function getMandataires ( $codeTribunal = 0 , $type = array ( 'A' , 'M' ))
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 15:29:01 +00:00
//Initialisation
2011-01-25 16:32:49 +00:00
$iInsee = new MInsee ();
2010-11-23 15:29:01 +00:00
$error = new ErrorType ();
$trib = serialize ( $codeTribunal );
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Liste des Mandaitaires ou Administrateur du Tribunal/Cours d'Appel $trib demandé " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-23 15:29:01 +00:00
if ( ! is_array ( $codeTribunal ) && strlen ( $codeTribunal ) > 3 && $codeTribunal * 1 == 0 )
{
2010-11-23 10:24:44 +00:00
// $codeTribunal est un identifiant de tribunal
2010-11-23 15:29:01 +00:00
$iBodacc = new MBodacc ();
2011-01-25 16:32:49 +00:00
$tabTmp = $iInsee -> getMandataires ( array ( $iBodacc -> getTribunalIdCA ( $codeTribunal )), true , $type );
2010-11-23 15:29:01 +00:00
}
elseif ( $codeTribunal * 1 == 0 )
{
2010-11-23 10:24:44 +00:00
// On veut tous les mandataires
2011-01-25 16:32:49 +00:00
$tabTmp = $iInsee -> getMandataires ( array (), true , $type );
2010-11-23 15:29:01 +00:00
}
elseif ( is_array ( $codeTribunal ))
{
2010-11-23 10:24:44 +00:00
// On veut les mandataires d'une CA
2011-01-25 16:32:49 +00:00
$tabTmp = $iInsee -> getMandataires ( $codeTribunal , true , $type );
2010-11-23 10:24:44 +00:00
}
2010-11-23 15:29:01 +00:00
$tabRet = array ();
foreach ( $tabTmp as $i => $mand ){
$mandataire = new Mandataire ();
$mandataire -> id = 'm' . $i ;
$mandataire -> mand = $mand ;
$tabRet [] = $mandataire ;
}
$output = new MandatairesReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-18 16:42:01 +00:00
2011-01-19 09:22:05 +00:00
2010-11-15 16:28:25 +00:00
/**
*
* Retourne la liste des conventions
* @ param string $siren
* @ return ListeConventionsReturn
*/
2010-11-17 16:52:52 +00:00
public function getListeConventions ( $siren )
2010-11-15 16:28:25 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-15 16:28:25 +00:00
//Initialisation
$error = new ErrorType ();
2011-01-25 16:32:49 +00:00
$tabRet = array ();
2010-11-15 16:28:25 +00:00
debugLog ( 'I' , " Liste des conventions demandée pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-01-25 16:32:49 +00:00
if ( strlen ( $siren ) <> 9 ){
2010-11-15 16:28:25 +00:00
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren Siret inexistant' ;
2011-01-25 16:32:49 +00:00
} elseif ( $siren * 1 == 0 ){
2010-11-15 16:28:25 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2011-01-25 16:32:49 +00:00
} else {
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteEntreprise ( $siren );
2010-11-15 16:28:25 +00:00
if ( empty ( $tabIdentite ) && isset ( $tabIdentite [ 'erreur' ]) &&
2011-01-25 16:32:49 +00:00
$tabIdentite [ 'erreur' ] <> '' ){
2010-11-15 16:28:25 +00:00
debugLog ( 'W' , " Siren $siren non présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2011-01-25 16:32:49 +00:00
} else {
2010-11-15 16:28:25 +00:00
$naf = $tabIdentite [ 'NafEnt' ];
$trancheEffectif = $tabIdentite [ 'EffEnTr' ];
$effectif = $tabIdentite [ 'Effectif' ];
$fj = $tabIdentite [ 'entreprise' ][ 'FJCodeEntrep' ];
2011-01-25 16:32:49 +00:00
$isolv = new MSolvabilite ( $siren , $naf , $trancheEffectif ,
$effectif , $tabIdentite [ 'CP' ], $fj , $tabIdentite [ 'Capital' ],
$tabIdentite [ 'CapitalDev' ], $tabIdentite [ 'DateCreaEn' ],
$tabIdentite [ 'DateCreaEt' ]
);
2010-11-15 16:28:25 +00:00
$noteStructure = $isolv -> getSolvabilite ();
$naf4 = $isolv -> getNaf4 ( $naf );
2011-01-25 16:32:49 +00:00
$tabTmp = $iInsee -> listeConventions ( $naf4 , $tabIdentite [ 'Dept' ]);
foreach ( $tabTmp as $conv )
2010-11-15 16:28:25 +00:00
{
$convention = new Convention ();
$convention -> idCC = $conv [ 'id CC' ];
$convention -> nomCC = $conv [ 'nom CC' ];
$convention -> infoCC = $conv [ 'infoCC' ];
$convention -> editorCC = $conv [ 'editeur CC' ];
$convention -> nbPageCC = $conv [ 'nb page CC' ];
$convention -> isbnCC = $conv [ 'isbn CC' ];
$convention -> dateCC = $conv [ 'date edition CC' ];
$convention -> joCCmaj = $conv [ 'joCCmaj' ];
2011-01-25 16:32:49 +00:00
$tabRet [] = $convention ;
2010-11-15 16:28:25 +00:00
}
2011-01-13 16:52:27 +00:00
$this -> wsLog ( 'conventions' , $siren );
2010-11-15 16:28:25 +00:00
}
}
$output = new ListeConventionsReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
2010-11-17 16:52:52 +00:00
/**
* Donne la cours d 'appel d' un tribunal par son code
* @ param string $codeTribunal Code BODACC sur 6 caractères du tribunal
* @ return int
**/
public function getIdCoursAppel ( $codeTribunal )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-17 16:52:52 +00:00
$iBodacc = new MBodacc ();
return $iBodacc -> getTribunalIdCA ( $codeTribunal );
}
2010-11-15 16:28:25 +00:00
2010-11-23 10:24:44 +00:00
/**
* Duplique une annonce issue de la collecte
* @ param string $idAnn
* @ param string $siret
* @ return DupliqueAnnonceReturn
*/
public function dupliqueAnnonceCollecte ( $idAnn , $siret = null )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 10:24:44 +00:00
//Initialisation
if ( empty ( $siret )) $siret = '' ;
$error = new ErrorType ();
$result = 0 ;
2011-01-07 09:15:49 +00:00
if ( $this -> tabInfoUser [ 'idClient' ] <> 1 ){
2010-11-23 10:24:44 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Code Client Incorrect' ;
2011-01-07 09:15:49 +00:00
} else {
2011-02-15 11:27:45 +00:00
$siren = intval ( substr ( $siret , 0 , 9 ));
$nic = intval ( substr ( $siret , 9 , 5 ));
2010-11-23 10:24:44 +00:00
$iDb = new WDB ();
2011-02-15 11:27:45 +00:00
$idAnn = intval ( preg_replace ( '/^0\./' , '' , '' . $idAnn ));
2011-01-07 09:15:49 +00:00
if ( $idAnn > 0 && $siren > 1000 ){
2010-11-23 10:24:44 +00:00
$res = $iDb -> select ( 'annonces' , '*' , " id= $idAnn " , false , MYSQL_ASSOC );
2011-02-15 11:27:45 +00:00
if ( count ( $res ) == 0 ) {
2010-11-23 10:24:44 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Annonce inexistante' ;
2011-01-07 09:15:49 +00:00
} else {
2010-11-23 10:24:44 +00:00
$annonce = $res [ 0 ];
2011-01-07 09:15:49 +00:00
// Suppression des zones inexistantes dans la table ou devant être vides
2010-11-23 10:24:44 +00:00
unset ( $annonce [ 'id' ]);
2011-01-07 09:15:49 +00:00
unset ( $annonce [ 'nic' ]); //=$nic;
2010-11-23 10:24:44 +00:00
$annonce [ 'siren' ] = $siren ;
$annonce [ 'nic' ] = $nic ;
2011-01-07 09:15:49 +00:00
if ( $iDb -> insert ( 'annonces' , $annonce , false )) {
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Duplication de l'annonce collectée n° $idAnn sur $siret " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$result = 1 ;
2011-01-07 09:15:49 +00:00
} else {
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Suppression impossible de l'annonce collectée n° $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 1 ;
$error -> errmsg = 'Suppression de l\'annonce impossible' ;
}
}
}
}
$output = new DupliqueAnnonceCollecte ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-11-17 16:52:52 +00:00
/**
* Récupère le contenu d ' une annonce issue de la collecte
* @ param string $idAnn
* @ param string $siret
* @ return AnnonceCollecteReturn
*/
public function getAnnonceCollecte ( $idAnn , $siret )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-17 16:52:52 +00:00
//Initialisation
$error = new ErrorType ();
$annonceCollecte = new AnnonceCollecte ();
2011-02-01 17:27:03 +00:00
$siren = substr ( $siret , 0 , 9 ) * 1 ;
if ( $this -> tabInfoUser [ 'idClient' ] <> 1 ) {
2010-11-17 16:52:52 +00:00
$error -> errnum = 0 ;
$error -> errmsg = 'Code Client Incorrect' ;
2011-02-01 17:27:03 +00:00
} else {
2010-11-17 16:52:52 +00:00
$iDb = new WDB ();
debugLog ( 'I' , " Lecture de l'annonce collectée n° $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
if ( $idAnn > 0 )
{
$res = $iDb -> select ( 'annonces' ,
'id, siren, sirenValide, typeEven, strEven, raisonSociale, adresse, codePostal, ville, dateJugement, dateCessationPaiement, dateEffetFinP, numero, inter1type, inter1id, inter1nom, inter2type, inter2id, inter2nom, inter3type, inter3id, inter3nom, inter4type, inter4id, inter4nom, tribunal, montant, actionsNb, complement, infosBrutes, nouvActivite, nouvDir, nouvAdr, nouvFJ, annonce, source, parutionIdJal, parutionNum, dateSource, idSaisie, idAnnonce, dateInsert' ,
" id= $idAnn " , false , MYSQL_ASSOC
);
if ( count ( $res ) > 0 )
{
$ann = $res [ 0 ];
$annonceCollecte -> id = $ann [ 'id' ];
$annonceCollecte -> siren = $ann [ 'siren' ];
$annonceCollecte -> raisonSociale = $ann [ 'raisonSociale' ];
$annonceCollecte -> adresse = $ann [ 'adresse' ];
$annonceCollecte -> codePostal = $ann [ 'codePostal' ];
$annonceCollecte -> ville = $ann [ 'ville' ];
$annonceCollecte -> dateJugement = $ann [ 'dateJugement' ];
2011-08-10 12:16:03 +00:00
//@todo : Les libellées ne sont pas présent LibEven
2010-11-17 16:52:52 +00:00
$tabEven = array ();
2011-08-10 12:16:03 +00:00
$annonceEvenement = new AnnonceEvenement ();
$annonceEvenement -> CodeEven = $ann [ 'typeEven' ];
$annonceEvenement -> LibEven = '' ;
$tabEven [] = $annonceEvenement ;
if ( ! empty ( $ann [ 'strEven' ])){
foreach ( explode ( ';' , $ann [ 'strEven' ]) as $code )
{
$annonceEvenement = new AnnonceEvenement ();
$annonceEvenement -> CodeEven = $code ;
$annonceEvenement -> LibEven = '' ;
$tabEven [] = $annonceEvenement ;
}
2010-11-17 16:52:52 +00:00
}
2011-08-10 12:16:03 +00:00
2010-11-17 16:52:52 +00:00
$annonceCollecte -> even = $tabEven ;
$annonceCollecte -> dateSource = $ann [ 'dateSource' ];
$annonceCollecte -> dateCessationPaiement = $ann [ 'dateCessationPaiement' ];
$annonceCollecte -> dateEffetFinP = $ann [ 'dateEffetFinP' ];
$annonceCollecte -> tribunal = $ann [ 'tribunal' ];
$annonceCollecte -> numero = $ann [ 'numero' ];
$annonceCollecte -> montant = $ann [ 'montant' ];
$annonceCollecte -> actionsNb = $ann [ 'actionsNb' ];
$annonceCollecte -> inter1type = $ann [ 'inter1type' ];
$annonceCollecte -> inter1id = $ann [ 'inter1id' ];
$annonceCollecte -> inter1nom = $ann [ 'inter1nom' ];
$annonceCollecte -> inter2type = $ann [ 'inter2type' ];
$annonceCollecte -> inter2id = $ann [ 'inter2id' ];
$annonceCollecte -> inter2nom = $ann [ 'inter2nom' ];
$annonceCollecte -> inter3type = $ann [ 'inter3type' ];
$annonceCollecte -> inter3id = $ann [ 'inter3id' ];
$annonceCollecte -> inter3nom = $ann [ 'inter3nom' ];
$annonceCollecte -> complement = $ann [ 'complement' ];
$annonceCollecte -> nouvActivite = $ann [ 'nouvActivite' ];
$annonceCollecte -> nouvDir = $ann [ 'nouvDir' ];
$annonceCollecte -> nouvAdr = $ann [ 'nouvAdr' ];
$annonceCollecte -> nouvFJ = $ann [ 'nouvFJ' ];
$annonceCollecte -> source = $ann [ 'source' ];
debugLog ( 'I' , " Lecture de l'annonce collectée n° $idAnn ( $siret ) : " . $ann [ 'raisonSociale' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
}
else
{
$error -> errnum = 745741 ;
$error -> errmsg = 'Selection impossible' ;
}
}
$output = new AnnonceCollecteReturn ();
$output -> error = $error ;
$output -> result = $annonceCollecte ;
return $output ;
}
2010-11-15 16:28:25 +00:00
2010-11-18 17:11:34 +00:00
/**
* getDevises
* @ param string $codeIsoDevise
* @ return DevisesReturn
*/
public function getDevises ( $codeIsoDevise = '' )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-18 17:11:34 +00:00
//Initialisation
$error = new ErrorType ();
if ( empty ( $codeIsoDevise )) $codeIsoDevise = '' ;
debugLog ( 'I' , " Liste des devises ou devise $codeIsoDevise demandée " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-01-25 16:32:49 +00:00
$iInsee = new MInsee ();
$tabTmp = $iInsee -> getDevises ( $codeIsoDevise );
2010-11-18 17:11:34 +00:00
$tabRet = array ();
2011-01-25 16:32:49 +00:00
foreach ( $tabTmp as $i => $dev )
2010-11-18 17:11:34 +00:00
{
2011-01-25 16:32:49 +00:00
if ( $i != '' ){
$devise = new Devise ();
$devise -> devIso = $i ;
$devise -> devNom = $dev ;
$tabRet [] = $devise ;
}
2010-11-18 17:11:34 +00:00
}
$output = new DevisesReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
2010-11-18 16:42:01 +00:00
2010-11-18 17:19:25 +00:00
/**
* Retourne la liste des codes devises , libellés , date et valeur
* ( toutes les devises ou une seule )
* @ param string $devise Devise sur 3 lettres ( facultatif )
* @ return DevisesCoursReturn
*/
public function getDeviseCours ( $devise = false )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-18 17:19:25 +00:00
//Initialisation
$error = new ErrorType ();
$iDb = new WDB ( 'sdv1' );
if ( $devise ) $strDevise = " AND c.devise=' $devise ' " ;
else $strDevise = '' ;
$tabRet = array ();
$res = $iDb -> select ( 'devise_cours c, devise_liste l' , 'c.devise, l.devNom, max(c.date) as dateChange, c.valeur' , " c.devise=l.devIso $strDevise GROUP BY c.devise ORDER BY c.devise ASC " , false , MYSQL_ASSOC );
foreach ( $res as $tabDev )
{
$devise = new DevisesCours ();
$devise -> codeDevise = $tabDev [ 'devise' ];
$devise -> nomDevise = $tabDev [ 'devNom' ];
$devise -> dateChange = $tabDev [ 'dateChange' ];
$devise -> valeurDevise = $tabDev [ 'valeur' ];
$tabRet [] = $devise ;
}
$output = new DevisesCoursReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
2010-11-18 16:42:01 +00:00
2010-11-24 15:43:20 +00:00
/**
2010-12-14 10:23:40 +00:00
* getMarques
2010-11-24 15:43:20 +00:00
* @ param string $siren
* @ param int $idDepot
2010-12-14 10:23:40 +00:00
* @ return MarquesReturn
2010-11-24 15:43:20 +00:00
*/
2010-12-14 10:23:40 +00:00
public function getMarques ( $siren , $idDepot = 0 )
{
$this -> authenticate ();
2011-01-06 16:26:46 +00:00
$this -> permission ( 'marques' );
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Liste des marques déposées pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-12-14 10:23:40 +00:00
if ( empty ( $idDepot )) $idDepot = 0 ;
$error = new ErrorType ();
$marques = array ();
2010-11-29 16:12:32 +00:00
require_once 'Metier/partenaires/classMMarques.php' ;
2010-12-14 10:23:40 +00:00
$iMarque = new MMarques ();
$ret = $iMarque -> getMarques ( $siren , $idDepot );
2011-02-01 11:08:50 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( __FUNCTION__ . ' : ' .
print_r ( $ret , 1 ));
foreach ( $ret as $item ) {
if ( trim ( $item [ 'imgLink' ]) <> '' ) $idLien = $item [ 'numeroMarque' ];
else $idLien = '' ;
if ( $idDepot == $item [ 'numeroMarque' ]) {
2010-12-14 10:23:40 +00:00
$marque = new Marque ();
2011-02-01 11:08:50 +00:00
$marque -> Marques = $item [ 'nomMarque' ];
$marque -> Date = $item [ 'dateDepot' ];
$marque -> Depot = $item [ 'numeroMarque' ];
2010-12-14 10:23:40 +00:00
$marque -> IdLien = $idLien ;
2011-02-01 11:08:50 +00:00
$marque -> UrlLien = $item [ 'UrlLien' ];
$marque -> PdfDispo = $item [ 'pdfLink' ];
$marque -> Classes = $item [ 'classesMarque' ];
$marque -> Perimetre = $item [ 'periMarque' ];
$marque -> DateExpir = $item [ 'dateExpir' ];
2010-12-14 10:23:40 +00:00
$marques = array ();
$marques [] = $marque ;
break ;
} else {
$marque = new Marque ();
2011-02-01 11:08:50 +00:00
$marque -> Marques = $item [ 'nomMarque' ];
$marque -> Date = $item [ 'dateDepot' ];
$marque -> Depot = $item [ 'numeroMarque' ];
2010-12-14 10:23:40 +00:00
$marque -> IdLien = $idLien ;
2011-02-01 11:08:50 +00:00
$marque -> UrlLien = $item [ 'UrlLien' ];
$marque -> PdfDispo = $item [ 'pdfLink' ];
2010-12-14 10:23:40 +00:00
$marques [] = $marque ;
2010-11-23 10:24:44 +00:00
}
}
2011-02-01 11:08:50 +00:00
Zend_Registry :: get ( 'WsLogger' ) -> info ( __FUNCTION__ . ' : ' .
print_r ( $marques , 1 ));
2011-01-13 16:52:27 +00:00
$this -> wsLog ( 'marques' , $siren );
2010-12-14 10:23:40 +00:00
$output = new MarquesReturn ();
$output -> error = $error ;
$output -> result = $marques ;
return $output ;
2010-11-23 10:24:44 +00:00
}
/**
* Enter description here ...
2010-12-06 17:01:21 +00:00
* @ param string $siren
* @ param string $piece
* @ param string $type
* @ param integer $visu
* @ param integer $courrier
* @ param string $ref
* @ return PieceReturn
2010-11-23 10:24:44 +00:00
*/
2010-12-06 17:01:21 +00:00
public function getPiece ( $siren , $piece = 'kbis' , $type = '' , $visu = 1 , $courrier = 0 , $ref = '' )
{
$this -> authenticate ();
2011-01-06 16:26:46 +00:00
$this -> permission ( 'kbis' );
2010-12-06 17:01:21 +00:00
set_time_limit ( 400 );
if ( empty ( $piece )) $piece = 'kbis' ;
if ( empty ( $type )) $type = '' ;
if ( empty ( $visu )) $visu = 1 ;
if ( empty ( $courrier )) $courrier = 1 ;
if ( empty ( $ref )) $ref = '' ;
$error = new ErrorType ();
2011-02-17 17:28:52 +00:00
$erreur = false ;
$kbisLocalPDF = DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ;
if ( file_exists ( $kbisLocalPDF )
&& date ( 'Ymd' , filemtime ( $kbisLocalPDF )) == date ( 'Ymd' )
&& filesize ( $kbisLocalPDF ) > 0 ) {
$size = filesize ( $kbisLocalPDF );
$erreur = false ;
$tabNom = array ();
$ficDist = '' ;
$cache = 1 ;
2010-12-06 17:01:21 +00:00
} else {
2011-04-27 08:32:00 +00:00
exec ( " php " . APPLICATION_PATH . " /../batch/getPieces.php $siren $piece > /dev/null & " );
2010-12-06 17:01:21 +00:00
$ficDist = '' ;
$size = $cache = 0 ;
}
2011-02-17 17:28:52 +00:00
// On supprimer l'ancien kbis si trop vieux ou vide
if ( date ( 'Ymd' , filemtime ( $kbisLocalPDF )) <> date ( 'Ymd' )
|| filesize ( $kbisLocalPDF ) == 0 ) {
unlink ( $kbisLocalPDF );
2010-12-06 17:01:21 +00:00
}
$result = new PieceResult ();
$result -> Siren = $siren ;
2011-02-17 17:28:52 +00:00
//@todo : Envoyer vers controlleur
2010-12-07 09:49:01 +00:00
$result -> Url = $hostName . '/data/kbis/' . $piece . '-' . $siren . '.pdf' ;
2011-02-17 17:28:52 +00:00
2010-12-06 17:01:21 +00:00
$result -> Taille = $size ;
$result -> Cache = $cache ;
$result -> fichier = $ficDist ;
2011-01-13 16:52:27 +00:00
$this -> wsLog ( 'kbis' , $siren , " $cache / $visu / $courrier / $type / $ref " );
2010-12-06 17:01:21 +00:00
$output = new PieceReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2011-03-24 15:53:58 +00:00
/**
* Enregistrement de document actes ou status d ' association
* @ param string $siren Numéro Siren
* @ param string $waldec Numéro waldec
* @ param string $type Type d ' acte
* @ param string $libelle Libellé de l ' acte
* @ param string $date Date des l ' acte au format
* @ param int $nbPages Nombre de pages dans le fichier
* return boolean
*/
public function setActeAsso ( $siren , $waldec , $type , $libelle , $date , $nbPages )
{
$this -> authenticate ();
if ( $this -> tabInfoUser [ 'idClient' ] != 1 ) {
$this -> sendError ( '0902' );
}
( $type == 'ST' ) ? $type_acte = 'ST' : $type_acte = '' ;
$data = array (
'siren' => $siren ,
'waldec' => waldec ,
'pdfLink' => '' ,
'pdfSize' => '' ,
'pdfVer' => '' ,
'pdfPage' => '' ,
'date_acte' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , $date ),
'type_acte' => $type_acte ,
'type_acte_libelle' => $libelle ,
'nbpages_acte' => $nbPages ,
);
try {
$db = Zend_Db :: factory ( $this -> dbConfig -> Webservice );
Zend_Db_Table_Abstract :: setDefaultAdapter ( $db );
$doc = new Application_Model_AssoActes ();
$doc_id = $doc -> insert ( $data );
} catch ( Zend_Exception $e ) {
Zend_Registry :: get ( 'WsLogger' )
-> err ( __FUNCTION__ . ' - ' . $e -> getMessage ());
}
if ( $commande_id )
{
return true ;
}
return false ;
}
2010-11-23 10:24:44 +00:00
2011-02-01 11:08:50 +00:00
/**
* Commande de statut association
* @ param InfoCmdAsso $infosCommande
2011-02-01 17:27:03 +00:00
* @ param InfosDemandeur $infosDemandeur
2011-02-01 11:08:50 +00:00
* @ return CmdAssoReturn
*/
2011-06-29 15:24:43 +00:00
public function setCmdAsso ( $infosCommande , $infosDemandeur )
2010-11-24 14:22:44 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2011-01-06 16:26:46 +00:00
$this -> permission ( 'actes' );
2010-11-24 14:22:44 +00:00
//Initialisation
$error = new ErrorType ();
2010-11-23 10:24:44 +00:00
2010-11-24 14:22:44 +00:00
$iDb = new WDB ();
2010-11-23 10:24:44 +00:00
2011-06-29 15:24:43 +00:00
$siren = $infosCommande -> siren ;
$idEntreprise = intval ( $infosCommande -> idEntreprise );
$assoNom = $infosCommande -> raisonSociale ;
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " commandeAsso pour $assoNom ( $siren ) début " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-01-25 16:32:49 +00:00
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteLight ( $siren , 0 , $idEntreprise );
2010-11-24 14:22:44 +00:00
$assoSigle = $tabIdentite [ 'Sigle' ];
$assoAdresse = $tabIdentite [ 'Adresse' ] . EOL . $tabIdentite [ 'Adresse2' ];
$assoCP = $tabIdentite [ 'CP' ];
$assoVille = $tabIdentite [ 'Ville' ];
2011-02-01 17:27:03 +00:00
$mail = trim ( $infosDemandeur -> email );
2010-11-29 10:45:03 +00:00
if ( $mail == '' ) $mail = $this -> tabInfoUser [ 'email' ];
2010-11-24 14:22:44 +00:00
$tabInsert = array (
2010-11-29 10:45:03 +00:00
'idUser' => $this -> tabInfoUser [ 'id' ],
2010-11-24 14:22:44 +00:00
'source' => 'asso' ,
2010-11-29 10:45:03 +00:00
'login' => $this -> tabInfoUser [ 'login' ],
2010-11-24 14:22:44 +00:00
'emailCommande' => $mail ,
'siren' => $siren ,
2011-02-01 17:27:03 +00:00
'refUtilisateur' => $infosDemandeur -> reference ,
'refDocument' => serialize ( $infosDemandeur ),
2011-06-29 15:24:43 +00:00
'refCommande' => serialize ( $infosCommande ),
2010-11-24 14:22:44 +00:00
'dateCommande' => DATETIME ,
);
2010-11-23 10:24:44 +00:00
$url = 'http://d2g.refasso.com/Dev2Go.web' ;
$referer = '' ; // http://d2g.refasso.com/dev2go.web?anchor=dem_statuts_02
$cookie = '' ;
2010-11-24 14:22:44 +00:00
$post = array (
'mode' => 20 ,
'lBlockID' => 445031 ,
'sInputNames' => '' ,
'lFormSubAction' => 100 ,
'sLinkTo' => 'dem_statuts_03' ,
'iDune_DateDemande_input' => str_replace ( '/' , '%2F' , date ( 'd/m/Y' )),
'iDune_TitreAsso_input' => urlencode ( $assoNom ),
'iDune_SigleAsso_input' => urlencode ( $assoSigle ),
'iDune_AdresseAsso_input' => urlencode ( $assoAdresse ),
'iDune_CpAsso_input' => urlencode ( $assoCP ),
'iDune_VilleAsso_input' => urlencode ( $assoVille ),
'iDune_TelAsso_input' => '' ,
'iDune_FaxAsso_input' => '' ,
'iDune_EmailAsso_input' => '' ,
'iDune_DateCreaAsso_input' => '' ,
'iDune_DateDerDeclaAsso_input' => '' ,
'iDune_NomDem_input' => 'SCORES+ET+DECISIONS' ,
'iDune_PrenomDem_input' => 'Yoann+LE+NAOUR' ,
'iDune_AdresseDem_input' => '19+rue+de+Clairefontaine' ,
'iDune_CpDem_input' => 78120 ,
'iDune_VilleDem_input' => 'RAMBOUILLET' ,
'iDune_TelDem_input' => '0134573953' ,
'iDune_EmailDem_input' => 'asso%40scores-decisions.com' ,
'iDune_CGAccepte_input' => 'o' ,
'iDune_Statut_input' => 'n' ,
'iDune_Archive_input' => 'n' ,
'x' => 48 ,
'y' => 8 ,
);
2010-11-23 10:24:44 +00:00
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $post , $referer , false , '' , '' , 7 );
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$body = $page [ 'body' ];
$fp =@ fopen ( " /tmp/asso- $siren .html " , " a " );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
2010-11-24 14:22:44 +00:00
if ( preg_match ( '/Votre commande est enregistr/i' , $body ))
{
2010-11-29 16:12:32 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'asso@scores-decisions.com' ,
2010-11-24 14:22:44 +00:00
" Commande de statuts association pour $assoNom ( $siren ) " ,
2011-06-29 15:24:43 +00:00
" Association : " . EOL . print_r ( $infosCommande , true ) . EOL . EOL .
2011-02-01 17:27:03 +00:00
" Demandeur: " . EOL . print_r ( $infosDemandeur , true ) . EOL . EOL .
2010-11-24 14:22:44 +00:00
" Réponse RefAsso en $duree secondes : " . EOL . print_r ( $page , true )
);
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2010-11-24 14:22:44 +00:00
$ret = $iDbCrm -> insert ( 'commandes' , $tabInsert , true );
2011-02-01 11:08:50 +00:00
$result = new CmdAssoDetail ();
2010-11-24 14:22:44 +00:00
$result -> siren = $siren ;
$result -> emailCommande = $mail ;
$result -> dateCommande = DATETIME ;
$result -> refCmd = 'i' . $ret ;
2010-11-23 10:24:44 +00:00
@ sendMail ( 'production@scores-decisions.com' , $mail , " Votre commande de statuts association sur $assoNom ( $siren ) " , " Votre demande de statuts sur l'association $assoNom a été prise en compte sous la référence i $ret - " . DATETIME );
2011-01-13 16:52:27 +00:00
$this -> wsLog ( 'commandeAsso' , $siren , 'i' . $ret . '-' . DATETIME );
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " commandeAsso pour $assoNom ( $siren ) fin " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
} else {
2010-11-29 16:12:32 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'asso@scores-decisions.com' ,
2011-06-29 15:24:43 +00:00
" ERREUR lors de lommande de statuts association pour $assoNom ( $siren ) " , " Association : " . EOL . print_r ( $infosCommande , true ) . EOL . EOL .
2011-02-01 17:27:03 +00:00
" Demandeur: " . EOL . print_r ( $infosDemandeur , true ) . EOL . EOL .
2010-11-24 14:22:44 +00:00
" Réponse RefAsso en $duree secondes : " . EOL . print_r ( $page , true ));
2011-02-01 11:08:50 +00:00
$error -> errmsg = 'ERREUR' ;
$error -> errnum = 1 ;
2010-11-23 10:24:44 +00:00
debugLog ( 'E' , " commandeAsso pour $assoNom ( $siren ) fin " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
2011-02-01 11:08:50 +00:00
$output = new CmdAssoReturn ();
2010-11-24 14:22:44 +00:00
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2011-02-01 11:08:50 +00:00
/**
* Renvoi des informations sur une commande association
* @ param string $reference
* @ return CmdAssoReturn
*/
public function getCmdAsso ( $reference ){}
2010-11-24 13:53:15 +00:00
/**
* Commande d 'une enquête sur une entreprise en France ou à l' Internationale
2011-02-01 17:27:03 +00:00
* @ param InfosCmdEnquete $infosCommande
* @ param InfosDemandeur $infosDemandeur
* @ return CmdEnqueteReturn
2010-11-23 10:24:44 +00:00
**/
2011-02-01 17:27:03 +00:00
public function setCmdEnquete ( $infosCommande , $infosDemandeur )
2010-11-24 13:53:15 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2011-01-06 16:26:46 +00:00
$this -> permission ( 'enquetec' );
2010-11-24 13:53:15 +00:00
//Initialisation
$error = new ErrorType ();
2011-02-01 17:27:03 +00:00
$siren = $infosCommande -> siren ;
$mail = trim ( $infosDemandeur -> email );
2010-11-24 13:53:15 +00:00
if ( $mail == '' ) $mail = $this -> tabInfoUser [ 'email' ];
$tabInsert = array (
'idUser' => $this -> tabInfoUser [ 'id' ],
'source' => 'intersud' , // 'greffes', 'asso', 'graydon'
'login' => $this -> tabInfoUser [ 'login' ],
'emailCommande' => $mail ,
'siren' => $siren ,
2011-02-01 17:27:03 +00:00
'refDocument' => serialize ( $infosDemandeur ),
'refCommande' => serialize ( $infosCommande ),
2010-11-24 13:53:15 +00:00
'dateCommande' => DATETIME ,
);
2011-06-10 10:08:21 +00:00
debugLog ( 'I' , " Intersud, début sur $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-02-01 17:27:03 +00:00
$messageInfo = print_r ( $infosCommande , 1 ) . EOL . print_r ( $infosDemandeur , 1 ) . EOL ;
2010-11-23 10:24:44 +00:00
2010-11-24 13:53:15 +00:00
$idClient = $this -> tabInfoUser [ 'idClient' ];
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2010-11-24 13:53:15 +00:00
$rep = $iDbCrm -> select ( 'clients' , ' nom, racineLogin, InterSudLogin, InterSudPass' , " id=' $idClient ' " , false , MYSQL_ASSOC );
$login = trim ( $rep [ 0 ][ 'InterSudLogin' ]);
$pass = trim ( $rep [ 0 ][ 'InterSudPass' ]);
$nomClient = trim ( strtoupper ( $rep [ 0 ][ 'nom' ]));
2011-02-01 17:27:03 +00:00
$strInfoCommande = " NOM et Prénom du client demandeur : " . $infoDemandeur -> nom . EOL ;
2010-11-23 10:24:44 +00:00
$strInfoCommande .= " Email du client demandeur : $mail " . EOL ;
2011-02-01 17:27:03 +00:00
$strInfoCommande .= " Tel/Fax du demandeur : " . $infosDemandeur -> tel . ' / ' . $infosDemandeur -> fax . EOL ;
$strInfoCommande .= " Profil du demandeur : " . trim ( $infosDemandeur -> service ) . EOL ;
2010-11-23 10:24:44 +00:00
$typeEnqLog = 'enqueteDemNF' ;
2011-06-10 10:08:21 +00:00
if ( $login == '' || $pass == '' ) {
2010-11-23 10:24:44 +00:00
/** Il ne s'agit pas d'un client final, on anonymise la commande **/
2011-02-01 17:27:03 +00:00
$login = 'YLENA' ; // Demandes en test
$pass = 'WYLFE' ;
$nomClient = $strInfoCommande = '' ;
$typeEnqLog = 'enqueteDem' ;
2010-11-23 10:24:44 +00:00
/* ENQUETES EN PROD
$login = 'FACTURE' ;
$pass = 'AWKROM' ;
*/
}
$url = 'http://www.intersud.fr/espace_client/espace_client.php' ;
2010-11-24 13:53:15 +00:00
$cookie = $referer = '' ;
2011-02-01 17:27:03 +00:00
$tabPost = array ( 'login' => $login , 'pwd' => $pass );
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $tabPost , $referer , false , '' , '' , 7 );
2011-06-10 10:08:21 +00:00
if ( $page [ 'code' ] <> 200 ) {
$tabRet = array ();
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ATTENTION : Commande d'enquete sur $siren " , " Connexion impossible à la plateforme Intersud " . EOL . $strInfoCommande );
// wsLog($typeEnqLog, $siren, 'i'.$ret.'-'.DATETIME);
//@todo
return array ( 'error' => array ( 'errnum' => 4563456 , 'errmsg' => 'Connexion impossible à la plateforme d\'enquetes' ), 'results' => $tabRet );
}
2011-02-01 17:27:03 +00:00
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
$cookie = $page [ 'header' ][ 'Set-Cookie' ];
2011-06-10 10:08:21 +00:00
/** Connexion à l ' Extranet Intersud
**/
2011-02-01 17:27:03 +00:00
$url = 'http://intersud.fr/espace_client/demande_enquete.php' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' , 7 );
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
2011-06-10 10:08:21 +00:00
2010-11-24 13:53:15 +00:00
$fp =@ fopen ( LOG_PATH . " intersud.log " , " a " );
2010-11-23 10:24:44 +00:00
@ fwrite ( $fp , print_r ( $page , true ));
@ fclose ( $fp );
$tabInterSud = array ();
if ( preg_match_all ( '/<input(?:.*)name="(.*)"(?:.*)value="(.*)"/Uim' , $body , $matches )) {
foreach ( $matches [ 1 ] as $i => $field ) {
$tmp = explode ( '"' , $matches [ 2 ][ $i ]);
$tabInterSud [ $field ] = $tmp [ 0 ];
}
}
if ( preg_match_all ( '/<input(?:.*)value="(.*)"(?:.*)name="(.*)"/Uim' , $body , $matches )) {
foreach ( $matches [ 2 ] as $i => $field ) {
$tmp = explode ( '"' , $matches [ 1 ][ $i ]);
$tabInterSud [ $field ] = $tmp [ 0 ];
}
}
2011-06-10 10:08:21 +00:00
$ref_exp = $tabInterSud [ 'ref_exp' ];
$email_exp = $tabInterSud [ 'email_exp' ];
$tel_exp = $tabInterSud [ 'tel_exp' ];
debugLog ( 'I' , " Intersud, formulaire enquête ref $ref_exp , $email_exp , $tel_exp " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-24 13:53:15 +00:00
$fp =@ fopen ( LOG_PATH . " intersud.log " , " a " );
2010-11-23 10:24:44 +00:00
@ fwrite ( $fp , print_r ( $matches , true ));
@ fwrite ( $fp , print_r ( $tabInterSud , true ));
@ fclose ( $fp );
2011-06-10 10:08:21 +00:00
/** Insertion de la commande en base
**/
2010-11-24 13:53:15 +00:00
$ret = $iDbCrm -> insert ( 'commandes' , $tabInsert , true );
$comment = " Référence de la commande chez Scores et Décisions : i $ret - " .
DATETIME . " \n " .
" Date et heure de la commande : " . date ( 'd/m/Y - H:i' ) . " \n " .
" Origine de la commande : $nomClient " .
" $strInfoCommande " . " \n \n " .
2010-11-23 10:24:44 +00:00
2011-02-01 17:27:03 +00:00
" CA : " . $infosCommande -> PrecisionsMontantCA . " \n " .
" Motif de la demande : " . trim ( $infosCommande -> PrecisionsMotif . ' ' . $infosCommande -> PrecisionsAutre ) . " \n " .
" Type de la demande : " . $infosCommande -> PrecisionsType . " \n " .
" Anciennete de la relation : " . $infosCommande -> Anciennete . ' ' . $infosCommande -> AncienneteDuree . " \n " .
" Observations : " . $infosCommande -> Observation . EOL ;
2010-11-23 10:24:44 +00:00
2011-02-01 17:27:03 +00:00
if ( $infosCommande -> ImpayeesChoix <> 'non' )
$comment .= " Impayé(s) : " . $infosCommande -> ImpayeesNombre . " impayé(s) pour un montant de " . $infosCommande -> ImpayeesMontant . " en date du " . $infosCommande -> ImpayeesDate . EOL ;
2010-11-23 10:24:44 +00:00
2011-02-01 17:27:03 +00:00
if ( $infosCommande -> RetardPaiementChoix <> 'non' )
$comment .= " Retard(s) de paiement : " . $infosCommande -> RetardPaiementNombre . " retard(s) pour un montant de " . $infosCommande -> RetardPaiementMontant . " en date du " . $infosCommande -> RetardPaiementDate . EOL ;
2010-11-23 10:24:44 +00:00
2011-02-01 17:27:03 +00:00
if ( $infosCommande -> LitigeChoix <> 'non' )
$comment .= " Présence de litige(s) : " . $infosCommande -> LitigePrecisions . EOL ;
2010-11-23 10:24:44 +00:00
$enqType = 0 ;
$enqDelai = 7 ;
2011-02-01 17:27:03 +00:00
switch ( strtolower ( $infosCommande -> Type )) {
2010-11-23 10:24:44 +00:00
case 'premier' : $enqType = 0 ; $enqDelai = 6 ; break ;
case 'gold' : $enqType = 1 ; break ;
case 'distrimat' : $enqType = 2 ; break ;
case 'star' : $enqType = 3 ; break ;
case 'avis_bancaire' : $enqType = 4 ; break ;
case 'autre' : $enqType = 5 ; break ;
}
/** Ajout du RIB si communiqué **/
2011-02-01 17:27:03 +00:00
if ( @ trim ( implode ( ' ' , $infosCommande -> RIB )) <> '' )
2010-11-24 13:53:15 +00:00
$iDbCrm -> insert ( 'banques' , array (
'siren' => $siren ,
'libBanqueGuichet' => '' ,
'precis' => 1 ,
2011-02-01 17:27:03 +00:00
'codeBanque' => $infosCommande -> RIB -> banque ,
'codeGuichet' => $infosCommande -> RIB -> guichet ,
'numCompte' => $infosCommande -> RIB -> compte . $infosCommande -> RIB -> cle ,
2010-11-24 13:53:15 +00:00
'dateSource' => DATETIME ,
), true );
2011-01-25 16:32:49 +00:00
2011-06-10 10:08:21 +00:00
/** Remplissage du formulaire d'enquête pour soumission à Intersud **/
2011-01-25 16:32:49 +00:00
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteLight ( $siren );
2010-11-24 13:53:15 +00:00
$tabPost = array (
'soc' => $tabIdentite [ 'Nom' ],
'cible_enk' => 9 , // 9
'siret' => $siren ,
'acti' => '' ,
'soc_exp' => $tabInterSud [ 'soc_exp' ],
'type_enk' => $enqType , // 0=Premier, 1=Gold, 2=Distrimat, 3=Star, 4=Avis bancaire, 5=Autre
'nom_diri' => '' ,
'adr' => $tabIdentite [ 'Adresse' ],
'ref_exp' => $tabInterSud [ 'ref_exp' ],
'autre_type_enk' => '' , // Texte libre
'adr2' => $tabIdentite [ 'Adresse2' ],
'delai_enk' => $enqDelai , // 6=24h, 7=72h, 8=+de5jours
'ville' => $tabIdentite [ 'Ville' ],
'cp' => $tabIdentite [ 'CP' ],
'pays' => '' , // International ?
'nom_exp' => $tabInterSud [ 'nom_exp' ],
'tel' => $tabIdentite [ 'Tel' ],
2011-02-01 17:27:03 +00:00
'port' => $infosCommande -> AutreTel ,
2010-11-24 13:53:15 +00:00
'tel_exp' => $tabInterSud [ 'tel_exp' ],
2011-02-01 17:27:03 +00:00
'bank' => trim ( implode ( ' ' , $infosCommande -> RIB )),
2010-11-24 13:53:15 +00:00
'int_enk' => $tabInterSud [ 'int_enk' ], // International ?
2011-02-01 17:27:03 +00:00
'encours' => $infosCommande -> Encours ,
'nb_ech' => $infosCommande -> NbEcheances ,
2010-11-24 13:53:15 +00:00
'delai2_enk' => $tabInterSud [ 'delai2_enk' ], // International ?
'email_exp' => $tabInterSud [ 'email_exp' ],
'cred' => '' ,
'comment' => urlencode ( $comment ),
2011-06-10 10:08:21 +00:00
'val_ret' => $tabInterSud [ 'val_ret' ],
2010-11-24 13:53:15 +00:00
);
2010-11-23 10:24:44 +00:00
$url = 'http://intersud.fr/espace_client/demande_enquete.php' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $tabPost , $referer , false , '' , '' , 7 );
2011-06-10 10:08:21 +00:00
if ( $page [ 'code' ] <> 200 ) {
$tabRet = array ();
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ATTENTION : Commande d'enquete sur $siren " , " Validation impossible du formulaire d'enquête Intersud " . EOL . $strInfoCommande );
//@todo
return array ( 'error' => array ( 'errnum' => 456345 , 'errmsg' => 'Connexion impossible à la plateforme d\'enquetes 3' ), 'results' => $tabRet );
}
2010-11-23 10:24:44 +00:00
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
2011-02-01 17:27:03 +00:00
$result = new CmdEnquete ();
2010-11-24 13:53:15 +00:00
$result -> siren = $siren ;
$result -> emailCommande = $mail ;
$result -> dateCommande = DATETIME ;
$result -> refCmd = 'i' . $ret ;
2011-06-10 10:08:21 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " Commande d'enquete sur $siren " , $comment . EOL . EOL . '---------------------------------' . EOL . $messageInfo . EOL . EOL . '---------------------------------' . EOL . $body );
2010-11-23 10:24:44 +00:00
@ sendMail ( 'production@scores-decisions.com' , $mail , " Votre demande d'enquete sur " . $tabIdentite [ 'Nom' ] . " ( $siren ) " , " Votre demande d'enquête sur la société " . $tabIdentite [ 'Nom' ] . " a été prise en compte sous la référence i $ret - " . DATETIME );
2011-01-13 16:52:27 +00:00
$this -> wsLog ( $typeEnqLog , $siren , 'i' . $ret . '-' . DATETIME );
2010-11-24 13:53:15 +00:00
2011-06-10 10:08:21 +00:00
/** Gestion de la déconnexion **/
$url = 'http://intersud.fr/espace_client/index.php?code_ret=9' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' , 7 );
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$ret = $iDbCrm -> update ( 'commandes' , array ( 'dureeCommande' => round ( $duree , 3 )), " idCommande= $ret " );
2011-02-01 17:27:03 +00:00
$output = new CmdEnqueteReturn ();
2010-11-24 13:53:15 +00:00
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-23 10:42:33 +00:00
/**
* Récupération d ' un kbis
* @ param string $siren
* @ param int $visu
* @ param int $courrier
* @ param string $mail
* @ param string $ref
2010-12-06 17:01:21 +00:00
* @ return PieceReturn
2010-11-23 10:42:33 +00:00
*/
public function getKbis ( $siren , $visu = 1 , $courrier = 0 , $mail = '' , $ref = '' )
{
2010-11-23 10:24:44 +00:00
return $this -> getPiece ( $siren , 'kbis' , '' , $visu , $courrier , $ref );
}
2010-11-23 16:44:09 +00:00
/**
* Récupère les informations du profil connecté
* @ param string $login
* @ param int $idClient
* @ return ListeUtilisateursReturn
*/
public function getListeUtilisateurs ( $login , $idClient =- 1 )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 10:24:44 +00:00
2010-11-23 16:44:09 +00:00
//Initialisation
if ( empty ( $idClient )) $idClient = - 1 ;
$error = new ErrorType ();
$tabRet = array ();
2010-11-23 10:24:44 +00:00
2010-11-23 16:44:09 +00:00
if ( $this -> tabInfoUser [ 'profil' ] <> 'Administrateur' &&
$this -> tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' )
{
$error -> errnum = 1 ;
$error -> errmsg = 'Profil non administrateur' ;
2011-01-18 16:09:33 +00:00
} else {
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2011-01-18 16:09:33 +00:00
if ( $idClient ==- 1 ){
$rep = $iDbCrm -> select ( 'utilisateurs' , 'idClient' , " login=' $login ' " );
$idClient = $rep [ 0 ][ 0 ];
}
if ( $idClient ==- 1 ){
2010-11-23 16:44:09 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'idClient=0' ;
2011-01-18 16:09:33 +00:00
} else {
2011-08-24 10:30:21 +00:00
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id, idClient, login, email, actif, nom, prenom, referenceParDefaut' , " idClient=' $idClient ' AND deleted=0 ORDER BY login ASC " , false , MYSQL_ASSOC );
2011-01-18 16:09:33 +00:00
foreach ( $rep as $uti ){
2010-11-23 16:44:09 +00:00
$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 ;
2010-11-23 10:24:44 +00:00
}
2010-11-18 16:42:01 +00:00
2010-12-02 16:45:25 +00:00
/**
* Créations / 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' );
2011-08-24 10:30:21 +00:00
$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 );
2010-12-02 16:45:25 +00:00
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 ;
}
/**
* 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 ' un client
* @ param Client $infos
* @ param integer $idModele
* @ return ClientReturn
*/
public function setClient ( $infos , $idModele = null )
{
$this -> authenticate ();
$error = new ErrorType ();
$result = false ;
//Pas SuperAdministrateur
2011-01-13 13:54:41 +00:00
if ( $this -> tabInfoUser [ 'profil' ] != 'SuperAdministrateur' ){
2010-12-02 16:45:25 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Profil insuffisant pour cette méthode' ;
2011-01-13 13:54:41 +00:00
} else {
2010-12-02 16:45:25 +00:00
$tabInfos = array ();
$tabInfos [ 'nom' ] = $infos -> nom ;
$tabInfos [ 'actif' ] = ( $infos -> actif == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'test' ] = ( $infos -> test == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'racineLogin' ] = $infos -> racineLogin ;
$tabInfos [ 'siren' ] = ( int ) $infos -> siren ;
$tabInfos [ 'nic' ] = ( int ) $infos -> nic ;
$tabInfos [ 'tva' ] = $infos -> tva ;
$tabInfos [ 'idClientFacture' ] = $infos -> idClientFacture ;
if ( $infos -> editerFacture == 'Non' ) {
$tabInfos [ 'editerFacture' ] = 'Non' ;
}
$tabInfos [ 'fact_detail' ] = ( $infos -> fact_detail == 'Oui' ) ? 'Oui' : 'Non' ;
2011-01-17 08:56:12 +00:00
$tabInfos [ 'fac_dest' ] = $infos -> fac_dest ;
$tabInfos [ 'fac_adr1' ] = $infos -> fac_adr1 ;
$tabInfos [ 'fac_adr2' ] = $infos -> fac_adr2 ;
$tabInfos [ 'fac_adr3' ] = $infos -> fac_adr3 ;
$tabInfos [ 'fac_email' ] = $infos -> fac_email ;
$tabInfos [ 'fac_tel' ] = $infos -> fac_tel ;
if ( in_array ( $infos -> fac_rib , array ( 'BPOSTALE' , 'CCOOP' , 'CDNORD' ))){
2010-12-02 16:45:25 +00:00
$tabInfos [ 'fact_rib' ] = $infos -> fact_rib ;
}
$tabInfos [ 'liv_dest' ] = $infos -> liv_dest ;
$tabInfos [ 'liv_adr1' ] = $infos -> liv_adr1 ;
$tabInfos [ 'liv_adr2' ] = $infos -> liv_adr2 ;
$tabInfos [ 'liv_adr3' ] = $infos -> liv_adr3 ;
$tabInfos [ 'liv_email' ] = $infos -> liv_email ;
$tabInfos [ 'liv_tel' ] = $infos -> liv_tel ;
2011-08-05 14:30:22 +00:00
$tabInfos [ 'droits' ] = strtolower ( $infos -> droits );
2010-12-02 16:45:25 +00:00
$tabInfos [ 'filtres_ip' ] = $infos -> filtres_ip ;
//$tabInfos['respComSD'] = $infos->respComSD;
if ( in_array ( $infos -> typeContrat , array ( 'Contrat' , 'Marché' ))){
$tabInfos [ 'typeContrat' ] = $infos -> typeContrat ;
}
if ( in_array ( $infos -> typeAcces , array ( 'userPassword' , 'userPasswordIP' , 'IP' ))){
$tabInfos [ 'typeAcces' ] = $infos -> typeAcces ;
}
if ( in_array ( $infos -> typeScore , array ( '20' , '100' ))){
2011-01-17 08:56:12 +00:00
$tabInfos [ 'typeScore' ] = $infos -> typeScore ;
2010-12-02 16:45:25 +00:00
}
if ( ! empty ( $timeout )){
$tabInfos [ 'timeout' ] = $infos -> timeout ;
}
$tabInfos [ 'accesPieces' ] = ( $infos -> accesPieces == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'accesKbis' ] = ( $infos -> accesKbis == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'accesInvestigations' ] = ( $infos -> accesInvestigations == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'accesInternationnal' ] = ( $infos -> accesInternationnal == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'accesEnquetes' ] = ( $infos -> accesEnquetes == 'Oui' ) ? 'Oui' : 'Non' ;
$tabInfos [ 'miseSousSurveillance' ] = ( $infos -> miseSousSurveillance == 'Oui' ) ? 'Oui' : 'Non' ;
if ( in_array ( $infos -> forfaitExtranetPeriode , array ( 'Mensuel' , 'Trimestriel' , 'Semestriel' , 'Annuel' ))){
$tabInfos [ 'forfaitExtranetPeriode' ] = $infos -> forfaitExtranetPeriode ;
}
$tabInfos [ 'forfaitExtranetMontant' ] = $infos -> forfaitExtranetMontant ;
if ( $infos -> reconductionAuto == 'Non' ) {
$tabInfos [ 'reconductionAuto' ] = 'Non' ;
}
$tabInfos [ 'remarque' ] = $infos -> remarque ;
$tabInfos [ 'forfaitPiecesNb' ] = $infos -> forfaitPiecesNb ;
$tabInfos [ 'forfaitPiecesMt' ] = $infos -> forfaitPiecesMt ;
$tabInfos [ 'forfaitPiecesDep' ] = $infos -> forfaitPiecesDep ;
$tabInfos [ 'forfaitInvestigNb' ] = $infos -> forfaitInvestigNb ;
$tabInfos [ 'forfaitInvestigMt' ] = $infos -> forfaitInvestigMt ;
$tabInfos [ 'forfaitInvestigDep' ] = $infos -> forfaitInvestigDep ;
$tabInfos [ 'tarifIndiscore' ] = $infos -> tarifIndiscore ;
$tabInfos [ 'InterSudLogin' ] = $infos -> InterSudLogin ;
$tabInfos [ 'InterSudPass' ] = $infos -> InterSudPass ;
$iDbCrm = new WDB ( 'sdv1' );
if ( empty ( $infos -> idClient )){
//Ajout
//$tabInfos['dateInsert'] = now();
2011-01-17 08:56:12 +00:00
$result = $iDbCrm -> insert ( 'clients' , $tabInfos , true );
2010-12-02 16:45:25 +00:00
} else {
//Modification
2011-01-17 10:44:18 +00:00
if ( $iDbCrm -> update ( 'clients' , $tabInfos , " id=' $infos->idClient ' " , true )){
2010-12-02 16:45:25 +00:00
$result = true ;
}
}
}
$output = new ClientReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
}
2010-11-23 11:24:25 +00:00
/**
* Récupère la liste des clients ou les informations d ' un client
2011-06-08 11:54:06 +00:00
* @ param integer | boolean $idClient
* @ param ClientFiltre $filtre
2010-11-23 11:24:25 +00:00
* @ return ListeClientsReturn
*/
2011-06-08 11:54:06 +00:00
public function getListeClients ( $idClient = false , $filtre = null )
2010-11-23 11:24:25 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 10:24:44 +00:00
2010-11-23 11:24:25 +00:00
//Initialisation
$error = new ErrorType ();
2011-06-22 15:40:22 +00:00
if ( empty ( $idClient )) $idClient = false ;
2010-11-23 11:24:25 +00:00
$isAuthorized = false ;
2010-11-23 10:24:44 +00:00
2010-11-23 11:24:25 +00:00
if ( $this -> tabInfoUser [ 'profil' ] == 'Administrateur' &&
2011-06-08 11:54:06 +00:00
( $idClient == 'false' || $idClient == $this -> tabInfoUser [ 'idClient' ])){
2010-11-23 11:24:25 +00:00
$idClient = $this -> tabInfoUser [ 'idClient' ];
$isAuthorized = true ;
}
2011-01-13 13:54:41 +00:00
if ( $this -> tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' ){
2010-11-23 11:24:25 +00:00
$error -> errnum = 1 ;
$error -> errmsg = 'Profil non administrateur' ;
2011-01-13 13:54:41 +00:00
} else {
2010-11-23 11:24:25 +00:00
$isAuthorized = true ;
}
if ( $isAuthorized )
{
$strClient = '' ;
2011-06-08 11:54:06 +00:00
if ( is_numeric ( $idClient )) $strClient .= " AND id=' $idClient ' " ;
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2011-01-13 13:54:41 +00:00
$rep = $iDbCrm -> select ( 'clients' ,
2011-08-24 10:30:21 +00:00
'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 );
2010-11-23 11:24:25 +00:00
$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' ];
2011-08-05 14:30:22 +00:00
$client -> droits = strtolower ( $uti [ 'droits' ]);
2010-11-23 11:24:25 +00:00
$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 ;
2011-01-13 13:54:41 +00:00
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-12-02 16:45:25 +00:00
/**
*
* 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 ;
}
2010-11-23 10:24:44 +00:00
/**
2010-11-24 15:46:42 +00:00
* getStatsUtilisateurs
* @ param string $login
* @ param string $mois
* @ param string $type
* @ param boolean $payants
* @ return array
2010-11-23 10:24:44 +00:00
*/
2010-11-24 15:46:42 +00:00
public function getStatsUtilisateurs ( $login , $mois , $type = 'jour' , $payants = false )
2010-11-23 10:24:44 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 10:24:44 +00:00
//Initialisation
$error = new ErrorType ();
if ( $payants )
{
$strPayant = " AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis') AND params<>'' AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') " ;
}
else {
$strPayant = '' ;
}
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2011-03-11 15:41:46 +00:00
if ( $type == 'jour' ) {
$rep = $iDbCrm -> select ( 'logs' ,
'date(dateHeure) as jours, count(*) as nb' ,
" 1 $strPayant AND login=' $login ' AND dateHeure BETWEEN ' $mois -01' AND ' $mois -31' GROUP BY jours " ,
2011-08-24 10:30:21 +00:00
false , MYSQL_ASSOC );
2011-03-11 15:41:46 +00:00
} elseif ( $type == 'heure' ) {
$rep = $iDbCrm -> select ( 'logs' ,
'HOUR(dateHeure) as heures, count(*) as nb' ,
" 1 $strPayant AND login=' $login ' AND dateHeure BETWEEN ' $mois -01' AND ' $mois -31' GROUP BY heures " ,
2011-08-24 10:30:21 +00:00
false , MYSQL_ASSOC );
2010-11-25 09:11:42 +00:00
}
$tabRet = $rep ;
2011-03-11 15:41:46 +00:00
2010-11-23 10:24:44 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
2010-11-23 15:29:01 +00:00
/**
2010-11-24 15:43:20 +00:00
* getPortefeuilleCsv
* @ param string $login
* @ param int $idClient
* @ return ListeSurveillancesCsvReturn
2010-11-23 15:29:01 +00:00
*/
2010-11-24 15:43:20 +00:00
public function getPortefeuilleCsv ( $login = '' , $idClient = 0 )
2010-11-23 10:24:44 +00:00
{
return $this -> getListeSurveillancesCsv ( 'portefeuille' , $login , $idClient );
}
2011-01-12 15:46:17 +00:00
/**
* getPortefeuille
* @ param PortefeuilleFiltre $filtre
* @ param int $deb
* @ param int $nbRet
* @ return PortefeuilleReturn
*/
public function getPortefeuille ( $filtre , $deb = 0 , $nbRet = 100 )
{
$this -> authenticate ();
// Initialisation
$error = new ErrorType ();
if ( empty ( $deb )) { $deb = 0 ; }
if ( empty ( $nbRet )) { $nbRet = 100 ; }
2011-01-24 08:48:25 +00:00
$tri = strtolower ( trim ( $filtre -> tri ));
switch ( $tri ) {
2011-01-12 15:46:17 +00:00
case 'ref' : $orderBy = 'ORDER BY ref' ; break ;
case 'dateAjout' : $orderBy = 'ORDER BY dateAjout' ; break ;
case 'dateDerEnvoi' : $orderBy = 'ORDER BY dateDerEnvoi' ; break ;
case 'rs' : $orderBy = 'ORDER BY rs' ; break ;
case 'cp' : $orderBy = 'ORDER BY cp' ; break ;
case 'ville' : $orderBy = 'ORDER BY ville' ; break ;
case 'indiScore' : $orderBy = 'ORDER BY indiScore' ; break ;
case 'encours' : $orderBy = 'ORDER BY encours' ; break ;
default : $orderBy = 'ORDER BY siren' ; break ; // siren ou vide ou autre
}
$tabRet = array ();
$siren = substr ( $filtre -> siret , 0 , 9 );
$nic = substr ( $filtre -> siret , 9 , 5 );
$iDb = new WDB ();
$login = $this -> tabInfoUser [ 'login' ];
$strSelect = 's.email, s.siren, s.nic, s.ref, s.dateAjout, s.rs, s.cp, s.ville, s.dateDerEnvoi, s.encoursClient, c.actif, c.procol, c.indiScore, c.indiScore20, c.encours, c.indiScoreDate, c.dateBilan, c.indiScorePre, c.indiScore20Pre, c.encoursPre, c.indiScoreDatePre, c.sourceModif, c.scoreSolv, c.scoreSolvPre, c.scoreDir, c.scoreDirPre, c.scoreConf, c.scoreConfPre, c.scoreZ, c.scoreZPre, c.scoreCH, c.scoreCHPre, c.scoreAfdcc2, c.scoreAfdcc2Pre, c.situFi, c.situFiPre, c.infoNote, c.infoNotePre, c.noteStruct, c.noteStructPre, c.noteFin, c.noteFinPre, c.tendance, c.tendancePre, c.dateUpdate' ;
$strFiltre = '' ;
if ( intval ( $siren ) > 0 ) $strFiltre .= " AND s.siren= $siren " ;
2011-01-24 08:48:25 +00:00
if ( ! empty ( $filtre -> ref )) $strFiltre .= " AND s.ref LIKE % $filtre->ref % " ;
if ( ! empty ( $filtre -> rs )) $strFiltre .= " AND s.ref LIKE % $filtre->rs % " ;
2011-01-12 15:46:17 +00:00
// Il faut compter le nombre de siren au total
$tabTmp = $iDb -> select ( 'surveillances_site' , 'count(*) as nb' , " login=' $login ' AND source='score' AND dateSuppr=0 $strFiltre " , false , MYSQL_ASSOC );
$nbRepTot = $tabTmp [ 0 ][ 'nb' ];
$tabTmp = $iDb -> select ( 'surveillances_site s, scores_surveillance c' , $strSelect , " s.login=' $login ' AND s.source='score' AND s.dateSuppr=0 AND s.siren=c.siren $strFiltre $orderBy LIMIT $deb , $nbRet " , false , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabSurv ) {
if ( trim ( $tabSurv [ 'rs' ]) <> '' ) {
$rs = $tabSurv [ 'rs' ];
$cp = $tabSurv [ 'cp' ];
$ville = $tabSurv [ 'ville' ];
} else {
2011-01-25 16:32:49 +00:00
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteLight ( $tabSurv [ 'siren' ], $tabSurv [ 'nic' ]);
2011-01-12 15:46:17 +00:00
$rs = $tabIdentite [ 'Nom' ];
$cp = $tabIdentite [ 'CP' ];
$ville = $tabIdentite [ 'Ville' ];
$iDb -> update ( 'surveillances_site' , array (
'rs' => $rs ,
'cp' => $cp ,
'ville' => $ville ),
" login=' $login ' AND source='score' AND dateSuppr=0 AND siren= " . $tabSurv [ 'siren' ] . " AND nic= " . $tabSurv [ 'nic' ],
false
);
}
$portefeuille = new Portefeuille ();
$portefeuille -> email = $tabSurv [ 'email' ];
$portefeuille -> siren = $tabSurv [ 'siren' ];
$portefeuille -> nic = $tabSurv [ 'nic' ];
$portefeuille -> ref = $tabSurv [ 'ref' ];
$portefeuille -> dateAjout = $tabSurv [ 'dateAjout' ];
$portefeuille -> rs = $rs ;
$portefeuille -> cp = $cp ;
$portefeuille -> ville = $ville ;
// Entreprise
$portefeuille -> actif = $tabSurv [ 'actif' ];
$portefeuille -> procol = $tabSurv [ 'procol' ];
$portefeuille -> indiScore = $tabSurv [ 'indiScore' ];
$portefeuille -> indiScore20 = $tabSurv [ 'indiScore20' ];
$portefeuille -> indiScorePre = $tabSurv [ 'indiScorePre' ];
$portefeuille -> indiScore20Pre = $tabSurv [ 'indiScore20Pre' ];
$portefeuille -> encours = $tabSurv [ 'encours' ];
$portefeuille -> encoursPre = $tabSurv [ 'encoursPre' ];
$portefeuille -> indiScoreDate = $tabSurv [ 'indiScoreDate' ];
$portefeuille -> indiScoreDatePre = $tabSurv [ 'indiScoreDatePre' ];
$portefeuille -> encoursClient = $tabSurv [ 'encoursClient' ];
$portefeuille -> dateBilan = $tabSurv [ 'dateBilan' ];
$portefeuille -> sourceModif = $tabSurv [ 'sourceModif' ];
//, c.scoreSolv, c.scoreSolvPre, c.scoreDir, c.scoreDirPre, c.scoreConf, c.scoreConfPre, c.scoreZ, c.scoreZPre, c.scoreCH, c.scoreCHPre, c.scoreAfdcc2, c.scoreAfdcc2Pre, c.situFi, c.situFiPre, c.infoNote, c.infoNotePre, c.noteStruct, c.noteStructPre, c.noteFin, c.noteFinPre, c.tendance, c.tendancePre, c.dateUpdate';
$portefeuille -> dateDerEnvoi = $tabSurv [ 'dateDerEnvoi' ];
$tabRet [] = $portefeuille ;
}
$output = new PortefeuilleReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
$output -> nbReponses = count ( $tabRet );
$output -> nbReponsesTotal = $nbRepTot ;
return $output ;
}
2010-11-23 10:24:44 +00:00
2010-11-23 15:29:01 +00:00
/**
* rechercheHisto
2010-11-24 13:53:15 +00:00
* @ param string $recherche
* @ param string $annee
* @ param string $typeBod
* @ param int $deb
* @ param int $nbRep
* @ param int $maxRep
* @ param bool $pertinence
2010-11-24 16:47:22 +00:00
* @ return RechercheHistoReturn
2010-11-23 15:29:01 +00:00
*/
2010-11-24 16:47:22 +00:00
public function rechercheHisto ( $recherche , $annee = '' , $typeBod = '' , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false )
2010-11-23 15:29:01 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-24 13:53:15 +00:00
//Initialisation
$error = new ErrorType ();
2011-03-07 17:16:53 +00:00
if ( empty ( $annee )) $annee = '' ;
if ( empty ( $typeBod )) $typeBod = '' ;
if ( empty ( $deb )) $deb = 0 ;
if ( empty ( $nbRep )) $nbRep = 20 ;
if ( empty ( $maxRep )) $maxRep = 200 ;
if ( empty ( $annee )) $pertinence = false ;
require_once 'Metier/sphinx/sphinxsearch.php' ;
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " rechercheHisto de $recherche ( $annee ) (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-24 16:42:40 +00:00
$tabFiltresAnnee = array ();
2010-11-23 10:24:44 +00:00
if ( $annee <> '' && $annee * 1 >= 1953 && $annee * 1 <= date ( 'Y' ) * 1 )
2010-11-24 16:42:40 +00:00
$tabFiltresAnnee = array ( 'annee1' => $annee );
2011-03-07 17:16:53 +00:00
$sphinxsearch = new SphinxSearch ();
$ret = $sphinxsearch -> searchByHisto ( $recherche , $tabFiltresAnnee , $deb , $nbRep , $maxRep , $pertinence );
2010-11-24 16:42:40 +00:00
$liste = $ret [ 'results' ];
$nbTot = $ret [ 'nbTot' ];
$duree = $ret [ 'duration' ];
$tabMots = $ret [ 'words' ];
2010-11-23 10:24:44 +00:00
2010-11-24 16:42:40 +00:00
$tabRet = array ();
2010-11-23 10:24:44 +00:00
$k = 0 ;
2011-03-07 17:16:53 +00:00
if ( count ( $liste ) > 0 ) {
foreach ( $liste as $n => $etab )
{
$texte = $etab [ 'Texte' ];
$posMin = 100000 ;
$hitMin = 1000000 ;
foreach ( $tabMots as $mot => $tabMot ){
if ( $tabMot [ 'hits' ] < $hitMin ) {
$hitMin = $tabMot [ 'hits' ];
$motSignificatif = $mot ;
}
2010-11-23 10:24:44 +00:00
}
2011-03-07 17:16:53 +00:00
$posMin = stripos ( $texte , '' . $motSignificatif );
if ( $posMin < 150 ) $posMin = 150 ;
$texte2 = substr ( $texte , $posMin - 150 , 250 );
$reponse = new RechercheHistoReponses ();
$reponse -> id = $etab [ 'id' ];
$reponse -> Pertinence = $etab [ 'Pertinence' ];
$reponse -> Fichier = strtr ( $etab [ 'Fichier' ],
array ( '.txt' => '.pdf' , '/mnt/bodacc/' => 'http://tville.scores-decisions.com/bodacc/' )
);
$reponse -> Annee = $etab [ 'Annee' ];
$reponse -> Code = $etab [ 'Code' ];
$reponse -> Texte = utf8_encode ( $texte2 );
$tabRet [] = $reponse ;
$k ++ ;
2010-11-24 16:42:40 +00:00
}
2010-11-23 10:24:44 +00:00
}
2010-11-24 16:42:40 +00:00
$criteres = new RechercheHistoCriteres ();
$criteres -> recherche = $recherche ;
$criteres -> annee = $annee ;
$output = new RechercheHistoReturn ();
$output -> criteres = $criteres ;
$output -> nbReponses = count ( $tabRet );
$output -> nbReponsesTotal = $nbTot ;
$output -> duree = $duree ;
$output -> mots = array_keys ( $tabMots );
$output -> reponses = $tabRet ;
return $output ;
2010-11-23 10:24:44 +00:00
}
/**
2010-11-24 14:47:18 +00:00
* getLogsClients
2011-02-01 13:48:46 +00:00
* @ param string $mois ( Format : AAAA - MM ou AAAA / MM )
2010-11-24 14:47:18 +00:00
* @ param int $detail
* @ param int $idClient
* @ param string $login
* @ param int $all
* @ return LogsClientsReturn
2010-11-23 10:24:44 +00:00
*/
2010-11-24 14:47:18 +00:00
public function getLogsClients ( $mois , $detail = 0 , $idClient = 0 , $login = '' , $all = 0 )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-24 14:47:18 +00:00
//Initialisation
$error = new ErrorType ();
2011-02-01 13:48:46 +00:00
if ( empty ( $detail )) $detail = 0 ;
if ( empty ( $idClient )) $idClient = 0 ;
if ( empty ( $login )) $login = '' ;
if ( empty ( $all )) $all = 0 ;
2010-11-24 14:47:18 +00:00
$strDetail = $strClient = $strLogin = '' ;
2010-11-23 10:24:44 +00:00
// Vue détaillée ou uniquement les infos payantes
2011-02-01 13:48:46 +00:00
if ( $detail == 0 ) {
2010-11-24 14:47:18 +00:00
$detail = 'Non' ;
//$strDetail=" AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page='indiscore' ) AND (params<>'' OR page='indiscore' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') ";
2010-11-29 16:12:32 +00:00
$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%') " ;
2010-11-24 14:47:18 +00:00
} elseif ( $detail == 1 ) {
$detail = 'Oui' ;
}
2010-11-23 10:24:44 +00:00
// On veut uniquement le client précis
2010-11-24 14:47:18 +00:00
if ( $all && $this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) {
2011-02-01 13:48:46 +00:00
$all = 'Oui' ;
2010-11-23 10:24:44 +00:00
} else {
2011-08-25 15:57:59 +00:00
$all = 'Non' ;
2010-11-23 10:24:44 +00:00
}
2011-08-25 15:57:59 +00:00
// 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 " ;
2010-11-23 10:24:44 +00:00
// On veut uniquement le login précis
2011-08-25 15:57:59 +00:00
if ( $login != '' ) {
$strLogin = " AND l.login=' $login ' " ;
} else {
$login = 'Non' ;
}
2010-11-23 10:24:44 +00:00
// Dates de début et de fin
2011-02-01 13:48:46 +00:00
$mois = strtr ( $mois , array ( '-' => '' , '/' => '' ));
$annee = substr ( $mois , 0 , 4 );
$mois = substr ( $mois , 4 , 2 );
2010-11-23 10:24:44 +00:00
$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
2011-03-25 16:18:01 +00:00
GROUP BY l . login , l . siren , page , date ( dateHeure ), params
2010-11-23 10:24:44 +00:00
ORDER BY l . login ASC , dateHeure ASC " ;
2010-11-24 14:47:18 +00:00
$fp = fopen ( DOC_WEB_LOCAL . " /csv/logs- $annee - $mois - $detail - $idClient - $login - $all .sql " , 'w' );
2010-11-23 10:24:44 +00:00
fwrite ( $fp , $sql . EOL );
fclose ( $fp );
2011-06-27 10:13:10 +00:00
exec ( " php " . APPLICATION_PATH . " /../batch/sql2csv.php sdv1 " . DOC_WEB_LOCAL . " csv/logs- $annee - $mois - $detail - $idClient - $login - $all .sql $fichierCsv > /dev/null & " );
2011-02-01 13:48:46 +00:00
$size = $cache = 0 ;
2010-11-23 10:24:44 +00:00
}
2011-04-27 08:32:00 +00:00
$hostname = 'http://' . $_SERVER [ 'SERVER_NAME' ];
2010-11-23 10:24:44 +00:00
2010-11-24 14:47:18 +00:00
$result = new LogsClients ();
2011-04-27 08:32:00 +00:00
$result -> Url = $hostname . DOC_WEB_URL . " csv/logs- $annee - $mois - $detail - $idClient - $login - $all .csv " ;
2010-11-24 14:47:18 +00:00
$result -> Taille = $size ;
$result -> Cache = $cache ;
$output = new LogsClientsReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-24 15:22:07 +00:00
/**
* getListeSurveillanceCsv
* @ param string $source
* @ param string $login
2011-01-25 16:32:49 +00:00
* @ param int $idClient
2010-11-24 15:22:07 +00:00
* @ return ListeSurveillancesCsvReturn
*/
public function getListeSurveillancesCsv ( $source = '' , $login = '' , $idClient = 0 )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-24 15:22:07 +00:00
//Initialisation
$error = new ErrorType ();
2011-02-01 14:04:51 +00:00
if ( empty ( $source )) $source = '' ;
if ( empty ( $idClient )) $idClient = 0 ;
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " getListeSurveillancesCsv Début $source $login $idClient " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-24 15:22:07 +00:00
$tabRet = array ();
$iDb = new WDB ();
$strClient = $strLogin = '' ;
$exportPtf = false ;
switch ( $source )
{
2010-11-23 10:24:44 +00:00
case 'insee' :
case 'annonces' :
case 'bilans' :
case 'score' :
case 'actes' :
case 'privileges' :
case 'dirigeants' :
break ;
case 'portefeuille' :
$source = 'score' ;
$exportPtf = true ;
break ;
default :
$source = '' ;
break ;
}
2011-04-27 08:32:00 +00:00
if ( $source <> '' ) $strSource = " AND source=' $source ' " ;
else $strSource = '' ;
2010-11-23 10:24:44 +00:00
2011-01-25 16:32:49 +00:00
// Control idClient
2011-04-26 10:09:03 +00:00
if ( $idClient == 0 || ( $idClient != $this -> tabInfoUser [ 'idClient' ] && $this -> tabInfoUser [ 'profil' ] != 'SuperAdministrateur' ) ){
2011-01-25 16:32:49 +00:00
$idClient = $this -> tabInfoUser [ 'idClient' ];
2010-11-24 15:22:07 +00:00
}
2011-04-27 08:32:00 +00:00
$strClient = " AND u.idClient= $idClient " ;
if ( $this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' || $this -> tabInfoUser [ 'profil' ] == 'Administrateur' ) {
// Surveillances de tous les utilisateurs du client
if ( empty ( $login )) {
$login = '' ;
//Surveillances de l'utilisateur
} else {
$strLogin = " AND s.login=' $login ' " ;
}
2011-01-25 16:32:49 +00:00
} else {
2011-04-27 08:32:00 +00:00
//Par défaut préselection de l'utilisateur
$login = $this -> tabInfoUser [ 'login' ];
$strLogin = " AND s.login=' $login ' " ;
2010-11-24 15:22:07 +00:00
}
2011-04-27 08:32:00 +00:00
2011-01-25 16:32:49 +00:00
$fichierCsv = DOC_WEB_LOCAL . " csv/listesurv- $source - $login - $idClient .csv " ;
2010-11-23 10:24:44 +00:00
if ( file_exists ( $fichierCsv ) &&
date ( 'Ymd' , filemtime ( $fichierCsv )) == date ( 'Ymd' ) &&
filesize ( $fichierCsv ) > 60 ) {
2011-01-25 16:32:49 +00:00
$size = filesize ( $fichierCsv );
$erreur = false ;
$tabNom = array ();
$cache = 1 ;
2010-11-23 10:24:44 +00:00
} else {
2011-04-27 08:32:00 +00:00
unlink ( $fichierCsv );
if ( $source == 'score' ){
2011-01-25 16:32:49 +00:00
if ( $tabInfoUser [ 'typeScore' ] == 20 ) {
$strScore = 'v.indiScore20 AS indiScore20' ;
$strScorePre = 'v.indiScore20Pre AS indiScore20Pre' ;
} else {
$strScore = 'v.indiScore AS indiScore100' ;
$strScorePre = 'v.indiScorePre AS indiScore100Pre' ;
}
2010-11-29 16:12:32 +00:00
/* v . scoreZ , v . scoreZPre , v . scoreCH , v . scoreCHPre ,
v . scoreAfdcc2 , v . scoreAfdcc2Pre , v . situFi , v . situFiPre , v . infoNote , v . infoNotePre ,
v . noteStruct , v . noteStructPre , v . noteFin , v . noteFinPre , v . tendance , v . tendancePre , */
2010-11-23 10:24:44 +00:00
$sql = " SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
2010-11-29 16:12:32 +00:00
s . rs , s . cp , s . ville , s . dateDerEnvoi ,
s . encoursClient , v . actif , v . procol , $strScore , v . encours , v . indiScoreDate , v . dateBilan ,
$strScorePre , v . encoursPre , v . indiScoreDatePre , v . sourceModif , v . scoreSolv , v . scoreSolvPre , v . scoreDir ,
v . scoreDirPre , v . scoreConf , v . scoreConfPre ,
e . cj , e . capital , e . capitalDev , e . ape_entrep , e . tca , e . teff_entrep ,
v . dateUpdate
FROM surveillances_site s , sdv1 . utilisateurs u , sdv1 . clients c , scores_surveillance v , etablissements e
WHERE s . source = 'score' $strClient $strLogin AND dateSuppr = 0 AND s . login = u . login AND u . idClient = c . id AND s . siren = v . siren AND s . siren = e . siren
GROUP BY loginUti , s . siren , s . nic , s . source , s . ref
2010-11-23 10:24:44 +00:00
ORDER BY loginUti ASC , s . siren ASC , s . nic ASC , s . source ASC , s . ref ASC " ;
2010-11-29 16:12:32 +00:00
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeSurveillancesCsv($source, $login, $idClient)", $sql);
2010-11-24 15:22:07 +00:00
} else {
2010-11-23 10:24:44 +00:00
$sql = " SELECT LOWER(s.login) as loginUti, s.source, s.email, s.siren, s.nic, s.ref, s.dateAjout,
s . rs , s . cp , s . ville , s . dateDerEnvoi
FROM surveillances_site s , sdv1 . utilisateurs u , sdv1 . clients c
WHERE 1 $strSource $strClient $strLogin AND dateSuppr = 0 AND s . login = u . login AND u . idClient = c . id
ORDER BY loginUti ASC , s . siren ASC , s . nic ASC , s . source ASC , s . ref ASC " ;
2010-11-24 15:22:07 +00:00
}
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " getListeSurveillancesCsv SQL $sql " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-24 15:22:07 +00:00
$fp = fopen ( DOC_WEB_LOCAL . " csv/listesurv- $source - $login - $idClient .sql " , 'w' );
2010-11-23 10:24:44 +00:00
fwrite ( $fp , $sql . EOL );
fclose ( $fp );
2011-04-26 12:29:11 +00:00
exec ( " php " . APPLICATION_PATH . " /../batch/sql2csv.php jo " . DOC_WEB_LOCAL . " csv/listesurv- $source - $login - $idClient .sql $fichierCsv > /dev/null & " );
2010-11-23 10:24:44 +00:00
$size = $cache = 0 ;
}
2011-04-26 10:16:09 +00:00
$hostname = 'http://' . $_SERVER [ 'SERVER_NAME' ];
2010-11-24 15:22:07 +00:00
$result = new ListeSurveillancesCsv ();
2011-04-26 10:16:09 +00:00
$result -> Url = $hostname . DOC_WEB_URL . " csv/listesurv- $source - $login - $idClient .csv " ;
2010-11-24 15:22:07 +00:00
$result -> Taille = $size ;
$result -> Cache = $cache ;
2011-04-26 10:16:09 +00:00
debugLog ( 'I' , 'getListeSurveillancesCsv Url=' . $hostname . DOC_WEB_URL . " csv/listesurv- $source - $login - $idClient .csv, Taille= $size , Cache= $cache " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-23 10:24:44 +00:00
2010-11-24 15:22:07 +00:00
$output = new ListeSurveillancesCsvReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-23 16:00:51 +00:00
/**
* getListeJalCollecte
* @ return ListeJalCollecteReturn
*/
public function getListeJalCollecte ()
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 16:00:51 +00:00
//Initialisation
$error = new ErrorType ();
$iBodacc = new MBodacc ();
2011-01-26 10:16:47 +00:00
$tabJal = $iBodacc -> getListeJalCollecte ();
foreach ( $tabJal as $i => $jal )
2010-11-23 16:00:51 +00:00
{
$jalCollecte = new JalCollecte ();
$jalCollecte -> id = $i ;
$jalCollecte -> nom = $jal ;
$tabRet [] = $jalCollecte ;
}
$output = new ListeJalCollecteReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
2010-11-23 10:24:44 +00:00
}
/**
2010-11-24 15:43:20 +00:00
* getListeFichierSurv
* @ param string $login
* @ param string $ref
* @ param string $nomFic
* @ return ListeFichierSurvReturn
2010-11-23 10:24:44 +00:00
*/
2010-12-06 16:30:32 +00:00
public function getListeFichierSurv ( $login , $ref = '*' , $nomFic = '' )
2010-11-24 15:43:20 +00:00
{
2010-12-06 16:30:32 +00:00
$this -> authenticate ();
if ( empty ( $ref )) $ref = '*' ;
if ( empty ( $nomFic )) $nomFic = '' ;
$error = new ErrorType ();
2010-11-29 16:12:32 +00:00
//debugLog('I',"getListeFichierSurv pour $login, $ref, $nomFic",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
2010-11-23 10:24:44 +00:00
$tabFichier = $tabDates = array ();
$numAbo = substr ( $ref , 0 , 5 );
2011-03-25 16:18:01 +00:00
if ( strtolower ( $login ) == 'vwbank' ) {
2010-11-23 10:24:44 +00:00
$repClient = 'volkswagen bank' ;
$ficClient = 'surveillanceBodacc_SURBODPRDCFTVWBANK' ;
$numAbo = $ref = '19300' ;
2010-11-29 16:12:32 +00:00
} elseif ( substr ( $login , 0 , 6 ) == 'apicil' ) {
$repClient = 'apicil' ;
$ficClient = 'surveillanceBodacc_SURBODPRDCFTAPICIL' ;
$numAbo = $ref = '' ;
2011-03-25 16:18:01 +00:00
} elseif ( strtolower ( $login ) == 'omni04' ) {
$repClient = 'aggm mederic ' ;
$ficClient = 'surveillanceBodacc_SURBODPRDFTSOMNIREP' ;
$numAbo = $ref = '' ;
2010-11-23 10:24:44 +00:00
} else {
$repClient = 'cnasea' ;
$ficClient = 'surveillanceBodacc_SURBODTSTFTSCNASEA' ;
}
2010-12-06 16:30:32 +00:00
$dh = opendir ( DOC_WEB_LOCAL . " clients/ $repClient / " );
2010-11-29 16:12:32 +00:00
if ( ! $dh ) {
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , $nomFic " , " Impossible d'ouvrir le dossier '/home/data/clients/ $repClient /' " );
2010-12-06 16:30:32 +00:00
$error -> errnum = 1 ;
$error -> errmsg = " Impossible d'ouvrir le dossier client " ;
} else {
while ( false !== ( $filename = readdir ( $dh ))) {
if ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 42 ) == $ficClient . $numAbo ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 43 , 8 );
$tabClients [] = substr ( $filename , 0 , 42 );
}
elseif ( $ref == '*' && $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 37 ) == $ficClient && substr ( $filename , 37 , 1 ) <> '_' ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 43 , 8 );
$tabClients [] = substr ( $filename , 0 , 42 );
}
elseif ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 37 ) == $ficClient && substr ( $filename , 37 , 1 ) == '_' && $repClient == 'apicil' ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 38 , 8 );
$tabClients [] = substr ( $filename , 0 , 37 );
}
2011-03-25 16:18:01 +00:00
elseif ( $filename <> '.' && $filename <> '..' && substr ( $filename , - 4 ) == '.csv' && substr ( $filename , 0 , 38 ) == $ficClient && substr ( $filename , 38 , 1 ) == '_' && $repClient == 'aggm mederic ' ) {
$tabFichier [] = $filename ;
$tabDates [] = substr ( $filename , 39 , 8 );
$tabClients [] = substr ( $filename , 0 , 38 );
}
2010-12-06 16:30:32 +00:00
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic : fichier lu '$filename'", "Fichier lu '$filename'");
}
/** Tableau des noms de fichier **/
sort ( $tabFichier );
/** Tableau des dates de livraisons **/
$tabDates = array_unique ( $tabDates );
sort ( $tabDates );
/** Tableau des Clients **/
$tabClients = array_unique ( $tabClients );
sort ( $tabClients );
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>$tabDates);
/*@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , $nomFic " ,
" Fichiers : " . EOL .
print_r ( $tabFichier , true ) .
" Dates: " . EOL .
print_r ( $tabDates , true ) .
" Clients : " . EOL .
print_r ( $tabClients , true )
); */
if ( $ref == '*' ) {
$tabFichier = array ();
// Boucle sur les dates de livraison
foreach ( $tabDates as $dateFic ) {
if ( strlen ( $dateFic ) <> 8 ) continue ;
if ( ! file_exists ( DOC_WEB_LOCAL . " clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " ) ||
filesize ( DOC_WEB_LOCAL . " clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " ) == 0 ) {
$fpW = fopen ( DOC_WEB_LOCAL . " clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " , 'w' );
$entete = true ;
// Boucle afin de vérifier si on est sur le bon client
foreach ( $tabClients as $nomClient ) {
$dh = opendir ( DOC_WEB_LOCAL . " clients/ $repClient / " );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( substr ( $filename , 0 , 51 ) == $nomClient . '_' . $dateFic && substr ( $filename , - 4 ) == '.csv' ) {
$fichier = $filename ;
//break;
2010-11-23 10:24:44 +00:00
}
2010-12-06 16:30:32 +00:00
}
$fpR = fopen ( DOC_WEB_LOCAL . " clients/ $repClient / $fichier " , 'r' );
//return array('error'=>array('errnum'=>0, 'errmsg'=>''), 'results'=>array(($fichier)));//die;
if ( $fpR ) {
while ( ! feof ( $fpR )) {
$ligne = trim ( fgets ( $fpR ));
if ( substr ( $ligne , 0 , 5 ) == 'Siren' && $entete == true ) {
fwrite ( $fpW , 'SITE;' . $ligne . EOL );
$entete = false ;
}
elseif ( substr ( $ligne , 0 , 5 ) <> 'Siren' && trim ( $ligne ) <> '' ) {
fwrite ( $fpW , strtr ( $nomClient , array ( 'surveillanceBodacc_SURBODTSTFTS' => '' ,
'surveillanceBodacc_SURBODPRDCFT' => '' )) . ';' . $ligne . EOL );
}
2010-11-23 10:24:44 +00:00
}
2010-12-06 16:30:32 +00:00
fclose ( $fpR );
2010-11-23 10:24:44 +00:00
}
}
2010-12-06 16:30:32 +00:00
fclose ( $fpW );
2010-11-23 10:24:44 +00:00
}
2010-12-06 16:30:32 +00:00
if ( strlen ( $dateFic ) == 8 )
$tabFichier [] = $ficClient . '_' . $dateFic . '.csv' ;
2010-11-23 10:24:44 +00:00
}
}
2010-12-06 16:30:32 +00:00
rsort ( $tabFichier );
2010-11-23 10:24:44 +00:00
2010-12-06 16:30:32 +00:00
if ( $nomFic <> '' ) {
2011-03-25 16:18:01 +00:00
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, /home/data/clients/$repClient/$nomFic", 'Avant BZ2');
if ( ! file_exists ( DOC_WEB_LOCAL . " /csv/ $nomFic .bz2 " ) ||
filesize ( DOC_WEB_LOCAL . " /csv/ $nomFic .bz2 " ) <= 14 ) {
$string = file_get_contents ( " /home/data/clients/ $repClient / $nomFic " );
if ( $string === false ) {
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , $nomFic " , " Ouverture impossible du fichier '/home/data/clients/ $repClient / $nomFic ' " );
}
$bz = bzopen ( DOC_WEB_LOCAL . " /csv/ $nomFic .bz2 " , 'w' );
2010-12-06 16:30:32 +00:00
if ( $bz ) {
bzwrite ( $bz , $string , strlen ( $string ));
bzclose ( $bz );
}
2011-03-25 16:18:01 +00:00
} /* else
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , /home/data/clients/ $repClient / $nomFic " , 'Sans BZ2' );
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " getListeFichierSurv pour $login , $ref , /home/data/clients/ $repClient / $nomFic " , 'Après BZ2' );
*/
2010-11-23 10:24:44 +00:00
}
2010-12-06 16:30:32 +00:00
debugLog ( 'I' , " getListeFichierSurv pour $login , $ref , $nomFic : nb fichiers= " . count ( $tabFichier ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2011-06-27 12:24:48 +00:00
$hostname = 'http://' . $_SERVER [ 'SERVER_NAME' ];
2010-12-06 16:30:32 +00:00
$result = array ();
foreach ( $tabFichier as $fichier ){
$retFichier = new ListeFichierSurv ();
2011-06-27 12:24:48 +00:00
$retFichier -> UrlFichier = $hostname . '/data/csv/' . $fichier ;
2010-12-06 16:30:32 +00:00
$result [] = $retFichier ;
}
2010-11-23 10:24:44 +00:00
}
2010-12-06 16:30:32 +00:00
$output = new ListeFichierSurvReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-23 16:20:29 +00:00
/**
* Geocodage d ' une adresse
* @ param string $adresse
* @ param string $cp
* @ param string $ville
* @ param string $pays
* @ return GeoCodeReturn
*/
public function geoCode ( $adresse , $cp , $ville , $pays = 'France' )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 16:20:29 +00:00
$ligne = date ( 'YmdHis' ) . " ; $siren ;MMap AVANT " ;
$fp = fopen ( LOG_PATH . '/accesDistant.log' , 'a' );
2010-11-23 10:24:44 +00:00
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
2010-11-23 16:20:29 +00:00
$mMap = new MMap ( $adresse , $cp , $ville , $pays );
2010-11-23 10:24:44 +00:00
$ligne = date ( 'YmdHis' ) . " ; $siren ;MMap APRES " ;
2010-11-23 16:20:29 +00:00
$fp = fopen ( LOG_PATH . '/accesDistant.log' , 'a' );
2010-11-23 10:24:44 +00:00
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
2010-11-23 16:20:29 +00:00
$geocode = new GeoCode ();
$geocode -> latitude = $mMap -> latitudeDec ;
$geocode -> longitude = $mMap -> longitudeDec ;
$geocode -> precis = $mMap -> precision ;
$geocode -> adresseValidee = $mMap -> adresseValidee ;
$geocode -> latitudeDeg = $mMap -> latitudeDeg ;
$geocode -> longitudeDeg = $mMap -> longitudeDeg ;
$output = new GeoCodeReturn ();
$output -> error = $error ;
$output -> result = $geocode ;
2010-11-23 10:24:44 +00:00
}
2011-03-25 16:18:01 +00:00
/**
* Suppression logique d ' une annonce relative à une entité
* @ param integer $source 0 = Collecte , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association , 4 = Boamp
* @ param string $idAnn Identifiant de l ' annonce
* @ param string $siret Siren de l 'entreprise ou Siret de l' établissement
* @ return bool
*/
public function supprAnnonce ( $source = 0 , $idAnn , $siret = 0 ) {
global $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
switch ( $source ) {
case 0 :
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
$table = 'annonces' ;
break ;
case 1 :
if ( $idAnn < 0 )
return array ( 'error' => array ( 'errnum' => 415245461 , 'errmsg' => 'Code annonce Incorrect' ), 'result' => 0 );
if ( $siren > 0 )
$strSql = " AND siren= $siren " ;
$table = 'bodacc_detail' ;
break ;
case 3 :
$table = 'asso' ;
break ;
case 2 :
case 4 :
default :
return array ( 'error' => array ( 'errnum' => 4461 , 'errmsg' => 'Cas non géré' ), 'result' => 0 );
break ;
}
if ( $idAnn > 0 ) {
if ( $iDb -> update ( $table ,
array ( 'dateSuppr' => date ( 'YmdHis' ),
'idSuppr' => $tabInfoUser [ 'id' ],
),
" id= $idAnn $strSql " , false ))
debugLog ( 'I' , " Suppression de l'annonce en source $source n° $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
}
debugLog ( 'I' , " Suppression impossible de l'annonce en source $source n° $idAnn ( $siret ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 987964641 , 'errmsg' => 'Suppression de l\'annonce impossible' ), 'result' => 0 );
}
/**
* Duplication d ' une annonce relative à une entité
*
* @ param integer $source 0 = Collecte , 1 = BODACC , 2 = B . A . L . O , 3 = JO Association , 4 = Boamp
* @ param string $idAnn Identifiant de l ' annonce
* @ param string $siretIn Siren de l 'entreprise ou Siret de l' établissement de l ' annonce à duppliquer
* @ param string $siretOut Siren / Siret de l 'entreprise ou étab sur lequel il faut dupliquer l' annonce
* @ return bool
*/
public function dupliqueAnnonce ( $source = 0 , $idAnn , $siretIn = 0 , $siretOut = 0 ) {
debugLog ( 'I' , " Demande de duplication d'annonce en source $source sur n° $idAnn (siretIn= $siretIn , siretOut= $siretOut ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
global $tabInfoUser ;
if ( $tabInfoUser [ 'idClient' ] <> 1 )
return array ( 'error' => array ( 'errnum' => 464561 , 'errmsg' => 'Code Client Incorrect' ), 'result' => 0 );
$sirenIn = substr ( '' . $siretIn , 0 , 9 ) * 1 ;
$nicIn = substr ( '' . $siretIn , 9 , 5 ) * 1 ;
$sirenOut = substr ( '' . $siretOut , 0 , 9 ) * 1 ;
$nicOut = substr ( '' . $siretOut , 9 , 5 ) * 1 ;
$iDb = new WDB ();
$strSql = '' ;
switch ( $source ) {
case 0 :
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
$table = 'annonces' ;
break ;
case 1 :
if ( $idAnn < 0 )
return array ( 'error' => array ( 'errnum' => 415245461 , 'errmsg' => 'Code annonce Incorrect' ), 'result' => 0 );
if ( $sirenIn > 0 )
$strSql .= " AND siren= $sirenIn " ;
$table = 'bodacc_detail' ;
break ;
case 3 :
$table = 'asso' ;
break ;
case 2 :
case 4 :
default :
return array ( 'error' => array ( 'errnum' => 4461 , 'errmsg' => 'Cas non géré' ), 'result' => 0 );
break ;
}
if ( $idAnn > 0 ) {
$res = $iDb -> select ( $table , '*' , " id= $idAnn $strSql " , false , MYSQL_ASSOC );
if ( count ( $res ) == 0 ) return array ( 'error' => array ( 'errnum' => 4645644561 , 'errmsg' => 'Annonce inexistante' ), 'result' => 0 );
$annonce = $res [ 0 ];
$annonce [ 'siren' ] = $sirenOut ;
$annonce [ 'sirenValide' ] = 2 ;
$annonce [ 'dateInsert' ] = date ( 'YmdHis' );
if ( $source == 0 ) {
// Suppression des zones inexistantes dans la table ou devant être vides
unset ( $annonce [ 'id' ]);
unset ( $annonce [ 'nic' ]);
$annonce [ 'idSaisie' ] = $tabInfoUser [ 'id' ];
} else {
$annonce [ 'idSirenage' ] = $tabInfoUser [ 'id' ];
$annonce [ 'nic' ] = $nicOut ;
if ( $nicOut > 0 ) $annonce [ 'nicValide' ] = 2 ;
}
if ( $iDb -> insert ( $table , $annonce , true , true )) {
debugLog ( 'I' , " Duplication de l'annonce en source $source sur n° $idAnn (siretIn= $siretIn , siretOut= $siretOut ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => 1 );
} else
debugLog ( 'I' , " Duplication imposible de l'annonce en source $source sur n° $idAnn (siretIn= $siretIn , siretOut= $siretOut ) : " . mysql_error (), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
debugLog ( 'I' , " Duplication impossible de l'annonce en source $source sur n° $idAnn (siretIn= $siretIn , siretOut= $siretOut ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 987964641 , 'errmsg' => 'Duplication de l\'annonce impossible' ), 'result' => 0 );
}
2011-08-12 15:26:46 +00:00
/**
* Recherche d ' entreprise par leur actionnaire
* @ param string $nom Raison sociale / Nom de l ' actionnaire ( obligatoire )
* @ param string $cpVille CP , Ville
* @ param string $siren Siren de l ' actionnaire
* @ param string $pays Pays de l ' actionnaire
* @ param string $pctMin Niveau de détention Minimam de l ' actionnaire
* @ param string $pctMax Niveau de détention Maximum de l ' actionnaire
* @ param integer $deb Position du curseur dans la liste des réponses ( 0 par défaut )
* @ param integer $nbRep Nombre de réponses retournées au maximum par cette requete ( 20 par défaut )
* @ param integer $maxRep Nombre de réponses recherchées au maximum ( 200 par défaut )
* @ param boolean $pertinence Recherche orthographique stricte sur les noms et prénoms ( si true )
* @ return SearchActReturn
*/
public function searchAct ( $nom , $cpVille = '' , $siren = 0 , $pays = '' , $pctMin = 0 , $pctMax = 100 , $deb = 0 , $nbRep = 20 , $maxRep = 200 , $pertinence = false )
{
debugLog ( 'I' , " Recherche Actionnaire de $nom , $cpVille (Max Rep= $nbRep ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( ! empty ( $pays )){
$wdb = new WDB ( 'jo' );
$result = $wdb -> select ( 'tabPays' , 'codPays3' , " libPays LIKE ' " . $pays );
if ( count ( $result > 0 )){
$pays = $result [ 0 ][ 'codPays3' ];
} else {
$pays = '' ;
}
}
2011-08-17 20:41:42 +00:00
if ( empty ( $cpVille )) $cpVille = '' ;
if ( empty ( $siren )) $siren = '' ;
if ( empty ( $pctMin )) $pctMin = 0 ;
if ( empty ( $pctMax )) $pctMax = 100 ;
if ( empty ( $deb )) $deb = 0 ;
if ( empty ( $nbRep )) $nbRep = 20 ;
if ( empty ( $maxRep )) $maxRep = 200 ;
if ( empty ( $pertinence )) $pertinence = false ;
2011-08-12 15:26:46 +00:00
$mLiens = new MLiens ( '' );
2011-08-17 20:41:42 +00:00
// rechercheActionnaire($nom, $cpVille, $siren, $pays, $pctMin, $pctMax, $deb, $nbRep, $maxRep, $pertinence)
2011-08-12 15:26:46 +00:00
$etabs = $mLiens -> rechercheActionnaire ( $nom , $cpVille , $siren , $pays , $pctMin , $pctMax , $deb , $nbRep , $maxRep , $pertinence );
2011-08-17 20:41:42 +00:00
$iInsee = new MInsee ();
2011-08-12 15:26:46 +00:00
$tabRet = array ();
foreach ( $etabs [ 'reponses' ] as $etab ) {
$act = new EntrepriseActItem ();
$act -> id = $etab [ 'id' ];
$act -> Pertinence = $etab [ 'Pertinence' ];
$act -> Siret = $etab [ 'Siret' ];
$act -> Siege = $etab [ 'Siege' ];
$act -> Nom = prepareString ( strtr ( $etab [ 'Nom' ], '/*' , ' ' ));
$act -> Nom2 = prepareString ( $etab [ 'Nom2' ]);
$act -> Sigle = prepareString ( $etab [ 'Sigle' ]);
$act -> Enseigne = prepareString ( $etab [ 'Enseigne' ]);
$act -> Adresse = prepareString ( $etab [ 'Adresse' ]);
$act -> Adresse2 = prepareString ( $etab [ 'Adresse2' ]);
$act -> CP = $etab [ 'CP' ];
$act -> Ville = prepareString ( $etab [ 'Ville' ]);
$act -> Tel = $etab [ 'Tel' ];
$act -> Fax = $etab [ 'Fax' ];
$act -> FJ = $etab [ 'FJ' ];
2011-08-17 20:41:42 +00:00
$act -> FJLib = prepareString ( $iInsee -> getLibelleFJ ( $etab [ 'FJ' ]));
2011-08-12 15:26:46 +00:00
$act -> Siren = $etab [ 'Siren' ];
$act -> Nic = $etab [ 'Nic' ];
$act -> Actif = $etab [ 'Actif' ];
$act -> NafEtab = $etab [ 'NafEtab' ]; // Etablissement
2011-08-17 20:41:42 +00:00
$act -> NafEtabLib = prepareString ( $iInsee -> getLibelleNaf ( $etab [ 'NafEtab' ])); // Etablissement
2011-08-12 15:26:46 +00:00
$act -> NafEnt = $etab [ 'NafEnt' ]; // Entreprise
2011-08-17 20:41:42 +00:00
$act -> NafEntLib = prepareString ( $iInsee -> getLibelleNaf ( $etab [ 'NafEnt' ]));
2011-08-12 15:26:46 +00:00
$act -> ActNomRs = $etab [ 'ActNomRs' ];
$act -> ActPays = $etab [ 'ActPays' ];
$act -> ActDateLien = $etab [ 'ActDateLien' ];
$act -> ActActif = $etab [ 'ActActif' ];
$act -> ActPmin = $etab [ 'ActPmin' ];
$tabRet [] = $act ;
}
$output = new SearchActReturn ();
$output -> nbReponses = $etabs [ 'nbReponses' ];
$output -> nbReponsesTotal = $etabs [ 'nbReponsesTotal' ];
$output -> result = $tabRet ;
if ( $tabRet [ 'nbReponses' ] == 0 ) {
debugLog ( 'W' , " Aucun résultat pour cette recherche ! " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
return $output ;
}
2010-11-25 09:11:42 +00:00
}
?>