2010-10-18 13:51:58 +00:00
< ? php
2010-11-25 10:25:34 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/WsScore.php' ;
2010-11-15 14:17:19 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/functions.php' ;
2010-10-20 13:32:33 +00:00
require_once realpath ( dirname ( __FILE__ )) . '/Types/InterneTypes.php' ;
2010-11-25 10:25:34 +00:00
class WsInterne extends WsScore
2010-10-18 13:51:58 +00:00
{
/**
* Enregistrement des informations saisie manuellement
* @ param string $siret
* @ param int $idEntreprise
* @ param array $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 ();
2010-11-23 14:27:11 +00:00
//Initialisation
2010-11-23 15:12:32 +00:00
$tabRet = array ();
$iBodacc = new MBodacc ();
$result = false ;
2010-11-23 10:24:44 +00:00
2010-11-23 15:12:32 +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 15:12:32 +00:00
else
{
$siren = substr ( $siret , 0 , 9 ) * 1 ;
$iDb = new WDB ();
debugLog ( 'W' , print_r ( $tabInfos , true ), __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabIdentite = $tabInfos [ 'identite' ];
$tabJugement = $tabInfos [ 'jugement' ];
$tabActio = $tabInfos [ 'actionnaire' ];
$tabParti = $tabInfos [ 'participation' ];
$tabScores = $tabInfos [ 'score' ];
/** Mise à jour de l'identité **/
if ( trim ( strtolower ( $tabIdentite [ 'web' ])) == 'http://' ) $web = '' ;
else $web = trim ( $tabIdentite [ 'web' ]);
$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 ),
);
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
}
2010-11-23 15:12:32 +00:00
if ( isset ( $tabIdentite [ 'moisOppositionInsee' ]) && $tabIdentite [ 'moisOppositionInsee' ] > 0 &&
$tabIdentite [ 'moisOppositionInsee' ] <= ( date ( 'Ym' ) * 1 ))
{
$iDb2 = new WDB ( 'insee' );
if ( ! $iDb2 -> insert ( 'insee_nondiff' , array ( 'siren' => $siren , 'mois' => $tabIdentite [ 'moisOppositionInsee' ])))
if ( $iDb2 -> getLastErrorNum () <> 1062 )
@ 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-11-23 10:24:44 +00:00
}
2010-11-23 15:12:32 +00:00
if ( isset ( $tabIdentite [ 'domiciliataire' ]) && $tabIdentite [ 'domiciliataire' ] == 'oui' && $siren > 1000 )
{
if ( ! $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 , NOW () as dateInsert
FROM jo . etablissements WHERE siren = $siren ; " , false))
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , " Erreur lors de l'inscription comme entreprise de domiciliation : " . EOL . print_r ( $tabIdentite , true ) . EOL . $iDb -> getLastError ());
2010-11-23 10:24:44 +00:00
}
2010-11-23 15:12:32 +00:00
/** Insertion des scores **/
if ( isset ( $tabScores [ 'encours' ]) || isset ( $tabScores [ 'scoreSolv' ]) ||
isset ( $tabScores [ 'scoreDir' ]) || isset ( $tabScores [ 'scoreConf' ]))
{
$tabUpdate = array ();
$setScore = false ;
if ( isset ( $tabScores [ 'encours' ]) && $tabScores [ 'encours' ] <> '' ) { $tabUpdate [ 'encours' ] = $tabScores [ 'encours' ] * 1 ; $setScore = true ; }
if ( isset ( $tabScores [ 'scoreSolv' ]) && $tabScores [ 'scoreSolv' ] <> '' ) { $tabUpdate [ 'scoreSolv' ] = $tabScores [ 'scoreSolv' ] * 1 ; $setScore = true ; }
if ( isset ( $tabScores [ 'scoreDir' ]) && $tabScores [ 'scoreDir' ] <> '' ) { $tabUpdate [ 'scoreDir' ] = $tabScores [ 'scoreDir' ] * 1 ; $setScore = true ; }
if ( isset ( $tabScores [ 'scoreConf' ]) && $tabScores [ 'scoreConf' ] <> '' ) { $tabUpdate [ 'scoreConf' ] = $tabScores [ 'scoreConf' ] * 1 ; $setScore = true ; }
if ( $setScore )
// Mise à jour des Cute Offs
if ( ! $iDb -> update ( 'scores_cutoff' , $tabUpdate , " siren= $siren " ))
if ( ! $iDb -> insert ( 'scores_cutoff' , array_merge ( array ( 'siren' => $siren ,
'dateInsert' => date ( 'Ymd' )), $tabUpdate )))
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' , " ERREUR setInfosEntrep pour $siren " , print_r ( $tabScores , true ) . EOL . $iDb -> getLastError ());
2010-11-23 10:24:44 +00:00
}
2010-11-23 15:12:32 +00:00
/** Insertion du jugement **/
//print_r($tabJugement);die();
if ( isset ( $tabJugement [ 'even' ]) && is_array ( $tabJugement [ 'even' ]) && count ( $tabJugement [ 'even' ]) > 0 )
{
$idAdmin = str_replace ( 'm' , '' , trim ( $tabJugement [ 'admin' ])) * 1 ;
$idMand = str_replace ( 'm' , '' , trim ( $tabJugement [ 'mand' ])) * 1 ;
$idOppo = str_replace ( 'm' , '' , trim ( $tabJugement [ 'oppo' ])) * 1 ;
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
2010-11-23 15:12:32 +00:00
$tabSource = explode ( '_' , $tabJugement [ 'source' ]);
$source =@ $tabSource [ 0 ];
$numJal =@ $tabSource [ 1 ];
$dateSource = WDate :: dateT ( 'd/m/Y' , 'Ymd' , trim ( $tabJugement [ 'dateParution' ])) * 1 ;
if ( $dateSource < 20000101 )
$dateSource = date ( 'YmdHis' );
$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 ;
if ( $montant > 0 && ( $actionsNb > 0 || $actionsMt > 0 )) {
if ( $actionsNb > 0 ) $actionsMt = $montant / $actionsNb ;
elseif ( $actionsMt > 0 ) $actionsNb = $montant / $actionsMt ;
}
$strDir = '' ;
if ( $tabJugement [ 'nouvDir1Fonc' ] * 1 > 0 ) {
$strDir .= $iBodacc -> getFctDir ( $tabJugement [ 'nouvDir1Fonc' ] * 1 ) . ' : ' . $tabJugement [ 'nouvDir1Genre' ] . ' ' . ucwords ( strtolower ( $tabJugement [ 'nouvDir1Pre' ])) . ' ' . strtoupper ( $tabJugement [ 'nouvDir1Nom' ]) . ', domicilié à ' . $tabJugement [ 'nouvDir1Dom' ] . '. ' ;
}
if ( $tabJugement [ 'nouvDir2Fonc' ] * 1 > 0 ) {
$strDir .= $iBodacc -> getFctDir ( $tabJugement [ 'nouvDir2Fonc' ] * 1 ) . ' : ' . $tabJugement [ 'nouvDir2Genre' ] . ' ' . ucwords ( strtolower ( $tabJugement [ 'nouvDir2Pre' ])) . ' ' . strtoupper ( $tabJugement [ 'nouvDir2Nom' ]) . ', domicilié à ' . $tabJugement [ 'nouvDir2Dom' ] . '. ' ;
}
if ( $tabJugement [ 'nouvDir3Fonc' ] * 1 > 0 ) {
$strDir .= $iBodacc -> getFctDir ( $tabJugement [ 'nouvDir3Fonc' ] * 1 ) . ' : ' . $tabJugement [ 'nouvDir3Genre' ] . ' ' . ucwords ( strtolower ( $tabJugement [ 'nouvDir3Pre' ])) . ' ' . strtoupper ( $tabJugement [ 'nouvDir3Nom' ]) . ', domicilié à ' . $tabJugement [ 'nouvDir3Dom' ] . '. ' ;
}
if ( trim ( $tabJugement [ 'nouvAdrCp' ]) <> '' )
$strAdr = stripslashes ( trim ( $tabJugement [ 'nouvAdr' ]) . ', ' . trim ( $tabJugement [ 'nouvAdrCp' ]) . ' ' . trim ( $tabJugement [ 'nouvAdrVille' ]));
else
$strAdr = '' ;
$nic = $tabJugement [ 'nic' ] * 1 ;
$entrep = $this -> iInsee -> getIdentiteLight ( $siren , $nic );
if ( $nic > 0 && $tabJugement [ 'even' ][ 0 ] == 6700 && $entrep [ 'Siege' ] == 0 )
// Radiation d'un établissement
$tabJugement [ 'even' ][ 0 ] = 6600 ;
$tabEven = array ();
for ( $i = 1 ; isset ( $tabJugement [ 'even' ][ $i ]); $i ++ )
$tabEven [] = $tabJugement [ 'even' ][ $i ];
$strEven = implode ( ';' , $tabEven );
$tabUpdate = array (
'strEven' => $strEven ,
'sirenValide' => $this -> iInsee -> valideSiren ( $siren ),
'dateCessationPaiement' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement [ 'datePaie' ])),
'dateEffetFinP' => WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement [ 'dateFinPeriode' ])),
'tribunal' => trim ( $tabJugement [ 'tribunal' ]),
'montant' => $montant ,
'actionsNb' => $actionsNb ,
'inter1type' => 'A' ,
'inter1id' => $idAdmin ,
'inter1nom' => $this -> iInsee -> getMandatairesParId ( $idAdmin ),
'inter2type' => 'M' ,
'inter2id' => $idMand ,
'inter2nom' => $this -> iInsee -> getMandatairesParId ( $idMand ),
'inter3type' => 'O' ,
'inter3id' => $idOppo ,
'inter3nom' => $this -> 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' ],
);
$dateJuge = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabJugement [ 'dateJuge' ]));
$tabInsert = array_merge ( $tabUpdate , array ( 'siren' => $siren ,
'dateJugement' => $dateJuge ,
'typeEven' => $tabJugement [ 'even' ][ 0 ],
'dateSource' => $dateSource ,
));
if ( ! $iDb -> insert ( 'annonces' , array_merge ( $tabInsert , array ( 'dateInsert' => date ( 'YmdHis' ))), true ))
{
if ( ! $iDb -> update ( 'annonces' , $tabUpdate , " siren= $siren AND dateJugement=' $dateJuge ' AND typeEven= " . $tabJugement [ 'even' ][ 0 ], true ))
{
$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
}
2010-11-23 15:12:32 +00:00
/** Insertion de l'actionnaire **/
if ( is_array ( $tabActio ) && trim ( $tabActio [ 'siren' ]) <> '' ) {
// Tableau des actionnaires
//die('Actionnaires:'.print_r($tabActio));
$nom = $pays = $dateMAJ = '' ;
$ppPm = 'P' ;
$pct = trim ( str_replace ( ',' , '.' , $tabActio [ 'pct' ])) * 1 ;
$siren2 = preg_replace ( '/[^0-9]/' , '' , $tabActio [ 'siren' ]);
$entrep2 = $this -> iInsee -> getIdentiteEntreprise ( $siren );
$nom2 = $entrep2 [ 'Nom' ];
$pays2 = $entrep2 [ 'Pays' ];
if ( $pays2 == '' ) $pays2 = 'FRA' ;
if ( substr ( $entrep2 [ 'FJ' ], 0 , 1 ) * 1 <> 1 ) $ppPm = 'M' ;
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren2 );
$nom = $entrep [ 'Nom' ];
$pays = trim ( $entrep [ 'Pays' ]);
if ( $pays == '' ) $pays = 'FRA' ;
if ( trim ( $tabActio [ 'nom' ]) <> '' ) $nom = $tabActio [ 'nom' ];
if ( $tabActio [ 'pays' ] <> 'XXX' ) $pays = $tabActio [ 'pays' ];
if ( trim ( $tabActio [ 'dateMAJ' ]) <> 'JJ/MM/AAAA' && trim ( $tabActio [ 'dateMAJ' ]) <> '' )
$dateMAJ = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabActio [ 'dateMAJ' ]));
if ( $tabActio [ 'majMin' ] == 'maj' ) $majMin = '+' ;
elseif ( $tabActio [ 'majMin' ] == 'min' ) $majMin = '-' ;
else $majMin = '' ;
$tabUpdate = array ( //'Siren1'=> $siren,
'Pmin' => $pct ,
'Pmax' => $pct ,
'MajMin' => $majMin ,
'PpPm' => $ppPm ,
//'Siren2'=> $siren2,
//'RaisonSociale'=> $nom,
//'Pays'=> $pays,
'dateLien' => $dateMAJ ,
);
$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 ')) " );
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 ;
}
$tabInsert2 = array_merge ( $tabUpdate , array ( 'ActionPart' => 2 ),
array ( 'Siren1' => $siren2 ,
'Siren2' => $siren ,
'RaisonSociale' => $nom2 ,
'Pays' => $pays2 ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' )));
$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
}
2010-11-23 15:12:32 +00:00
/** Insertion de la participation
**/
if ( is_array ( $tabParti ) && trim ( $tabParti [ 'siren' ]) <> '' ) {
//die('Participation:'.print_r($tabParti));
$nom = $pays = $dateMAJ = '' ;
$ppPm = 'P' ;
$pct = trim ( str_replace ( ',' , '.' , $tabParti [ 'pct' ])) * 1 ;
$siren2 = preg_replace ( '/[^0-9]/' , '' , $tabParti [ 'siren' ]);
$entrep2 = $this -> iInsee -> getIdentiteEntreprise ( $siren );
$nom2 = $entrep2 [ 'Nom' ];
$pays2 = $entrep2 [ 'Pays' ];
if ( $pays2 == '' ) $pays2 = 'FRA' ;
if ( substr ( $entrep2 [ 'FJ' ], 0 , 1 ) * 1 <> 1 ) $ppPm = 'M' ;
$entrep = $this -> 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' ];
if ( trim ( $tabParti [ 'dateMAJ' ]) <> 'JJ/MM/AAAA' && trim ( $tabParti [ 'dateMAJ' ]) <> '' )
$dateMAJ = WDate :: dateT ( 'd/m/Y' , 'Y-m-d' , trim ( $tabParti [ 'dateMAJ' ]));
if ( $tabParti [ 'majMin' ] == 'maj' ) $majMin = '+' ;
elseif ( $tabParti [ 'majMin' ] == 'min' ) $majMin = '-' ;
else $majMin = '' ;
$tabUpdate = array ( 'Pmin' => $pct ,
'Pmax' => $pct ,
'MajMin' => $majMin ,
'PpPm' => $ppPm ,
'dateLien' => $dateMAJ ,
);
$tabInsert1 = array_merge ( $tabUpdate , array ( 'ActionPart' => 2 ),
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 ')) " );
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 ;
}
$tabInsert2 = array_merge ( $tabUpdate , array ( 'ActionPart' => 1 ),
array ( 'Siren1' => $siren2 ,
'Siren2' => $siren ,
'RaisonSociale' => $nom2 ,
'Pays' => $pays2 ,
'actif' => 1 ,
'source' => 1900 ,
'dateInsert' => date ( 'YmdHis' )));
$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 ;
}
}
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
* @ param InfoDemandeur $infoDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdBilanReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function setCmdBilan ( InfoCommandeBilan $infoCommande , InfoDemandeur $infoDemandeur )
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
* @ param InfoDemandeur $infoDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdActeReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function setCmdActe ( $infoCommande , $infoDemandeur )
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
* @ param InfoDemandeur $infoDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdKbisReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function setCmdKbis ( InfoCommandeKbis $infoCommande , InfoDemandeur $infoDemandeur )
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' ,
'demandeurReference' => $infoDemandeur -> reference ,
'demandeurEmail' => $infoDemandeur -> email ,
'demandeurTel' => $infoDemandeur -> tel ,
'demandeurNom' => $infoDemandeur -> nom ,
'demandeurService' => $infoDemandeur -> service ,
'demandeurSociete' => $infoDemandeur -> societe ,
'demandeurAdresse' => $infoDemandeur -> adresse ,
'demandeurCp' => $infoDemandeur -> cp ,
'demandeurVille' => $infoDemandeur -> ville ,
'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 ;
$cmd -> infoDemandeur = $infoDemandeur ;
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
/**
* Commande de statut association
2010-10-25 07:33:43 +00:00
* @ param InfoCommandeAsso $infoCommande
2010-10-20 13:32:33 +00:00
* @ param InfoDemandeur $infoDemandeur
2010-11-08 11:27:04 +00:00
* @ return CmdAssoReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function setCmdAsso ( $infoCommande , $infoDemandeur ){}
2010-10-20 13:32:33 +00:00
/**
2010-10-25 07:33:43 +00:00
* Renvoi des informations sur une commande association
2010-10-20 13:32:33 +00:00
* @ param string $reference
2010-11-08 11:27:04 +00:00
* @ return CmdAssoReturn
2010-10-20 13:32:33 +00:00
*/
2010-11-08 11:27:04 +00:00
public function getCmdAsso ( $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
* @ param InfoDemandeur $infoDemandeur
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 setCmdPieces ( $infoCommande , $infoDemandeur )
2010-10-25 07:33:43 +00:00
{
2010-11-29 10:35:36 +00:00
$this -> authenticate ();
2010-11-08 11:27:04 +00:00
2010-10-25 07:33:43 +00:00
$error = new ErrorType ();
$ref = new RefCommande ();
2010-11-08 11:27:04 +00:00
2010-10-25 07:33:43 +00:00
if ( ! empty ( $infoCommande -> siren ))
{
//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' ,
'demandeurReference' => $infoDemandeur -> reference ,
'demandeurEmail' => $infoDemandeur -> email ,
'demandeurTel' => $infoDemandeur -> tel ,
'demandeurNom' => $infoDemandeur -> nom ,
'demandeurService' => $infoDemandeur -> service ,
'demandeurSociete' => $infoDemandeur -> societe ,
'demandeurAdresse' => $infoDemandeur -> adresse ,
'demandeurCp' => $infoDemandeur -> cp ,
'demandeurVille' => $infoDemandeur -> 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-10-28 16:23:51 +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
}
}
else
{
$error -> errnum = 0 ;
$error -> errmsg = " Erreur enregistrement commande " ;
}
}
else
{
$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 ;
$cmd -> infoDemandeur = $infoDemandeur ;
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 ();
$infoDemandeur = new InfoDemandeur ();
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 );
$infoDemandeur -> reference = $commande -> demandeurReference ;
$infoDemandeur -> email = $commande -> demandeurEmail ;
$infoDemandeur -> tel = $commande -> demandeurTel ;
$infoDemandeur -> nom = $commande -> demandeurNom ;
$infoDemandeur -> service = $commande -> demandeurService ;
$infoDemandeur -> societe = $commande -> demandeurSociete ;
$infoDemandeur -> adresse = $commande -> demandeurAdresse ;
$infoDemandeur -> cp = $commande -> demandeurCp ;
$infoDemandeur -> ville = $commande -> demandeurVille ;
}
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 ;
$cmd -> infoDemandeur = $infoDemandeur ;
$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 );
$infoDemandeur = new InfoDemandeur ();
$infoDemandeur -> reference = $commande -> demandeurReference ;
$infoDemandeur -> email = $commande -> demandeurEmail ;
$infoDemandeur -> tel = $commande -> demandeurTel ;
$infoDemandeur -> nom = $commande -> demandeurNom ;
$infoDemandeur -> service = $commande -> demandeurService ;
$infoDemandeur -> societe = $commande -> demandeurSociete ;
$infoDemandeur -> adresse = $commande -> demandeurAdresse ;
$infoDemandeur -> cp = $commande -> demandeurCp ;
$infoDemandeur -> ville = $commande -> demandeurVille ;
$cmd = new CmdPiecesDetail ();
$cmd -> refCommande = $ref ;
$cmd -> infoCommande = $infoCommande ;
$cmd -> infoDemandeur = $infoDemandeur ;
$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
/**
* Liste des bilans
* @ param string $siren
* @ param string $waldec
* @ param int $idEntreprise
* @ return ListeBilan
*/
2010-10-25 07:33:43 +00:00
public function getListeBilan ( $siren , $waldec = null , $idEntreprise = null ){}
2010-10-20 13:32:33 +00:00
/**
* Liste des actes
* @ param string $siren
* @ return ListeActe
*/
2010-10-25 07:33:43 +00:00
public function getListeActe ( $siren ){}
/**
* 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 ();
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 " ,
true , MYSQL_ASSOC
);
$tabRep = $rep [ 0 ];
if ( count ( $rep ) > 0 )
{
$timeOutSec = $tabRep [ 'timeout' ] * 60 ;
if ( $timeOutSec == 0 ) $timeOutSec = 1800 ;
$rep = array (
'login' => $login ,
'id' => $tabRep [ 'id' ],
'email' => $tabRep [ 'email' ],
'typeCompte' => $tabRep [ 'typeCompte' ],
'idClient' => $tabRep [ 'idClient' ],
'filtre_ip' => $tabRep [ 'filtre_ip' ],
'civilite' => $tabRep [ 'civilite' ],
'nom' => $tabRep [ 'nom' ],
'prenom' => $tabRep [ 'prenom' ],
'raisonSociale' => $tabRep [ 'raisonSociale' ],
'siret' => $tabRep [ 'siret' ],
'adrNum' => $tabRep [ 'adrNum' ],
'adrIndRep' => $tabRep [ 'adrIndRep' ],
'adrTypeVoie' => $tabRep [ 'adrTypeVoie' ],
'adrLibVoie' => $tabRep [ 'adrLibVoie' ],
'adrCp' => $tabRep [ 'adrCp' ],
'adrVille' => $tabRep [ 'adrVille' ],
'adrComp' => $tabRep [ 'adrComp' ],
'tel' => $tabRep [ 'tel' ],
'fax' => $tabRep [ 'fax' ],
'mobile' => $tabRep [ 'mobile' ],
'pref' => $tabRep [ 'pref' ],
'profil' => $tabRep [ 'profil' ],
'dateInscription' => $tabRep [ 'dateInscription' ],
'dateValidation' => $tabRep [ 'dateValidation' ],
'nombreConnexions' => $tabRep [ 'nombreConnexions' ],
'dateDerniereConnexion' => $tabRep [ 'dateDerniereConnexion' ],
'droits' => $tabRep [ 'droits' ],
'droitsClients' => $tabRep [ 'droitsClients' ],
'timeout' => $timeOutSec ,
'nbReponses' => $tabRep [ 'nbReponses' ],
'formatMail' => $tabRep [ 'formatMail' ],
'reference' => $tabRep [ 'referenceParDefaut' ],
'dateDebutCompte' => $tabRep [ 'dateDebutCompte' ],
'dateFinCompte' => $tabRep [ 'dateFinCompte' ],
'maxFicheId' => $tabRep [ 'maxFicheId' ],
);
2010-11-25 09:11:42 +00:00
$tabTmp = $iDbCrm -> select ( 'clients' , 'typeScore' , 'id=' . $tabRep [ 'idClient' ], true , 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
* @ param array $tabInfoUserWS
* @ return SetInfosLoginReturn
2010-11-23 10:24:44 +00:00
*/
2010-11-23 14:27:11 +00:00
public function setInfosLogin ( $login , $tabInfoUserWS )
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 ;
if ( $tabInfoUserWS [ 'delete' ] == 1 &&
( $this -> tabInfoUser [ 'profil' ] == 'Administrateur' ||
$this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) )
{
$tabUpdate = array ( 'deleted' => 1 );
}
elseif ( isset ( $tabInfoUserWS [ 'actif' ]) && $tabInfoUserWS [ 'actif' ] == 0 &&
( $this -> tabInfoUser [ 'profil' ] == 'Administrateur' ||
$this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) )
{
$tabUpdate = array ( 'actif' => 0 );
}
elseif ( isset ( $tabInfoUserWS [ 'actif' ]) && $tabInfoUserWS [ 'actif' ] == 1 &&
( $this -> tabInfoUser [ 'profil' ] == 'Administrateur' ||
$this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) )
{
$tabUpdate = array ( 'actif' => 1 );
}
else
{
$strPrefs = @ implode ( ' ' , $tabInfoUserWS [ 'pref' ]);
$strDroits = @ implode ( ' ' , $tabInfoUserWS [ 'droits' ]);
$tabUpdate = array ();
2010-11-23 10:24:44 +00:00
if ( isset ( $tabInfoUserWS [ 'email' ])) $tabUpdate [ 'email' ] = stripslashes ( $tabInfoUserWS [ 'email' ]);
if ( isset ( $tabInfoUserWS [ 'tel_fix' ])) $tabUpdate [ 'tel' ] = stripslashes ( $tabInfoUserWS [ 'tel_fix' ]);
if ( isset ( $tabInfoUserWS [ 'tel_fax' ])) $tabUpdate [ 'fax' ] = stripslashes ( $tabInfoUserWS [ 'tel_fax' ]);
if ( isset ( $tabInfoUserWS [ 'tel_mob' ])) $tabUpdate [ 'mobile' ] = stripslashes ( $tabInfoUserWS [ 'tel_mob' ]);
if ( isset ( $tabInfoUserWS [ 'rech_nbrep' ])) $tabUpdate [ 'nbReponses' ] = $tabInfoUserWS [ 'rech_nbrep' ];
if ( isset ( $tabInfoUserWS [ 'formatMail' ])) $tabUpdate [ 'formatMail' ] = $tabInfoUserWS [ 'formatMail' ];
if ( isset ( $tabInfoUserWS [ 'pref' ])) $tabUpdate [ 'pref' ] = $strPrefs ;
if ( isset ( $tabInfoUserWS [ 'changepwd' ]) && $tabInfoUserWS [ 'changepwd' ] == 1 &&
isset ( $tabInfoUserWS [ 'password' ]) && trim ( $tabInfoUserWS [ 'password' ]) <> '' )
$tabUpdate [ 'password' ] = stripslashes ( $tabInfoUserWS [ 'password' ]);
if ( $tabInfoUser [ 'profil' ] == 'Administrateur' || $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' ) {
$tabUpdate [ 'droits' ] = $strDroits ;
if ( isset ( $tabInfoUserWS [ 'nom' ])) $tabUpdate [ 'nom' ] = stripslashes ( $tabInfoUserWS [ 'nom' ]);
if ( isset ( $tabInfoUserWS [ 'prenom' ])) $tabUpdate [ 'prenom' ] = stripslashes ( $tabInfoUserWS [ 'prenom' ]);
if ( isset ( $tabInfoUserWS [ 'reference' ])) $tabUpdate [ 'referenceParDefaut' ] = stripslashes ( $tabInfoUserWS [ 'reference' ]);
}
}
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
2010-11-23 14:27:11 +00:00
if ( $tabInfoUserWS [ 'action' ] == 'new' )
{
2010-11-23 10:24:44 +00:00
$tabUpdate [ 'login' ] = $login ;
$tabUpdate [ 'idClient' ] = $tabInfoUserWS [ 'idClient' ];
2010-11-25 09:11:42 +00:00
if ( $iDbCrm -> insert ( 'utilisateurs' , $tabUpdate ))
2010-11-23 14:27:11 +00:00
{
$result = true ;
}
2010-11-23 10:24:44 +00:00
else
2010-11-23 14:27:11 +00:00
{
$error -> errnum = 1 ;
$error -> errmsg = 'Création impossible' ;
}
2010-11-23 10:24:44 +00:00
}
2010-11-25 09:11:42 +00:00
if ( $iDbCrm -> update ( 'utilisateurs' , $tabUpdate , " login=' $login ' " ))
2010-11-23 14:27:11 +00:00
{
$result = true ;
}
2010-11-23 10:24:44 +00:00
else
2010-11-23 14:27:11 +00:00
{
$error -> errnum = 1 ;
$error -> errmsg = 'Mise a jour impossible' ;
}
$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' ||
$this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' )
{
/** 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' ;
}
else
{
$last_i = preg_replace ( " / \ D/ " , '' , $rep [ 0 ][ 'login' ]) * 1 ;
$racine .= $last_i + 1 ;
}
$result = new NextLoginResult ();
$result -> racine = $racine ;
$result -> idClient = $idClient ;
$result -> droitsClients = $droitsClients ;
}
else
{
$error -> errnum = 0 ;
$error -> errmsg = 'Acces non authorisé!' ;
}
$output = new NextLoginReturn ();
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 = '' ;
$error = new ErrorType ();
if ( $id <> 0 ) { $ref2 = '' . $id . '/' . $ref ; }
else { $ref2 = $ref ; }
wsLog ( $page , $siret , $ref2 );
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
* @ param array $tabInfos Tableau des informations sur le mandataire à créer ou à ajouter ( ajout si id absent )
* @ return SetMandataireReturn
2010-11-23 10:24:44 +00:00
**/
2010-11-23 11:38:19 +00:00
public function setMandataire ( $tabInfos = array ())
{
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__ );
2010-11-23 11:38:19 +00:00
$type = substr ( strtoupper ( $tabInfos [ 'type' ]), 0 , 1 );
$stag = substr ( strtoupper ( $tabInfos [ 'type' ]), 1 , 1 );
if ( $stag == 'S' ) { $stag = 1 ; } else { $stag = 0 ; }
if ( $type == 'A' || $type == 'H' || $type == 'M' || $type == 'V' ||
$type == 'N' || $type == 'T' )
{
$tabUpdate = array (
'sirenGrp' => substr ( $tabInfos [ 'sirenGrp' ], 0 , 9 ) * 1 ,
'nicGrp' => substr ( $tabInfos [ 'sirenGrp' ], 9 , 5 ) * 1 ,
'sirenMand' => substr ( $tabInfos [ 'sirenMand' ], 0 , 9 ) * 1 ,
'nicMand' => substr ( $tabInfos [ 'sirenMand' ], 9 , 5 ) * 1 ,
'Nom' => ucwords ( strtolower ( $tabInfos [ 'Nom' ])),
'Prenom' => ucwords ( strtolower ( $tabInfos [ 'Prenom' ])),
'type' => $type ,
'stagiaire' => $stag ,
'coursAppel' => $tabInfos [ 'coursAppel' ] * 1 ,
'coursAppel2' => $tabInfos [ 'coursAppel2' ] * 1 ,
'tribunal' => $tabInfos [ 'tribunal' ],
'Statut' => strtoupper ( $tabInfos [ 'Statut' ]),
'adresse' => ucwords ( $tabInfos [ 'adresse' ]),
'adresseComp' => strtoupper ( $tabInfos [ 'adresseComp' ]),
'cp' => $tabInfos [ 'cp' ] * 1 ,
'ville' => strtoupper ( $tabInfos [ 'ville' ]),
'tel' => $tabInfos [ 'tel' ],
'fax' => $tabInfos [ 'fax' ],
'email' => $tabInfos [ 'email' ],
'web' => $tabInfos [ 'web' ],
'contact' => $tabInfos [ 'contact' ],
'idUser' => $idUser ,
);
2010-11-23 10:24:44 +00:00
}
2010-11-23 11:38:19 +00:00
$id = str_replace ( 'm' , '' , '' . $tabInfos [ 'id' ]) * 1 ;
if ( isset ( $tabInfos [ 'id' ]) && $id > 0 )
{
2010-11-23 10:24:44 +00:00
// MAJ
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 ;
}
}
else
{
2010-11-23 10:24:44 +00:00
// Insertion
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' ),
'idSuppr' => $tabInfoUser [ 'id' ]),
" 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
$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 ();
$tabTmp = $this -> iInsee -> getMandataires ( array ( $iBodacc -> getTribunalIdCA ( $codeTribunal )), true , $type );
}
elseif ( $codeTribunal * 1 == 0 )
{
2010-11-23 10:24:44 +00:00
// On veut tous les mandataires
2010-11-23 15:29:01 +00:00
$tabTmp = $this -> iInsee -> getMandataires ( array (), true , $type );
}
elseif ( is_array ( $codeTribunal ))
{
2010-11-23 10:24:44 +00:00
// On veut les mandataires d'une CA
2010-11-23 15:29:01 +00:00
$tabTmp = $this -> 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
2010-11-15 14:17:19 +00:00
/**
* Enter description here ...
* @ param string $siret
* @ param string $type
* @ param string $codeInsee
* @ return ListeCompetencesReturn
*/
public function getListeCompetences ( $siret , $type , $codeInsee )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-15 14:17:19 +00:00
//Initialisation
$error = new ErrorType ();
$type = strtolower ( $type );
debugLog ( 'I' , " Liste des compétences $type demandée pour la commune $codeInsee " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$iBodacc = new MBodacc ();
$cp = $codeInsee * 1 ;
$dep = false ;
if ( substr ( $codeInsee , 0 , 2 ) == '2A' || substr ( $codeInsee , 0 , 2 ) == '2B' )
{
$dep = 20 ; $cp = 20000 + ( substr ( $codeInsee , 2 , 3 )) * 1 ;
}
elseif ( $cp > 0 && $cp < 100 ) $dep = $cp ;
elseif ( $cp > 970 && $cp < 977 ) $dep = $cp ;
elseif ( $cp > 999 && $cp < 10000 ) $dep = '0' . substr ( $cp , 0 , 1 );
elseif ( $cp >= 10000 && $cp < 96000 ) $dep = substr ( $cp , 0 , 2 );
elseif ( $cp >= 99000 ) $dep = substr ( $cp , 0 , 2 );
elseif ( $cp >= 98000 ) $dep = substr ( $cp , 0 , 3 );
elseif ( $cp >= 97100 && $cp < 97700 ) $dep = substr ( $cp , 0 , 3 );
if ( $type == 'pre' )
{
$iDb = new WDB ( 'jo' );
$tabTmp2 = $iDb -> select ( 'villes' , 'DEP, COM, AR, CT' , 'codeInsee=' . $codeInsee , false , MYSQL_ASSOC );
$arrond = $tabTmp2 [ 0 ][ 'AR' ];
unset ( $iDb );
$iDb = new WDB ( 'insee' );
$tabTmp2 = $iDb -> select ( 'insee_tabArrond' , 'CHEFLIEU, ARTMAJ, NCC' , " DEP=' $dep ' AND AR=' $arrond ' " , false , MYSQL_ASSOC );
$nomSousPref = trim ( strtr ( $tabTmp2 [ 0 ][ 'ARTMAJ' ], array ( '(' => '' , ')' => '' , ' ' => '' , " ' " => '' )) . ' ' . $tabTmp2 [ 0 ][ 'NCC' ]);
unset ( $iDb );
$tabTmp = $iBodacc -> getTribunauxParDep ( $dep );
foreach ( $tabTmp as $i => $tribunal )
{
if ( $tribunal [ 'triType' ] == 'A' || $tribunal [ 'triType' ] == 'B' )
{
$pref = levenshtein ( $tribunal [ 'triNom' ], 'PREFECTURE DE ' . $nomSousPref );
$spref = levenshtein ( $tribunal [ 'triNom' ], 'SOUS PREFECTURE DE ' . $nomSousPref );
if ( $tribunal [ 'triType' ] == 'B' && ( $pref > 7 || $spref > 5 )) continue ;
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => $tribunal [ 'triId' ],
'IdSup' => $tribunal [ 'triIdSup' ],
'Code' => $tribunal [ 'triCode' ],
'Type' => $tribunal [ 'triType' ] . $typeP ,
'Nom' => strtoupper ( $tribunal [ 'triNom' ]),
'Siret' => $tribunal [ 'triSiret' ],
'Adr' => strtoupper ( preg_replace ( '/ +/' , ' ' , $tribunal [ 'triAdrNum' ] . ' ' . $tribunal [ 'triAdrIndRep' ] . ' ' .
$tribunal [ 'triAdrTypeVoie' ] . ' ' . $tribunal [ 'triAdrVoie' ])),
'AdrComp' => strtoupper ( $tribunal [ 'triAdrComp' ]),
'CP' => $tribunal [ 'triCP' ],
'Ville' => strtoupper ( $tribunal [ 'triVille' ]),
'CodeInsee' => $tribunal [ 'CodeInsee' ],
'Tel' => $tribunal [ 'triTel' ],
'Fax' => $tribunal [ 'triFax' ],
'Web' => $tribunal [ 'triWeb' ],
'Mail' => $tribunal [ 'triMail' ],
'Statut' => $tribunal [ 'triStatut' ],
'DateCessation' => $tribunal [ 'triDateCessation' ],
'Remarque' => $tribunal [ 'triCommentaire' ],
), 'Competence' );
$tabRet [ $i ] = $competence ;
}
}
}
elseif ( $type == 'jal' )
{
$tabTmp = $iBodacc -> getJALparDep ( $dep );
foreach ( $tabTmp as $i => $comp )
{
$infos = '' ;
if ( trim ( $comp [ 'parution' ]) <> '' ) $infos .= 'Parution ' . $comp [ 'parution' ] . '. ' ;
if ( trim ( $comp [ 'aboAnnuel' ]) > 0 ) $infos .= 'Abonnement Annuel : ' . $comp [ 'aboAnnuel' ] . ' euros. ' ;
if ( trim ( $comp [ 'infos' ]) <> '' ) $infos .= $comp [ 'infos' ];
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => 9000 + $comp [ 'id' ] * 1 ,
'IdSup' => 0 ,
'Code' => '' ,
'Type' => '' ,
'Nom' => strtoupper ( $comp [ 'nomJal' ]),
'Siret' => '' ,
'Adr' => strtoupper ( $comp [ 'adresse' ]),
'AdrComp' => '' ,
'CP' => $comp [ 'cp' ],
'Ville' => strtoupper ( $comp [ 'ville' ]),
'CodeInsee' => '' ,
'Tel' => $comp [ 'tel' ],
'Fax' => $comp [ 'fax' ],
'Web' => $comp [ 'siteWeb' ],
'Mail' => $comp [ 'email' ],
'Statut' => 'Actif' ,
'DateCessation' => '' ,
'Remarque' => trim ( $infos ),
), 'Competence' );
$tabRet [ $i ] = $competence ;
}
}
elseif ( $type == 'tri' || $type == 'adm' || $type == 'hui' )
{
$tabTmp = $iBodacc -> getTribunauxParCommune ( $codeInsee );
foreach ( $tabTmp as $i => $tribunal )
{
if ( //$tribunal['triType']=='C' ||
$tribunal [ 'triType' ] == 'G' // ||
/*$tribunal['triType']=='I'*/ ) {
$idCA = $tribunal [ 'triIdSup' ];
$codeTGI = $tribunal [ 'triCode' ];
$code = strtoupper ( substr ( $tribunal [ 'triCode' ], 0 , 3 ));
}
debugLog ( 'D' , " Liste des compétences $type demandée pour la commune $codeInsee ( $dep ) : " .
" Type= " . $tribunal [ 'triType' ] . ', ' .
" Code= " . $tribunal [ '$codeTGI' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $tribunal [ 'triType' ] <> 'E' && $tribunal [ 'triType' ] <> 'O' &&
$tribunal [ 'triType' ] <> 'T' && $tribunal [ 'triType' ] <> 'R' &&
$tribunal [ 'triType' ] <> 'N' && $tribunal [ 'triType' ] <> 'U' &&
$tribunal [ 'triType' ] <> 'Z' )
{
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => $tribunal [ 'triId' ],
'IdSup' => $tribunal [ 'triIdSup' ],
'Code' => $tribunal [ 'triCode' ],
'Type' => $tribunal [ 'triType' ],
'Nom' => strtoupper ( $tribunal [ 'triNom' ]),
'Siret' => $tribunal [ 'triSiret' ],
'Adr' => strtoupper ( preg_replace ( '/ +/' , ' ' , $tribunal [ 'triAdrNum' ] . ' ' . $tribunal [ 'triAdrIndRep' ] . ' ' .
$tribunal [ 'triAdrTypeVoie' ] . ' ' . $tribunal [ 'triAdrVoie' ])),
'AdrComp' => strtoupper ( $tribunal [ 'triAdrComp' ]),
'CP' => $tribunal [ 'triCP' ],
'Ville' => strtoupper ( $tribunal [ 'triVille' ]),
'CodeInsee' => $tribunal [ 'CodeInsee' ],
'Tel' => $tribunal [ 'triTel' ],
'Fax' => $tribunal [ 'triFax' ],
'Web' => $tribunal [ 'triWeb' ],
'Mail' => $tribunal [ 'triMail' ],
'Statut' => $tribunal [ 'triStatut' ],
'DateCessation' => $tribunal [ 'triDateCessation' ],
'Remarque' => $tribunal [ 'triCommentaire' ],
), 'Competence' );
if ( $tribunal [ 'triNumGreffe' ] * 1 > 0 )
{
$competence -> IdentifiantGreffe = $tribunal [ 'triNumGreffe' ];
}
$tabRet [ $i ] = $competence ;
}
}
}
if ( $type == 'adm' )
{
$tabTmp = $this -> iInsee -> getMandataires ( array ( $idCA ), false );
$tabRet = array ();
$nbAff = 0 ;
foreach ( $tabTmp as $i => $tribunal )
{ /** @todo A revoir Debut **/
if ( stripos ( $tribunal [ 'tribunal' ], $code ) !== false ||
stripos ( $tribunal [ 'tribunal' ], 'SAINT' ) !== false )
{
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => $tribunal [ 'id' ],
'IdSup' => $tribunal [ 'sirenGrp' ],
'Code' => $tribunal [ 'tribunal' ] . '/' . $code ,
'Type' => $tribunal [ 'type' ],
'Nom' => $tribunal [ 'Nom' ] . ' ' . $tribunal [ 'Prenom' ],
'Siret' => $tribunal [ 'sirenMand' ],
'Adr' => strtoupper ( $tribunal [ 'adresse' ]),
'AdrComp' => strtoupper ( $tribunal [ 'adresseComp' ]),
'CP' => $tribunal [ 'cp' ],
'Ville' => strtoupper ( $tribunal [ 'ville' ]),
//'CodeInsee'=>$tribunal['CodeInsee'],
'Tel' => $tribunal [ 'tel' ],
'Fax' => $tribunal [ 'fax' ],
'Web' => $tribunal [ 'web' ],
'Mail' => $tribunal [ 'email' ],
'Statut' => $tribunal [ 'Statut' ],
//'DateCessation'=>$tribunal['triDateCessation'],
'Remarque' => $tribunal [ 'contact' ],
), 'Competence' ); //,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
$tabRet [ $i ] = $competence ;
$nbAff ++ ;
}
}
if ( $nbAff == 0 )
{
foreach ( $tabTmp as $i => $tribunal )
{
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => $tribunal [ 'id' ],
'IdSup' => $tribunal [ 'sirenGrp' ],
'Code' => $tribunal [ 'tribunal' ] . '/' . $code ,
'Type' => $tribunal [ 'type' ],
'Nom' => $tribunal [ 'Nom' ] . ' ' . $tribunal [ 'Prenom' ],
'Siret' => $tribunal [ 'sirenMand' ],
'Adr' => strtoupper ( $tribunal [ 'adresse' ]),
'AdrComp' => strtoupper ( $tribunal [ 'adresseComp' ]),
'CP' => $tribunal [ 'cp' ],
'Ville' => strtoupper ( $tribunal [ 'ville' ]),
//'CodeInsee'=>$tribunal['CodeInsee'],
'Tel' => $tribunal [ 'tel' ],
'Fax' => $tribunal [ 'fax' ],
'Web' => $tribunal [ 'web' ],
'Mail' => $tribunal [ 'email' ],
'Statut' => $tribunal [ 'Statut' ],
//'DateCessation'=>$tribunal['triDateCessation'],
'Remarque' => $tribunal [ 'contact' ],
), 'Competence' ); //,,,,Prenom,,,Statut,,,cp,ville,tel,fax,email,web,contact
$tabRet [ $i ] = $competence ;
}
} /** @todo A revoir Fin : Lier correctement les mandataires à un TI principal **/
}
elseif ( $type == 'hui' )
{
$tabTmp = $this -> iInsee -> getHuissiers ( array ( $codeTGI ), false );
$tabRet = array ();
$nbAff = 0 ;
foreach ( $tabTmp as $i => $tribunal )
{
$adr = $this -> iInsee -> structureVoie ( $tribunal [ 'adresse' ]);
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => $tribunal [ 'id' ],
'IdSup' => $tribunal [ 'sirenGrp' ],
'Code' => $tribunal [ 'tribunal' ] . '/' . $code ,
'Type' => $tribunal [ 'type' ],
'Nom' => $tribunal [ 'Nom' ] . ' ' . $tribunal [ 'Prenom' ],
'Siret' => $tribunal [ 'sirenMand' ],
'Adr' => strtoupper ( $adr [ 'num' ] . ' ' . $adr [ 'adr_btq' ] . ' ' .
$adr [ 'typeVoie' ] . ' ' . $adr [ 'libVoie' ]),
'AdrComp' => strtoupper ( $tribunal [ 'adresseComp' ]),
'CP' => $adr [ 'cp' ],
'Ville' => strtoupper ( $tribunal [ 'ville' ]),
//'CodeInsee'=>$tribunal['CodeInsee'],
'Tel' => $tribunal [ 'tel' ],
'Fax' => $tribunal [ 'fax' ],
'Web' => $tribunal [ 'web' ],
'Mail' => $tribunal [ 'email' ],
'Statut' => $tribunal [ 'Statut' ],
//'DateCessation'=>$tribunal['triDateCessation'],
'Remarque' => strtr ( $tribunal [ 'contact' ],
array ( '<br/>' => ', ' , '<br>' => ', ' ,
'<br />' => ', ' ,
)),
), 'Competence' );
$tabRet [ $i ] = $competence ;
}
$nbComp = count ( $tabTmp );
debugLog ( 'I' , " $nbComp compétences $type trouvées pour le tribunal $codeTGI " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
elseif ( $type == 'cfe' )
{
$tabTmp = $iBodacc -> getTribunauxParCommune ( $codeInsee );
foreach ( $tabTmp as $i => $tribunal )
{
if ( $tribunal [ 'triType' ] == 'C' || $tribunal [ 'triType' ] == 'O' ||
$tribunal [ 'triType' ] == 'T' || $tribunal [ 'triType' ] == 'R' ||
$tribunal [ 'triType' ] == 'N' || $tribunal [ 'triType' ] == 'U' ||
$tribunal [ 'triType' ] == 'Z' )
{
if ( strlen ( $tribunal [ 'triCommentaire' ]) == 32 &&
strpos ( $tribunal [ 'triCommentaire' ], ' ' ) === false )
$remarque = '' ;
else $remarque = prepareString ( $tribunal [ 'triCommentaire' ]);
$competence = new Competence ();
$competence = arrayToClass ( array (
'Id' => $tribunal [ 'triId' ],
'IdSup' => $tribunal [ 'triIdSup' ],
'Code' => $tribunal [ 'triCode' ],
'Type' => $tribunal [ 'triType' ],
'Nom' => strtoupper ( $tribunal [ 'triNom' ]),
'Siret' => $tribunal [ 'triSiret' ],
'Adr' => strtoupper ( preg_replace ( '/ +/' , ' ' , $tribunal [ 'triAdrNum' ] . ' ' . $tribunal [ 'triAdrIndRep' ] . ' ' .
$tribunal [ 'triAdrTypeVoie' ] . ' ' . $tribunal [ 'triAdrVoie' ])),
'AdrComp' => strtoupper ( $tribunal [ 'triAdrComp' ]),
'CP' => $tribunal [ 'triCP' ],
'Ville' => strtoupper ( $tribunal [ 'triVille' ]),
'CodeInsee' => $tribunal [ 'CodeInsee' ],
'Tel' => $tribunal [ 'triTel' ],
'Fax' => $tribunal [ 'triFax' ],
'Web' => $tribunal [ 'triWeb' ],
'Mail' => $tribunal [ 'triMail' ],
'Statut' => $tribunal [ 'triStatut' ],
'DateCessation' => $tribunal [ 'triDateCessation' ],
'Remarque' => $remarque ,
), 'Competence' );
$tabRet [ $i ] = $competence ;
}
}
}
wsLog ( 'competences' , $siret , $type . '/' . $codeInsee );
$result = new ListeCompetencesResult ();
$result -> nbReponses = count ( $tabRet );
$result -> liste = $tabRet ;
$output = new ListeCompetencesReturn ();
$output -> error = $error ;
$output -> result = $result ;
/* Zend_Registry :: get ( 'WsLogger' )
-> info ( __FUNCTION__ . ' - ' . print_r ( $output , 1 )); */
return $output ;
}
2010-11-15 16:02:55 +00:00
/**
* Retourne la liste des banques connues pour une entreprise
* @ param string $siren Siren de l ' entreprise
* @ return BanquesReturn
**/
public function getBanques ( $siren )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-15 16:02:55 +00:00
//Initialisation
$error = new ErrorType ();
$iDb = new WDB ( 'sdv1' );
$tabRet = array ();
debugLog ( 'I' , " Liste des banques demandée pour siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( $siren * 1 > 1000 )
{
$res = $iDb -> select ( 'banques' , 'codeBanque, codeGuichet, libBanqueGuichet, precis, dateSource*1 AS dateSource' , " siren= $siren " , false , MYSQL_ASSOC );
$tmp = $iDb -> select ( 'fedRib' , " codeBanque, codeGuichet, CONCAT(libBanque,' ',libGuichet) AS libBanqueGuichet, 0 AS precis, IF (dateInfo='0000-00-00', dateDispo*1, dateInfo*1) AS dateSource " , " siren= $siren " , false , MYSQL_ASSOC );
$res = array_merge ( $res , $tmp );
foreach ( $res as $tabBanque )
{
$dateSource = $tabBanque [ 'dateSource' ];
$codBanque = $tabBanque [ 'codeBanque' ];
$codGuichet = $tabBanque [ 'codeGuichet' ];
$libBanque = trim ( $tabBanque [ 'libBanqueGuichet' ]);
$found = false ;
$adrBanque1 = $adrBanque2 = $adrBanqueCP = $adrBanqueVille = '' ;
if ( $codBanque > 0 && $codGuichet > 0 &&
$dateSource > ( date ( 'Y' ) - 4 ) * 10000 + 101 &&
$dateSource < date ( 'Ymd' ))
{
$tmp = $iDb -> select ( 'insee.BDF_Etabs b, insee.BDF_Guichets g' , 'g.bdfFibCodeEtab AS banque, g.bdfFibCodeGuichet AS guichet, b.bdfFibDenom40 AS nomBanque, b.bdfFibDenom10 AS sigleBanque, g.bdfFibDenom20 AS nomGuichet, g.bdfFibAdresse1 AS adresse1, g.bdfFibAdresse2 AS adresse2, g.bdfFibAdresse3 AS adresse3, g.CP, g.Ville' , " g.bdfFibCodeEtab= $codBanque AND g.bdfFibCodeGuichet= $codGuichet AND b.bdfFibCodeEtab=g.bdfFibCodeEtab " , false , MYSQL_ASSOC );
if ( isset ( $tmp [ 0 ]))
{
$libBanque = trim ( $tmp [ 0 ][ 'nomBanque' ] . ' ' . $tmp [ 0 ][ 'nomGuichet' ]);
$adrBanque1 = $tmp [ 0 ][ 'adresse1' ];
$adrBanque2 = trim ( $tmp [ 0 ][ 'adresse2' ] . ' ' . $tmp [ 0 ][ 'adresse3' ]);
$adrBanqueCP = $tmp [ 0 ][ 'CP' ];
$adrBanqueVille = $tmp [ 0 ][ 'Ville' ];
$found = true ;
};
}
if ( ! $found && $codBanque > 0 &&
$dateSource > ( date ( 'Y' ) - 4 ) * 10000 + 101 &&
$dateSource < date ( 'Ymd' ))
{
$tmp = $iDb -> select ( 'insee.BDF_Etabs' , " bdfFibCodeEtab AS banque, '' AS guichet, bdfFibDenom40 AS nomBanque, '' AS nomGuichet, '' AS adresse1, '' AS adresse2, '' AS adresse3, '' AS CP, '' AS Ville " , " bdfFibCodeEtab= $codBanque " , false , MYSQL_ASSOC );
if ( isset ( $tmp [ 0 ]))
{
$libBanque = trim ( $tmp [ 0 ][ 'nomBanque' ] . ' ' . $tmp [ 0 ][ 'nomGuichet' ]);
$adrBanque1 = $tmp [ 0 ][ 'adresse1' ];
$adrBanque2 = trim ( $tmp [ 0 ][ 'adresse2' ] . ' ' . $tmp [ 0 ][ 'adresse3' ]);
$adrBanqueCP = $tmp [ 0 ][ 'CP' ];
$adrBanqueVille = $tmp [ 0 ][ 'Ville' ];
} else continue ;
} else continue ;
$banque = new Banque ();
$banque -> codeBanque = $codBanque ;
$banque -> codeGuichet = $codGuichet ;
$banque -> libBanque = $libBanque ;
$banque -> adresse1 = $adrBanque1 ;
$banque -> adresse2 = $adrBanque2 ;
$banque -> ville = $adrBanqueCP ;
$banque -> cp = $adrBanqueCP ;
$banque -> ville = $adrBanqueVille ;
$tabRet [] = $banque ;
}
}
else
{
$error -> errnum = 75454698 ;
$error -> errmsg = 'Siren invalide' ;
}
debugLog ( 'I' , " Liste des banques pour siren $siren : " . count ( $tabRet ) . ' banques' , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-15 14:17:19 +00:00
2010-11-15 16:02:55 +00:00
if ( count ( $tabRet ) == 0 )
{
$error -> errnum = 256454 ;
$error -> errmsg = 'Aucune relation bancaire en base' ;
}
$output = new BanquesReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
}
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 ();
$tabRet = array ();
debugLog ( 'I' , " Liste des conventions demandée pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
if ( strlen ( $siren ) <> 9 )
{
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren Siret inexistant' ;
}
elseif ( $siren * 1 == 0 )
{
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
$tabIdentite = $this -> iInsee -> getIdentiteEntreprise ( $siren );
if ( empty ( $tabIdentite ) && isset ( $tabIdentite [ 'erreur' ]) &&
$tabIdentite [ 'erreur' ] <> '' )
{
debugLog ( 'W' , " Siren $siren non présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
$naf = $tabIdentite [ 'NafEnt' ];
$trancheEffectif = $tabIdentite [ 'EffEnTr' ];
$effectif = $tabIdentite [ 'Effectif' ];
$fj = $tabIdentite [ 'entreprise' ][ 'FJCodeEntrep' ];
$isolv = new MSolvabilite ( $siren , $naf , $trancheEffectif , $effectif , $tabIdentite [ 'CP' ], $fj , $tabIdentite [ 'Capital' ],
$tabIdentite [ 'CapitalDev' ], $tabIdentite [ 'DateCreaEn' ], $tabIdentite [ 'DateCreaEt' ]); //, $tabIdentite['Singularite']);
$noteStructure = $isolv -> getSolvabilite ();
$naf4 = $isolv -> getNaf4 ( $naf );
$tabTmp = $this -> iInsee -> listeConventions ( $naf4 , $tabIdentite [ 'Dept' ]);
foreach ( $tabTmp as $i => $conv )
{
$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' ];
$tabRet [ $i ] = $convention ;
}
wsLog ( 'conventions' , $siren );
}
}
$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 ;
if ( $this -> tabInfoUser [ 'idClient' ] <> 1 )
{
$error -> errnum = 1 ;
$error -> errmsg = 'Code Client Incorrect' ;
}
else
{
$siren = substr ( $siret , 0 , 9 ) * 1 ;
$nic = substr ( $siret , 9 , 5 ) * 1 ;
$iDb = new WDB ();
$idAnn = preg_replace ( '/^0\./' , '' , '' . $idAnn ) * 1 ;
if ( $idAnn > 0 && $siren > 1000 )
{
$res = $iDb -> select ( 'annonces' , '*' , " id= $idAnn " , false , MYSQL_ASSOC );
if ( count ( $res ) == 0 )
{
$error -> errnum = 1 ;
$error -> errmsg = 'Annonce inexistante' ;
}
else
{
$annonce = $res [ 0 ];
unset ( $annonce [ 'id' ]);
$annonce [ 'siren' ] = $siren ;
$annonce [ 'nic' ] = $nic ;
if ( $iDb -> insert ( 'annonces' , $annonce , false ))
{
debugLog ( 'I' , " Duplication de l'annonce collectée n° $idAnn sur $siret " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$result = 1 ;
}
else
{
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 ();
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
if ( $this -> tabInfoUser [ 'idClient' ] <> 1 )
{
$error -> errnum = 0 ;
$error -> errmsg = 'Code Client Incorrect' ;
}
else
{
$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' ];
$tabEven = array ();
foreach ( $ann [ 'typeEven' ] as $code => $even )
{
$annonceEvenement = new AnnonceEvenement ();
$annonceEvenement -> codeEven = $code ;
$annonceEvenement -> LibEven = $even ;
$tabEven [] = $annonceEvenement ;
}
foreach ( explode ( ';' , $ann [ 'strEven' ]) as $code => $even )
{
$annonceEvenement = new AnnonceEvenement ();
$annonceEvenement -> codeEven = $code ;
$annonceEvenement -> LibEven = $even ;
$tabEven [] = $annonceEvenement ;
}
$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__ );
$tabTmp = $this -> iInsee -> getDevises ( $codeIsoDevise );
$tabRet = array ();
foreach ( $tabTmp as $i => $devise )
{
$devise = new Devise ();
$devise -> devIso = $i ;
$devise -> devNom = $devise ;
$tabRet [] = $devise ;
}
$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
/**
* Enter description here ...
* @ param string $siren
* @ param int $idDepot
* @ return
*/
2010-11-23 10:24:44 +00:00
protected function getMarques ( $siren , $idDepot = 0 ) {
debugLog ( 'I' , " Liste des marques déposées pour le siren $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$marques = array ();
$iDb = new WDB ();
$res = $iDb -> select ( 'marques' , 'count(*)' , " Siren= $siren AND DATEDIFF(NOW(),dateUpdate)<30 " );
if ( $res [ 0 ][ 0 ] == 0 ||
( $idDepot > 0 && ( ! file_exists ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " ) || filesize ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " ) < 1 ) )
) {
if ( $idDepot == 0 ) $url = " http://www.societe.com/marques/- $siren .html " ;
else $url = " http://www.societe.com/cgi-bin/consultcgi?en= $idDepot " ;
$referer = $cookie = '' ;
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , '' , $referer , false , '' , '' , 21 );
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
if ( $idDepot == 0 ) $fp =@ fopen ( " /tmp/marques- $siren .html " , " a " );
else $fp =@ fopen ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " , " a " );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
$fp =@ fopen ( " /var/www/log/marques.log " , " a " );
@ fwrite ( $fp , date ( 'Y-m-d H:i:s' ) . " ; $siren ; $idDepot ; $duree\n " );
@ fclose ( $fp );
}
if ( $idDepot == 0 ) {
if ( preg_match_all ( '/<tr>.*<td width="80" align="left" height="20" valign="middle">(.*)<\/td>.*<td width="240" align="left" valign="middle" ><a href="(.*)">(.*)<\/a><\/td>.*<td width="80" align="center" valign="middle".*>(.*)<\/td>.*<\/tr>/Uis' , $body , $matches )) {
$fp =@ fopen ( " /tmp/marques- $siren - $date .log " , " a " );
@ fwrite ( $fp , print_r ( $matches , true ));
@ fclose ( $fp );
foreach ( $matches [ 3 ] as $i => $marqueNom ) {
preg_match ( '/\/cgi-bin\/consultcgi\?en=(.*)\'\);"/Uis' , $matches [ 4 ][ $i ], $matches2 );
$lien = $matches2 [ 1 ];
preg_match ( '/\/cgi-bin\/v(?:erif|)cpte\?no=(.*)$/Ui' , $matches [ 2 ][ $i ], $matches2 );
$depot = $matches2 [ 1 ];
$rs = trim ( str_replace ( '(semi-figurative)' , '' , $marqueNom ));
if ( substr ( $rs , - 1 , 1 ) == '.' ) $rs = substr ( $rs , 0 , strlen ( $rs ) - 1 );
$tabUpdate = array ( 'Marques' => $rs ,
'Date' => WDate :: dateT ( 'd-m-Y' , 'Y-m-d' , $matches [ 1 ][ $i ]),
'Depot' => $depot , //$matches[2][$i],
'IdLien' => $lien , // http://www.societe.com/cgi-bin/consultcgi?en= 3173102
);
if ( ! $iDb -> insert ( 'marques' , array_merge ( $tabUpdate , array ( 'Siren' => $siren )), true ))
$iDb -> update ( 'marques' , $tabUpdate , " Siren= $siren AND Depot= $depot " , true );
//$marques[$i]=$tabUpdate;
$marques [ $i ][ 'Marques' ] = prepareString ( $rs );
$marques [ $i ][ 'Date' ] = WDate :: dateT ( 'd-m-Y' , 'Y-m-d' , $matches [ 1 ][ $i ]);
$marques [ $i ][ 'Depot' ] = $depot ;
$marques [ $i ][ 'IdLien' ] = $lien ;
}
}
}
$res = $iDb -> select ( 'marques' , 'Marques,Date,Depot,IdLien, DATEDIFF(NOW(),dateUpdate) AS nbJourLastUpdate' , " Siren= $siren ORDER BY `Date` DESC " );
if ( count ( $res ) > 0 ) {
foreach ( $res as $i => $marque ) {
$marques [ $i ] = array ( 'Marques' => prepareString ( $marque [ 'Marques' ]),
'Date' => prepareString ( $marque [ 'Date' ]),
'Depot' => prepareString ( $marque [ 'Depot' ]),
'IdLien' => prepareString ( $marque [ 'IdLien' ]),
);
if ( $idDepot <> 0 ) {
$marques [ $i ][ 'UrlLien' ] = DOC_WEB_URL . " marques/ $siren - $idDepot .jpg " ;
if ( $marque [ 'IdLien' ] == $idDepot ) {
if ( ! file_exists ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " ) ||
filesize ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " ) < 43 ) {
// $url=;
// filesize("/var/www/site_extranet/www/pdf/acte-$siren-$option.pdf")==0) {
$tdeb = microtime ( true );
$page = getUrl ( " http://www.societe.com/cgi-bin/consultcgi?en= $idDepot " , '' , '' , '' , false , '' , '' , 21 );
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$body = $page [ 'body' ];
$fp =@ fopen ( DOC_WEB_LOCAL . " marques/ $siren - $idDepot .jpg " , 'w' );
@ fwrite ( $fp , $body );
@ fclose ( $fp );
$fp =@ fopen ( " /var/www/log/marques.log " , " a " );
@ fwrite ( $fp , date ( 'Y-m-d H:i:s' ) . " ; $siren ; $idDepot ; $duree\n " );
@ fclose ( $fp );
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => array ( end ( $marques )));
}
}
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $marques );
}
wsLog ( 'marques' , $siren );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $marques );
}
/**
* Enter description here ...
* @ param unknown_type $siren
* @ param unknown_type $piece
* @ param unknown_type $type
* @ param unknown_type $visu
* @ param unknown_type $courrier
* @ param unknown_type $ref
* @ throws SoapFault
*/
protected function getPiece ( $siren , $piece = 'kbis' , $type = '' , $visu = 1 , $courrier = 0 , $ref = '' ) {
set_time_limit ( 400 );
$erreur = false ;
if ( file_exists ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ) &&
date ( 'Ymd' , filemtime ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " )) == date ( 'Ymd' ) &&
filesize ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ) > 0 ) {
$size = filesize ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " );
$erreur = false ;
$tabNom = array ();
$ficDist = '' ;
$cache = 1 ;
} else {
exec ( " ./getPieces.php $siren $piece > /dev/null & " );
$ficDist = '' ;
$size = $cache = 0 ;
}
/** On supprimer l'ancien kbis si trop vieux ou vide **/
if ( date ( 'Ymd' , filemtime ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " )) <> date ( 'Ymd' ) ||
filesize ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " ) == 0 )
move ( DOC_WEB_LOCAL . " kbis/ $piece - $siren .pdf " , DOC_WEB_LOCAL . " kbis/ $piece - $siren - " . date ( 'Ymd' ) . " .pdf " );
$tabRet = array ( 'Siren' => $siren ,
'Url' => DOC_WEB_URL . " kbis/ $piece - $siren .pdf " ,
'Taille' => $size ,
'Cache' => $cache ,
'debug' => array ( 'tabNom' => $tabNom , 'tabDir' => $tabDirs ),
'fichier' => $ficDist ,
);
wsLog ( 'kbis' , $siren , " $cache / $visu / $courrier / $type / $ref " );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
/**
2010-11-24 14:22:44 +00:00
* commandeAsso
* @ param string $siren
* @ param array $infoAsso
* @ param array $infoDemande
* @ return CommandeAssoReturn
2010-11-23 10:24:44 +00:00
*/
2010-11-24 14:22:44 +00:00
public function commandeAsso ( $siren , $infoAsso = array (), $infoDemande = array ())
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
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
2010-11-24 14:22:44 +00:00
$idEntreprise = $infoAsso [ 'idEntreprise' ] * 1 ;
$assoNom = $infoAsso [ 'RaisonSociale' ];
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " commandeAsso pour $assoNom ( $siren ) début " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-24 14:22:44 +00:00
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren , 0 , $idEntreprise );
$assoSigle = $tabIdentite [ 'Sigle' ];
$assoAdresse = $tabIdentite [ 'Adresse' ] . EOL . $tabIdentite [ 'Adresse2' ];
$assoCP = $tabIdentite [ 'CP' ];
$assoVille = $tabIdentite [ 'Ville' ];
$mail = trim ( $infoDemande [ 'Email' ]);
if ( $mail == '' ) $mail = $tabInfoUser [ 'email' ];
$tabInsert = array (
'idUser' => $tabInfoUser [ 'id' ],
'source' => 'asso' ,
'login' => $tabInfoUser [ 'login' ],
'emailCommande' => $mail ,
'siren' => $siren ,
'refUtilisateur' => $infoDemande [ 'Ref' ],
'refDocument' => serialize ( $infoDemande ),
'refCommande' => serialize ( $infoAsso ),
'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 ))
{
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' ,
" Commande de statuts association pour $assoNom ( $siren ) " ,
" Association : " . EOL . print_r ( $infoAsso , true ) . EOL . EOL .
" Demandeur: " . EOL . print_r ( $infoDemande , true ) . EOL . EOL .
" 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 );
$result = new CommandeAsso ();
$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 );
wsLog ( 'commandeAsso' , $siren , 'i' . $ret . '-' . DATETIME );
debugLog ( 'I' , " commandeAsso pour $assoNom ( $siren ) fin " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
} else {
2010-11-24 14:22:44 +00:00
@ sendMail ( 'production@scores-decisions.com' , 'ylenaour@scores-decisions.com' ,
" ERREUR lors de lommande de statuts association pour $assoNom ( $siren ) " , " Association : " . EOL . print_r ( $infoAsso , true ) . EOL . EOL .
" Demandeur: " . EOL . print_r ( $infoDemande , true ) . EOL . EOL .
" Réponse RefAsso en $duree secondes : " . EOL . print_r ( $page , true ));
$result = new CommandeAsso ();
$result -> siren = $siren ;
$result -> emailCommande = $mail ;
$result -> dateCommande = DATETIME ;
$result -> refCmd = 'ERREUR' ;
2010-11-23 10:24:44 +00:00
debugLog ( 'E' , " commandeAsso pour $assoNom ( $siren ) fin " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
}
2010-11-24 14:22:44 +00:00
$output = new CommandeAssoReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-24 13:53:15 +00:00
/**
* Commande d 'une enquête sur une entreprise en France ou à l' Internationale
* @ param string $siren
* @ param array $infoEnq
* @ param array $infoDemande
* @ return CommandeEnqueteReturn
2010-11-23 10:24:44 +00:00
**/
2010-11-24 13:53:15 +00:00
public function commandeEnquete ( $siren , $infoEnq = array (), $infoDemande = array ())
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-24 13:53:15 +00:00
//Initialisation
$error = new ErrorType ();
2010-11-23 10:24:44 +00:00
2010-11-24 13:53:15 +00:00
$mail = trim ( $infoDemande [ 'Email' ]);
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 ,
'refDocument' => serialize ( $infoDemande ),
'refCommande' => serialize ( $infoEnq ),
'dateCommande' => DATETIME ,
);
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " commande d'enquete sur $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$messageInfo = print_r ( $infoEnq , 1 ) . EOL . print_r ( $infoDemande , 1 ) . EOL ;
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' ]));
2010-11-23 10:24:44 +00:00
$strInfoCommande = " NOM et Prénom du client demandeur : " . $infoDemande [ 'Identite' ] . EOL ;
$strInfoCommande .= " Email du client demandeur : $mail " . EOL ;
$strInfoCommande .= " Tel/Fax du demandeur : " . $infoDemande [ 'Tel' ] . ' / ' . $infoDemande [ 'Fax' ] . EOL ;
$strInfoCommande .= " Profil du demandeur : " . trim ( $infoDemande [ 'Profil' ] . ' ' . $infoDemande [ 'ProfilAutre' ]) . EOL ;
$typeEnqLog = 'enqueteDemNF' ;
2010-11-24 13:53:15 +00:00
if ( $login == '' ) {
2010-11-23 10:24:44 +00:00
/** Il ne s'agit pas d'un client final, on anonymise la commande **/
$login = 'YLENA' ; // Demandes en test
$pass = 'WYLFE' ;
$nomClient = $strInfoCommande = '' ;
$typeEnqLog = 'enqueteDem' ;
/* 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 = '' ;
$tabPost = array ( 'login' => $login , 'pwd' => $pass );
2010-11-23 10:24:44 +00:00
$tdeb = microtime ( true );
$page = getUrl ( $url , $cookie , $tabPost , $referer , false , '' , '' , 7 );
$tfin = microtime ( true );
$duree = $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
$cookie = $page [ 'header' ][ 'Set-Cookie' ];
$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' ];
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 ];
}
}
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 );
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
2010-11-24 13:53:15 +00:00
" CA : " . $infoEnq [ 'Precisions' ][ 'MontantCA' ] . " \n " .
" Motif de la demande : " . trim ( $infoEnq [ 'Precisions' ][ 'Motif' ] . ' ' . $infoEnq [ 'Precisions' ][ 'Autre' ]) . " \n " .
" Type de la demande : " . $infoEnq [ 'Precisions' ][ 'Type' ] . " \n " .
" Anciennete de la relation : " . $infoEnq [ 'Anciennete' ] . ' ' . $infoEnq [ 'AncienneteDuree' ] . " \n " .
" Observations : " . $infoEnq [ 'Observation' ] . EOL ;
2010-11-23 10:24:44 +00:00
2010-11-24 13:53:15 +00:00
if ( $infoEnq [ 'ImpayeesChoix' ] <> 'non' )
$comment .= " Impayé(s) : " . $infoEnq [ 'Impayees' ][ 'Nombre' ] . " impayé(s) pour un montant de " . $infoEnq [ 'Impayees' ][ 'Montant' ] . " en date du " . $infoEnq [ 'Impayees' ][ 'Date' ] . EOL ;
2010-11-23 10:24:44 +00:00
2010-11-24 13:53:15 +00:00
if ( $infoEnq [ 'RetardPaiementChoix' ] <> 'non' )
$comment .= " Retard(s) de paiement : " . $infoEnq [ 'RetardPaiement' ][ 'Nombre' ] . " retard(s) pour un montant de " . $infoEnq [ 'RetardPaiement' ][ 'Montant' ] . " en date du " . $infoEnq [ 'RetardPaiement' ][ 'Date' ] . EOL ;
2010-11-23 10:24:44 +00:00
2010-11-24 13:53:15 +00:00
if ( $infoEnq [ 'LitigeChoix' ] <> 'non' )
$comment .= " Présence de litige(s) : " . $infoEnq [ 'Litige' ][ 'Precisions' ] . EOL ;
2010-11-23 10:24:44 +00:00
$enqType = 0 ;
$enqDelai = 7 ;
switch ( strtolower ( $infoEnq [ 'Type' ])) {
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é **/
if ( @ trim ( implode ( ' ' , $infoEnq [ 'Entrep' ][ 'Rib' ])) <> '' )
2010-11-24 13:53:15 +00:00
$iDbCrm -> insert ( 'banques' , array (
'siren' => $siren ,
'libBanqueGuichet' => '' ,
'precis' => 1 ,
'codeBanque' => $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Banque' ],
'codeGuichet' => $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Guichet' ],
'numCompte' => $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Compte' ] . $infoEnq [ 'Entrep' ][ 'Rib' ][ 'Cle' ],
'dateSource' => DATETIME ,
), true );
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $siren );
$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' ],
'port' => $infoEnq [ 'Entrep' ][ 'AutreTel' ],
'tel_exp' => $tabInterSud [ 'tel_exp' ],
'bank' => trim ( implode ( ' ' , $infoEnq [ 'Entrep' ][ 'Rib' ])),
'int_enk' => $tabInterSud [ 'int_enk' ], // International ?
'encours' => $infoEnq [ 'Encours' ],
'nb_ech' => $infoEnq [ 'NbEcheances' ],
'delai2_enk' => $tabInterSud [ 'delai2_enk' ], // International ?
'email_exp' => $tabInterSud [ 'email_exp' ],
'cred' => '' ,
'comment' => urlencode ( $comment ),
'val_ret' => 1 ,
);
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 );
$tfin = microtime ( true );
$duree += $tfin - $tdeb ;
$referer = $url ;
$body = $page [ 'body' ];
2010-11-24 13:53:15 +00:00
$result = new CommandeEnquete ();
$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' , 'ylenaour@scores-decisions.com' , " Commande d'enquete sur $siren " , $comment . EOL . EOL . '---------------------------------' . EOL . $messageInfo );
@ 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 );
wsLog ( $typeEnqLog , $siren , 'i' . $ret . '-' . DATETIME );
2010-11-24 13:53:15 +00:00
$output = new CommandeEnqueteReturn ();
$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
* @ return PiecesReturn
*/
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' ;
}
else
{
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
$rep = $iDbCrm -> select ( 'utilisateurs' , 'idClient' , " login=' $login ' " );
2010-11-23 16:44:09 +00:00
$idClient = $rep [ 0 ][ 0 ];
if ( $idClient ==- 1 )
{
$error -> errnum = 1 ;
$error -> errmsg = 'idClient=0' ;
}
else
{
2010-11-25 09:11:42 +00:00
$rep = $iDbCrm -> select ( 'utilisateurs' , 'id, idClient, login, email, actif, nom, prenom, referenceParDefaut' , " idClient=' $idClient ' AND deleted=0 ORDER BY login ASC " , true , MYSQL_ASSOC );
2010-11-23 16:44:09 +00:00
foreach ( $rep as $uti )
{
$utilisateur = new Utilisateur ();
$utilisateur -> idUti = $uti [ 'id' ];
$utilisateur -> idClient = $uti [ 'idClient' ];
$utilisateur -> login = $uti [ 'login' ];
$utilisateur -> email = $uti [ 'email' ];
$utilisateur -> actif = $uti [ 'actif' ];
$utilisateur -> nom = $uti [ 'nom' ];
$utilisateur -> prenom = $uti [ 'prenom' ];
$utilisateur -> reference = $uti [ 'referenceParDefaut' ];
$tabRet [] = $utilisateur ;
}
}
}
$output = new ListeUtilisateursReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-18 16:42:01 +00:00
2010-11-23 11:24:25 +00:00
/**
* Récupère la liste des clients ou les informations d ' un client
* @ param int $idClient
* @ return ListeClientsReturn
*/
public function getListeClients ( $idClient = 0 )
{
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
if ( empty ( $idClient )) $idClient = 0 ;
$error = new ErrorType ();
2010-11-23 10:24:44 +00:00
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' &&
( $idClient == 0 || $idClient == $this -> $tabInfoUser [ 'idClient' ]))
{
$idClient = $this -> tabInfoUser [ 'idClient' ];
$isAuthorized = true ;
}
if ( $this -> tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' )
{
$error -> errnum = 1 ;
$error -> errmsg = 'Profil non administrateur' ;
}
else
{
$isAuthorized = true ;
}
if ( $isAuthorized )
{
$strClient = '' ;
if ( $idClient > 0 ) $strClient .= " AND id=' $idClient ' " ;
2010-11-25 09:11:42 +00:00
$iDbCrm = new WDB ( 'sdv1' );
$rep = $iDbCrm -> select ( 'clients' , 'id, nom, actif, test, racineLogin, siren, nic, tva, editerFacture, fact_detail, fac_dest, fac_adr1, fac_adr2, fac_adr3, fac_email, fac_tel, fact_rib, liv_dest, liv_adr1, liv_adr2, liv_adr3, liv_email, liv_tel, droits, filtres_ip, dateInsert, dateUpdate, respComSD, typeContrat, dateSignature, typeAcces, typeScore, accesPieces, accesKbis, accesInvestigations, accesInternationnal, accesEnquetes, miseSousSurveillance, forfaitExtranetPeriode, forfaitExtranetMontant, reconductionAuto, remarque, forfaitPiecesNb, forfaitPiecesMt, forfaitPiecesDep, forfaitInvestigNb, forfaitInvestigMt, forfaitInvestigDep, tarifIndiscore' , " 1 $strClient " , true , 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' ];
$client -> droits = $uti [ 'droits' ];
$client -> timeout = $uti [ 'timeout' ];
$client -> filtres_ip = $uti [ 'filtres_ip' ];
$client -> dateInsert = $uti [ 'dateInsert' ];
$client -> dateUpdate = $uti [ 'dateUpdate' ];
$client -> respComSD = $uti [ 'respComSD' ];
$client -> typeContrat = $uti [ 'typeContrat' ];
$client -> dateSignature = $uti [ 'dateSignature' ];
$client -> typeAcces = $uti [ 'typeAcces' ];
$client -> typeScore = $uti [ 'typeScore' ];
$client -> accesPieces = $uti [ 'accesPieces' ];
$client -> accesKbis = $uti [ 'accesKbis' ];
$client -> accesInvestigations = $uti [ 'accesInvestigations' ];
$client -> accesInternationnal = $uti [ 'accesInternationnal' ];
$client -> accesEnquetes = $uti [ 'accesEnquetes' ];
$client -> miseSousSurveillance = $uti [ 'miseSousSurveillance' ];
$client -> forfaitExtranetPeriode = $uti [ 'forfaitExtranetPeriode' ];
$client -> forfaitExtranetMontant = $uti [ 'forfaitExtranetMontant' ];
$client -> reconductionAuto = $uti [ 'reconductionAuto' ];
$client -> remarque = $uti [ 'remarque' ];
$client -> forfaitPiecesNb = $uti [ 'forfaitPiecesNb' ];
$client -> forfaitPiecesMt = $uti [ 'forfaitPiecesMt' ];
$client -> forfaitPiecesDep = $uti [ 'forfaitPiecesDep' ];
$client -> forfaitInvestigNb = $uti [ 'forfaitInvestigNb' ];
$client -> forfaitInvestigMt = $uti [ 'forfaitInvestigMt' ];
$client -> forfaitInvestigDep = $uti [ 'forfaitInvestigDep' ];
$client -> tarifIndiscore = $uti [ 'tarifIndiscore' ];
$tabRet [] = $client ;
}
}
$output = new ListeClientsReturn ();
$output -> error = $error ;
$output -> result = $tabRet ;
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' );
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 " , true , MYSQL_ASSOC );
} 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 " , true , MYSQL_ASSOC );
}
$tabRet = $rep ;
2010-11-23 10:24:44 +00:00
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabRet );
}
/** @ nodoc
**
** @ param unknown_type $siren
** @ param unknown_type $niveau
** @ param unknown_type $id
** @ param unknown_type $forceVerif
** @ return unknown
**/
protected function getRapport ( $siren , $niveau = 3 , $id = 0 , $forceVerif = false )
{
$filtre = 0 ;
$idAnn = 0 ;
$accesDist = true ;
if ( $niveau == 1 )
$tabRet = array ( 'getIndiScore' => $this -> getIndiScore ( $siren , 0 , $accesDist ),
);
elseif ( $niveau == 2 )
$tabRet = array ( 'getIdentite' => $this -> getIdentite ( $siren , $id = 0 , $forceVerif ),
'getDirigeants' => $this -> getDirigeants ( $siren , false ),
'getLiens' => $this -> getLiens ( $siren , true ),
'getRatios' => $this -> getRatios ( $siren , $page = " rapport $niveau " ),
'getIndiScore' => $this -> getIndiScore ( $siren , 0 , $accesDist ),
);
elseif ( $niveau == 3 )
$tabRet = array ( 'getIdentite' => $this -> getIdentite ( $siren , $id = 0 , $forceVerif ),
'getDirigeants' => $this -> getDirigeants ( $siren , false ),
'getLiens' => $this -> getLiens ( $siren , true ),
'getRatios' => $this -> getRatios ( $siren , $page = " rapport $niveau " ),
'getIndiScore' => $this -> getIndiScore ( $siren , 0 , $accesDist ),
'getAnnonces' => $this -> getAnnonces ( $siren , $filtre , $idAnn ),
);
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 );
}
2010-11-23 15:29:01 +00:00
/**
2010-11-23 17:18:37 +00:00
* getRatios
* @ param string $siren
* @ param string $page
* @ return RatiosReturn
2010-11-23 15:29:01 +00:00
*/
2010-11-23 17:18:37 +00:00
public function getRatios ( $siren , $page = 'ratios' )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-23 10:24:44 +00:00
2010-11-23 17:18:37 +00:00
//Initialisation
$error = new ErrorType ();
2010-11-23 10:24:44 +00:00
$tabRatiosInfos = $tabRatiosSecteurs = $tabBilansR = $tabRatios2 = $tabRatiosEvol = array ();
2010-11-23 17:18:37 +00:00
$tabRet = array ();
//global $tva, $tabFormules, $mBil, $tabBilan, $efftr;
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , " Liste des Ratios demandée pour $siren " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-23 17:18:37 +00:00
if ( strlen ( $siren ) <> 9 )
{
2010-11-23 10:24:44 +00:00
debugLog ( 'W' , " Siren $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-23 17:18:37 +00:00
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
2010-11-23 10:24:44 +00:00
}
2010-11-23 17:18:37 +00:00
elseif ( $siren * 1 == 0 )
{
2010-11-23 10:24:44 +00:00
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
2010-11-23 17:18:37 +00:00
$error -> errnum = 102 ;
$error -> errmsg = 'Siren inexistant' ;
}
else
{
debugLog ( 'I' , " Liste des Ratios demandée pour $siren avant getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$iInsee = new MInsee ();
$tabIdentite = $iInsee -> getIdentiteEntreprise ( $siren , 0 , 0 , false , false );
debugLog ( 'I' , " Liste des Ratios demandée pour $siren après getIdentiteEntreprise " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$naf = $tabIdentite [ 'NafEnt' ];
$nafLib = $tabIdentite [ 'NafEntLib' ];
$efftr = $tabIdentite [ 'Effectif' ] * 1 ;
$fj = $tabIdentite [ 'FJ' ];
$mBil = new MBilans ( $siren );
$tabBilans = $mBil -> listeBilans ( true );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getRatios sur $siren", print_r($tabBilans, true));
$nbBilans = count ( $tabBilans );
$tabBilan = $tabBil = array ();
if ( $nbBilans > 0 )
$tabRatios =@ calculRatios ( $tabBilans , $tabIdentite , true );
$nbRatios = count ( $tabRatios );
debugLog ( 'I' , " Liste des Ratios demandée pour $siren après calculRatios ( $nbRatios ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
/** Tableau d'infos sur les formules **/
$tabBorneMin = $tabBorneMax = array ();
foreach ( $tabFormules as $formule ) {
$id = $formule [ 'id' ] * 1 ;
$libelle = $formule [ 'libelle' ];
$unite = $formule [ 'unite' ];
$commentaires = $formule [ 'commentaires' ];
// Utilisation d'un index texte à cause du webservice
$tabRatiosInfos [ 'r' . $id ] = array ( 'libelle' => prepareString ( $formule [ 'libelle' ]),
'unite' => $formule [ 'unite' ],
//'borneMin' => $formule['borneMin'],
//'borneMax' => $formule['borneMax'],
'commentaires' => prepareString ( $formule [ 'commentaires' ]),
);
$tabBorneMin [ $id ] = $formule [ 'borneMin' ];
$tabBorneMax [ $id ] = $formule [ 'borneMax' ];
}
2010-11-23 10:24:44 +00:00
2010-11-23 17:18:37 +00:00
/** Tanleau des années de bilans **/
$tabAnnees = array ();
// Tableau d'infos sur les bilans
foreach ( $tabRatios as $i => $R ) {
$tabBilansR [ $i ] = array ( 'dateCloture' => $tabBilan [ $i ][ 'DATE_CLOTURE' ],
'duree' => $tabBilan [ $i ][ 'DUREE_MOIS' ],
'devise' => $tabBilan [ $i ][ 'MONNAIE' ],
'typeBilan' => $tabBilan [ $i ][ 'CONSOLIDE' ],
'unite' => 'U' ,
);
if ( substr ( $tabBilan [ $i ][ 'DATE_CLOTURE' ], 0 , 4 ) > 1900 )
$tabAnnees [ $i ] = substr ( $tabBilan [ $i ][ 'DATE_CLOTURE' ], 0 , 4 );
2010-11-23 10:24:44 +00:00
}
2010-11-23 17:18:37 +00:00
foreach ( $tabRatios as $i => $R ) {
// Utilisation d'un index texte à cause du webservice
foreach ( $R as $Ridx => $Rmont ) {
if ( $Rmont <> 'NS' ) {
if ( $tabBorneMin [ $Ridx ] <> '' && $Rmont < $tabBorneMin [ $Ridx ])
$Rmont = '<' . $tabBorneMin [ $Ridx ];
elseif ( $tabBorneMax [ $Ridx ] <> '' && $Rmont > $tabBorneMax [ $Ridx ])
$Rmont = '>' . $tabBorneMax [ $Ridx ];
}
if ( substr ( $Rmont , 0 , 1 ) == 'N' || substr ( $Rmont , 0 , 1 ) == '<' || substr ( $Rmont , 0 , 1 ) == '>' )
$tabRatios2 [ $i ][ 'r' . $Ridx ] = $Rmont ;
else
$tabRatios2 [ $i ][ 'r' . $Ridx ] = round ( $Rmont , 2 );
if ( ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'S' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'S' || ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'N' && $tabBilan [ $i + 1 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
|| ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'N' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'N' || ( $tabBilan [ $i + 1 ][ 'CONSOLIDE' ] == 'S' && $tabBilan [ $i + 1 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
)
$Rmont = (( $R [ $Ridx ] - $tabRatios [ $i + 1 ][ $Ridx ]) * 100 ) / abs ( $tabRatios [ $i + 1 ][ $Ridx ]);
elseif ( ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'S' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'S' || ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'N' && $tabBilan [ $i + 2 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
|| ( $tabBilan [ $i ][ 'CONSOLIDE' ] == 'N' && isset ( $tabRatios [ $i + 1 ]) && ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'N' || ( $tabBilan [ $i + 2 ][ 'CONSOLIDE' ] == 'S' && $tabBilan [ $i + 2 ][ 'DATE_CLOTURE' ] <> $tabBilan [ $i ][ 'DATE_CLOTURE' ])))
)
$Rmont = (( $R [ $Ridx ] - $tabRatios [ $i + 2 ][ $Ridx ]) * 100 ) / abs ( $tabRatios [ $i + 2 ][ $Ridx ]);
else
$Rmont = 'NS' ;
2010-11-23 10:24:44 +00:00
2010-11-23 17:18:37 +00:00
if ( $Rmont == 'NS' || $Rmont <- 800 || $Rmont > 800 )
$tabRatiosEvol [ $i ][ 'r' . $Ridx ] = 'NS' ;
else
$tabRatiosEvol [ $i ][ 'r' . $Ridx ] =@ number_format ( $Rmont , 2 , ',' , ' ' );
// debugLog('I',"Liste des Ratios demandée pour $siren ratio $i, $Ridx=$Rmont",__LINE__,__FILE__, __FUNCTION__, __CLASS__);
}
2010-11-23 10:24:44 +00:00
}
2010-11-23 17:18:37 +00:00
debugLog ( 'I' , " Liste des Ratios demandée pour $siren après EVOLUTION " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
/** Tableau des ratios secteurs */
$tabRatiosSecteurs = array ();
if ( strlen ( $naf ) > 4 ) $strNaf = " AND naf5=' $naf ' " ;
else $strNaf = " AND naf4=' $naf ' " ;
$strAnnees = implode ( ',' , $tabAnnees );
if ( count ( $tabAnnees ) > 0 ) {
$iDb = new WDB ( 'jo' );
$tabTmp = $iDb -> select ( 'ratios_secteurs' , 'annee, naf5, naf4, id, (montant/nombre) AS ratio, nombre' , " 1 $strNaf AND annee IN ( $strAnnees ) ORDER BY annee DESC, id ASC " , true , MYSQL_ASSOC );
$nbRatiosSec = 0 ;
$anneePre = $tabTmp [ 0 ][ 'annee' ];
$iAn = 0 ;
foreach ( $tabTmp as $tabTmp2 ) {
if ( $anneePre <> $tabTmp2 [ 'annee' ]) $iAn ++ ;
$Ridx = $tabTmp2 [ 'id' ];
if ( $tabTmp2 [ 'nombre' ] > $nbRatiosSec ) $nbRatiosSec = $tabTmp2 [ 'nombre' ];
if ( $tabRatiosInfos [ 'r' . $Ridx ][ 'unite' ] == 'EUR' ) $montant = round ( $tabTmp2 [ 'ratio' ] * 1000 );
else $montant = round ( $tabTmp2 [ 'ratio' ]);
if ( $tabBorneMin [ $Ridx ] <> '' && $montant < $tabBorneMin [ $Ridx ])
$montant = '<' . $tabBorneMin [ $Ridx ];
elseif ( $tabBorneMax [ $Ridx ] <> '' && $montant > $tabBorneMax [ $Ridx ])
$montant = '>' . $tabBorneMax [ $Ridx ];
if ( substr ( $montant , 0 , 1 ) == 'N' || substr ( $montant , 0 , 1 ) == '<' || substr ( $montant , 0 , 1 ) == '>' )
$tabRatiosSecteurs [ $iAn ][ 'r' . $Ridx ] = $montant ;
else
$tabRatiosSecteurs [ $iAn ][ 'r' . $Ridx ] = round ( $montant , 2 );
// $tabRatiosSecteurs[$iAn]['r'.$Ridx]=$montant;
$anneePre = $tabTmp2 [ 'annee' ];
//$tabRatiosSecteurs=array('titi');
}
}
//$tabRatiosSecteurs=array(count($tabTmp), "1 $strNaf AND annee IN ($strAnnees) ORDER BY annee DESC, id ASC");
$result = new RatiosResult ();
$result -> Nom = $tabIdentite [ 'Nom' ];
$result -> NafEnt = $tabIdentite [ 'NafEnt' ];
$result -> NafEntLib = $tabIdentite [ 'NafEntLib' ];
$result -> FJ = $fj ;
$result -> FJ_lib = $tabIdentite [ 'FJ_lib' ];
$result -> Siren = $siren ;
$result -> NbEntNaf = $nbRatiosSec ;
$result -> BilansInfos = $tabBilansR ;
$result -> RatiosInfos = $tabRatiosInfos ;
$result -> RatiosEntrep = $tabRatios2 ;
$result -> RatiosEntrepEvol = $tabRatiosEvol ;
$result -> RatiosSecteur = $tabRatiosSecteurs ;
debugLog ( 'I' , " Liste des Ratios demandée pour $siren RETURN " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( $page , $siren );
$output = new RatiosReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
}
2010-11-23 15:29:01 +00:00
/**
2010-11-24 16:42:40 +00:00
* getSurveillances
* @ param string $siret
* @ param string $source
* @ param boolean $detail
* @ param int $deb
* @ param int $nbRet
* @ param string $tri
* @ return SurveillancesReturn
2010-11-23 15:29:01 +00:00
*/
2010-11-24 17:23:48 +00:00
public function getSurveillances ( $siret = 0 , $source = 'annonces' , $detail = false , $deb = 0 , $nbRet = 100 , $tri = 'siren' )
2010-11-23 15:29:01 +00:00
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-24 16:42:40 +00:00
//Initialisation
$error = new ErrorType ();
$tri = strtolower ( trim ( $tri ));
2010-11-23 10:24:44 +00:00
switch ( $tri ) {
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 ;
default : $orderBy = 'ORDER BY siren' ; break ; // siren ou vide ou autre
}
2010-11-24 16:42:40 +00:00
$tabRet = array ();
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
$nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
$iDb = new WDB ();
$login = $this -> tabInfoUser [ 'login' ];
2010-11-23 10:24:44 +00:00
if ( $detail ) $strSelect = 'source, email, siren, nic, ref, dateAjout, encoursClient, rs, cp, ville, dateDerEnvoi' ;
else $strSelect = 'source, email, siren, nic, ref, dateAjout, dateDerEnvoi' ;
if ( $source <> '' ) $strSource = " AND source=' $source ' " ;
else $strSource = '' ;
if ( $siren > 0 ) $strSiren = " AND siren= $siren " ;
else $strSiren = '' ;
// Il faut compter le nombre de siren au total
2010-11-24 16:42:40 +00:00
$tabTmp = $iDb -> select ( 'surveillances_site' , 'count(*) as nb' , " login=' $login ' AND dateSuppr=0 $strSiren $strSource " , false , MYSQL_ASSOC );
2010-11-23 10:24:44 +00:00
$nbRepTot = $tabTmp [ 0 ][ 'nb' ];
2010-11-24 16:42:40 +00:00
$tabTmp = $iDb -> select ( 'surveillances_site' , $strSelect , " login=' $login ' AND dateSuppr=0 $strSiren $strSource $orderBy LIMIT $deb , $nbRet " , false , MYSQL_ASSOC );
foreach ( $tabTmp as $i => $tabSurv )
{
2010-11-23 10:24:44 +00:00
if ( ! $detail )
2010-11-24 16:42:40 +00:00
{
2010-11-24 17:23:48 +00:00
$surveillance = new SurveillancesReponses ();
$surveillance -> source = $tabSurv [ 'source' ];
$surveillance -> email = $tabSurv [ 'email' ];
$surveillance -> siren = $tabSurv [ 'siren' ];
$surveillance -> nic = $tabSurv [ 'nic' ];
$surveillance -> ref = $tabSurv [ 'ref' ];
$surveillance -> dateAjout = $tabSurv [ 'dateAjout' ];
$surveillance -> dateDerEnvoi = $tabSurv [ 'dateDerEnvoi' ];
2010-11-24 16:42:40 +00:00
}
else
{
2010-11-23 10:24:44 +00:00
if ( trim ( $tabSurv [ 'rs' ]) <> '' ) {
$rs = $tabSurv [ 'rs' ];
$cp = $tabSurv [ 'cp' ];
$ville = $tabSurv [ 'ville' ];
} else {
$tabIdentite = $this -> iInsee -> getIdentiteLight ( $tabSurv [ 'siren' ], $tabSurv [ 'nic' ]);
$rs = $tabIdentite [ 'Nom' ];
$cp = $tabIdentite [ 'CP' ];
$ville = $tabIdentite [ 'Ville' ];
2010-11-24 17:23:48 +00:00
$iDb -> update ( 'surveillances_site' , array (
'rs' => $rs ,
'cp' => $cp ,
'ville' => $ville ),
" login=' $login ' AND dateSuppr=0 AND siren= " . $tabSurv [ 'siren' ] . " AND nic= " . $tabSurv [ 'nic' ] . " $strSource " , false );
2010-11-23 10:24:44 +00:00
}
2010-11-24 17:23:48 +00:00
$surveillance = new SurveillancesReponses ();
$surveillance -> source = $tabSurv [ 'source' ];
$surveillance -> email = $tabSurv [ 'email' ];
$surveillance -> siren = $tabSurv [ 'siren' ];
$surveillance -> nic = $tabSurv [ 'nic' ];
$surveillance -> ref = $tabSurv [ 'ref' ];
$surveillance -> dateAjout = $tabSurv [ 'dateAjout' ];
$surveillance -> dateDerEnvoi = $tabSurv [ 'dateDerEnvoi' ];
$surveillance -> encoursClient = $tabSurv [ 'encoursClient' ];
$surveillance -> rs = $rs ;
$surveillance -> cp = $cp ;
$surveillance -> ville = $ville ;
2010-11-23 10:24:44 +00:00
}
2010-11-24 17:23:48 +00:00
$tabRet [] = $surveillance ;
2010-11-23 10:24:44 +00:00
}
2010-11-24 17:23:48 +00:00
$criteres = new SurveillancesCriteres ();
$criteres -> siren = $siren ;
$criteres -> nic = $nic ;
$criteres -> source = $source ;
$result = new SurveillancesResult ();
$result -> criteres = $criteres ;
$result -> nbReponses = count ( $tabRet );
$result -> nbReponsesTotal = $nbRepTot ;
$result -> reponses = $tabRet ;
$output = new SurveillancesReturn ();
$output -> error = $error ;
$output -> result = $result ;
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 ();
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 'framework/sphinx/recherche2.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 );
2010-11-23 10:24:44 +00:00
2010-11-24 16:42:40 +00:00
$ret = search2 ( 'idx_histo' , " $recherche " , $tabFiltresAnnee , $deb , $nbRep , $maxRep , $pertinence );
$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 ;
2010-11-24 16:42:40 +00:00
foreach ( $liste as $n => $etab )
{
2010-11-23 10:24:44 +00:00
$texte =/* preg_replace ( '/ +/' , ' ' , */ $etab [ 'Texte' ]; //);
$posMin = 100000 ;
$hitMin = 1000000 ;
2010-11-24 16:42:40 +00:00
foreach ( $tabMots as $mot => $tabMot ){
if ( $tabMot [ 'hits' ] < $hitMin ) {
2010-11-23 10:24:44 +00:00
$hitMin = $tabMot [ 'hits' ];
$motSignificatif = $mot ;
}
2010-11-24 16:42:40 +00:00
}
2010-11-23 10:24:44 +00:00
$posMin = stripos ( $texte , '' . $motSignificatif );
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug", print_r($tabMots,true).EOL.$motSignificatif.' trouvé en position '.$posMin) ;
if ( $posMin < 150 ) $posMin = 150 ;
$texte2 = substr ( $texte , $posMin - 150 , 250 );
2010-11-24 16:42:40 +00:00
$reponse = new RechercheHistoReponses ();
$reponse -> id = $etab [ 'id' ];
2010-11-24 16:47:22 +00:00
$reponse -> Pertinence = $etab [ 'Pertinence' ];
$reponse -> Fichier = strtr ( $etab [ 'Fichier' ], array ( '.txt' => '.pdf' , '/mnt/bodacc/' => 'http://tville.scores-decisions.com/bodacc/' ));
2010-11-24 16:42:40 +00:00
$reponse -> Annee = $etab [ 'Annee' ];
$reponse -> Code = $etab [ 'Code' ];
$reponse -> Texte = preg_replace ( '/^[A-Za-z0-9\sàáâãäåæçèéêëìíîïðñòóôõöùúûüýÿÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝŸ]/' , '' , $texte2 );
$tabRet [] = $reponse ;
2010-11-23 10:24:44 +00:00
$k ++ ;
}
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
* @ param string $mois
* @ 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 ();
$strDetail = $strClient = $strLogin = '' ;
2010-11-23 10:24:44 +00:00
// Vue détaillée ou uniquement les infos payantes
2010-11-24 14:47:18 +00:00
if ( $detail == 0 )
{
$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%') ";
$strDetail = " AND (page LIKE 'greffe_%' OR page LIKE 'inpi_%' OR page='kbis' OR page='indiscore' OR page='privileges' OR page='commandeAsso') AND (params<>'' OR page='indiscore' AND tarifIndiscore<>0) AND (params NOT LIKE '%erreur%' OR params LIKE '%erreur 17%') " ;
} 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' ) {
2010-11-23 10:24:44 +00:00
$all = 'Oui' ;
} else {
$all = 'Non' ;
// Pas d'idClient mentionné ou tentative sur autre client et non SAD
2010-11-24 14:47:18 +00:00
if ( $idClient * 1 == 0 || ( $idClient * 1 <> $this -> tabInfoUser [ 'idClient' ] &&
$this -> tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' ) ){
2010-11-29 10:05:04 +00:00
$idClient = $this -> tabInfoUser [ 'idClient' ];
2010-11-24 14:47:18 +00:00
}
2010-11-23 10:24:44 +00:00
$strClient = " AND u.idClient= $idClient " ;
}
// On veut uniquement le login précis
if ( $login <> '' ) $strLogin = " AND l.login=' $login ' " ;
else $login = 'Non' ;
// Dates de début et de fin
$mois = strtr ( $mois , array ( '-' => '' , '/' => '' )) * 1 ;
$annee = substr ( $mois , 0 , 4 );
$mois = substr ( $mois , 4 , 2 );
$dateDeb = date ( 'Y-m-d' , mktime ( 0 , 0 , 0 , $mois , 1 , $annee ));
$dateFin = date ( 'Y-m-t' , mktime ( 0 , 0 , 0 , $mois , 15 , $annee ));
$fichierCsv = DOC_WEB_LOCAL . " csv/logs- $annee - $mois - $detail - $idClient - $login - $all .csv " ;
if ( file_exists ( $fichierCsv ) &&
date ( 'Ymd' , filemtime ( $fichierCsv )) == date ( 'Ymd' ) &&
filesize ( $fichierCsv ) > 60 ) {
$size = filesize ( $fichierCsv );
$erreur = false ;
$tabNom = array ();
$cache = 1 ;
} else {
@ unlink ( $fichierCsv );
$sql = " SELECT LOWER(l.login) as loginUti, page, l.siren, l.nic, l.params, l.dateHeure, u.idClient, c.nom, u.referenceParDefaut AS refUti
FROM `logs` l , utilisateurs u , clients c
WHERE 1 $strDetail $strClient $strLogin AND dateHeure BETWEEN '$dateDeb 00:00:00' AND '$dateFin 23:59:59' AND l . login = u . login AND u . idClient = c . id
GROUP BY l . login , l . siren , date ( dateHeure ), params
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 );
2010-11-29 10:05:04 +00:00
exec ( APPLICATION_PATH . " /batch/sql2csv.php sdv1 " . DOC_WEB_LOCAL . " /csv/logs- $annee - $mois - $detail - $idClient - $login - $all .sql $fichierCsv > /dev/null & " );
2010-11-23 10:24:44 +00:00
$size = $cache = 0 ;
}
2010-11-24 14:47:18 +00:00
$result = new LogsClients ();
$result -> Url = DOC_WEB_URL . " csv/logs- $annee - $mois - $detail - $idClient - $login - $all .csv " ;
$result -> Taille = $size ;
$result -> Cache = $cache ;
$output = new LogsClientsReturn ();
$output -> error = $error ;
$output -> result = $result ;
return $output ;
2010-11-23 10:24:44 +00:00
}
2010-11-24 15:22:07 +00:00
/**
* getListeSurveillanceCsv
* @ param string $source
* @ param string $login
* @ param string $idClient
* @ 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 ();
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 ;
}
if ( $source <> '' ) $strSource = " AND source=' $source ' " ;
else $strSource = '' ;
2010-11-24 15:22:07 +00:00
if ( $idClient * 1 == 0 || ( $idClient * 1 <> $this -> tabInfoUser [ 'idClient' ] && $this -> tabInfoUser [ 'profil' ] <> 'SuperAdministrateur' ) )
{
$idClient = $this -> tabInfoUser [ 'idClient' ];
}
$strClient = " AND u.idClient= $idClient " ;
2010-11-23 10:24:44 +00:00
2010-11-24 15:22:07 +00:00
if ( $login == '' && ( $this -> tabInfoUser [ 'profil' ] == 'SuperAdministrateur' || $this -> tabInfoUser [ 'profil' ] == 'Administrateur' ))
{
2010-11-23 10:24:44 +00:00
// On veut toutes les surveillances du client
$login = '' ; //$tabInfoUser['login'];
2010-11-24 15:22:07 +00:00
}
2010-11-23 10:24:44 +00:00
elseif ( $login <> '' && ( $tabInfoUser [ 'profil' ] == 'SuperAdministrateur' || $tabInfoUser [ 'profil' ] == 'Administrateur' ))
2010-11-24 15:22:07 +00:00
{
2010-11-23 10:24:44 +00:00
$strLogin = " AND s.login=' $login ' " ;
2010-11-24 15:22:07 +00:00
}
2010-11-23 10:24:44 +00:00
else
2010-11-24 15:22:07 +00:00
{
2010-11-23 10:24:44 +00:00
$strLogin = " AND s.login=' " . $tabInfoUser [ 'login' ] . " ' " ;
2010-11-24 15:22:07 +00:00
}
2010-11-23 10:24:44 +00:00
$fichierCsv = DOC_WEB_LOCAL . " csv/listesurv- $source - $login - $idClient .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 );
2010-11-24 15:22:07 +00:00
if ( $source == 'score' ){
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 , s . encoursClient , v . actif , v . procol , v . indiScore ,
v . indiScore20 , v . encours , v . indiScoreDate , v . dateBilan , v . indiScorePre , v . indiScore20Pre ,
v . encoursPre , v . indiScoreDatePre , v . sourceModif , v . scoreSolv , v . scoreSolvPre , v . scoreDir ,
v . scoreDirPre , v . scoreConf , v . scoreConfPre , /* 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 , */ v . dateUpdate
FROM surveillances_site s , sdv1 . utilisateurs u , sdv1 . clients c , scores_surveillance v
WHERE s . source = 'score' $strClient $strLogin AND dateSuppr = 0 AND s . login = u . login AND u . idClient = c . id AND s . siren = v . siren
ORDER BY loginUti ASC , s . siren ASC , s . nic ASC , s . source ASC , s . ref ASC " ;
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 );
2010-11-29 10:37:18 +00:00
exec ( 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 ;
}
2010-11-24 15:22:07 +00:00
$result = new ListeSurveillancesCsv ();
$result -> Url = DOC_WEB_URL . " csv/listesurv- $source - $login - $idClient .csv " ;
$result -> Taille = $size ;
$result -> Cache = $cache ;
2010-11-23 10:24:44 +00:00
debugLog ( 'I' , 'getListeSurveillancesCsv Url=' . DOC_WEB_URL . " csv/listesurv- $source - $login - $idClient .csv, Taille= $size , Cache= $cache " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
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 ();
$tabRet = $iBodacc -> getListeJalCollecte ();
2010-11-23 10:24:44 +00:00
foreach ( $tabRet 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-11-24 15:43:20 +00:00
protected function getListeFichierSurv ( $login , $ref = '*' , $nomFic = '' )
{
2010-11-25 10:25:34 +00:00
$this -> authenticate ();
2010-11-24 15:43:20 +00:00
//Initialisation
$error = new ErrorType ();
2010-11-23 10:24:44 +00:00
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "getListeFichierSurv pour $login, $ref, $nomFic", 'vide');
debugLog ( 'I' , " getListeFichierSurv pour $login , $ref , $nomFic " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabFichier = $tabDates = array ();
$numAbo = substr ( $ref , 0 , 5 );
if ( $login == 'vwbank' ) {
$repClient = 'volkswagen bank' ;
$ficClient = 'surveillanceBodacc_SURBODPRDCFTVWBANK' ;
$numAbo = $ref = '19300' ;
} else {
$repClient = 'cnasea' ;
$ficClient = 'surveillanceBodacc_SURBODTSTFTSCNASEA' ;
}
2010-11-24 15:43:20 +00:00
$dh = opendir ( " /home/data/clients/ $repClient / " );
2010-11-23 10:24:44 +00:00
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 );
}
}
/** 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);
if ( $ref == '*' ) {
$tabFichier = array ();
// Boucle sur les dates de livraison
foreach ( $tabDates as $dateFic ) {
if ( strlen ( $dateFic ) <> 8 ) continue ;
if ( ! file_exists ( " /home/data/clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " ) ||
filesize ( " /home/data/clients/ $repClient / $ficClient " . '_' . " $dateFic .csv " ) == 0 ) {
$fpW = fopen ( " /home/data/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 ( " /home/data/clients/ $repClient / " );
while ( false !== ( $filename = readdir ( $dh ))) {
if ( substr ( $filename , 0 , 51 ) == $nomClient . '_' . $dateFic && substr ( $filename , - 4 ) == '.csv' ) {
$fichier = $filename ;
//break;
}
}
$fpR = fopen ( " /home/data/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 );
}
}
fclose ( $fpR );
}
}
fclose ( $fpW );
}
if ( strlen ( $dateFic ) == 8 )
$tabFichier [] = $ficClient . '_' . $dateFic . '.csv' ;
}
}
rsort ( $tabFichier );
if ( $nomFic <> '' ) {
if ( ! file_exists ( " /var/www/html/csv/ $nomFic .bz2 " ) ||
filesize ( " /var/www/html/csv/ $nomFic .bz2 " ) == 0 ) {
$string = file_get_contents ( " /home/data/clients/ $repClient / $nomFic " );
$bz = bzopen ( " /var/www/html/csv/ $nomFic .bz2 " , 'w' );
if ( $bz ) {
bzwrite ( $bz , $string , strlen ( $string ));
bzclose ( $bz );
}
}
}
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'results' => $tabFichier );
}
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
}
/** Retourne les informations identitaires de l 'entreprise ou de l' établissement demandé
**
** @ param integer $siret Siren de l 'entreprise ou siret de l' établissement
** @ param integer $id Identifiant S & D de l ' établissement
** @ return array Fiche d 'identité de l' établissement
**/
protected function getIdentiteAGS ( $siret , $id = 0 , $forceVerif = false ) {
debugLog ( 'I' , " Identité AGS demandée pour siret $siret (id= $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$tabRet = array ();
$siret = trim ( $siret );
$len = strlen ( $siret );
$id = trim ( $id ) * 1 ;
if ( $len == 14 ) $nic = substr ( '' . $siret , 9 , 5 ) * 1 ;
elseif ( $len == 9 ) $nic = 0 ;
elseif ( $len == 0 ) { $siren = 0 ; $nic = 0 ; }
else {
debugLog ( 'W' , " Siren/Siret $siren incorrect " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren Siret inexistant' ), 'result' => $tabRet );
}
$siren = substr ( '' . $siret , 0 , 9 ) * 1 ;
if ( $siren == 0 && $id == 0 ) {
debugLog ( 'W' , " Siren $siren inexistant " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
debugLog ( 'I' , " Avant getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$entrep = $this -> iInsee -> getIdentiteEntreprise ( $siren , $nic , $id , $forceVerif );
debugLog ( 'I' , " Après getIdentiteEntreprise( $siren , $nic , $id ) " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
$duree = round ( microtime ( 1 ) - $tdeb , 3 );
$ligne = date ( 'YmdHis' ) . " ; $siret ;Ws->getIdentite juste apres iInsee->... ( $duree s) " ;
$fp = fopen ( '/var/www/log/accesDistant.log' , 'a' );
fwrite ( $fp , $ligne . EOL );
fclose ( $fp );
if ( empty ( $entrep )) {
debugLog ( 'W' , " Siren $siren non présent en base " , __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
return array ( 'error' => array ( 'errnum' => 102 , 'errmsg' => 'Siren inexistant' ), 'result' => $tabRet );
}
$tabRet = array ( 'id' => $entrep [ 'id' ],
'Siret' => $entrep [ 'Siret' ],
'SiretSiege' => $entrep [ 'SiretSiege' ],
'Siege' => $entrep [ 'Siege' ],
'TribunalCode' => prepareString ( $entrep [ 'Tribunal' ]),
'TribunalLib' => prepareString ( $entrep [ 'TribunalLib' ]),
//'NumGreffe' =>$entrep['numGreffe'], // Ajouté le 4 08 2009
'NumRC' => $entrep [ 'numRC' ], // Ajouté le 4 08 2009
'Actif' => $entrep [ 'Actif' ],
'AutreId' => $entrep [ 'AutreId' ],
'Source' => $entrep [ 'Source' ],
'SourceId' => $entrep [ 'SourceId' ],
'Isin' => $entrep [ 'Isin' ],
'Nom' => prepareString ( strtr ( $entrep [ 'Nom' ], '/*' , ' ' )),
'Nom2' => prepareString ( $entrep [ 'Nom2' ]),
'NomLong' => prepareString ( $entrep [ 'nomLong' ]), // Ajouté le 4 08 2009
'Siret' => $entrep [ 'Siret' ],
'Sigle' => prepareString ( $entrep [ 'Sigle' ]),
'SigleLong' => prepareString ( $entrep [ 'sigleLong' ]), // Ajouté le 4 08 2009
'Enseigne' => prepareString ( $entrep [ 'Enseigne' ]),
'Adresse' => prepareString ( $entrep [ 'Adresse' ]),
'Adresse2' => prepareString ( $entrep [ 'Adresse2' ]),
'AdresseNum' => prepareString ( $entrep [ 'AdresseNum' ]),
'AdresseBtq' => prepareString ( $entrep [ 'AdresseBtq' ]),
'AdresseVoie' => prepareString ( $entrep [ 'AdresseVoie' ]),
'AdresseRue' => prepareString ( $entrep [ 'AdresseRue' ]),
'CP' => $entrep [ 'CP' ],
'Ville' => prepareString ( $entrep [ 'Ville' ]),
'Pays' => prepareString ( $entrep [ 'Pays' ]), // Ajouté le 18 02 2008
'Civilite' => $entrep [ 'Civilite' ],
'NbEtab' => $entrep [ 'NbEtab' ],
'Tel' => prepareString ( $entrep [ 'Tel' ]),
'Fax' => prepareString ( $entrep [ 'Fax' ]),
'Web' => prepareString ( $entrep [ 'Web' ]),
'Mail' => prepareString ( $entrep [ 'Mail' ]),
'GeoLat' => $entrep [ 'GeoLat' ],
'GeoLon' => $entrep [ 'GeoLon' ],
'GeoPrecis' => $entrep [ 'GeoPrecis' ],
'GeoInfos' => $entrep [ 'GeoInfos' ],
'TvaNumero' => $entrep [ 'TvaNumero' ],
'TvaAttribue' => $entrep [ 'TvaAttribue' ],
'FJ' => $entrep [ 'FJ' ],
'FJ_lib' => prepareString ( $entrep [ 'FJ_lib' ]),
'FJ2' => $entrep [ 'FJ2' ], // Ajouté le 4 08 2009
'FJ2_Lib' => prepareString ( $entrep [ 'FJ2_Lib' ]), // Ajouté le 4 08 2009
'Siren' => $entrep [ 'Siren' ],
'Nic' => $entrep [ 'Nic' ],
'NafEnt' => $entrep [ 'NafEnt' ],
'NafEntLib' => prepareString ( $entrep [ 'NafEntLib' ]),
'NafEtab' => $entrep [ 'NafEtab' ],
'NafEtabLib' => prepareString ( $entrep [ 'NafEtabLib' ]),
'Activite' => prepareString ( $entrep [ 'Activite' ]),
'Capital' => $entrep [ 'Capital' ],
'CapitalDev' => $entrep [ 'CapitalDev' ],
'CapitalLib' => prepareString ( $entrep [ 'CapitalLib' ]), // Ajouté le 18 02 2008
'CapitalType' => prepareString ( $entrep [ 'CapitalType' ]), // Ajouté le 4 08 2009
'DateCreaEt' => $entrep [ 'DateCreaEt' ],
'DateCreaEn' => $entrep [ 'DateCreaEn' ],
'DateClotEt' => $entrep [ 'DateClotEt' ],
'DateImmat' => $entrep [ 'dateImmat' ], // Ajouté le 4 08 2009
'DateRadiation' => $entrep [ 'dateRad' ], // Ajouté le 4 08 2009
// 'DateMajRCS' =>$entrep['DateMajRCS'], // Ajouté le 4 08 2009
'EffEnTr' => prepareString ( $entrep [ 'EffEnTr' ]),
'EffEnTrLib' => prepareString ( $entrep [ 'EffEnTrLib' ]),
'Effectif' => prepareString ( $entrep [ 'Effectif' ]),
'Dept' => $entrep [ 'Dept' ],
'codeCommune' => prepareString ( $entrep [ 'codeCommune' ]),
'TrancheCA' => prepareString ( $entrep [ 'TrancheCA' ]),
'TrancheCALib' => prepareString ( $entrep [ 'TrancheCALib' ]),
'dir1Code' => $entrep [ 'dir1Code' ],
'dir1Titre' => prepareString ( $entrep [ 'dir1Titre' ]), //utf8
'dir1NomPrenom' => prepareString ( $entrep [ 'dir1NomPrenom' ]),
'dir1DateFct' => prepareString ( $entrep [ 'dir1DateFct' ]),
'dir1DateNaiss' => $entrep [ 'dir1DateNaiss' ], // Ajouté le 4 08 2009
'dir1LieuNaiss' => prepareString ( $entrep [ 'dir1LieuNaiss' ]), // Ajouté le 4 08 2009
'dir2Code' => $entrep [ 'dir2Code' ],
'dir2Titre' => prepareString ( $entrep [ 'dir2Titre' ]), //utf8
'dir2NomPrenom' => prepareString ( $entrep [ 'dir2NomPrenom' ]),
'dir2DateFct' => prepareString ( $entrep [ 'dir2DateFct' ]),
'dir2DateNaiss' => $entrep [ 'dir2DateNaiss' ], // Ajouté le 4 08 2009
'dir2LieuNaiss' => prepareString ( $entrep [ 'dir2LieuNaiss' ]), // Ajouté le 4 08 2009
'Rivoli' => $entrep [ 'Rivoli' ],
'NatureActivite' => $entrep [ 'NatureActivite' ], // Nature de l'activité
'OrigineCreation' => $entrep [ 'OrigineCreation' ], // Origine de la création
'TypeExploitation' => $entrep [ 'TypeExploitation' ],
'Auxiliaire' => $entrep [ 'Auxiliaire' ], // 1=Auxiliaire / 0=Non auxiliaire
'Saisonnalite' => $entrep [ 'Saisonnalite' ], // P=Activité permanente / S=Activité saisonnière
'SituationJuridique' => $entrep [ 'SituationJuridique' ],
'Bilan' => array ( 'Cloture' => $entrep [ 'bilanDate' ],
'Duree' => $entrep [ 'bilanMois' ],
'Devise' => $entrep [ 'bilanDevise' ],
'Capital' => $entrep [ 'bilanDA' ],
'CA' => $entrep [ 'bilanFL' ],
'Resultat' => $entrep [ 'bilanHN' ],
'Effectif' => $entrep [ 'bilanYP' ],
),
'Bourse' => $entrep [ 'Bourse' ],
'AutreSiren' => $entrep [ 'AutreSiren' ],
'DateMajINSEE' => $entrep [ 'DateMajINSEE' ],
'DateMajRCS' => $entrep [ 'DateMajRCS' ],
'DateMajBILAN' => $entrep [ 'bilanDateMaj' ],
'DateMajANN' => $entrep [ 'dateMajANN' ],
'DateMajID' => $entrep [ 'dateMajIdentite' ],
//'importExport' =>$entrep['importExport'],
);
$anns = $this -> getAnnonces ( $siren , 1 );
$tabRetAnn = $tabLastEven = array ();
$anns = $anns [ 'result' ];
$tribunalProcol = false ;
foreach ( $anns as $nb => $ann ) {
$tabRetEven = array ();
foreach ( $ann [ 'evenements' ] as $tabEven ) {
// On ignore les éléments suivants
if ( $tabEven [ 'CodeEven' ] >= 7000 ) continue ;
if ( $tabEven [ 'CodeEven' ] >= 4000 && $tabEven [ 'CodeEven' ] <= 4999 ) continue ;
// Par défaut, on force le tribunal à celui présent dans la dernière annonce de Procol
if ( $tribunalProcol == false && $tabEven [ 'CodeEven' ] >= 1000 && $tabEven [ 'CodeEven' ] < 2000 && $ann [ 'BodaccCode' ] == 'BODA' ) {
$tabRet [ 'TribunalCode' ] = $ann [ 'TribunalCode' ];
$tabRet [ 'TribunalLib' ] = prepareString ( $ann [ 'Tribunal' ]);
$tribunalProcol = true ;
}
// On ne prend que le dernier élément de chaque type
if ( in_array ( $tabEven [ 'CodeEven' ], $tabLastEven )) continue ;
$tabLastEven [] = $tabEven [ 'CodeEven' ];
$tabRetEven [] = array ( 'CodeEven' => $tabEven [ 'CodeEven' ],
'LibEven' => prepareString ( $tabEven [ 'LibEven' ]));
}
if ( count ( $tabRetEven ) > 0 ) {
$tabRetAnn [] = array ( 'id' => $ann [ 'id' ],
'BodaccCode' => $ann [ 'BodaccCode' ],
'BodaccNum' => $ann [ 'BodaccNum' ],
'NumAnnonce' => $ann [ 'NumAnnonce' ],
'DateParution' => $ann [ 'DateParution' ],
'Departement' => $ann [ 'Departement' ],
'Tribunal' => $ann [ 'Tribunal' ],
'TribunalSiret' => $ann [ 'TribunalSiret' ],
'Rubrique' => $ann [ 'Rubrique' ],
'typeAnnonce' => $ann [ 'typeAnnonce' ],
'texteRectificatif' => $ann [ 'texteRectificatif' ],
'texteAnnonce' => $ann [ 'texteAnnonce' ],
'dateEffet' => $ann [ 'dateEffet' ],
'dateJugement' => $ann [ 'dateJugement' ],
'dateInsertionSD' => $ann [ 'dateInsertionSD' ],
'evenements' => $tabRetEven ,
'Lien_Annonce_Pdf' => $ann [ 'Lien_Annonce_Pdf' ]
);
}
}
$tabRet [ 'Annonces' ] = $tabRetAnn ;
$iRncs = new MRncs ();
if ( $entrep [ 'Siege' ] == 1 || $entrep [ 'Siege' ] == 11 )
$tabRet [ 'LibTypeEtab' ] = 'Etablissement Siege' ;
else {
$tabEtabRncs = $iRncs -> getIdentiteEtab ( $siren , $entrep [ 'Nic' ]);
if ( $tabEtabRncs [ 'Siege' ] == 2 ) $tabRet [ 'LibTypeEtab' ] = 'Etablissement Principal' ;
elseif ( $tabEtabRncs [ 'Siege' ] == 1 ) $tabRet [ 'LibTypeEtab' ] = 'Etablissement Complementaire' ;
elseif ( $tabEtabRncs [ 'Siege' ] == 0 ) $tabRet [ 'LibTypeEtab' ] = 'Etablissement Secondaire' ;
}
$tabJuge = $iRncs -> getIntervenants ( $siren );
$tabDepots = array ();
foreach ( $tabJuge as $iDepot => $depot ) {
$tabDepots [] = array ( 'codEven' => $depot [ 'codEven' ],
'libEven' => prepareString ( $depot [ 'libEven' ]),
'dateEffet' => $depot [ 'dateEffet' ],
'admcode' => $depot [ 'admcode' ],
'admfonction' => prepareString ( $depot [ 'admfonction' ]),
'admnom' => prepareString ( $depot [ 'admnom' ]),
'admadrNum' => $depot [ 'admadrNum' ],
'admadrInd' => $depot [ 'admadrInd' ],
'admadrVoie' => prepareString ( $depot [ 'admadrVoie' ]), // @todo : adm1adr1, adm1adr2, adm1adr3,
'admadrCP' => $depot [ 'admadrCP' ],
'admadrVille' => prepareString ( $depot [ 'admadrVille' ]),
);
}
$tabRet [ 'Organes' ] = $tabDepots ;
$mLiens = new MLiens ( $siren );
$tabA = $mLiens -> getActionnaires ( $siren , 1 );
$nbA = count ( $tabA );
$tabAct = array ();
foreach ( $tabA as $i => $lien )
$tabAct [] = array ( 'Pmin' => $lien [ 'Pmin' ],
'MajMin' => $lien [ 'MajMin' ],
'RaisonSociale' => prepareString ( $lien [ 'RaisonSociale' ]),
'Pays' => prepareString ( $lien [ 'Pays' ]),
'Siren' => $lien [ 'Siren' ],
'Actif' => $lien [ 'Actif' ],
);
$tabRet [ 'Actionnaires' ] = $tabAct ;
$iGreffes = new MGreffes ();
$tabActes = $iGreffes -> getListeActes ( $siren );
$tabRet [ 'StatutsModifDepot' ] = $tabRet [ 'StatutsModif' ] = '0000-00-00' ;
foreach ( $tabActes as $i => $acte ) {
if ( '_' . $acte [ 'acte_type' ] == '_04' ) { // STATUTS CONSTITUTIFS
$tabRet [ 'StatutsConstDepot' ] = $acte [ 'depot_date' ]; // => 1997-12-18
$tabRet [ 'StatutsConst' ] = $acte [ 'acte_date' ]; // => 1997-11-13
break ;
} elseif ( in_array ( '_' . $acte [ 'acte_type' ],
array ( //'_04', // STATUTS CONSTITUTIFS
'_06' , // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
'_07' , // STATUTS A JOUR 9 0000-00-00 2009-09-02 17:05:55
'_08' , // STATUTS A JOUR ET DECLARATION DE CONFORMITE 9 0000-00-00 2009-09-02 17:05:55
'_09' , // STATUTS APRES TRANSFERT DE SIEGE 9 0000-00-00 2009-09-02 17:05:55
'_A1' , // STATUTS 9 0000-00-00 2009-09-02 17:05:55
'_AH' , // AVENANT AUX STATUTS
))) {
// On ne prend que la dernière modif
if ( $tabRet [ 'StatutsModifDepot' ] == '0000-00-00' && $tabRet [ 'StatutsModif' ] == '0000-00-00' ) {
$tabRet [ 'StatutsModifDepot' ] = $acte [ 'depot_date' ]; // => 1997-12-18
$tabRet [ 'StatutsModif' ] = $acte [ 'acte_date' ]; // => 1997-11-13
}
}
}
/** Y a t il eu des informations relatives à une cession ? **/
$tabCes = $iGreffes -> getInfosCessions ( $siren );
if ( $tabCes ) {
$tabRet [ 'CessionJugeLib' ] = $tabCes [ 'cessJuge' ];
$tabRet [ 'CessionJugeDate' ] = $tabCes [ 'cessDateJuge' ];
$tabRet [ 'CessionAvisBodac' ] = $tabCes [ 'cessDateBod' ];
$tabRet [ 'CessionInvenDate' ] = $tabCes [ 'cessDateInv' ];
$tabRet [ 'CessionCAdeclare' ] = $tabCes [ 'cessCAdec' ];
$tabRet [ 'CessionEffectif' ] = $tabCes [ 'cessEffectif' ];
$tabRet [ 'CessionDesc' ] = $tabCes [ 'cessDesc' ];
$tabRet [ 'CessionDescDate' ] = $tabCes [ 'cessDateDesc' ];
$tabRet [ 'CessionOffreDate' ] = $tabCes [ 'cessDateLim' ];
$tabRet [ 'CessionMandataire' ] = $tabCes [ 'cessMand' ];
}
//@sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren", print_r($tabActes,true)) ;
global $tabInfoUser ;
if ( preg_match ( '/NAF4/i' , $tabInfoUser [ 'pref' ])) {
$entrep2 = $this -> iInsee -> getNaf4 ( $siren , $nic , $id );
$tabRet [ 'Naf4Ent' ] = $entrep2 [ 'apen4' ];
$tabRet [ 'Naf4Etab' ] = $entrep2 [ 'apet4' ];
$tabRet [ 'Naf4EntLib' ] = prepareString ( $entrep2 [ 'apen4_lib' ]);
$tabRet [ 'Naf4EtabLib' ] = prepareString ( $entrep2 [ 'apet4_lib' ]);
}
//sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', "Debug $siren", print_r($tabRet,true)) ;
debugLog ( 'I' , 'Etablissement retourné = ' . $entrep [ 'Nom' ], __LINE__ , __FILE__ , __FUNCTION__ , __CLASS__ );
wsLog ( 'identite' , $siret , $id );
return array ( 'error' => array ( 'errnum' => 0 , 'errmsg' => '' ), 'result' => $tabRet );
}
protected function getIdentiteProcol ( $siret , $id = 0 , $forceVerif = false ) {
return $this -> getIdentiteAGS ( $siret , $id , $forceVerif );
}
2010-11-25 09:11:42 +00:00
}
?>