Formattage

This commit is contained in:
Michael RICOIS 2015-02-09 08:32:40 +00:00
parent d9e5eba8ad
commit ce50ccae3b

View File

@ -92,32 +92,32 @@ $tableSurvTmp = 'tmp.scores_surveillance';
$tabQueries = array(
/* Bilans Asso déposé(s) */
'bilansasso' => "SELECT $strSelect, 'bilansasso' as source FROM ".$tableSurvTmp."_bilansasso s, jo.asso_bilans b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'bilansasso' => "SELECT $strSelect, 'bilansasso' as source FROM ".$tableSurvTmp."_bilansasso s, jo.asso_bilans b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate GROUP BY siren",
//asso_bilans', 'dateCloture, dateCloture*1 as dateClotureNum', "siren=$siren ORDER BY DESC LIMIT 0,5", true, MYSQL_ASSOC);
/* Privileges Infogreffe */
'privileges' => "SELECT $strSelect, 'privileges' AS source FROM ".$tableSurvTmp."_privileges s, jo.greffes_privileges p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>s.dateUpdate OR p.dateUpdate>s.dateUpdate) /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'privileges' => "SELECT $strSelect, 'privileges' AS source FROM ".$tableSurvTmp."_privileges s, jo.greffes_privileges p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>s.dateUpdate OR p.dateUpdate>s.dateUpdate) GROUP BY siren",
/* Privileges Facto */
'privileges2' => "SELECT $strSelect, 'privileges2' AS source FROM ".$tableSurvTmp."_privileges2 s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs='P' /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'privileges2' => "SELECT $strSelect, 'privileges2' AS source FROM ".$tableSurvTmp."_privileges2 s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs='P' GROUP BY siren",
/* IMPAYES Facto */
'impayes' => "SELECT $strSelect, 'impayes' AS source FROM ".$tableSurvTmp."_impayes s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs='I' /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'impayes' => "SELECT $strSelect, 'impayes' AS source FROM ".$tableSurvTmp."_impayes s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs='I' GROUP BY siren",
/* Ajout d'un nouveau score */
'ajout' => "SELECT $strSelect, 'ajout' AS source FROM ".$tableSurvTmp."_ajout s WHERE s.siren>1000 AND ((DATEDIFF(NOW(),s.indiScoreDate) IS NULL AND s.dateUpdate<DATE(NOW()) OR s.indiScoreDate=0)) GROUP BY siren",
/* IndiScores demandés ce jour */
//'jour' => "SELECT $strSelect, 'jour' AS source FROM ".$tableSurvTmp."_jour s, sdv1.`logs` l WHERE l.siren>1000 AND s.siren=l.siren AND l.page='indiscore' AND l.dateHeure>s.dateUpdate AND s.procol NOT IN('P') GROUP BY siren",
/* Dirigeants */
'dirigeants' => "SELECT $strSelect, 'dirigeants' AS source FROM ".$tableSurvTmp."_dirigeants s, jo.rncs_dirigeants d WHERE d.siren>1000 AND s.siren = d.siren AND (d.dateInsert>s.dateUpdate OR d.dateUpdate>s.dateUpdate) AND (d.dateInsert>'2013-03-15 00:00:00' OR d.dateUpdate>'2013-03-15 00:00:00') /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'dirigeants' => "SELECT $strSelect, 'dirigeants' AS source FROM ".$tableSurvTmp."_dirigeants s, jo.rncs_dirigeants d WHERE d.siren>1000 AND s.siren = d.siren AND (d.dateInsert>s.dateUpdate OR d.dateUpdate>s.dateUpdate) AND (d.dateInsert>'2013-03-15 00:00:00' OR d.dateUpdate>'2013-03-15 00:00:00') GROUP BY siren",
/* Evenements INSEE */
'insee' => "SELECT $strSelect, 'insee' as source FROM ".$tableSurvTmp."_insee s, insee.insee_even i WHERE i.insSIREN>1000 AND s.siren=i.insSIREN AND i.dateInsert>s.dateUpdate /*AND s.procol NOT IN('P') AND i.insEVE IN ('400','410','420','425')*/ AND i.insSIEGE=1 GROUP BY siren",
'insee' => "SELECT $strSelect, 'insee' as source FROM ".$tableSurvTmp."_insee s, insee.insee_even i WHERE i.insSIREN>1000 AND s.siren=i.insSIREN AND i.dateInsert>s.dateUpdate AND i.insSIEGE=1 GROUP BY siren",
/* Entreprises RNCS */
//'rncs' => "SELECT $strSelect, 'rncs' as source FROM scores_surveillance_tmp s, rncs_entrep r WHERE s.siren>1000 AND s.siren=r.siren AND (r.dateInsert>s.dateUpdate OR r.dateUpdate>s.dateUpdate) /*AND (d.dateInsert>'2013-03-15 00:00:00' OR d.dateUpdate>'2013-03-15 00:00:00')*/ AND s.procol NOT IN('P') GROUP BY siren",
/* Bodacc */
'bodacc' => "SELECT $strSelect, 'bodacc' as source FROM ".$tableSurvTmp."_bodacc s, jo.bodacc_detail b WHERE b.siren>1000 AND s.siren=b.siren AND( b.dateInsert>s.dateUpdate OR b.dateUpdate>s.dateUpdate) /*AND s.procol NOT IN('P')*/ AND b.Rubrique NOT IN('creations','comptes') GROUP BY siren",
'bodacc' => "SELECT $strSelect, 'bodacc' as source FROM ".$tableSurvTmp."_bodacc s, jo.bodacc_detail b WHERE b.siren>1000 AND s.siren=b.siren AND( b.dateInsert>s.dateUpdate OR b.dateUpdate>s.dateUpdate) AND b.Rubrique NOT IN('creations','comptes') GROUP BY siren",
/* Collecte */
'collecte' => "SELECT $strSelect, 'collecte' as source FROM ".$tableSurvTmp."_collecte s, jo.annonces b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate /*AND s.procol NOT IN('P') AND b.typeEven NOT IN(3200)*/ GROUP BY siren",
'collecte' => "SELECT $strSelect, 'collecte' as source FROM ".$tableSurvTmp."_collecte s, jo.annonces b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate GROUP BY siren",
/* Bilans en base */
'bilans1' => "SELECT $strSelect, 'bilans1' as source FROM ".$tableSurvTmp."_bilans1 s, jo.bilans b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate AND (DATEDIFF(b.dateExercice,s.dateBilan)>1 OR DATEDIFF(b.dateExercice,s.dateBilan) IS NULL) /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'bilans1' => "SELECT $strSelect, 'bilans1' as source FROM ".$tableSurvTmp."_bilans1 s, jo.bilans b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate AND (DATEDIFF(b.dateExercice,s.dateBilan)>1 OR DATEDIFF(b.dateExercice,s.dateBilan) IS NULL) GROUP BY siren",
/* Défaut divers Facto (D:Défaut, 24:Groupe en diff, 31:Cessation Annoncée, 50:Terrorisme)*/
'defaut' => "SELECT $strSelect, 'defaut' AS source FROM ".$tableSurvTmp."_defaut s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs IN ('D','24','31','50') /*AND s.procol NOT IN('P')*/ GROUP BY siren",
'defaut' => "SELECT $strSelect, 'defaut' AS source FROM ".$tableSurvTmp."_defaut s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs IN ('D','24','31','50') GROUP BY siren",
/* RAS Facto */
'regulier' => "SELECT $strSelect, 'regulier' AS source FROM ".$tableSurvTmp."_regulier s, sdv1.ge_cs2 p WHERE p.siren>1000 AND s.siren = p.siren AND (p.dateInsert>=s.dateUpdate OR p.dateConf>=s.dateUpdate) AND p.cs='00' AND s.procol NOT IN('P') GROUP BY siren",
// Rajouter AND (DATEDIFF(NOW(),s.indiScoreDate)>365
@ -209,10 +209,8 @@ echo date('Y/m/d H:i:s') ." - DEBUT du programme de calcul des scores en surveil
if ( $opts->tout ) {
echo date('Y/m/d H:i:s') ." - Mise en surveillance Scores de l'ensemble des demandes de scoring...".PHP_EOL;
$query="INSERT IGNORE INTO jo.scores_surveillance(siren)
SELECT DISTINCT siren FROM jo.surveillances_site
WHERE source='score' AND siren>=100000 AND siren NOT IN
(SELECT siren FROM jo.scores_surveillance) ";
$query = "INSERT IGNORE INTO jo.scores_surveillance(siren) SELECT DISTINCT siren FROM jo.surveillances_site
WHERE source='score' AND siren>=100000 AND siren NOT IN (SELECT siren FROM jo.scores_surveillance) ";
$db->query($query);
}