Déplacement des méthodes getBanques et getListeCompétences dans le WSEntreprise

This commit is contained in:
Michael RICOIS 2011-01-19 09:22:05 +00:00
parent d407d606a6
commit 772c52e9e8
6 changed files with 510 additions and 511 deletions

View File

@ -78,3 +78,8 @@ Type[] = "PrivilegesDetailReturn"
Type[] = "PrivilegesDetail"
Type[] = "AdresseDomEnt"
Type[] = "InfosIris"
Type[] = "BanquesReturn"
Type[] = "Banque"
Type[] = "ListeCompetencesReturn"
Type[] = "ListeCompetencesResult"
Type[] = "Competence"

View File

@ -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"

View File

@ -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;
}

View File

@ -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 */

View File

@ -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 &&
$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__);
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( '<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=$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

View File

@ -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( '<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=$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 &&
$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__);
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;
}
/**
*