diff --git a/scripts/jobs/enrichissement.php b/scripts/jobs/enrichissement.php index 54ed8c6b..cd0e4db8 100644 --- a/scripts/jobs/enrichissement.php +++ b/scripts/jobs/enrichissement.php @@ -566,6 +566,7 @@ if ( $opts->reprise ) { $row = 0; $doublonList = array(); +$iDb = new WDB(); //Vérification et création des données foreach($tabIdentifiant as $item) @@ -821,7 +822,7 @@ function dateFermetureEtEntete($values) function dateFermetureEtData($siren, $nic, $values = false) { - $iDb = new WDB(); + global $iDb; $ret = $iDb->select('insee.insee_even', 'insEVE, insDATEVE', 'insSIREN='.$siren.' AND insNIC='.$nic." AND insEVE IN('FF','OF','400','410','420','425','430','435') ORDER BY insDATEVE DESC LIMIT 1", false, MYSQL_ASSOC); if (count($ret)==0) { $siret = $siren.$nic; @@ -842,7 +843,7 @@ function dateFermetureEnEntete($values) function dateFermetureEnData($siren, $nic, $values = false) { - $iDb = new WDB(); + global $iDb; $ret = $iDb->select('insee.insee_even', 'insEVE, insDATEVE', 'insSIREN='.$siren." AND insEVE IN('FF','410','420','425') ORDER BY insDATEVE DESC", false, MYSQL_ASSOC); if (mysql_errno()>0) die( 'Erreur B3 '.mysql_errno().' : '.mysql_error() ); $tabData['dateFermetureEn'] = isset($ret[0]['insDATEVE']) ? $ret[0]['insDATEVE'] : ''; @@ -871,12 +872,12 @@ function situationJuridiqueEntete($values) function situationJuridiqueData($siren, $nic, $values = false) { - $tabTmp = array('P','A','D'); + global $iDb; + $tabTmp = array('P','A','D'); $tabData['situationJuridique']='NC'; $tabData['situationParution']=''; $tabData['situationDernCode']=''; $tabData['situationDernEven']=''; - $iDb = new WDB(); foreach ($tabTmp as $sit) { $iInsee = new MInsee($iDb); $tmp = $iInsee->getAnnoncesLegales($siren, 0, $sit); @@ -1319,8 +1320,8 @@ function indiScoreEntete($values) function indiScoreData($siren, $nic, $values = false) { - $tabData = array(); - $iDb = new WDB(); + global $iDb; + $tabData = array(); $ret = $iDb->select('jo.scores_surveillance', 'indiScore, encours, indiScoreDate, dateBilan', 'siren='.$siren, false, MYSQL_ASSOC); if (isset($ret[0]['indiScore'])) { $tabData['indiScore'] = $ret[0]['indiScore']; @@ -1423,7 +1424,7 @@ function SiretSucEntete($values) function SiretSucData($siren, $nic, $values = false) { - $iDb = new WDB(); + global $iDb; $iInsee = new MInsee(); //Init @@ -1531,12 +1532,12 @@ function GPSEntete($values) function GPSData($siren, $nic, $values = false) { + global $iDb; $tabData['latitude'] = ''; $tabData['longitude'] = ''; $tabData['altitude'] = ''; $tabData['precis'] = ''; - $iDb = new WDB('jo'); $result = $iDb->select( 'etablissements e', "e.adr_num, e.adr_btq, e.adr_typeVoie, e.adr_libVoie, e.adr_comp, e.adr_cp, e.adr_ville", @@ -1572,11 +1573,11 @@ function NaceEtabEntete($values) } function NaceEtabData($siren, $nic, $values) { - $tabData = array( + global $iDb; + $tabData = array( 'NaceEtab' => '', 'NaceEtabLib' => '', ); - $iDb = new WDB('jo'); $result = $iDb->select('jo.etablissements e, jo.tabNaf5 n, insee.tabNace i', "CONCAT(n.codNaf1, SUBSTRING(n.codNaf5,1,4)) AS codNace, i.libelleFR", "siren=$siren AND nic=$nic AND n.codNaf5=e.ape_etab AND i.codNace=SUBSTRING(n.codNaf5,1,4)", false, MYSQL_ASSOC); @@ -1596,11 +1597,11 @@ function NaceEntEntete() } function NaceEntData() { - $tabData = array( + global $iDb; + $tabData = array( 'NaceEn' => '', 'NaceEnLib' => '', ); - $iDb = new WDB('jo'); $result = $iDb->select('jo.etablissements e, jo.tabNaf5 n, insee.tabNace i', "CONCAT(n.codNaf1, SUBSTRING(n.codNaf5,1,4)) AS codNace, i.libelleFR", "siren=$siren AND nic=$nic AND n.codNaf5=e.ape_entrep AND i.codNace=SUBSTRING(n.codNaf5,1,4)", false, MYSQL_ASSOC);