From 772c52e9e8ab8aa3d466d3f60459b448603c5948 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 19 Jan 2011 09:22:05 +0000 Subject: [PATCH] =?UTF-8?q?D=C3=A9placement=20des=20m=C3=A9thodes=20getBan?= =?UTF-8?q?ques=20et=20getListeComp=C3=A9tences=20dans=20le=20WSEntreprise?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/configs/WsEntreprise.ini | 5 + application/configs/WsInterne.ini | 7 +- library/WsScore/Types/EntrepriseTypes.php | 84 +++++ library/WsScore/Types/InterneTypes.php | 84 ----- library/WsScore/WsEntreprise.php | 419 +++++++++++++++++++++ library/WsScore/WsInterne.php | 422 +--------------------- 6 files changed, 510 insertions(+), 511 deletions(-) diff --git a/application/configs/WsEntreprise.ini b/application/configs/WsEntreprise.ini index 69bf5338..f2505021 100644 --- a/application/configs/WsEntreprise.ini +++ b/application/configs/WsEntreprise.ini @@ -78,3 +78,8 @@ Type[] = "PrivilegesDetailReturn" Type[] = "PrivilegesDetail" Type[] = "AdresseDomEnt" Type[] = "InfosIris" +Type[] = "BanquesReturn" +Type[] = "Banque" +Type[] = "ListeCompetencesReturn" +Type[] = "ListeCompetencesResult" +Type[] = "Competence" diff --git a/application/configs/WsInterne.ini b/application/configs/WsInterne.ini index e049ae25..469dcf8d 100644 --- a/application/configs/WsInterne.ini +++ b/application/configs/WsInterne.ini @@ -8,7 +8,7 @@ Type[] = "InfoCommandePieces" Type[] = "ListeCmdBilanReturn" Type[] = "CmdBilanReturn" Type[] = "CmdBilanDetail" -Type[] = "InfoCommandeBilan" +Type[] = "InfoCommandeBilan" Type[] = "ListeCmdActeReturn" Type[] = "CmdActeReturn" Type[] = "CmdActeDetail" @@ -30,11 +30,6 @@ Type[] = "Acte" Type[] = "CmdStatut" Type[] = "InfosLoginReturn" Type[] = "InfosLogin" -Type[] = "ListeCompetencesReturn" -Type[] = "ListeCompetencesResult" -Type[] = "Competence" -Type[] = "BanquesReturn" -Type[] = "Banque" Type[] = "ListeConventionsReturn" Type[] = "Convention" Type[] = "AnnonceCollecteReturn" diff --git a/library/WsScore/Types/EntrepriseTypes.php b/library/WsScore/Types/EntrepriseTypes.php index a7796864..f9512a91 100644 --- a/library/WsScore/Types/EntrepriseTypes.php +++ b/library/WsScore/Types/EntrepriseTypes.php @@ -2889,4 +2889,88 @@ class InfosIris { * @var string */ public $grdQuartier; +} + +class BanquesReturn +{ + /** @var ErrorType */ + public $error; + /** @var Banque[] */ + public $result; +} + +class Banque +{ + /** @var string */ + public $codeBanque; + /** @var string */ + public $codeGuichet; + /** @var string */ + public $libBanque; + /** @var string */ + public $adresse1; + /** @var string */ + public $adresse2; + /** @var string */ + public $cp; + /** @var string */ + public $ville; +} + +class ListeCompetencesReturn +{ + /** @var ErrorType */ + public $error; + /** @var ListeCompetencesResult */ + public $result; +} + +class ListeCompetencesResult +{ + /** @var int */ + public $nbReponses; + /** @var Competence[] */ + public $liste; +} + +class Competence +{ + /** @var string */ + public $Id; + /** @var string */ + public $IdSup; + /** @var string */ + public $Code; + /** @var string */ + public $IdentifiantGreffe; + /** @var string */ + public $Type; + /** @var string */ + public $Nom; + /** @var string */ + public $Siret; + /** @var string */ + public $Adr; + /** @var string */ + public $AdrComp; + /** @var string */ + public $CP; + /** @var string */ + public $Ville; + /** @var string */ + public $CodeInsee; + /** @var string */ + public $Tel; + /** @var string */ + public $Fax; + /** @var string */ + public $Web; + /** @var string */ + public $Mail; + /** @var string */ + public $Statut; + /** @var string */ + public $DateCessation; + /** @var string */ + public $Remarque; } \ No newline at end of file diff --git a/library/WsScore/Types/InterneTypes.php b/library/WsScore/Types/InterneTypes.php index 4a692be2..f2705e7d 100644 --- a/library/WsScore/Types/InterneTypes.php +++ b/library/WsScore/Types/InterneTypes.php @@ -476,90 +476,6 @@ class InfosLogin public $typeScore; } -class ListeCompetencesReturn -{ - /** @var ErrorType */ - public $error; - /** @var ListeCompetencesResult */ - public $result; -} - -class ListeCompetencesResult -{ - /** @var int */ - public $nbReponses; - /** @var Competence[] */ - public $liste; -} - -class Competence -{ - /** @var string */ - public $Id; - /** @var string */ - public $IdSup; - /** @var string */ - public $Code; - /** @var string */ - public $IdentifiantGreffe; - /** @var string */ - public $Type; - /** @var string */ - public $Nom; - /** @var string */ - public $Siret; - /** @var string */ - public $Adr; - /** @var string */ - public $AdrComp; - /** @var string */ - public $CP; - /** @var string */ - public $Ville; - /** @var string */ - public $CodeInsee; - /** @var string */ - public $Tel; - /** @var string */ - public $Fax; - /** @var string */ - public $Web; - /** @var string */ - public $Mail; - /** @var string */ - public $Statut; - /** @var string */ - public $DateCessation; - /** @var string */ - public $Remarque; -} - -class BanquesReturn -{ - /** @var ErrorType */ - public $error; - /** @var Banque[] */ - public $result; -} - -class Banque -{ - /** @var string */ - public $codeBanque; - /** @var string */ - public $codeGuichet; - /** @var string */ - public $libBanque; - /** @var string */ - public $adresse1; - /** @var string */ - public $adresse2; - /** @var string */ - public $cp; - /** @var string */ - public $ville; -} - class ListeConventionsReturn { /** @var ErrorType */ diff --git a/library/WsScore/WsEntreprise.php b/library/WsScore/WsEntreprise.php index 0cacb4e4..07921db8 100644 --- a/library/WsScore/WsEntreprise.php +++ b/library/WsScore/WsEntreprise.php @@ -2274,6 +2274,425 @@ class WsEntreprise extends WsScore return $output; } + /** + * Retourne la liste des banques connues pour une entreprise + * @param string $siren Siren de l'entreprise + * @return BanquesReturn + **/ + public function getBanques($siren) + { + $this->authenticate(); + + //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 && + $dateSourceselect('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 && + $dateSourceselect('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__); + + 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; + } + + /** + * Enter description here ... + * @param string $siret + * @param string $type + * @param string $codeInsee + * @return ListeCompetencesReturn + */ + public function getListeCompetences($siret, $type, $codeInsee) + { + $this->authenticate(); + + //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( '
'=>', ', '
'=>', ', + '
'=>', ', + )), + ), '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=$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; + } + } + } + $this->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; + } + /** * Retourne le statut du webservice * @return StatusReturn diff --git a/library/WsScore/WsInterne.php b/library/WsScore/WsInterne.php index a33702d0..be815ebe 100644 --- a/library/WsScore/WsInterne.php +++ b/library/WsScore/WsInterne.php @@ -1435,427 +1435,7 @@ class WsInterne extends WsScore return $output; } - /** - * Enter description here ... - * @param string $siret - * @param string $type - * @param string $codeInsee - * @return ListeCompetencesReturn - */ - public function getListeCompetences($siret, $type, $codeInsee) - { - $this->authenticate(); - - //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( '
'=>', ', '
'=>', ', - '
'=>', ', - )), - ), '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=$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; - } - } - } - $this->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; - } - - /** - * Retourne la liste des banques connues pour une entreprise - * @param string $siren Siren de l'entreprise - * @return BanquesReturn - **/ - public function getBanques($siren) - { - $this->authenticate(); - - //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 && - $dateSourceselect('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 && - $dateSourceselect('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__); - - 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; - } + /** *