Regroupement et organisation des scripts
This commit is contained in:
parent
a91a299aea
commit
8c42bb9ed5
File diff suppressed because it is too large
Load Diff
@ -4,14 +4,14 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
@ -8,14 +8,14 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
@ -1002,4 +1002,3 @@ function execDbInternal($values, $debug = false)
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
@ -7,14 +7,14 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
@ -134,5 +134,3 @@ if ( $opts->in ) {
|
||||
echo date('Y-m-d H:i:s')." - Erreur confirmation des SIREN." . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,317 +1,317 @@
|
||||
<?php
|
||||
/**
|
||||
* Calcul des scores sur la base S&D
|
||||
* Déclencheur
|
||||
* - "bilans1" à 7h
|
||||
* - "ajout" à 8h, 22h
|
||||
* - "insee" à 8h
|
||||
* - "dirigeants" à 9h
|
||||
* - "bodacc" à 13h
|
||||
* - "collecte" à 13h30
|
||||
*
|
||||
* Crontab
|
||||
* 0 12 * * 1-5 /home/scores/batch/scripts/calculScoreSurv.php >> /home/scores/batch/shared/sources/log/calculScoreSurv.log
|
||||
* 0 8 * * 0,6 /home/scores/batch/scripts/calculScoreSurv.php >> /home/scores/batch/shared/sources/log/calculScoreSurv.log
|
||||
*
|
||||
* TODO
|
||||
* - Option lecture sur bdd slave et ecriture sur bdd master
|
||||
* - Modifier les requetes sur les sources pour
|
||||
* Sélectionner suivant des règles toutes les x heures les nouveaux éléments sur x heures + 1
|
||||
* Si déjà calculé du jour, alors on passe sinon on calcul
|
||||
* - Vérifier les éléments déjà calculés si il n'y a pas de changement
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
//Options
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(array(
|
||||
'help|?' => "Displays usage information.",
|
||||
'tout|t' => "Calculer tous les scores",
|
||||
'verbose|v' => "Mode bavard ou debug",
|
||||
'ancien|a' => "Recalculer tous les scores avec indiscore>0 et un encours à 0 !",
|
||||
'list|l' => "Lister les déclencheurs existants pour le recalcul des scores",
|
||||
'declencheur|d=s' => "Lancer le calcul des scores pour le déclencheur XXX",
|
||||
'max=s' => "Nombre max d'unités à calculer pour un déclencheur",
|
||||
'nostop' => "Ne pas stopper",
|
||||
'dbread' => "choix de la database pour la lecture des informations (master, slave)",
|
||||
));
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if( isset($opts->help) || count($opts->getOptions())==0 )
|
||||
{
|
||||
echo "Scorer toute la base entreprise S&D.\n";
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$strSelect="s.siren, s.actif, s.procol, s.indiScore, s.indiScore20, s.encours, s.indiScoreDate, scoreSolv, scoreConf, scoreDir, scoreZ, scoreCH, scoreAfdcc1, scoreAfdcc2, scoreAfdcc2note, scoreAltman, scoreAltmanCote, scoreCCF, situFi, infoNote, noteStruct, noteFin, tendance, nbModifs, s.dateUpdate, s.cs, s.csMoisMaj, s.csMoisFin";
|
||||
|
||||
$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 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) 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' 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' 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') 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 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 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 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) 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') 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
|
||||
// et vérifier si ça en enlève en recalcul régulier
|
||||
/* Scores trop anciens */
|
||||
'ancien' => "SELECT $strSelect, 'ancien' AS source FROM ".$tableSurvTmp."_ancien s WHERE s.siren>1000 AND (DATEDIFF(NOW(),s.indiScoreDate)>365) AND s.procol NOT IN('P') AND s.dateUpdate<DATE(NOW()) GROUP BY siren",
|
||||
/** @todo A revoir **/
|
||||
/* Bilans déposés */
|
||||
//'bilans2'=>"SELECT s.siren, s.actif, s.procol, s.indiScore, s.indiScore20, s.encours, s.indiScoreDate, scoreSolv, scoreConf, scoreDir, scoreZ, scoreCH, scoreAfdcc1, scoreAfdcc2, scoreAfdcc2note, scoreAltman, scoreAltmanCote, scoreCCF, situFi, infoNote, noteStruct, noteFin, tendance, nbModifs, 'bilans2' as source, s.dateUpdate FROM scores_surveillance_tmp s, bilans_deposes b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate AND s.procol NOT IN('P') GROUP BY siren",
|
||||
);
|
||||
|
||||
$tabQueriesOrder = array(
|
||||
'siren' => " ORDER BY siren ASC LIMIT 5000",
|
||||
'old' => " ORDER BY s.dateUpdate ASC LIMIT 5000",
|
||||
);
|
||||
$queryOrder = 'old';
|
||||
|
||||
/**
|
||||
* Liste des déclencheurs
|
||||
*/
|
||||
if ( $opts->list ) {
|
||||
foreach ( $tabQueries as $key => $query) {
|
||||
echo "\t- $key\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
$db = Zend_Db::factory($c->profil->db->metier);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||
|
||||
/**
|
||||
* Delete all temporary table
|
||||
*/
|
||||
$day = date('N');
|
||||
if ( $opts->tout && $day == 6) {
|
||||
foreach ( $tabQueries as $key => $query) {
|
||||
try {
|
||||
$db->query("DROP TABLE IF EXISTS $key;");
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force declencheur
|
||||
*/
|
||||
if ( $opts->declencheur ) {
|
||||
if ( in_array($opts->declencheur, array_keys($tabQueries)) ) {
|
||||
$tabQueries = array($opts->declencheur => $tabQueries[$opts->declencheur]);
|
||||
} else {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
require_once APPLICATION_PATH.'/configs/config.php';
|
||||
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
require_once 'Metier/Scores/MScores.php';
|
||||
|
||||
$tDeb=microtime(true);
|
||||
|
||||
$dateJour=date('Y-m-d');
|
||||
|
||||
function wsLog($service, $siret='', $ref='') {}
|
||||
|
||||
$message = $error = '';
|
||||
echo date('Y/m/d H:i:s') ." - DEBUT du programme de calcul des scores en surveillance...\n";
|
||||
|
||||
/**
|
||||
* Mise en surveillance de l'ensemble des scores
|
||||
*/
|
||||
if ( $opts->tout ) {
|
||||
echo date('Y/m/d H:i:s') ." - Mise en surveillance Scores de l'ensemble des demandes de scoring...\n";
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lancement du programme
|
||||
*/
|
||||
echo date('Y/m/d H:i:s') ." - Recherche des scores susceptibles d'avoir changés par déclencheur...\n";
|
||||
|
||||
$nbScoresSans=$nbScoresModif=$nbScoresNouv=$nbScoresProcol=$iRow=$nbRowsTot=0;
|
||||
|
||||
$iInsee = new Metier_Insee_MInsee();
|
||||
foreach ($tabQueries as $declencheur => $query)
|
||||
{
|
||||
$tableName = $tableSurvTmp . '_' . $declencheur;
|
||||
echo date('Y/m/d H:i:s') ." - Copie de la table ".$tableName."\n";
|
||||
|
||||
try {
|
||||
$db->query("CREATE TABLE $tableName ENGINE = MEMORY SELECT * FROM jo.scores_surveillance;");
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
//If the table exist an other scripts is running
|
||||
$error.= "Impossible de lancer le calcul des scores $declencheur, vérifier qu'il y a bien eu un calcul récemment!\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
echo date('Y/m/d H:i:s') ." - Recherche par la source '$declencheur'...\n";
|
||||
|
||||
try {
|
||||
$res = $db->fetchAll($query . $tabQueriesOrder[$queryOrder]);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$nbRows=count($res);
|
||||
echo date('Y/m/d H:i:s') ." - Il y a $nbRows scores à recalculer par '$declencheur'...\n";
|
||||
|
||||
$tabNbRows[$declencheur] = $nbRows;
|
||||
$nbRowsTot+=$nbRows;
|
||||
$tabNbScoresModif[$declencheur] = 0;
|
||||
|
||||
if ( $nbRows > 0 ) {
|
||||
foreach ( $res as $entrep ) {
|
||||
$iRow++;
|
||||
|
||||
//Traitement
|
||||
$siren = $entrep['siren'];
|
||||
if ( !$iInsee->valideSiren($siren) ) continue;
|
||||
$nic=0;
|
||||
|
||||
$indiScorePre = $entrep['indiScore']*1;
|
||||
$encoursPre = $entrep['encours']*1;
|
||||
$dateScore = str_replace('-','',$entrep['indiScoreDate'])*1;
|
||||
$sourceModif = $entrep['source'];
|
||||
$procol = $entrep['procol'];
|
||||
$nbModifs = ($entrep['nbModifs']*1)+1;
|
||||
|
||||
//echo date('Y/m/d - H:i:s') ." - Siren $siren : AVANT SCORE".PHP_EOL;
|
||||
$tabScore = calculIndiScore($siren, $nic, false, 0, false, 'scores', $declencheur);
|
||||
//echo date('Y/m/d - H:i:s') ." - Siren $siren : APRES SCORE".PHP_EOL;
|
||||
|
||||
$indiScore = $tabScore['Indiscore']*1;
|
||||
$naf = $tabScore['NafEnt'];
|
||||
$encours = round($tabScore['encours']);
|
||||
|
||||
if ( $indiScore == $indiScorePre && $encours == $encoursPre && $dateScore!=0 ) {
|
||||
$nbScoresSans++;
|
||||
echo date('Y/m/d H:i:s') ." - $iRow/$nbRowsTot - Siren $siren : $indiScore / 100 ($encours EUR) inchangé depuis $dateScore (Source=$sourceModif).\n";
|
||||
} else {
|
||||
if ($dateScore==0) {
|
||||
$nbScoresNouv++;
|
||||
} else {
|
||||
$nbScoresModif++;
|
||||
$tabNbScoresModif[$declencheur]++;
|
||||
}
|
||||
echo date('Y/m/d H:i:s') ." - $iRow/$nbRowsTot - Siren $siren : $indiScorePre=>$indiScore | $encoursPre=>$encours (Source=$sourceModif) !\n";
|
||||
}
|
||||
|
||||
//Arrêt de l'execution à 19h00
|
||||
if ( date('Hi')*1>=1900 && !$opts->nostop) break;
|
||||
|
||||
// Arret sur indicateur maximum
|
||||
if ( $opts->max && $iRow >= $opts->max) break;
|
||||
}
|
||||
}
|
||||
|
||||
//Delete the remporary table
|
||||
try {
|
||||
$db->query("DROP TABLE IF EXISTS $tableName;");
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rapport
|
||||
*/
|
||||
$duree = round(microtime(true) - $tDeb);
|
||||
$nbCalc = $nbScoresSans + $nbScoresProcol + $nbScoresNouv + $nbScoresModif;
|
||||
|
||||
$subject = "[CHARGEMENT] Calculs IndiScores";
|
||||
if ($opts->declencheur) {
|
||||
$subject.= " - Source ".$opts->declencheur;
|
||||
$message = "Calcul par la source ".$opts->declencheur."\n";
|
||||
}
|
||||
if ($opts->tout) {
|
||||
$subject.= " - Toutes sources";
|
||||
$message = "Calcul pour toutes les sources\n";
|
||||
}
|
||||
$message.= "($nbCalc/$nbRowsTot en $duree s)\n";
|
||||
$message.= $error;
|
||||
$message.= "\n";
|
||||
$message.= "Nombre de scores inchangés .................. $nbScoresSans / $nbRowsTot.\n";
|
||||
$message.= "Nombre de scores inchangés car procol ....... $nbScoresProcol / $nbRowsTot.\n";
|
||||
$message.= "Nombre de scores ajoutés .................... $nbScoresNouv / $nbRowsTot.\n";
|
||||
$message.= "Nombre de scores modifiées .................. $nbScoresModif / $nbRowsTot.\n";
|
||||
$message.= "\n";
|
||||
|
||||
foreach($tabNbRows as $declencheur => $nbTot) {
|
||||
$nbModifs = $tabNbScoresModif[$declencheur]*1;
|
||||
$message.= "Nombre de modifs par '$declencheur'\t...... $nbModifs / $nbTot.\n";
|
||||
}
|
||||
|
||||
// Envoi Mail
|
||||
$mail = new Scores_Mail_Method($c->profil->mail);
|
||||
$mail->setBodyTextC($message);
|
||||
$mail->setFrom('supportdev@scores-decisions.com', 'Machine');
|
||||
$mail->addTo('suivi@scores-decisions.com', 'Suivi');
|
||||
$mail->setSubjectC($subject);
|
||||
$mail->execute();
|
||||
|
||||
echo date('Y/m/d H:i:s') ." - Fin du traitement.".PHP_EOL;
|
||||
<?php
|
||||
/**
|
||||
* Calcul des scores sur la base S&D
|
||||
* Déclencheur
|
||||
* - "bilans1" à 7h
|
||||
* - "ajout" à 8h, 22h
|
||||
* - "insee" à 8h
|
||||
* - "dirigeants" à 9h
|
||||
* - "bodacc" à 13h
|
||||
* - "collecte" à 13h30
|
||||
*
|
||||
* Crontab
|
||||
* 0 12 * * 1-5 /home/scores/batch/scripts/calculScoreSurv.php >> /home/scores/batch/shared/sources/log/calculScoreSurv.log
|
||||
* 0 8 * * 0,6 /home/scores/batch/scripts/calculScoreSurv.php >> /home/scores/batch/shared/sources/log/calculScoreSurv.log
|
||||
*
|
||||
* TODO
|
||||
* - Option lecture sur bdd slave et ecriture sur bdd master
|
||||
* - Modifier les requetes sur les sources pour
|
||||
* Sélectionner suivant des règles toutes les x heures les nouveaux éléments sur x heures + 1
|
||||
* Si déjà calculé du jour, alors on passe sinon on calcul
|
||||
* - Vérifier les éléments déjà calculés si il n'y a pas de changement
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
error_reporting(E_ALL ^ E_STRICT ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
//Options
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(array(
|
||||
'help|?' => "Displays usage information.",
|
||||
'tout|t' => "Calculer tous les scores",
|
||||
'verbose|v' => "Mode bavard ou debug",
|
||||
'ancien|a' => "Recalculer tous les scores avec indiscore>0 et un encours à 0 !",
|
||||
'list|l' => "Lister les déclencheurs existants pour le recalcul des scores",
|
||||
'declencheur|d=s' => "Lancer le calcul des scores pour le déclencheur XXX",
|
||||
'max=s' => "Nombre max d'unités à calculer pour un déclencheur",
|
||||
'nostop' => "Ne pas stopper",
|
||||
'dbread' => "choix de la database pour la lecture des informations (master, slave)",
|
||||
));
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if( isset($opts->help) || count($opts->getOptions())==0 )
|
||||
{
|
||||
echo "Scorer toute la base entreprise S&D.\n";
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$strSelect="s.siren, s.actif, s.procol, s.indiScore, s.indiScore20, s.encours, s.indiScoreDate, scoreSolv, scoreConf, scoreDir, scoreZ, scoreCH, scoreAfdcc1, scoreAfdcc2, scoreAfdcc2note, scoreAltman, scoreAltmanCote, scoreCCF, situFi, infoNote, noteStruct, noteFin, tendance, nbModifs, s.dateUpdate, s.cs, s.csMoisMaj, s.csMoisFin";
|
||||
|
||||
$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 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) 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' 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' 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') 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 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 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 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) 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') 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
|
||||
// et vérifier si ça en enlève en recalcul régulier
|
||||
/* Scores trop anciens */
|
||||
'ancien' => "SELECT $strSelect, 'ancien' AS source FROM ".$tableSurvTmp."_ancien s WHERE s.siren>1000 AND (DATEDIFF(NOW(),s.indiScoreDate)>365) AND s.procol NOT IN('P') AND s.dateUpdate<DATE(NOW()) GROUP BY siren",
|
||||
/** @todo A revoir **/
|
||||
/* Bilans déposés */
|
||||
//'bilans2'=>"SELECT s.siren, s.actif, s.procol, s.indiScore, s.indiScore20, s.encours, s.indiScoreDate, scoreSolv, scoreConf, scoreDir, scoreZ, scoreCH, scoreAfdcc1, scoreAfdcc2, scoreAfdcc2note, scoreAltman, scoreAltmanCote, scoreCCF, situFi, infoNote, noteStruct, noteFin, tendance, nbModifs, 'bilans2' as source, s.dateUpdate FROM scores_surveillance_tmp s, bilans_deposes b WHERE b.siren>1000 AND s.siren=b.siren AND b.dateInsert>s.dateUpdate AND s.procol NOT IN('P') GROUP BY siren",
|
||||
);
|
||||
|
||||
$tabQueriesOrder = array(
|
||||
'siren' => " ORDER BY siren ASC LIMIT 5000",
|
||||
'old' => " ORDER BY s.dateUpdate ASC LIMIT 5000",
|
||||
);
|
||||
$queryOrder = 'old';
|
||||
|
||||
/**
|
||||
* Liste des déclencheurs
|
||||
*/
|
||||
if ( $opts->list ) {
|
||||
foreach ( $tabQueries as $key => $query) {
|
||||
echo "\t- $key\n";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
$db = Zend_Db::factory($c->profil->db->metier);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||
|
||||
/**
|
||||
* Delete all temporary table
|
||||
*/
|
||||
$day = date('N');
|
||||
if ( $opts->tout && $day == 6) {
|
||||
foreach ( $tabQueries as $key => $query) {
|
||||
try {
|
||||
$db->query("DROP TABLE IF EXISTS $key;");
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Force declencheur
|
||||
*/
|
||||
if ( $opts->declencheur ) {
|
||||
if ( in_array($opts->declencheur, array_keys($tabQueries)) ) {
|
||||
$tabQueries = array($opts->declencheur => $tabQueries[$opts->declencheur]);
|
||||
} else {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
require_once APPLICATION_PATH.'/configs/config.php';
|
||||
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
require_once 'Metier/Scores/MScores.php';
|
||||
|
||||
$tDeb=microtime(true);
|
||||
|
||||
$dateJour=date('Y-m-d');
|
||||
|
||||
function wsLog($service, $siret='', $ref='') {}
|
||||
|
||||
$message = $error = '';
|
||||
echo date('Y/m/d H:i:s') ." - DEBUT du programme de calcul des scores en surveillance...\n";
|
||||
|
||||
/**
|
||||
* Mise en surveillance de l'ensemble des scores
|
||||
*/
|
||||
if ( $opts->tout ) {
|
||||
echo date('Y/m/d H:i:s') ." - Mise en surveillance Scores de l'ensemble des demandes de scoring...\n";
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lancement du programme
|
||||
*/
|
||||
echo date('Y/m/d H:i:s') ." - Recherche des scores susceptibles d'avoir changés par déclencheur...\n";
|
||||
|
||||
$nbScoresSans=$nbScoresModif=$nbScoresNouv=$nbScoresProcol=$iRow=$nbRowsTot=0;
|
||||
|
||||
$iInsee = new Metier_Insee_MInsee();
|
||||
foreach ($tabQueries as $declencheur => $query)
|
||||
{
|
||||
$tableName = $tableSurvTmp . '_' . $declencheur;
|
||||
echo date('Y/m/d H:i:s') ." - Copie de la table ".$tableName."\n";
|
||||
|
||||
try {
|
||||
$db->query("CREATE TABLE $tableName ENGINE = MEMORY SELECT * FROM jo.scores_surveillance;");
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
//If the table exist an other scripts is running
|
||||
$error.= "Impossible de lancer le calcul des scores $declencheur, vérifier qu'il y a bien eu un calcul récemment!\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
echo date('Y/m/d H:i:s') ." - Recherche par la source '$declencheur'...\n";
|
||||
|
||||
try {
|
||||
$res = $db->fetchAll($query . $tabQueriesOrder[$queryOrder]);
|
||||
} catch(Zend_Db_Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$nbRows=count($res);
|
||||
echo date('Y/m/d H:i:s') ." - Il y a $nbRows scores à recalculer par '$declencheur'...\n";
|
||||
|
||||
$tabNbRows[$declencheur] = $nbRows;
|
||||
$nbRowsTot+=$nbRows;
|
||||
$tabNbScoresModif[$declencheur] = 0;
|
||||
|
||||
if ( $nbRows > 0 ) {
|
||||
foreach ( $res as $entrep ) {
|
||||
$iRow++;
|
||||
|
||||
//Traitement
|
||||
$siren = $entrep['siren'];
|
||||
if ( !$iInsee->valideSiren($siren) ) continue;
|
||||
$nic=0;
|
||||
|
||||
$indiScorePre = $entrep['indiScore']*1;
|
||||
$encoursPre = $entrep['encours']*1;
|
||||
$dateScore = str_replace('-','',$entrep['indiScoreDate'])*1;
|
||||
$sourceModif = $entrep['source'];
|
||||
$procol = $entrep['procol'];
|
||||
$nbModifs = ($entrep['nbModifs']*1)+1;
|
||||
|
||||
//echo date('Y/m/d - H:i:s') ." - Siren $siren : AVANT SCORE".PHP_EOL;
|
||||
$tabScore = calculIndiScore($siren, $nic, false, 0, false, 'scores', $declencheur);
|
||||
//echo date('Y/m/d - H:i:s') ." - Siren $siren : APRES SCORE".PHP_EOL;
|
||||
|
||||
$indiScore = $tabScore['Indiscore']*1;
|
||||
$naf = $tabScore['NafEnt'];
|
||||
$encours = round($tabScore['encours']);
|
||||
|
||||
if ( $indiScore == $indiScorePre && $encours == $encoursPre && $dateScore!=0 ) {
|
||||
$nbScoresSans++;
|
||||
echo date('Y/m/d H:i:s') ." - $iRow/$nbRowsTot - Siren $siren : $indiScore / 100 ($encours EUR) inchangé depuis $dateScore (Source=$sourceModif).\n";
|
||||
} else {
|
||||
if ($dateScore==0) {
|
||||
$nbScoresNouv++;
|
||||
} else {
|
||||
$nbScoresModif++;
|
||||
$tabNbScoresModif[$declencheur]++;
|
||||
}
|
||||
echo date('Y/m/d H:i:s') ." - $iRow/$nbRowsTot - Siren $siren : $indiScorePre=>$indiScore | $encoursPre=>$encours (Source=$sourceModif) !\n";
|
||||
}
|
||||
|
||||
//Arrêt de l'execution à 19h00
|
||||
if ( date('Hi')*1>=1900 && !$opts->nostop) break;
|
||||
|
||||
// Arret sur indicateur maximum
|
||||
if ( $opts->max && $iRow >= $opts->max) break;
|
||||
}
|
||||
}
|
||||
|
||||
//Delete the remporary table
|
||||
try {
|
||||
$db->query("DROP TABLE IF EXISTS $tableName;");
|
||||
} catch(Zend_Db_Adapter_Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rapport
|
||||
*/
|
||||
$duree = round(microtime(true) - $tDeb);
|
||||
$nbCalc = $nbScoresSans + $nbScoresProcol + $nbScoresNouv + $nbScoresModif;
|
||||
|
||||
$subject = "[CHARGEMENT] Calculs IndiScores";
|
||||
if ($opts->declencheur) {
|
||||
$subject.= " - Source ".$opts->declencheur;
|
||||
$message = "Calcul par la source ".$opts->declencheur."\n";
|
||||
}
|
||||
if ($opts->tout) {
|
||||
$subject.= " - Toutes sources";
|
||||
$message = "Calcul pour toutes les sources\n";
|
||||
}
|
||||
$message.= "($nbCalc/$nbRowsTot en $duree s)\n";
|
||||
$message.= $error;
|
||||
$message.= "\n";
|
||||
$message.= "Nombre de scores inchangés .................. $nbScoresSans / $nbRowsTot.\n";
|
||||
$message.= "Nombre de scores inchangés car procol ....... $nbScoresProcol / $nbRowsTot.\n";
|
||||
$message.= "Nombre de scores ajoutés .................... $nbScoresNouv / $nbRowsTot.\n";
|
||||
$message.= "Nombre de scores modifiées .................. $nbScoresModif / $nbRowsTot.\n";
|
||||
$message.= "\n";
|
||||
|
||||
foreach($tabNbRows as $declencheur => $nbTot) {
|
||||
$nbModifs = $tabNbScoresModif[$declencheur]*1;
|
||||
$message.= "Nombre de modifs par '$declencheur'\t...... $nbModifs / $nbTot.\n";
|
||||
}
|
||||
|
||||
// Envoi Mail
|
||||
$mail = new Scores_Mail_Method($c->profil->mail);
|
||||
$mail->setBodyTextC($message);
|
||||
$mail->setFrom('supportdev@scores-decisions.com', 'Machine');
|
||||
$mail->addTo('suivi@scores-decisions.com', 'Suivi');
|
||||
$mail->setSubjectC($subject);
|
||||
$mail->execute();
|
||||
|
||||
echo date('Y/m/d H:i:s') ." - Fin du traitement.\n";
|
@ -164,4 +164,3 @@ foreach($sourcesList as $declencheur => $sql)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,14 +7,14 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
@ -1,406 +1,406 @@
|
||||
<?php
|
||||
<?php
|
||||
/**
|
||||
* crontab
|
||||
* 30 9 * * * /home/scores/batch/scripts/getInpiDecisions.php >> /home/scores/batch/shared/sources/log/getInpiDecisions.log
|
||||
* crontab
|
||||
* 30 9 * * * /home/scores/batch/scripts/getInpiDecisions.php >> /home/scores/batch/shared/sources/log/getInpiDecisions.log
|
||||
* 00 19 * * * /home/scores/batch/getInpiDecisions.php >> /home/scores/batch/shared/sources/log/getInpiDecisionsSoir.log
|
||||
*/
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
$db = Zend_Db::factory($c->profil->db->metier);
|
||||
Zend_Db_Table::setDefaultAdapter($db);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
Zend_Registry::set('config', $c);
|
||||
$db = Zend_Db::factory($c->profil->db->metier);
|
||||
Zend_Db_Table::setDefaultAdapter($db);
|
||||
|
||||
require_once APPLICATION_PATH.'/configs/config.php';
|
||||
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
$table='jo.annonces';
|
||||
|
||||
function wsLog($service, $siret='', $ref='') {}
|
||||
|
||||
define('RNCS_IMR_FTP_HOST', '194.5.119.252');
|
||||
define('RNCS_IMR_FTP_LOGIN', 'score');
|
||||
define('RNCS_IMR_FTP_PASS', '1eUauTJZ');
|
||||
define('RNCS_IMR_FTP_DIR', '/var/home_ftp/score/Send/');
|
||||
define('RNCS_IMR_FTP_LOCALDIR', '/home/scores/batch/shared/sources/rncs/extelia/');
|
||||
define('RNCS_IMR_BACKUP_DIR', '/home/scores/batch/shared/sources/rncs/imr/');
|
||||
|
||||
$strInfoScript='Usage : '.basename($argv[0]). " <option> [FICHIERS]
|
||||
Chargement du/des informations complémentaires en provenance des actes Infogreffe (license RNCS IMR).
|
||||
|
||||
Options :
|
||||
-d Mode debug (Verbosité au maximum)
|
||||
-q Ne pas mettre à jour les listes d'évènements commandés ce jour
|
||||
-b Ne pas mettre à jour les listes des nouveaux bilans PDF
|
||||
-j Ne pas collecter les évènements INPI (annonces JAL Inpi)
|
||||
-s:AAAAMMJJ Reprendre le chargement des annonces JAL Inpi à compter du AAAAMMJJ
|
||||
Reprendre les actes INPI du AAAAMMJJ
|
||||
-i:XXX Reprendre les accès aux évènements Infogreffe à la ligne XXX
|
||||
";
|
||||
|
||||
global $iInsee;
|
||||
|
||||
$iDb = new WDB();
|
||||
$iDbR = new WDB();
|
||||
$iInsee = new Metier_Insee_MInsee($iDb);
|
||||
$iRncs = new Metier_Partenaires_MRncs($iDb);
|
||||
|
||||
$nbInsert=$nbDeja=0;
|
||||
$nbNatu=$nbDeci=0;
|
||||
|
||||
$modeDebug=false; // Par défaut, pas de message de debug
|
||||
$iReprise=false; // Reprendre les accès Infogreffe à la ligne d'évènenement nouveaux reçu XXX
|
||||
|
||||
$message=''; // Initialisation du contenu du message d'information
|
||||
$loadInpiLocal=true; // Par défaut on charge les évènements INPI (génération des annonces JAL)
|
||||
$jourStock=0; // Jour du stock SSAMMJJ (génération des annonces JAL à partir du ...)
|
||||
$loadActesDuJour=true; // Par défaut on charge les listes d'évènements commandés ce jour par l'extranet
|
||||
$loadBilans=true; // Par défaut on charge les listes de bilans IMAGES disponibles
|
||||
|
||||
$argv=$_SERVER['argv'];
|
||||
|
||||
for ($i=1,$j=0; isset($argv[$i]); $i++) {
|
||||
if (substr($argv[$i],0,1)=='-') {
|
||||
switch (substr($argv[$i],1,1)) {
|
||||
case 'd': $modeDebug=true; break;
|
||||
case 's': $jourStock=substr($argv[$i],3,8); break;
|
||||
case 'j': $loadInpiLocal=false; break;
|
||||
case 'q': $loadActesDuJour=false; break;
|
||||
case 'b': $loadBilans=false; break;
|
||||
case 'i': $iReprise=substr($argv[$i],3); break;
|
||||
case '-':
|
||||
case '?': die($strInfoScript); break;
|
||||
default: die('Option '. $argv[$i] . ' inconnue !'."\n"); break;
|
||||
}
|
||||
} else $tabFichLigneCmd[]=$argv[$i];
|
||||
}
|
||||
|
||||
echo date ('Y/m/d - H:i:s') . " - Début du traitement des évènements INPI"."\n";
|
||||
|
||||
$strDateFlux='';
|
||||
if ($jourStock>0) {
|
||||
$dateMaj=WDate::dateT('Ymd', 'Y-m-d', $jourStock);
|
||||
$strDateFlux=" AND dateFlux='$dateMaj' ";
|
||||
$message.="Forçage du dernier chargement de la collecte INPI en date du $dateMaj...\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Forçage de l'accès aux évènements Infogreffe en date du $dateMaj..."."\n";
|
||||
}
|
||||
|
||||
// Date du dernier chargement INPI
|
||||
$tabTmp=$iDb->select('jo.rncs_chargements', "nomFichier, dateFlux, nbEvenAnn", "1 $strDateFlux ORDER BY dateFlux DESC LIMIT 0,1", true, MYSQL_ASSOC);
|
||||
echo "SELECT nomFichier, dateFlux, nbEvenAnn
|
||||
FROM jo.rncs_chargements
|
||||
WHERE 1 $strDateFlux ORDER BY dateFlux DESC LIMIT 0,1;".mysql_error()."\n";
|
||||
$dateMaj=$tabTmp[0]['dateFlux'];
|
||||
$nomFichier=$tabTmp[0]['nomFichier'];
|
||||
$nbEvenAnn=$tabTmp[0]['nbEvenAnn'];
|
||||
echo "dateMaj='$dateMaj', nomFichier='$nomFichier', nbEvenAnn=$nbEvenAnn"."\n";
|
||||
|
||||
// Nombre d'évènements chargés
|
||||
echo "SELECT e.siren, e.codeInterne, e.dateDepot, e.codeEven, t.libEven, t.codEven, e.flux
|
||||
FROM jo.rncs_even e, jo.tabEvenRncs t
|
||||
WHERE e.flux='$dateMaj' AND e.codeEven=t.codeEven GROUP BY siren, dateDepot, codeEven;"."\n";
|
||||
$nbEven=$iDbR->select( 'jo.rncs_even e, jo.tabEvenRncs t',
|
||||
"e.siren, e.codeInterne, e.dateDepot, e.codeEven, t.libEven, t.codEven, e.flux",
|
||||
"e.flux='$dateMaj' AND e.codeEven=t.codeEven GROUP BY siren, dateDepot, codeEven LIMIT 0,100000",
|
||||
true, MYSQL_ASSOC, true);
|
||||
echo mysql_error()."\n";
|
||||
|
||||
// Nombre d'évènements déjà mis à jour (complétés)
|
||||
$tabTmp=$iDb->select('jo.rncs_even_info', "count(*) AS nb", "flux='$dateMaj'", true, MYSQL_ASSOC);
|
||||
$nbEvenMaj=$tabTmp[0]['nb'];
|
||||
if ($nbEvenMaj>$nbEven && !$iReprise && $nbEvenAnn>0) {
|
||||
$message.="Le dernier chargement INPI date du $dateMaj et contient $nbEvenMaj évènements déjà mis à jour sur les $nbEven évènements du jour !\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Le dernier chargement INPI date du $dateMaj et contient $nbEvenMaj évènements déjà mis à jour sur les $nbEven évènements du jour !."."\n";
|
||||
} else {
|
||||
$message.="Le dernier chargement INPI date du $dateMaj et contient $nbEven nouveaux évènements dont $nbEvenMaj à jour.\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Le dernier chargement INPI date du $dateMaj et contient $nbEven nouveaux évènements dont $nbEvenMaj à jour."."\n";
|
||||
$sirenPre=false;
|
||||
$iEven=-1;
|
||||
while($even=$iDbR->fetch(MYSQL_ASSOC)) {
|
||||
$iEven++;
|
||||
if ($iEven<$iReprise) continue;
|
||||
|
||||
echo "$iEven/$nbEven:".$even['siren'].' le '.$even['dateDepot'].': '.$even['codeEven'].' '.$even['libEven'].' ('.$even['codeInterne'].') ... ';
|
||||
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($even['siren']);
|
||||
$tabActes = $infogreffe->getList(true);
|
||||
|
||||
foreach ( $tabActes as $acte ) {
|
||||
if ( $even['dateDepot'] == $acte->DepotDate ) {
|
||||
|
||||
if ($acte->ActeDate=='0000-00-00') {
|
||||
$dateActe = $even['dateDepot'];
|
||||
} else {
|
||||
$dateActe = $acte->ActeDate;
|
||||
}
|
||||
|
||||
echo $acte->infos;
|
||||
$infos = explode(' : ',$acte->infos);
|
||||
if ( count($infos)>1 ) {
|
||||
$acteNature = $infos[0];
|
||||
}
|
||||
|
||||
$tabInsert=array(
|
||||
'siren' => $even['siren'],
|
||||
'codeInterne' => $even['codeInterne'],
|
||||
'dateDepot' => $even['dateDepot'],
|
||||
'codeEven' => $even['codeEven'],
|
||||
'flux' => $even['flux'],
|
||||
'depot_num' => $acte->DepotNum,
|
||||
'depot_date' => $acte->DepotDate,
|
||||
'acte_num' => $acte->ActeNum,
|
||||
'acte_date' => $dateActe,
|
||||
'acte_type' => $acte->ActeType,
|
||||
'acte_lib' => $acte->ActeTypeLabel,
|
||||
'acte_pages' => $acte->ActeNumberOfPages,
|
||||
'acte_nature' => $acte->ActeDecisionNature,
|
||||
'acte_decision' => $acte->ActeDecisionLabel,
|
||||
'collecte' => $even['codEven'],
|
||||
);
|
||||
|
||||
if ( $iDb->insert('jo.rncs_even_info', $tabInsert) ) {
|
||||
$nbInsert++;
|
||||
if ($acte->ActeDecisionNature<>'') $nbNatu++;
|
||||
if ($acte->ActeDecisionLabel<>'') $nbDeci++;
|
||||
} else {
|
||||
$nbDeja++;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
$sirenPre=$even['siren'];
|
||||
}
|
||||
$message.="$nbInsert évènements avec compléments ajoutés et $nbDeja évènements déjà en base ($nbNatu natures et $nbDeci décisions.\r\n";
|
||||
echo date('Y/m/d - H:i:s') ." - $nbInsert évènements avec compléments ajoutés et $nbDeja évènements déjà en base ($nbNatu natures et $nbDeci décisions."."\n";
|
||||
$iDb->update('jo.rncs_chargements', array('nbEvenAnn'=>@$iEven*1), "nomFichier='$nomFichier'");
|
||||
}
|
||||
|
||||
if ($loadInpiLocal) {
|
||||
/**
|
||||
* Evènements importants en collecte INPI
|
||||
*/
|
||||
if ($jourStock>0) {
|
||||
$dateMaj=WDate::dateT('Ymd', 'Y-m-d', $jourStock).' 00:00:00';
|
||||
$message.="Forçage du dernier chargement de la collecte INPI en date du $dateMaj...\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Forçage du dernier chargement de la collecte INPI en date du $dateMaj..."."\n";
|
||||
}
|
||||
|
||||
$AnnDb=$iDb->select('jo.rncs_even_info j, jo.rncs_entrep e, jo.tabEvenRncs l',
|
||||
"j.siren, e.sirenValide, l.codEven AS typeEven, j.acte_date AS dateJugement, j.depot_date AS dateSource,
|
||||
j.dateInsert, 'PP' AS source, e.triCode AS tribunal, e.raisonSociale, l.codeEven AS codeEvenRncs,
|
||||
j.acte_nature, j.acte_decision, e.flux",
|
||||
"j.dateInsert>'$dateMaj' AND j.siren=e.siren AND DATEDIFF(NOW(), j.dateDepot)<=60 AND
|
||||
j.codeEven=l.codeEven AND
|
||||
(l.codEven>0
|
||||
OR j.acte_decision LIKE '%FUSION%' OR j.acte_decision LIKE '%ABSORPTION%'
|
||||
OR j.acte_decision LIKE '%TRANSMISSION%UNIVERSELLE%PATRIMOINE%'
|
||||
OR j.acte_decision LIKE '%TUP%' OR j.acte_decision LIKE '%T.U.P%'
|
||||
OR j.acte_decision LIKE '%DISSOLUTION%' OR j.acte_nature LIKE '%DISSOLUTION%'
|
||||
OR j.acte_decision LIKE '%MISE%SOMMEIL%'
|
||||
OR j.acte_decision LIKE '%APPORT%PARTIEL%ACTIF%'
|
||||
OR j.acte_decision LIKE '%SCISSION%'
|
||||
) ",
|
||||
false, MYSQL_ASSOC);
|
||||
$nbAnnonces=count($AnnDb);
|
||||
|
||||
$message.="Il y a $nbAnnonces énements INPI IMR depuis le dernier chargement du $dateMaj :\r\n";
|
||||
echo date('Y/m/d - H:i:s') ." - Il y a $nbAnnonces énements INPI IMR depuis le dernier chargement du $dateMaj."."\n";
|
||||
|
||||
foreach ($AnnDb as $i=>$tabInsert) {
|
||||
$siren=$tabInsert['siren'];
|
||||
$dateJugement=$tabInsert['dateJugement'];
|
||||
if ($dateJugement=='0000-00-00') $tabInsert['dateJugement']=$tabInsert['dateSource'];
|
||||
$typeEven=$tabInsert['typeEven']*1;
|
||||
$strEven='';
|
||||
if ($typeEven==0) {//projet de fusion par absorption
|
||||
if (preg_match('/(FUSION|ABSORPTION)/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $typeEven=2726;
|
||||
else $typeEven=2725;
|
||||
} elseif (preg_match('/SCISSION/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $typeEven=2741;
|
||||
else $typeEven=2740;
|
||||
} elseif (preg_match('/TRANSMISSION.{1,3}UNIVERSELLE.{1,5}PATRIMOINE/i', $tabInsert['acte_decision'], $matches) ||
|
||||
preg_match('/T.U.P/i', $tabInsert['acte_decision'], $matches) ||
|
||||
preg_match('/\bTUP\b/i', $tabInsert['acte_decision'], $matches))
|
||||
$typeEven=2620;
|
||||
elseif (preg_match('/APPORT.{1,3}PARTIEL.{1,5}ACTIF/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $typeEven=2665;
|
||||
else $typeEven=2661;
|
||||
} elseif (preg_match('/DISSOLUTION/i', $tabInsert['acte_decision'], $matches) ||
|
||||
preg_match('/DISSOLUTION/i', $tabInsert['acte_nature'], $matches) )
|
||||
$typeEven=2203;
|
||||
elseif (preg_match('/MISE.{1,9}SOMMEIL/iu', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/REPRISE/i', $tabInsert['acte_decision'], $matches)) $typeEven=2316;
|
||||
else $typeEven=2206;
|
||||
}
|
||||
} elseif (preg_match('/(FUSION|ABSORPTION)/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $strEven=2726;
|
||||
else $strEven=2725;
|
||||
}
|
||||
|
||||
$tabInsert['complement']='';
|
||||
if ($typeEven==2100 || $typeEven==2101 || $typeEven==2102) { // Modification de capital
|
||||
$tabIdentite=$iRncs->getInfosEntrep($siren);
|
||||
$tabInsert['montant']=$tabIdentite['capital'];
|
||||
//$tabInsert['actionsNb'] ='';
|
||||
/** @todo Rechercher l'ancien capital **/
|
||||
} elseif ($typeEven==2305) { // Modification de la dénomination
|
||||
$tabIdentite=$iRncs->getInfosEntrep($siren);
|
||||
$tabInsert['complement'].="Nouvelle dénomination : ".$tabIdentite['raisonSociale'].'. ';
|
||||
|
||||
// Recherche de l'ancienne RS
|
||||
$dateFlux=$tabInsert['flux'];
|
||||
$rep=$iDb->select( 'jo.rncs_modifs',
|
||||
'siren, `table`, champs, valeur, flux, dateInsert',
|
||||
"siren=$siren AND type='raisonSociale' AND `table`='rncs_entrep'
|
||||
AND flux<='$dateFlux' ORDER BY flux DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$modif=@trim($rep[0]['valeur']).'';
|
||||
if ($modif<>'')
|
||||
$tabInsert['complement'].="Ancienne dénomination : $modif. ";
|
||||
|
||||
if ($tabIdentite['sigle']<>'')
|
||||
$tabInsert['complement'].="Sigle : ".$tabIdentite['sigle'].'. ';
|
||||
} elseif ($typeEven==2307) { // Modification de la forme juridique
|
||||
$tabIdentite=$iRncs->getInfosEntrep($siren);
|
||||
$tabInsert['nouvFJ']=$tabIdentite['cj'];
|
||||
/** @todo Rechercher l'ancienne FJ **/
|
||||
} elseif ($typeEven==2315) {
|
||||
switch ($tabInsert['codeEvenRncs']*1) {
|
||||
case 34: $tabInsert['complement'].='Changement de Gérant : '; break;
|
||||
case 37: $tabInsert['complement'].='Changement de Président : '; break;
|
||||
case 40: $tabInsert['complement'].='Modification du Conseil d\'Administration : '; break;
|
||||
case 81: $tabInsert['complement'].='Changement de Commissaire aux Comptes : '; break;
|
||||
default: $tabInsert['complement'].='Administration : '; break;
|
||||
}
|
||||
$dirs=$iInsee->getDirigeants($siren,false);
|
||||
foreach ($dirs as $nb=>$dir) {
|
||||
$tabInsert['complement'].=$dir['Titre'].' : '.@$dir['Civilite'].' '.$dir['Nom'].' '.$dir['Prenom'];
|
||||
if (($nb+1)<count($dirs))
|
||||
$tabInsert['complement'].=', ';
|
||||
else
|
||||
$tabInsert['complement'].='. ';
|
||||
}
|
||||
} elseif ($typeEven==2320) { // RECONSTITUTION DE LA L'ACTIF NET
|
||||
if (preg_match('/MOITIE/i', $tabInsert['acte_nature'], $matches))
|
||||
$typeEven=2321;
|
||||
} elseif ($typeEven==2203 &&
|
||||
(preg_match('/SANS/i', $tabInsert['acte_nature'], $matches)) ||
|
||||
(preg_match('/SANS/i', $tabInsert['acte_decision'], $matches))
|
||||
)
|
||||
// On ignore l'annonce
|
||||
continue;
|
||||
|
||||
unset($tabInsert['codeEvenRncs']);
|
||||
unset($tabInsert['flux']);
|
||||
//if ($tabInsert['acte_nature']<>'') $tabInsert['complement'].=$tabInsert['acte_nature'].' ';
|
||||
if ($tabInsert['acte_decision']<>'') $tabInsert['complement'].=strtolower($tabInsert['acte_decision']).' ';
|
||||
unset($tabInsert['acte_nature']);
|
||||
unset($tabInsert['acte_decision']);
|
||||
if ($strEven<>'') $tabInsert['strEven']=$strEven;
|
||||
|
||||
//echo "$siren $dateJugement $typeEven"."\n";
|
||||
$tabTmp=@$iInsee->getIdentiteLight($tabInsert['siren']);
|
||||
$tabInsert['typeEven'] = $typeEven;
|
||||
if ($typeEven==0) {
|
||||
print_r($tabInsert);
|
||||
sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', 'Chargement des évènements Greffes', "Erreur typeEven=0 ligne n°$i ($dateMaj)"."\n".print_r($tabInsert,true));
|
||||
//die();
|
||||
}
|
||||
$tabInsert['adresse'] = $tabTmp['Adresse'];
|
||||
$tabInsert['codePostal'] = $tabTmp['CP'];
|
||||
$tabInsert['ville'] = $tabTmp['Ville'];
|
||||
if (!$iDb->insert($table, $tabInsert)) {
|
||||
if (mysql_errno()==1062) {
|
||||
$tabTmp=$iDb->select($table, 'id, siren, typeEven, dateJugement, inter1type, inter1id, inter1nom, inter2type, inter2id, inter2nom, dateSource, dateInsert, source, tribunal, raisonSociale',"siren=$siren AND dateJugement='$dateJugement' AND typeEven=$typeEven", false, MYSQL_ASSOC);
|
||||
$tabEnbase=@$tabTmp[0];
|
||||
if ($tabEnbase['source']=='PC') {
|
||||
unset($tabInsert['source']);
|
||||
unset($tabInsert['dateInsert']);
|
||||
if (!$iDb->update($table, $tabInsert,"siren=$siren AND dateJugement='$dateJugement' AND typeEven=$typeEven", false, MYSQL_ASSOC))
|
||||
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .' : '. mysql_error() ." lors de la mise à jour de l'évènement $typeEven en date du $dateJugement pour $siren..."."\n";
|
||||
else $nbAnnUpdateE++;
|
||||
}
|
||||
} else
|
||||
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .' : '. mysql_error() ." lors de l'ajout de l'évènement $typeEven en date du $dateJugement pour $siren..."."\n";
|
||||
} else {
|
||||
$nbAnnInsertE++;
|
||||
echo date('Y/m/d - H:i:s') ." - Ajout de l'évènement $typeEven en date du $dateJugement pour $siren..."."\n";
|
||||
@$tabCptAnn[$typeEven]++;
|
||||
}
|
||||
}
|
||||
|
||||
$message.=" $nbAnnInsertE ajouts et $nbAnnUpdateE mises à jours sur $nbAnnonces annonces.\r\n\r\n";
|
||||
$message.=print_r(@$tabCptAnn, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de la liste des actes greffe à partir des éléments consultés
|
||||
*/
|
||||
if ( $loadActesDuJour ) {
|
||||
|
||||
$today=date('Y-m-d').' 00:00:00';
|
||||
$nbDepotsTot=0;
|
||||
$tabActes = $iDb->select("sdv1.logs", "siren", "page='greffe_actes' AND dateHeure>='$today' GROUP BY siren", false, MYSQL_ASSOC);
|
||||
shuffle($tabActes);
|
||||
$nbActesQuoti = count($tabActes);
|
||||
if ( $nbActesQuoti > 0) {
|
||||
foreach ($tabActes as $i=>$acte) {
|
||||
echo date('Y/m/d - H:i:s')." - $i/$nbActesQuoti: Mise à jour de la liste des actes pour ".$acte['siren'].'... ';
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($acte['siren']);
|
||||
$nbDepots = count($infogreffe->getList(true));
|
||||
echo date('Y/m/d - H:i:s')."$nbDepots dépot(s)."."\n";
|
||||
$nbDepotsTot+=$nbDepots;
|
||||
}
|
||||
}
|
||||
$message.="$nbActesQuoti listes d'évènements mises à jours pour un total de $nbDepotsTot dépots (listes du jour).\r\n";
|
||||
echo date('Y/m/d - H:i:s')." - $nbActesQuoti listes d'évènements mises à jours pour un total de $nbDepotsTot dépots (listes du jour)."."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de la liste des bilans greffe à partir des bilans déposés
|
||||
*/
|
||||
if ( $loadBilans ) {
|
||||
$tabTmp = $iDb->select('jo.bilans_deposes', 'MAX(DATE(dateInsert)) AS lastMAJ', '1', true, MYSQL_ASSOC);
|
||||
$lastUpdate = $tabTmp[0]['lastMAJ'];
|
||||
$message.="La dernière mise à jour des bilans Greffes date du $lastUpdate !\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - La dernière mise à jour des bilans Greffes date du $lastUpdate !"."\n";
|
||||
|
||||
$bilansDep = $iDb->select('jo.bilans_deposes', "siren, nicSiege, dateProvPartenaire, dateExercice, dureeExercice, monnaie, chiffreAffaire", "dateInsert>'$lastUpdate 00:00:00'", true, MYSQL_ASSOC);
|
||||
echo mysql_error();
|
||||
|
||||
$nbBilans = count($bilansDep);
|
||||
$message.="Il y a $nbBilans listes de bilans PDF à mettre à jour !\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Il y a $nbBilans listes de bilans PDF à mettre à jour !"."\n";
|
||||
|
||||
if ( $nbBilans > 0 ) {
|
||||
foreach ( $bilansDep as $iBilan=>$bil ) {
|
||||
echo date('Y/m/d - H:i:s') . " - $iBilan/$nbBilans: Mise à jour de la liste de bilans PDF pour ".$bil['siren']."... \n";
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($bil['siren']);
|
||||
$infogreffe->getList(true);
|
||||
}
|
||||
}
|
||||
|
||||
$message.="Fin de la mise à jour des listes de bilans PDF.\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Fin de la mise à jour des listes de bilans PDF."."\n";
|
||||
}
|
||||
|
||||
//Envoi du mail d'information
|
||||
sendMail('production@scores-decisions.com', 'suivi@scores-decisions.com', 'Chargement des informations Greffes', $message);
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
$table='jo.annonces';
|
||||
|
||||
function wsLog($service, $siret='', $ref='') {}
|
||||
|
||||
define('RNCS_IMR_FTP_HOST', '194.5.119.252');
|
||||
define('RNCS_IMR_FTP_LOGIN', 'score');
|
||||
define('RNCS_IMR_FTP_PASS', '1eUauTJZ');
|
||||
define('RNCS_IMR_FTP_DIR', '/var/home_ftp/score/Send/');
|
||||
define('RNCS_IMR_FTP_LOCALDIR', '/home/scores/batch/shared/sources/rncs/extelia/');
|
||||
define('RNCS_IMR_BACKUP_DIR', '/home/scores/batch/shared/sources/rncs/imr/');
|
||||
|
||||
$strInfoScript='Usage : '.basename($argv[0]). " <option> [FICHIERS]
|
||||
Chargement du/des informations complémentaires en provenance des actes Infogreffe (license RNCS IMR).
|
||||
|
||||
Options :
|
||||
-d Mode debug (Verbosité au maximum)
|
||||
-q Ne pas mettre à jour les listes d'évènements commandés ce jour
|
||||
-b Ne pas mettre à jour les listes des nouveaux bilans PDF
|
||||
-j Ne pas collecter les évènements INPI (annonces JAL Inpi)
|
||||
-s:AAAAMMJJ Reprendre le chargement des annonces JAL Inpi à compter du AAAAMMJJ
|
||||
Reprendre les actes INPI du AAAAMMJJ
|
||||
-i:XXX Reprendre les accès aux évènements Infogreffe à la ligne XXX
|
||||
";
|
||||
|
||||
global $iInsee;
|
||||
|
||||
$iDb = new WDB();
|
||||
$iDbR = new WDB();
|
||||
$iInsee = new Metier_Insee_MInsee($iDb);
|
||||
$iRncs = new Metier_Partenaires_MRncs($iDb);
|
||||
|
||||
$nbInsert=$nbDeja=0;
|
||||
$nbNatu=$nbDeci=0;
|
||||
|
||||
$modeDebug=false; // Par défaut, pas de message de debug
|
||||
$iReprise=false; // Reprendre les accès Infogreffe à la ligne d'évènenement nouveaux reçu XXX
|
||||
|
||||
$message=''; // Initialisation du contenu du message d'information
|
||||
$loadInpiLocal=true; // Par défaut on charge les évènements INPI (génération des annonces JAL)
|
||||
$jourStock=0; // Jour du stock SSAMMJJ (génération des annonces JAL à partir du ...)
|
||||
$loadActesDuJour=true; // Par défaut on charge les listes d'évènements commandés ce jour par l'extranet
|
||||
$loadBilans=true; // Par défaut on charge les listes de bilans IMAGES disponibles
|
||||
|
||||
$argv=$_SERVER['argv'];
|
||||
|
||||
for ($i=1,$j=0; isset($argv[$i]); $i++) {
|
||||
if (substr($argv[$i],0,1)=='-') {
|
||||
switch (substr($argv[$i],1,1)) {
|
||||
case 'd': $modeDebug=true; break;
|
||||
case 's': $jourStock=substr($argv[$i],3,8); break;
|
||||
case 'j': $loadInpiLocal=false; break;
|
||||
case 'q': $loadActesDuJour=false; break;
|
||||
case 'b': $loadBilans=false; break;
|
||||
case 'i': $iReprise=substr($argv[$i],3); break;
|
||||
case '-':
|
||||
case '?': die($strInfoScript); break;
|
||||
default: die('Option '. $argv[$i] . ' inconnue !'."\n"); break;
|
||||
}
|
||||
} else $tabFichLigneCmd[]=$argv[$i];
|
||||
}
|
||||
|
||||
echo date ('Y/m/d - H:i:s') . " - Début du traitement des évènements INPI"."\n";
|
||||
|
||||
$strDateFlux='';
|
||||
if ($jourStock>0) {
|
||||
$dateMaj=WDate::dateT('Ymd', 'Y-m-d', $jourStock);
|
||||
$strDateFlux=" AND dateFlux='$dateMaj' ";
|
||||
$message.="Forçage du dernier chargement de la collecte INPI en date du $dateMaj...\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Forçage de l'accès aux évènements Infogreffe en date du $dateMaj..."."\n";
|
||||
}
|
||||
|
||||
// Date du dernier chargement INPI
|
||||
$tabTmp=$iDb->select('jo.rncs_chargements', "nomFichier, dateFlux, nbEvenAnn", "1 $strDateFlux ORDER BY dateFlux DESC LIMIT 0,1", true, MYSQL_ASSOC);
|
||||
echo "SELECT nomFichier, dateFlux, nbEvenAnn
|
||||
FROM jo.rncs_chargements
|
||||
WHERE 1 $strDateFlux ORDER BY dateFlux DESC LIMIT 0,1;".mysql_error()."\n";
|
||||
$dateMaj=$tabTmp[0]['dateFlux'];
|
||||
$nomFichier=$tabTmp[0]['nomFichier'];
|
||||
$nbEvenAnn=$tabTmp[0]['nbEvenAnn'];
|
||||
echo "dateMaj='$dateMaj', nomFichier='$nomFichier', nbEvenAnn=$nbEvenAnn"."\n";
|
||||
|
||||
// Nombre d'évènements chargés
|
||||
echo "SELECT e.siren, e.codeInterne, e.dateDepot, e.codeEven, t.libEven, t.codEven, e.flux
|
||||
FROM jo.rncs_even e, jo.tabEvenRncs t
|
||||
WHERE e.flux='$dateMaj' AND e.codeEven=t.codeEven GROUP BY siren, dateDepot, codeEven;"."\n";
|
||||
$nbEven=$iDbR->select( 'jo.rncs_even e, jo.tabEvenRncs t',
|
||||
"e.siren, e.codeInterne, e.dateDepot, e.codeEven, t.libEven, t.codEven, e.flux",
|
||||
"e.flux='$dateMaj' AND e.codeEven=t.codeEven GROUP BY siren, dateDepot, codeEven LIMIT 0,100000",
|
||||
true, MYSQL_ASSOC, true);
|
||||
echo mysql_error()."\n";
|
||||
|
||||
// Nombre d'évènements déjà mis à jour (complétés)
|
||||
$tabTmp=$iDb->select('jo.rncs_even_info', "count(*) AS nb", "flux='$dateMaj'", true, MYSQL_ASSOC);
|
||||
$nbEvenMaj=$tabTmp[0]['nb'];
|
||||
if ($nbEvenMaj>$nbEven && !$iReprise && $nbEvenAnn>0) {
|
||||
$message.="Le dernier chargement INPI date du $dateMaj et contient $nbEvenMaj évènements déjà mis à jour sur les $nbEven évènements du jour !\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Le dernier chargement INPI date du $dateMaj et contient $nbEvenMaj évènements déjà mis à jour sur les $nbEven évènements du jour !."."\n";
|
||||
} else {
|
||||
$message.="Le dernier chargement INPI date du $dateMaj et contient $nbEven nouveaux évènements dont $nbEvenMaj à jour.\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Le dernier chargement INPI date du $dateMaj et contient $nbEven nouveaux évènements dont $nbEvenMaj à jour."."\n";
|
||||
$sirenPre=false;
|
||||
$iEven=-1;
|
||||
while($even=$iDbR->fetch(MYSQL_ASSOC)) {
|
||||
$iEven++;
|
||||
if ($iEven<$iReprise) continue;
|
||||
|
||||
echo "$iEven/$nbEven:".$even['siren'].' le '.$even['dateDepot'].': '.$even['codeEven'].' '.$even['libEven'].' ('.$even['codeInterne'].') ... ';
|
||||
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($even['siren']);
|
||||
$tabActes = $infogreffe->getList(true);
|
||||
|
||||
foreach ( $tabActes as $acte ) {
|
||||
if ( $even['dateDepot'] == $acte->DepotDate ) {
|
||||
|
||||
if ($acte->ActeDate=='0000-00-00') {
|
||||
$dateActe = $even['dateDepot'];
|
||||
} else {
|
||||
$dateActe = $acte->ActeDate;
|
||||
}
|
||||
|
||||
echo $acte->infos;
|
||||
$infos = explode(' : ',$acte->infos);
|
||||
if ( count($infos)>1 ) {
|
||||
$acteNature = $infos[0];
|
||||
}
|
||||
|
||||
$tabInsert=array(
|
||||
'siren' => $even['siren'],
|
||||
'codeInterne' => $even['codeInterne'],
|
||||
'dateDepot' => $even['dateDepot'],
|
||||
'codeEven' => $even['codeEven'],
|
||||
'flux' => $even['flux'],
|
||||
'depot_num' => $acte->DepotNum,
|
||||
'depot_date' => $acte->DepotDate,
|
||||
'acte_num' => $acte->ActeNum,
|
||||
'acte_date' => $dateActe,
|
||||
'acte_type' => $acte->ActeType,
|
||||
'acte_lib' => $acte->ActeTypeLabel,
|
||||
'acte_pages' => $acte->ActeNumberOfPages,
|
||||
'acte_nature' => $acte->ActeDecisionNature,
|
||||
'acte_decision' => $acte->ActeDecisionLabel,
|
||||
'collecte' => $even['codEven'],
|
||||
);
|
||||
|
||||
if ( $iDb->insert('jo.rncs_even_info', $tabInsert) ) {
|
||||
$nbInsert++;
|
||||
if ($acte->ActeDecisionNature<>'') $nbNatu++;
|
||||
if ($acte->ActeDecisionLabel<>'') $nbDeci++;
|
||||
} else {
|
||||
$nbDeja++;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
$sirenPre=$even['siren'];
|
||||
}
|
||||
$message.="$nbInsert évènements avec compléments ajoutés et $nbDeja évènements déjà en base ($nbNatu natures et $nbDeci décisions.\r\n";
|
||||
echo date('Y/m/d - H:i:s') ." - $nbInsert évènements avec compléments ajoutés et $nbDeja évènements déjà en base ($nbNatu natures et $nbDeci décisions."."\n";
|
||||
$iDb->update('jo.rncs_chargements', array('nbEvenAnn'=>@$iEven*1), "nomFichier='$nomFichier'");
|
||||
}
|
||||
|
||||
if ($loadInpiLocal) {
|
||||
/**
|
||||
* Evènements importants en collecte INPI
|
||||
*/
|
||||
if ($jourStock>0) {
|
||||
$dateMaj=WDate::dateT('Ymd', 'Y-m-d', $jourStock).' 00:00:00';
|
||||
$message.="Forçage du dernier chargement de la collecte INPI en date du $dateMaj...\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Forçage du dernier chargement de la collecte INPI en date du $dateMaj..."."\n";
|
||||
}
|
||||
|
||||
$AnnDb=$iDb->select('jo.rncs_even_info j, jo.rncs_entrep e, jo.tabEvenRncs l',
|
||||
"j.siren, e.sirenValide, l.codEven AS typeEven, j.acte_date AS dateJugement, j.depot_date AS dateSource,
|
||||
j.dateInsert, 'PP' AS source, e.triCode AS tribunal, e.raisonSociale, l.codeEven AS codeEvenRncs,
|
||||
j.acte_nature, j.acte_decision, e.flux",
|
||||
"j.dateInsert>'$dateMaj' AND j.siren=e.siren AND DATEDIFF(NOW(), j.dateDepot)<=60 AND
|
||||
j.codeEven=l.codeEven AND
|
||||
(l.codEven>0
|
||||
OR j.acte_decision LIKE '%FUSION%' OR j.acte_decision LIKE '%ABSORPTION%'
|
||||
OR j.acte_decision LIKE '%TRANSMISSION%UNIVERSELLE%PATRIMOINE%'
|
||||
OR j.acte_decision LIKE '%TUP%' OR j.acte_decision LIKE '%T.U.P%'
|
||||
OR j.acte_decision LIKE '%DISSOLUTION%' OR j.acte_nature LIKE '%DISSOLUTION%'
|
||||
OR j.acte_decision LIKE '%MISE%SOMMEIL%'
|
||||
OR j.acte_decision LIKE '%APPORT%PARTIEL%ACTIF%'
|
||||
OR j.acte_decision LIKE '%SCISSION%'
|
||||
) ",
|
||||
false, MYSQL_ASSOC);
|
||||
$nbAnnonces=count($AnnDb);
|
||||
|
||||
$message.="Il y a $nbAnnonces énements INPI IMR depuis le dernier chargement du $dateMaj :\r\n";
|
||||
echo date('Y/m/d - H:i:s') ." - Il y a $nbAnnonces énements INPI IMR depuis le dernier chargement du $dateMaj."."\n";
|
||||
|
||||
foreach ($AnnDb as $i=>$tabInsert) {
|
||||
$siren=$tabInsert['siren'];
|
||||
$dateJugement=$tabInsert['dateJugement'];
|
||||
if ($dateJugement=='0000-00-00') $tabInsert['dateJugement']=$tabInsert['dateSource'];
|
||||
$typeEven=$tabInsert['typeEven']*1;
|
||||
$strEven='';
|
||||
if ($typeEven==0) {//projet de fusion par absorption
|
||||
if (preg_match('/(FUSION|ABSORPTION)/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $typeEven=2726;
|
||||
else $typeEven=2725;
|
||||
} elseif (preg_match('/SCISSION/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $typeEven=2741;
|
||||
else $typeEven=2740;
|
||||
} elseif (preg_match('/TRANSMISSION.{1,3}UNIVERSELLE.{1,5}PATRIMOINE/i', $tabInsert['acte_decision'], $matches) ||
|
||||
preg_match('/T.U.P/i', $tabInsert['acte_decision'], $matches) ||
|
||||
preg_match('/\bTUP\b/i', $tabInsert['acte_decision'], $matches))
|
||||
$typeEven=2620;
|
||||
elseif (preg_match('/APPORT.{1,3}PARTIEL.{1,5}ACTIF/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $typeEven=2665;
|
||||
else $typeEven=2661;
|
||||
} elseif (preg_match('/DISSOLUTION/i', $tabInsert['acte_decision'], $matches) ||
|
||||
preg_match('/DISSOLUTION/i', $tabInsert['acte_nature'], $matches) )
|
||||
$typeEven=2203;
|
||||
elseif (preg_match('/MISE.{1,9}SOMMEIL/iu', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/REPRISE/i', $tabInsert['acte_decision'], $matches)) $typeEven=2316;
|
||||
else $typeEven=2206;
|
||||
}
|
||||
} elseif (preg_match('/(FUSION|ABSORPTION)/i', $tabInsert['acte_decision'], $matches)) {
|
||||
if (preg_match('/PROJET/i', $tabInsert['acte_decision'], $matches)) $strEven=2726;
|
||||
else $strEven=2725;
|
||||
}
|
||||
|
||||
$tabInsert['complement']='';
|
||||
if ($typeEven==2100 || $typeEven==2101 || $typeEven==2102) { // Modification de capital
|
||||
$tabIdentite=$iRncs->getInfosEntrep($siren);
|
||||
$tabInsert['montant']=$tabIdentite['capital'];
|
||||
//$tabInsert['actionsNb'] ='';
|
||||
/** @todo Rechercher l'ancien capital **/
|
||||
} elseif ($typeEven==2305) { // Modification de la dénomination
|
||||
$tabIdentite=$iRncs->getInfosEntrep($siren);
|
||||
$tabInsert['complement'].="Nouvelle dénomination : ".$tabIdentite['raisonSociale'].'. ';
|
||||
|
||||
// Recherche de l'ancienne RS
|
||||
$dateFlux=$tabInsert['flux'];
|
||||
$rep=$iDb->select( 'jo.rncs_modifs',
|
||||
'siren, `table`, champs, valeur, flux, dateInsert',
|
||||
"siren=$siren AND type='raisonSociale' AND `table`='rncs_entrep'
|
||||
AND flux<='$dateFlux' ORDER BY flux DESC LIMIT 0,1", false, MYSQL_ASSOC);
|
||||
$modif=@trim($rep[0]['valeur']).'';
|
||||
if ($modif<>'')
|
||||
$tabInsert['complement'].="Ancienne dénomination : $modif. ";
|
||||
|
||||
if ($tabIdentite['sigle']<>'')
|
||||
$tabInsert['complement'].="Sigle : ".$tabIdentite['sigle'].'. ';
|
||||
} elseif ($typeEven==2307) { // Modification de la forme juridique
|
||||
$tabIdentite=$iRncs->getInfosEntrep($siren);
|
||||
$tabInsert['nouvFJ']=$tabIdentite['cj'];
|
||||
/** @todo Rechercher l'ancienne FJ **/
|
||||
} elseif ($typeEven==2315) {
|
||||
switch ($tabInsert['codeEvenRncs']*1) {
|
||||
case 34: $tabInsert['complement'].='Changement de Gérant : '; break;
|
||||
case 37: $tabInsert['complement'].='Changement de Président : '; break;
|
||||
case 40: $tabInsert['complement'].='Modification du Conseil d\'Administration : '; break;
|
||||
case 81: $tabInsert['complement'].='Changement de Commissaire aux Comptes : '; break;
|
||||
default: $tabInsert['complement'].='Administration : '; break;
|
||||
}
|
||||
$dirs=$iInsee->getDirigeants($siren,false);
|
||||
foreach ($dirs as $nb=>$dir) {
|
||||
$tabInsert['complement'].=$dir['Titre'].' : '.@$dir['Civilite'].' '.$dir['Nom'].' '.$dir['Prenom'];
|
||||
if (($nb+1)<count($dirs))
|
||||
$tabInsert['complement'].=', ';
|
||||
else
|
||||
$tabInsert['complement'].='. ';
|
||||
}
|
||||
} elseif ($typeEven==2320) { // RECONSTITUTION DE LA L'ACTIF NET
|
||||
if (preg_match('/MOITIE/i', $tabInsert['acte_nature'], $matches))
|
||||
$typeEven=2321;
|
||||
} elseif ($typeEven==2203 &&
|
||||
(preg_match('/SANS/i', $tabInsert['acte_nature'], $matches)) ||
|
||||
(preg_match('/SANS/i', $tabInsert['acte_decision'], $matches))
|
||||
)
|
||||
// On ignore l'annonce
|
||||
continue;
|
||||
|
||||
unset($tabInsert['codeEvenRncs']);
|
||||
unset($tabInsert['flux']);
|
||||
//if ($tabInsert['acte_nature']<>'') $tabInsert['complement'].=$tabInsert['acte_nature'].' ';
|
||||
if ($tabInsert['acte_decision']<>'') $tabInsert['complement'].=strtolower($tabInsert['acte_decision']).' ';
|
||||
unset($tabInsert['acte_nature']);
|
||||
unset($tabInsert['acte_decision']);
|
||||
if ($strEven<>'') $tabInsert['strEven']=$strEven;
|
||||
|
||||
//echo "$siren $dateJugement $typeEven"."\n";
|
||||
$tabTmp=@$iInsee->getIdentiteLight($tabInsert['siren']);
|
||||
$tabInsert['typeEven'] = $typeEven;
|
||||
if ($typeEven==0) {
|
||||
print_r($tabInsert);
|
||||
sendMail('production@scores-decisions.com', 'ylenaour@scores-decisions.com', 'Chargement des évènements Greffes', "Erreur typeEven=0 ligne n°$i ($dateMaj)"."\n".print_r($tabInsert,true));
|
||||
//die();
|
||||
}
|
||||
$tabInsert['adresse'] = $tabTmp['Adresse'];
|
||||
$tabInsert['codePostal'] = $tabTmp['CP'];
|
||||
$tabInsert['ville'] = $tabTmp['Ville'];
|
||||
if (!$iDb->insert($table, $tabInsert)) {
|
||||
if (mysql_errno()==1062) {
|
||||
$tabTmp=$iDb->select($table, 'id, siren, typeEven, dateJugement, inter1type, inter1id, inter1nom, inter2type, inter2id, inter2nom, dateSource, dateInsert, source, tribunal, raisonSociale',"siren=$siren AND dateJugement='$dateJugement' AND typeEven=$typeEven", false, MYSQL_ASSOC);
|
||||
$tabEnbase=@$tabTmp[0];
|
||||
if ($tabEnbase['source']=='PC') {
|
||||
unset($tabInsert['source']);
|
||||
unset($tabInsert['dateInsert']);
|
||||
if (!$iDb->update($table, $tabInsert,"siren=$siren AND dateJugement='$dateJugement' AND typeEven=$typeEven", false, MYSQL_ASSOC))
|
||||
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .' : '. mysql_error() ." lors de la mise à jour de l'évènement $typeEven en date du $dateJugement pour $siren..."."\n";
|
||||
else $nbAnnUpdateE++;
|
||||
}
|
||||
} else
|
||||
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .' : '. mysql_error() ." lors de l'ajout de l'évènement $typeEven en date du $dateJugement pour $siren..."."\n";
|
||||
} else {
|
||||
$nbAnnInsertE++;
|
||||
echo date('Y/m/d - H:i:s') ." - Ajout de l'évènement $typeEven en date du $dateJugement pour $siren..."."\n";
|
||||
@$tabCptAnn[$typeEven]++;
|
||||
}
|
||||
}
|
||||
|
||||
$message.=" $nbAnnInsertE ajouts et $nbAnnUpdateE mises à jours sur $nbAnnonces annonces.\r\n\r\n";
|
||||
$message.=print_r(@$tabCptAnn, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de la liste des actes greffe à partir des éléments consultés
|
||||
*/
|
||||
if ( $loadActesDuJour ) {
|
||||
|
||||
$today=date('Y-m-d').' 00:00:00';
|
||||
$nbDepotsTot=0;
|
||||
$tabActes = $iDb->select("sdv1.logs", "siren", "page='greffe_actes' AND dateHeure>='$today' GROUP BY siren", false, MYSQL_ASSOC);
|
||||
shuffle($tabActes);
|
||||
$nbActesQuoti = count($tabActes);
|
||||
if ( $nbActesQuoti > 0) {
|
||||
foreach ($tabActes as $i=>$acte) {
|
||||
echo date('Y/m/d - H:i:s')." - $i/$nbActesQuoti: Mise à jour de la liste des actes pour ".$acte['siren'].'... ';
|
||||
$infogreffe = new SdMetier_Infogreffe_DocAC($acte['siren']);
|
||||
$nbDepots = count($infogreffe->getList(true));
|
||||
echo date('Y/m/d - H:i:s')."$nbDepots dépot(s)."."\n";
|
||||
$nbDepotsTot+=$nbDepots;
|
||||
}
|
||||
}
|
||||
$message.="$nbActesQuoti listes d'évènements mises à jours pour un total de $nbDepotsTot dépots (listes du jour).\r\n";
|
||||
echo date('Y/m/d - H:i:s')." - $nbActesQuoti listes d'évènements mises à jours pour un total de $nbDepotsTot dépots (listes du jour)."."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Mise à jour de la liste des bilans greffe à partir des bilans déposés
|
||||
*/
|
||||
if ( $loadBilans ) {
|
||||
$tabTmp = $iDb->select('jo.bilans_deposes', 'MAX(DATE(dateInsert)) AS lastMAJ', '1', true, MYSQL_ASSOC);
|
||||
$lastUpdate = $tabTmp[0]['lastMAJ'];
|
||||
$message.="La dernière mise à jour des bilans Greffes date du $lastUpdate !\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - La dernière mise à jour des bilans Greffes date du $lastUpdate !"."\n";
|
||||
|
||||
$bilansDep = $iDb->select('jo.bilans_deposes', "siren, nicSiege, dateProvPartenaire, dateExercice, dureeExercice, monnaie, chiffreAffaire", "dateInsert>'$lastUpdate 00:00:00'", true, MYSQL_ASSOC);
|
||||
echo mysql_error();
|
||||
|
||||
$nbBilans = count($bilansDep);
|
||||
$message.="Il y a $nbBilans listes de bilans PDF à mettre à jour !\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Il y a $nbBilans listes de bilans PDF à mettre à jour !"."\n";
|
||||
|
||||
if ( $nbBilans > 0 ) {
|
||||
foreach ( $bilansDep as $iBilan=>$bil ) {
|
||||
echo date('Y/m/d - H:i:s') . " - $iBilan/$nbBilans: Mise à jour de la liste de bilans PDF pour ".$bil['siren']."... \n";
|
||||
$infogreffe = new SdMetier_Infogreffe_DocBI($bil['siren']);
|
||||
$infogreffe->getList(true);
|
||||
}
|
||||
}
|
||||
|
||||
$message.="Fin de la mise à jour des listes de bilans PDF.\r\n";
|
||||
echo date ('Y/m/d - H:i:s') . " - Fin de la mise à jour des listes de bilans PDF."."\n";
|
||||
}
|
||||
|
||||
//Envoi du mail d'information
|
||||
sendMail('production@scores-decisions.com', 'suivi@scores-decisions.com', 'Chargement des informations Greffes', $message);
|
@ -5,14 +5,14 @@
|
||||
*/
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
@ -15,14 +15,14 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
@ -237,4 +237,3 @@ if ($opts->parsefile) {
|
||||
// --- Lire les fichiers dans clients/jalpdfsed/send
|
||||
// --- Vérifier la présence en base
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
@ -181,5 +181,3 @@ foreach($requests as $n => $r) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
@ -15,12 +15,6 @@ $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/config
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
|
||||
// Stockage Client => SD
|
||||
$pathClientSend = '/home/scores/batch/shared/clients/fransbonhomme/send';
|
||||
|
||||
// Stockage SD => Client
|
||||
$pathClientRecv = '/home/scores/batch/shared/clients/fransbonhomme/recv';
|
||||
|
||||
//Options
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(array(
|
48
build/exportCSV.php
Normal file
48
build/exportCSV.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
//mb_internal_encoding('ISO-8859-15');
|
||||
mb_internal_encoding('UTF-8');
|
||||
|
||||
$header = array(
|
||||
"siren", "infoTel"
|
||||
);
|
||||
|
||||
$sql = "";
|
||||
|
||||
$filename = '20160310-2.csv';
|
||||
$delimiter = ',';
|
||||
$enclosure = '"';
|
||||
|
||||
$host = '192.168.78.249';
|
||||
$user = 'admin';
|
||||
$pass = 'scores';
|
||||
|
||||
$mysqli = new mysqli($host, $user, $pass);
|
||||
if ($mysqli->connect_errno) {
|
||||
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
|
||||
exit;
|
||||
}
|
||||
|
||||
$fp = fopen($filename, 'w');
|
||||
fputcsv($fp, $header, $delimiter, $enclosure);
|
||||
|
||||
if (!$result = $mysqli->query($sql)) {
|
||||
echo $mysqli->error;
|
||||
exit;
|
||||
}
|
||||
if ($result->num_rows > 0) {
|
||||
$rTotal = $result->num_rows;
|
||||
$r = 0;
|
||||
while ($row = $result->fetch_object()) {
|
||||
$r++;
|
||||
$fline = array();
|
||||
foreach($header as $h) {
|
||||
$fline[] = $row->$h;
|
||||
}
|
||||
fputcsv($fp, $fline, $delimiter, $enclosure);
|
||||
echo str_pad($r, strlen($rTotal), ' ', STR_PAD_LEFT)." / ".$rTotal."\n";
|
||||
}
|
||||
$result->close();
|
||||
}
|
||||
|
||||
fclose($fp);
|
20
docs/README
20
docs/README
@ -2,18 +2,16 @@
|
||||
Scripts PHP
|
||||
===========
|
||||
|
||||
composer install
|
||||
. Installer les dépendances
|
||||
|
||||
composer install
|
||||
|
||||
Nommage des scripts
|
||||
. Nommage des scripts
|
||||
|
||||
Avoir un nom concis et ajouter le préfix suivant le type de scripts
|
||||
Avoir un nom concis et ajouter le préfix suivant le type de scripts
|
||||
|
||||
Prefix des catégories
|
||||
|
||||
- client
|
||||
- source
|
||||
- data
|
||||
- cache
|
||||
|
||||
- presta
|
||||
Prefix des catégories
|
||||
- client
|
||||
- source
|
||||
- data
|
||||
- presta
|
||||
|
@ -1,70 +0,0 @@
|
||||
[production]
|
||||
phpSettings.date.timezone = "Europe/Paris"
|
||||
phpSettings.display_startup_errors = 0
|
||||
phpSettings.display_errors = 0
|
||||
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
|
||||
bootstrap.class = "Bootstrap"
|
||||
appnamespace = "Application"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = development
|
||||
profil.mail.method = smtp
|
||||
profil.mail.host = 192.168.3.200
|
||||
profil.mail.port = 587
|
||||
profil.mail.auth = login
|
||||
profil.mail.username = batch1@srvbak01
|
||||
profil.mail.password = test
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.path.shared = "/home/scores/batch/shared"
|
||||
|
||||
; Metier - Infogreffe
|
||||
profil.infogreffe.wsdl = "infogreffe.wsdl"
|
||||
profil.infogreffe.url = "https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE"
|
||||
profil.infogreffe.uri = "https://webservices.infogreffe.fr/"
|
||||
profil.infogreffe.user = 85000109
|
||||
profil.infogreffe.password = 166
|
||||
profil.infogreffe.cache.path = APPLICATION_PATH "/../data/cache"
|
||||
profil.infogreffe.cache.time = 8
|
||||
profil.infogreffe.storage.path = ""
|
||||
|
||||
; Sphinx configuration
|
||||
profil.sphinx.ent.host = "192.168.3.25"
|
||||
profil.sphinx.ent.port = 3312
|
||||
profil.sphinx.ent.version = 1
|
||||
profil.sphinx.dir.host = "192.168.3.25"
|
||||
profil.sphinx.dir.port = 3312
|
||||
profil.sphinx.dir.version = 1
|
||||
profil.sphinx.act.host = "192.168.3.25"
|
||||
profil.sphinx.act.port = 3312
|
||||
profil.sphinx.act.version = 1
|
||||
profil.sphinx.histo.host = "192.168.3.25"
|
||||
profil.sphinx.histo.port = 3312
|
||||
profil.sphinx.histo.version = 1
|
||||
|
||||
; Database configuration - For old configuration - see Configure.php
|
||||
profil.db.metier.adapter=mysqli
|
||||
profil.db.metier.params.host=192.168.3.28
|
||||
profil.db.metier.params.username=batchuser
|
||||
profil.db.metier.params.password=2XQTpKatBVRezXE9
|
||||
profil.db.metier.params.dbname=sdv1
|
||||
profil.db.metier.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 0
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
/** BATCH **/
|
||||
define('FILLER',' ');
|
||||
define('VERSION_FICHIER_BODACC','0106');
|
||||
define('LONGUEUR_LIGNE_SORTIE', 2000);
|
||||
|
||||
/** Paramétres du FTP des JO **/
|
||||
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
|
||||
define('BODACC_FTP_USER', 'SCORE');
|
||||
define('BODACC_FTP_PASS', 'SD075');
|
||||
define('BODACC_LOCAL_DIR', '/home/scores/batch/shared/sources/bodacc/');
|
||||
define('JAL_LOCAL_DIR', '/home/scores/batch/shared/sources/jal/');
|
||||
|
||||
/** Paramétres du FTP de Hugin : Communiqués de presse **/
|
||||
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
|
||||
define('HUGIN_FTP_USER', 'scores');
|
||||
define('HUGIN_FTP_PASS', 'scores_632');
|
||||
define('HUGIN_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/hugin/');
|
||||
|
||||
/** Paramétres du FTP de ActusNews : Communiqués de presse **/
|
||||
define('ACTUSNEWS_FTP_URL', 'ftp.actusnews.com');
|
||||
define('ACTUSNEWS_FTP_USER', 'scores_act');
|
||||
define('ACTUSNEWS_FTP_PASS', '6_etIwL');
|
||||
define('ACTUSNEWS_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/actusnews/');
|
||||
|
||||
/** Paramétres du FTP de Di Release : Communiqués de presse **/
|
||||
define('DIRELEASE_FTP_URL', 'ftp.actusnews.com');
|
||||
define('DIRELEASE_FTP_USER', 'scores_dir');
|
||||
define('DIRELEASE_FTP_PASS', '-gT52sQ');
|
||||
define('DIRELEASE_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/direlease/');
|
||||
|
||||
/** Paramétres du FTP des Echos: Communiqués de presse **/
|
||||
define('LESECHOS_FTP_URL', 'ftp.webdisclosure.com');
|
||||
define('LESECHOS_FTP_USER', 'Scores');
|
||||
define('LESECHOS_FTP_PASS', 'scores2001');
|
||||
define('LESECHOS_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/lesechos/');
|
||||
|
||||
/** Paramétres du FTP de BusinessWire : Communiqués de presse **/
|
||||
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/scores/batch/shared/ftp/businesswire/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR', '/home/scores/batch/shared/infosreg/businesswire/');
|
||||
|
||||
/** Base de données de S&D **/
|
||||
define ('MYSQL_HOST', '192.168.3.28');
|
||||
define ('MYSQL_USER', 'batchuser');
|
||||
define ('MYSQL_PASS', '2XQTpKatBVRezXE9');
|
||||
define ('MYSQL_DEFAULT_DB', 'jo');
|
||||
define ('MYSQL_SQL_LOG', 'NONE');
|
||||
|
||||
define ('SPHINX_HOST', '192.168.3.25');
|
||||
define ('SPHINX_PORT', 3312);
|
||||
|
||||
define ('SPHINX_ENT_HOST', '192.168.3.25');
|
||||
define ('SPHINX_ENT_PORT', 3312);
|
||||
|
||||
define ('SPHINX_DIR_HOST', '192.168.3.25');
|
||||
define ('SPHINX_DIR_PORT', 3312);
|
||||
|
||||
define ('SPHINX_ACT_HOST', '192.168.3.25');
|
||||
define ('SPHINX_ACT_PORT', 3312);
|
||||
|
||||
define ('SPHINX_HISTO_HOST', '192.168.3.25');
|
||||
define ('SPHINX_HISTO_PORT', 3312);
|
||||
|
||||
|
||||
/** SERVEUR DE MESSAGERIE **/
|
||||
define ('SMTP_HOST', 'smtp.celeste.fr');
|
||||
define ('SMTP_PORT', 25);
|
||||
define ('SMTP_USER', '');
|
||||
define ('SMTP_PASS', '');
|
||||
|
||||
/** INFOGREFFE **/
|
||||
define('INFOGREFFE_DISPO', true);
|
||||
define('INFOGREFFE_DISPO_WS', true);
|
||||
define('INFOGREFFE_DISPO_WEB', true);
|
||||
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
|
||||
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
|
||||
define('INFOGREFFE_WS_USER', '85000109');
|
||||
define('INFOGREFFE_WS_PASS', '166');
|
||||
|
||||
/** AMABIS **/
|
||||
define('AMABIS_WS_URL', 'http://sw4.amabis.com:5101');
|
||||
define('AMABIS_WS_URI', 'http://sw4.amabis.com:5101');
|
||||
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define ('DOC_WEB_LOCAL', '/home/scores/batch/shared/datafile/');
|
||||
define ('DOC_WEB_URL', '/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', '/home/scores/batch/shared/log');
|
||||
|
||||
define ('DATETIME', date('YmdHis'));
|
||||
define ('DATE', substr(DATETIME,0,8));
|
||||
define ('TIME', substr(DATETIME,8,6));
|
||||
define ('DATE_LISIBLE', substr(DATETIME,6,2).'/'.substr(DATETIME,4,2).'/'.substr(DATETIME,0,4));
|
||||
define ('TIME_LISIBLE', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
|
@ -1,66 +0,0 @@
|
||||
[production]
|
||||
phpSettings.date.timezone = "Europe/Paris"
|
||||
phpSettings.display_startup_errors = 0
|
||||
phpSettings.display_errors = 0
|
||||
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
|
||||
bootstrap.class = "Bootstrap"
|
||||
appnamespace = "Application"
|
||||
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
resources.layout.layout = "main"
|
||||
resources.layout.layoutPath = APPLICATION_PATH "/views"
|
||||
resources.view.basePath = APPLICATION_PATH "/views"
|
||||
|
||||
; Scores configuration
|
||||
profil.server.name = development
|
||||
profil.mail.method = smtp
|
||||
profil.mail.smtp_host = smtp.free.fr
|
||||
profil.mail.email.support = supportdev@scores-decisions.com
|
||||
profil.mail.email.supportdev = supportdev@scores-decisions.com
|
||||
profil.mail.email.contact = supportdev@scores-decisions.com
|
||||
profil.mail.email.production = supportdev@scores-decisions.com
|
||||
profil.path.shared = "/home/scores/batch/shared"
|
||||
|
||||
; Metier - Infogreffe
|
||||
profil.infogreffe.wsdl = "infogreffe.wsdl"
|
||||
profil.infogreffe.url = "https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE"
|
||||
profil.infogreffe.uri = "https://webservices.infogreffe.fr/"
|
||||
profil.infogreffe.user = 85000109
|
||||
profil.infogreffe.password = 166
|
||||
profil.infogreffe.cache.path = APPLICATION_PATH "/../data/cache"
|
||||
profil.infogreffe.cache.time = 8
|
||||
profil.infogreffe.storage.path = "c:\Users\mricois\www\dataws\greffes"
|
||||
|
||||
; Sphinx configuration
|
||||
profil.sphinx.ent.host = "192.168.78.242"
|
||||
profil.sphinx.ent.port = 3312
|
||||
profil.sphinx.ent.version = 2
|
||||
profil.sphinx.dir.host = "192.168.78.242"
|
||||
profil.sphinx.dir.port = 3312
|
||||
profil.sphinx.dir.version = 2
|
||||
profil.sphinx.act.host = "192.168.78.242"
|
||||
profil.sphinx.act.port = 3312
|
||||
profil.sphinx.act.version = 2
|
||||
profil.sphinx.histo.host = "192.168.78.242"
|
||||
profil.sphinx.histo.port = 3312
|
||||
profil.sphinx.histo.version = 2
|
||||
|
||||
; Database configuration - For old configuration - see Configure.php
|
||||
profil.db.metier.adapter=mysqli
|
||||
profil.db.metier.params.host=192.168.78.230
|
||||
profil.db.metier.params.username=root
|
||||
profil.db.metier.params.password=scores
|
||||
profil.db.metier.params.dbname=sdv1
|
||||
profil.db.metier.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8"
|
||||
|
||||
[staging : production]
|
||||
resources.frontController.params.displayExceptions = 0
|
||||
|
||||
[development : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 0
|
||||
resources.frontController.params.displayExceptions = 1
|
||||
|
||||
[testing : production]
|
||||
phpSettings.display_startup_errors = 1
|
||||
phpSettings.display_errors = 1
|
@ -1,95 +0,0 @@
|
||||
<?php
|
||||
/** BATCH **/
|
||||
define('FILLER',' ');
|
||||
define('VERSION_FICHIER_BODACC','0106');
|
||||
define('LONGUEUR_LIGNE_SORTIE', 2000);
|
||||
|
||||
/** Paramétres du FTP des JO **/
|
||||
define('BODACC_FTP_URL', 'ftp.journal-officiel.gouv.fr');
|
||||
define('BODACC_FTP_USER', 'SCORE');
|
||||
define('BODACC_FTP_PASS', 'SD075');
|
||||
define('BODACC_LOCAL_DIR', '/home/scores/batch/shared/sources/bodacc/');
|
||||
define('JAL_LOCAL_DIR', '/home/scores/batch/shared/sources/jal/');
|
||||
|
||||
/** Paramétres du FTP de Hugin : Communiqués de presse **/
|
||||
define('HUGIN_FTP_URL', 'ftp.companynews.fr');
|
||||
define('HUGIN_FTP_USER', 'scores');
|
||||
define('HUGIN_FTP_PASS', 'scores_632');
|
||||
define('HUGIN_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/hugin/');
|
||||
|
||||
/** Paramétres du FTP de ActusNews : Communiqués de presse **/
|
||||
define('ACTUSNEWS_FTP_URL', 'ftp.actusnews.com');
|
||||
define('ACTUSNEWS_FTP_USER', 'scores_act');
|
||||
define('ACTUSNEWS_FTP_PASS', '6_etIwL');
|
||||
define('ACTUSNEWS_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/actusnews/');
|
||||
|
||||
/** Paramétres du FTP de Di Release : Communiqués de presse **/
|
||||
define('DIRELEASE_FTP_URL', 'ftp.actusnews.com');
|
||||
define('DIRELEASE_FTP_USER', 'scores_dir');
|
||||
define('DIRELEASE_FTP_PASS', '-gT52sQ');
|
||||
define('DIRELEASE_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/direlease/');
|
||||
|
||||
/** Paramétres du FTP des Echos: Communiqués de presse **/
|
||||
define('LESECHOS_FTP_URL', 'ftp.webdisclosure.com');
|
||||
define('LESECHOS_FTP_USER', 'Scores');
|
||||
define('LESECHOS_FTP_PASS', 'scores2001');
|
||||
define('LESECHOS_LOCAL_DIR', '/home/scores/batch/shared/sources/infosreg/lesechos/');
|
||||
|
||||
/** Paramétres du FTP de BusinessWire : Communiqués de presse **/
|
||||
define('BUSINESSWIRE_LOCAL_DIR_INCOMING', '/home/scores/batch/shared/ftp/businesswire/');
|
||||
define('BUSINESSWIRE_LOCAL_DIR', '/home/scores/batch/shared/infosreg/businesswire/');
|
||||
|
||||
/** Base de données de S&D **/
|
||||
define ('MYSQL_HOST', '192.168.78.230');
|
||||
define ('MYSQL_USER', 'root');
|
||||
define ('MYSQL_PASS', 'scores');
|
||||
define ('MYSQL_DEFAULT_DB', 'jo');
|
||||
define ('MYSQL_SQL_LOG', 'NONE');
|
||||
|
||||
define ('SPHINX_HOST', '192.168.78.242');
|
||||
define ('SPHINX_PORT', 3312);
|
||||
|
||||
define ('SPHINX_ENT_HOST', '192.168.78.242');
|
||||
define ('SPHINX_ENT_PORT', 3312);
|
||||
|
||||
define ('SPHINX_DIR_HOST', '192.168.78.242');
|
||||
define ('SPHINX_DIR_PORT', 3312);
|
||||
|
||||
define ('SPHINX_ACT_HOST', '192.168.78.242');
|
||||
define ('SPHINX_ACT_PORT', 3312);
|
||||
|
||||
define ('SPHINX_HISTO_HOST', '192.168.78.242');
|
||||
define ('SPHINX_HISTO_PORT', 3312);
|
||||
|
||||
|
||||
/** SERVEUR DE MESSAGERIE **/
|
||||
define ('SMTP_HOST', 'smtp.free.fr');
|
||||
define ('SMTP_PORT', 25);
|
||||
define ('SMTP_USER', '');
|
||||
define ('SMTP_PASS', '');
|
||||
|
||||
/** INFOGREFFE **/
|
||||
define('INFOGREFFE_DISPO', true);
|
||||
define('INFOGREFFE_DISPO_WS', true);
|
||||
define('INFOGREFFE_DISPO_WEB', true);
|
||||
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
|
||||
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
|
||||
define('INFOGREFFE_WS_USER', '85000109');
|
||||
define('INFOGREFFE_WS_PASS', '166');
|
||||
|
||||
/** AMABIS **/
|
||||
define('AMABIS_WS_URL', 'http://sw4.amabis.com:5101');
|
||||
define('AMABIS_WS_URI', 'http://sw4.amabis.com:5101');
|
||||
|
||||
/** Dossiers locaux pour les documents a telecharger (PDF kbis, marques, etc...) **/
|
||||
define ('DOC_WEB_LOCAL', '/home/scores/batch/shared/datafile/');
|
||||
define ('DOC_WEB_URL', '/data/');
|
||||
|
||||
/** LOGGING **/
|
||||
define('LOG_PATH', 'c:/Users/michael/www/batch-1.2/data/sources/log');
|
||||
|
||||
define ('DATETIME', date('YmdHis'));
|
||||
define ('DATE', substr(DATETIME,0,8));
|
||||
define ('TIME', substr(DATETIME,8,6));
|
||||
define ('DATE_LISIBLE', substr(DATETIME,6,2).'/'.substr(DATETIME,4,2).'/'.substr(DATETIME,0,4));
|
||||
define ('TIME_LISIBLE', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../../vendor/autoload.php');
|
||||
|
||||
//Copy configuration
|
||||
$configDir = realpath(dirname(__FILE__)).'/config';
|
||||
$appconfigDir = APPLICATION_PATH.'/configs';
|
||||
|
||||
if (stristr(PHP_OS, 'WIN')) {
|
||||
$hostname = 'development';
|
||||
} else {
|
||||
$hostname = exec('echo $(hostname)');
|
||||
}
|
||||
|
||||
if ( !copy($configDir.'/'.$hostname.'/application.ini', $appconfigDir.'/application.ini') ) {
|
||||
echo "application.ini could not be copied !\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !copy($configDir.'/'.$hostname.'/config.php', $appconfigDir.'/config.php') ) {
|
||||
echo "config.php could not be copied !\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(
|
||||
//Options
|
||||
array(
|
||||
'help|?' => "Display usage information.",
|
||||
'install' => "Make install operation.",
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if(isset($opts->help))
|
||||
{
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
if(isset($opts->install))
|
||||
{
|
||||
if (stristr(PHP_OS, 'WIN')) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
/home/scores/batch/shared/log/*.log {
|
||||
missingok
|
||||
notifempty
|
||||
weekly
|
||||
rotate 10
|
||||
compress
|
||||
delaycompress
|
||||
nocreate
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,691 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Crontab
|
||||
* 0 9 * * 1-5 /var/www/batch/getAsso.php -c >> /var/www/log/getAsso.log
|
||||
*
|
||||
* Recherche
|
||||
*
|
||||
* Compte initial
|
||||
* http://www.journal-officiel.gouv.fr/association/index.php?ACTION=Rechercher&HI_PAGE=1&HI_COMPTEUR=0&original_method=get&WHAT=&JTH_ID=&JAN_BD_CP=&JRE_ID=&JAN_LIEU_DECL=&JTY_ID=&JTY_WALDEC=&JTY_SIREN=776467102&JPA_D_D=&JPA_D_F=&rechercher.x=0&rechercher.y=0
|
||||
*
|
||||
*/
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
require_once APPLICATION_PATH.'/configs/config.php';
|
||||
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/common/chiffres.php';
|
||||
require_once 'framework/common/dates.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
$tabInfosGlobal=array();
|
||||
$repPdfAssoCpt='/home/scores/batch/shared/datafile/association/bilans/';
|
||||
|
||||
function getNextDate($dateCour, $nbJours=7) {
|
||||
$nextDate=date('Ymd', mktime(0, 0, 0, WDate::dateT('Ymd','m', $dateCour), WDate::dateT('Ymd','d', $dateCour)+$nbJours, WDate::dateT('Ymd','Y', $dateCour)));
|
||||
return $nextDate;
|
||||
}
|
||||
|
||||
global $tabDep;
|
||||
$tabDep = array(
|
||||
'Dordogne'=>'24',
|
||||
'Gironde'=>'33',
|
||||
'Landes'=>'40',
|
||||
'Lot-et-Garonne'=>'47',
|
||||
'Pyrénées-Atlantiques'=>'64',
|
||||
'Bas-Rhin'=>'67',
|
||||
'Haut-Rhin'=>'68',
|
||||
'Allier'=>'03',
|
||||
'Cantal'=>'15',
|
||||
'Haute-Loire'=>'43',
|
||||
'Puy-de-Dôme'=>'63',
|
||||
'Calvados'=>'14',
|
||||
'Manche'=>'50',
|
||||
'Orne'=>'61',
|
||||
'Côte-d\'Or'=>'21',
|
||||
'Nièvre'=>'58',
|
||||
'Saône-et-Loire'=>'71',
|
||||
'Yonne'=>'89',
|
||||
'Côtes-d\'Armor'=>'22',
|
||||
'Finistère'=>'29',
|
||||
'Ille-et-Vilaine'=>'35',
|
||||
'Morbihan'=>'56',
|
||||
'Cher'=>'18',
|
||||
'Eure-et-Loir'=>'28',
|
||||
'Indre'=>'36',
|
||||
'Indre-et-Loire'=>'37',
|
||||
'Loir-et-Cher'=>'41',
|
||||
'Loiret'=>'45',
|
||||
'Ardennes'=>'08',
|
||||
'Aube'=>'10',
|
||||
'Haute-Marne'=>'52',
|
||||
'Marne'=>'51',
|
||||
'Corse-du-sud'=>'2A',
|
||||
'Haute-Corse'=>'2B',
|
||||
'Doubs'=>'25',
|
||||
'Haute-Saône'=>'70',
|
||||
'Jura'=>'39',
|
||||
'Territoire-de-Belfort'=>'90',
|
||||
'Eure'=>'27',
|
||||
'Seine-Maritime'=>'76',
|
||||
'Essonne'=>'91',
|
||||
'Hauts-de-Seine'=>'92',
|
||||
'Paris'=>'75',
|
||||
'Seine-et-Marne'=>'77',
|
||||
'Seine-Saint-Denis'=>'93',
|
||||
'Val-d\'Oise'=>'95',
|
||||
'Val-de-Marne'=>'94',
|
||||
'Yvelines'=>'78',
|
||||
'Aude'=>'11',
|
||||
'Gard'=>'30',
|
||||
'Hérault'=>'34',
|
||||
'Lozère'=>'48',
|
||||
'Pyrénées-Orientales'=>'66',
|
||||
'Corrèze'=>'19',
|
||||
'Creuse'=>'23',
|
||||
'Haute-Vienne'=>'87',
|
||||
'Moselle'=>'57',
|
||||
'Meurthe-et-Moselle'=>'54',
|
||||
'Meuse'=>'55',
|
||||
'Vosges'=>'88',
|
||||
'Ariège'=>'09',
|
||||
'Aveyron'=>'12',
|
||||
'Gers'=>'32',
|
||||
'Haute-Garonne'=>'31',
|
||||
'Hautes-Pyrénées'=>'65',
|
||||
'Lot'=>'46',
|
||||
'Tarn'=>'81',
|
||||
'Tarn-et-Garonne'=>'82',
|
||||
'Nord'=>'59',
|
||||
'Pas-de-calais'=>'62',
|
||||
'Guadeloupe'=>'971',
|
||||
'Guyane'=>'973',
|
||||
'Martinique'=>'972',
|
||||
'Réunion'=>'974',
|
||||
'Saint-Pierre-et-Miquelon'=>'975',
|
||||
'Mayotte'=>'976',
|
||||
'Loire-Atlantique'=>'44',
|
||||
'Maine-et-Loire'=>'49',
|
||||
'Mayenne'=>'53',
|
||||
'Sarthe'=>'72',
|
||||
'Vendée'=>'85',
|
||||
'Aisne'=>'02',
|
||||
'Oise'=>'60',
|
||||
'Somme'=>'80',
|
||||
'Charente'=>'16',
|
||||
'Charente-Maritime'=>'17',
|
||||
'Deux-Sèvres'=>'79',
|
||||
'Vienne'=>'86',
|
||||
'Alpes-de-Haute-Provence'=>'04',
|
||||
'Alpes-Maritimes'=>'06',
|
||||
'Bouches-du-Rhone'=>'13',
|
||||
'Hautes-Alpes'=>'05',
|
||||
'Var'=>'83',
|
||||
'Vaucluse'=>'84',
|
||||
'Ain'=>'01',
|
||||
'Ardèche'=>'07',
|
||||
'Drôme'=>'26',
|
||||
'Haute-Savoie'=>'74',
|
||||
'Isère'=>'38',
|
||||
'Loire'=>'42',
|
||||
'Rhône'=>'69',
|
||||
'Savoie'=>'73',
|
||||
);
|
||||
|
||||
function getInfosAnnonceAsso($annonceHtml, $depotComptes=false)
|
||||
{
|
||||
$tabAnn=array();
|
||||
global $tabDep;
|
||||
global $iInsee;
|
||||
|
||||
$tabAnn['Assoc_Nom']=htm2txt(@getTextInHtml($annonceHtml, '<p>Association : <b>', '<b>', '</b>'));
|
||||
if (substr($tabAnn['Assoc_Nom'],-1)=='.') $tabAnn['Assoc_Nom']=substr($tabAnn['Assoc_Nom'],0,-1);
|
||||
|
||||
$tabAnn['Siren']=str_replace(' ','', strtr(htm2txt(@getTextInHtml($annonceHtml, '<p>Siren : <b>', '<b>', '</b>')),' .-/;,',' '))*1;
|
||||
$tabAnn['sirenValide']=$iInsee->valideSiren($tabAnn['Siren']);
|
||||
$tabAnn['Waldec']=strtoupper(@getTextInHtml($annonceHtml, '<p>Identification R.N.A. : <b>', '<b>', '</b>'));
|
||||
$tabAnn['Annonce_Html']=str_replace('</p>','',str_replace(chr(160), ' ', html_entity_decode(@getTextInHtml($annonceHtml, '<p align="LEFT"><br>', '<br>', '</p>'))));
|
||||
if ($tabAnn['Annonce_Html']=='') // Les fondations n'ont pas le même corps HTML
|
||||
$tabAnn['Annonce_Html']=str_replace('</p>','',str_replace(chr(160), ' ', html_entity_decode(@getTextInHtml($annonceHtml, '<p align="left"></p> <p align="left">', '</p> <p align="left">', '</p>'))));
|
||||
if ($tabAnn['Annonce_Html']=='') // Les fondations n'ont pas le même corps HTML
|
||||
$tabAnn['Annonce_Html']='#####'.str_replace(chr(160), ' ', html_entity_decode($annonceHtml));
|
||||
|
||||
if ($depotComptes) {
|
||||
|
||||
$tabAnn['pdfLink']=@getTextInHtml($annonceHtml, '<a href="/', '/', '">');
|
||||
|
||||
$tmp=@getTextInHtml($annonceHtml, 'Date de clôture de l\'exercice : <b>', '<b>', '</b>');
|
||||
$tabAnn['dateCloture']=WDate::dateT('d/m/Y', 'Y-m-d', $tmp);
|
||||
if ( $tabAnn['dateCloture']=='' ) {
|
||||
preg_match('/_([0-9]{8})/', $tabAnn['pdfLink'], $matches);
|
||||
/*sendMail(
|
||||
'mricois@scores-decisions.com',
|
||||
'mricois@scores-decisions.com',
|
||||
'Associations',
|
||||
$annonceHtml."\n\n\n".print_r($matches,1));*/
|
||||
}
|
||||
|
||||
$tabAnn['typeCompte']=@getTextInHtml($annonceHtml, '<a href="/', '">>', '</a>');
|
||||
$tabAnn['dateInsert']=date('YmdHis');
|
||||
} else {
|
||||
$tabAnn['nic']=0;
|
||||
$tabAnn['nicValide']=0;
|
||||
$tabAnn['Activite']=htm2txt(@getTextInHtml($annonceHtml, 'Activité(s) : <b>', '<b>', '</b>'));
|
||||
$tabAnn['Num_Annonce']=@getTextInHtml($annonceHtml, 'No d\'annonce : <b>', '<b>', '</b>');
|
||||
$tmp=@getTextInHtml($annonceHtml, 'Paru le : <b>', '<b>', '</b>');
|
||||
$tabAnn['Date_Parution']=substr($tmp,6,4).'-'.substr($tmp,3,2).'-'.substr($tmp,0,2);
|
||||
$tabAnn['Num_Parution']=@getTextInHtml($annonceHtml, 'No de parution : <b>', '<b>', '</b>');
|
||||
$depReg=trim(htm2txt(@getTextInHtml($annonceHtml, 'Département (Région) : <b>','<b>','</b></p>')));
|
||||
$tabDepReg=explode('(', $depReg);
|
||||
$dep=trim($tabDepReg[0]);
|
||||
$numDep=$tabDep[$dep];
|
||||
if ($numDep=='') echo date ('Y/m/d - H:i:s') ." - Attention, département '$dep' non trouvé !". EOL;
|
||||
$region=trim(substr($tabDepReg[1],0,strlen($tabDepReg[1])-1));
|
||||
$tabAnn['Departement']=$numDep;
|
||||
$tabAnn['Sous_Prefecture']=htm2txt(@getTextInHtml($annonceHtml, '<p>Lieu parution : <b>Déclaration à la ', ' à la ', '</b>'));
|
||||
$tabAnn['Type_Annonce']=htm2txt(@getTextInHtml($annonceHtml, 'Type d\'annonce : <b>', '<b>', '</b>'));
|
||||
|
||||
/** Recherche du type d'association
|
||||
**/
|
||||
if (preg_match('/ASL/i', $tabAnn['Type_Annonce']) || preg_match('/syndicale/i', $tabAnn['Type_Annonce']))
|
||||
$tabAnn['typeAsso']='ASL';
|
||||
elseif (preg_match('/Fondation/i', $tabAnn['Type_Annonce']))
|
||||
$tabAnn['typeAsso']='FON';
|
||||
elseif (preg_match('/dotation/i', $tabAnn['Type_Annonce']))
|
||||
$tabAnn['typeAsso']='FOD';
|
||||
else
|
||||
$tabAnn['typeAsso']='ASS';
|
||||
|
||||
/** Recherche du type d'insertion
|
||||
**/
|
||||
if (preg_match('/ANNULATION/i', $tabAnn['Type_Annonce']))
|
||||
$tabAnn['typeAnnonce']='Suppression';
|
||||
elseif (preg_match('/RECTIFICATIF/i', $tabAnn['Type_Annonce']))
|
||||
$tabAnn['typeAnnonce']='Rectificatif';
|
||||
else
|
||||
$tabAnn['typeAnnonce']='Insertion';
|
||||
|
||||
$tabAnn['Assoc_Duree']=trim(htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Durée :', 'Durée :', '.<br>')));
|
||||
$tabAnn['Assoc_Dotation']=trim(htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Montant de la dotation initiale :', 'initiale :', '.<br>')));
|
||||
$tabAnn['Assoc_ProgAction']=trim(htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'action pluriannuel :', 'pluriannuel :', '.<br>')));
|
||||
$tabAnn['Assoc_Fondateurs']=trim(htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], ' de chacun des fondateurs :', 'fondateurs :', '.</p>')));
|
||||
|
||||
|
||||
//<p align="LEFT">Autorisation administrative.</p> <p align="LEFT">
|
||||
//Date de signature de statuts : 21 décembre 1992.<br>
|
||||
//Date de la modification des statuts : 7 février 1996, autorisation délivrée par le préfet 16 mars 1996.</p> <p align="LEFT">Autorisation tacite.</p> <p align="LEFT">
|
||||
//Date de la demande de modification des statuts : 7 février 1996, sollicitée auprès du préfet de Paris.</p>
|
||||
|
||||
|
||||
$tabAnn['Assoc_Web']=@getTextInHtml($tabAnn['Annonce_Html'], 'ite Internet : </i>', '</i>', '<i>');
|
||||
if (substr($tabAnn['Assoc_Web'],-1)=='.')
|
||||
$tabAnn['Assoc_Web']=substr($tabAnn['Assoc_Web'],0,-1);
|
||||
$tabAnn['Assoc_Mail']= @getTextInHtml($tabAnn['Annonce_Html'], '<i>Courriel : </i>', '</i>', '<i>');
|
||||
if ($tabAnn['Assoc_Mail']=='')
|
||||
$tabAnn['Assoc_Mail']= @getTextInHtml($tabAnn['Annonce_Html'], '<i>Mél. : </i>', '</i>', '<i>');
|
||||
if (substr($tabAnn['Assoc_Mail'],-1)=='.')
|
||||
$tabAnn['Assoc_Mail']=substr($tabAnn['Assoc_Mail'],0,-1);
|
||||
$tabAnn['Assoc_Objet']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '>Objet : </i>', '</i>', '<i>'));
|
||||
if(trim($tabAnn['Assoc_Objet'])=='')
|
||||
$tabAnn['Assoc_Objet']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Objet : </i>', '</i>', '<br>'));
|
||||
|
||||
$tabAnn['Assoc_NObjet']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Nouvel objet : </i>', '</i>', '<i>'));
|
||||
$tabAnn['Assoc_AObjet']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Additif à l’objet : </i>', '</i>', '<i>'));
|
||||
$tabAnn['Assoc_NAdresse']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Transféré ; nouvelle adresse : </i>', '</i>', '. <i>'));
|
||||
$tabAnn['Assoc_Fusion']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Fusion des associations : </i>', '</i>', '<i>'));
|
||||
$tabAnn['Assoc_Adresse']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Siège social : </i>', '</i>', '. <i>'));
|
||||
// Fondations
|
||||
if (trim($tabAnn['Assoc_Adresse'])=='')
|
||||
$tabAnn['Assoc_Adresse']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Siège : </i>', '</i>', '.<br>'));
|
||||
if (trim($tabAnn['Assoc_Adresse'])=='')
|
||||
$tabAnn['Assoc_Adresse']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Siège : </i>', '</i>', '.</p>'));
|
||||
|
||||
$tabAnn['Assoc_Date_Declaration']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '>Date de la déclaration : </i>', '</i>', '.'));
|
||||
if ($tabAnn['Assoc_Date_Declaration']=='')
|
||||
$tabAnn['Assoc_Date_Declaration']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '>Date de délivrance du récépissé : </i>', '</i>', '.'));
|
||||
// Fondations
|
||||
if(trim($tabAnn['Assoc_Date_Declaration'])=='') {
|
||||
$tabAnn['Assoc_Date_Declaration']=trim(htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'autorisation administrative :', 'administrative :', ',')));
|
||||
if (trim($tabAnn['Assoc_Date_Declaration'])=='')
|
||||
$tabAnn['Assoc_Date_Declaration']=trim(htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Date de la modification des statuts :', 'statuts :', ',')));
|
||||
if(trim($tabAnn['Sous_Prefecture'])=='')
|
||||
$tabAnn['Sous_Prefecture']=htm2txt(@getTextInHtml($annonceHtml, 'sollicitée auprès du', 'du', '<br>'));
|
||||
if(trim($tabAnn['Sous_Prefecture'])=='')
|
||||
$tabAnn['Sous_Prefecture']=htm2txt(@getTextInHtml($annonceHtml, 'sollicitée auprès du', 'du', '</p>'));
|
||||
}
|
||||
$tabAnn['Assoc_Date_Declaration2']=WDate::dateT('d M Y', 'Y-m-d', $tabAnn['Assoc_Date_Declaration']);
|
||||
$tabAnn['Assoc_ANom']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Ancien titre : </i>', '</i>', '<i>'));
|
||||
$tabAnn['Assoc_Annulation']='Annulation '.htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '>Annulation', '</i>', '.'));
|
||||
/*<i>Annulation </i>de l’insertion n<sup>o</sup> 1014, parue au <i>Journal officiel </i>n<sup>o</sup> 25, du 24 juin 2006, page 3106.*/
|
||||
if ($tabAnn['Assoc_Annulation']=='Annulation ') $tabAnn['Assoc_Annulation']='';
|
||||
|
||||
if ($tabAnn['Assoc_ANom']=='')
|
||||
$tabAnn['Assoc_ANom']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], 'Au lieu de : </i>', '</i>', '<i>'));
|
||||
if (substr($tabAnn['Assoc_ANom'],-1)=='.')
|
||||
$tabAnn['Assoc_ANom']=substr($tabAnn['Assoc_ANom'],0,-1);
|
||||
$tabAnn['Assoc_NNom']=htm2txt(@getTextInHtml($tabAnn['Annonce_Html'], '<i>Nouveau titre :', '</i>', '<i>'));
|
||||
if (substr($tabAnn['Assoc_NNom'],-1)=='.')
|
||||
$tabAnn['Assoc_NNom']=substr($tabAnn['Assoc_NNom'],0,-1);
|
||||
}
|
||||
return $tabAnn;
|
||||
}
|
||||
|
||||
$tempsMinEntreRequetes=5;
|
||||
$tempsMaxEntreRequetes=30;
|
||||
set_time_limit(0);
|
||||
$lastJO=$dateDebut=$dateFin=$dateF=$dateCour=$verif=false;
|
||||
$strInfoProg='Usage : '.basename($argv[0]). " [OPTION]
|
||||
Recupère les annonces Association sur le site du JO Association.
|
||||
|
||||
Sans aucun paramètre, récupération du dernier JO Association.
|
||||
Sinon:
|
||||
-d:JJ/MM/AAAA Date de début de publication
|
||||
-f:JJ/MM/AAAA Date de fin de publication
|
||||
-l Dernier JO Association uniquement (*)
|
||||
-c Dépôts des comptes uniquement
|
||||
-s:123456789 Recherche par siren
|
||||
-n:X Intervalle MIN en secondes entre les requêtes sur le site des JO (défaut=$tempsMinEntreRequetes)
|
||||
-i:X \" MAX \" \" \" \" \" \" \" \" \" \" (défaut=$tempsMaxEntreRequetes)
|
||||
-v Vérifier que toutes les annonces du JO sont en base !
|
||||
";
|
||||
|
||||
$depotComptes=false;
|
||||
$siren = null;
|
||||
|
||||
$argv=$_SERVER['argv'];
|
||||
if ($_SERVER['argc']==1) $lastJO=true;
|
||||
else {
|
||||
for ($i=1; isset($argv[$i]); $i++) {
|
||||
if (substr($argv[$i],0,1)=='-') {
|
||||
switch (substr($argv[$i],1,1)) {
|
||||
case 'd':
|
||||
$dateDebut=substr($argv[$i],3,10);
|
||||
$dateDeb=WDate::dateT('d/m/Y', 'Ymd', $dateDebut);
|
||||
break;
|
||||
case 'f':
|
||||
$dateFin=substr($argv[$i],3,10);
|
||||
$dateF=WDate::dateT('d/m/Y', 'Ymd', $dateFin);
|
||||
break;
|
||||
case 'n':
|
||||
$tempsMinEntreRequetes=trim(substr($argv[$i],3))*1;
|
||||
if ($tempsMinEntreRequetes<0) $tempsMinEntreRequetes=0;
|
||||
break;
|
||||
case 'i':
|
||||
$tempsMaxEntreRequetes=trim(substr($argv[$i],3))*1;
|
||||
if ($tempsMaxEntreRequetes<5) $tempsMaxEntreRequetes=2;
|
||||
break;
|
||||
case 'l':
|
||||
$lastJO=true;
|
||||
break;
|
||||
case 'v':
|
||||
$verif=true;
|
||||
break;
|
||||
case 'c':
|
||||
$depotComptes=true;
|
||||
break;
|
||||
case 's':
|
||||
$siren = substr($argv[$i],3,9);
|
||||
break;
|
||||
case '-':
|
||||
die($strInfoProg);
|
||||
break;
|
||||
default: die('Option '. $argv[$i] . " inconnue !\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($depotComptes) {
|
||||
$tabReg = array(
|
||||
'ASSOCIATION%2FCOMPTE',
|
||||
'FONDATION%2FCOMPTE',
|
||||
'FONDS+DE+DOTATION%2FCOMPTE',
|
||||
'AUTRE%2FCOMPTE',
|
||||
);
|
||||
} else {
|
||||
$tabReg = array(
|
||||
'ASSOCIATION%2FCREATION',
|
||||
'ASSOCIATION%2FMODIFICATION',
|
||||
'ASSOCIATION%2FDISSOLUTION',
|
||||
'ASL',
|
||||
'FONDATION',
|
||||
'DECISION+JUSTICE',
|
||||
'AUTRE',
|
||||
'FONDS+DE+DOTATION',
|
||||
);
|
||||
}
|
||||
|
||||
$iDb=new WDB();
|
||||
$iInsee=new Metier_Insee_MInsee();
|
||||
|
||||
$referer='http://www.journal-officiel.gouv.fr/association/';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
if ($verif) {
|
||||
echo date('Y/m/d - H:i:s') ." - Comptage du nombre d'annonce présentes en base par date de parution...". EOL;
|
||||
$AnnDb=$iDb->select('asso', 'Date_Parution, count(*) as nb', '1 GROUP BY Date_Parution');
|
||||
foreach ($AnnDb as $i=>$tabDates) {
|
||||
if ($tabDates[0]<>'0000-00-00') {
|
||||
$parDate=$tabDates[0];
|
||||
$parNb =$tabDates[1];
|
||||
$dateFmt=str_replace('/', '%2F', WDate::dateT('Y-m-d', 'd/m/Y',$parDate));
|
||||
$url="http://www.journal-officiel.gouv.fr/association/index.php?ACTION=Rechercher&HI_PAGE=1&HI_COMPTEUR=0&original_method=get&WHAT=&JTH_ID=&JAN_BD_CP=&JRE_ID=&JAN_LIEU_DECL=&JTY_ID=&JTY_WALDEC=&JPA_D_D=$dateFmt&JPA_D_F=".$dateFmt.'&rechercher.x='.rand(1,68).'&rechercher.y='.rand(1,16).'&rechercher=Rechercher';
|
||||
|
||||
$page=getUrl($url, '', '', $referer, false, 'www.journal-officiel.gouv.fr');
|
||||
$body=$page['body'];
|
||||
$ctx=@getTextInHtml($body, '<A href="index.php?ctx=', 'ctx=', '&'); // Clé de contexte entre chaque page
|
||||
$nbAnnonces=@getTextInHtml($body, '<p>Résultat de la recherche : <strong>', '<strong>', 'annonce(s)</strong>');
|
||||
if ($nbAnnonces<>$parNb && $nbAnnonces<>0)
|
||||
echo date('Y/m/d - H:i:s') ." - Parution du $parDate : $parNb annonces en base / $nbAnnonces annonces parues !". EOL;
|
||||
elseif ($nbAnnonces==0)
|
||||
echo date('Y/m/d - H:i:s') ." - Parution du $parDate : $parNb annonces en base / Plus d'annonces sur le site JO.". EOL;
|
||||
randsleep($tempsMinEntreRequetes, $tempsMaxEntreRequetes);
|
||||
}
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
if ($lastJO==true) {
|
||||
$strLast=' dernier';
|
||||
$strDates='';
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
else {
|
||||
$strLast='';
|
||||
if ($depotComptes) {
|
||||
if ($dateDebut==false) {
|
||||
$dateDeb= getNextDate(date('Ymd'),-5);
|
||||
$dateDebut= WDate::dateT('Ymd', 'd/m/Y',$dateDeb);
|
||||
}
|
||||
if ($dateFin==false) {
|
||||
$dateF= getNextDate(date('Ymd'),0);
|
||||
$dateFin= WDate::dateT('Ymd', 'd/m/Y',$dateF);
|
||||
}
|
||||
$dateCour= $dateDeb;
|
||||
}
|
||||
if ($dateFin==false) {
|
||||
$dateFin=date('d/m/Y');
|
||||
$dateF=WDate::dateT('d/m/Y', 'Ymd', $dateFin);
|
||||
}
|
||||
if ($dateDebut==false)
|
||||
die($strInfoProg);
|
||||
else
|
||||
$strDates=" du $dateDebut au $dateFin";
|
||||
$dateCour=$dateDeb;
|
||||
}
|
||||
|
||||
|
||||
echo date('Y/m/d - H:i:s') ." - DEBUT du la récupération du$strLast JO Association$strDates".EOL;
|
||||
echo date('Y/m/d - H:i:s') .' - La durée maximum entre chaque requête est de '. $tempsMaxEntreRequetes .' secondes.'. EOL;
|
||||
|
||||
$message = '';
|
||||
|
||||
// Boucle sur les dates
|
||||
while ($dateCour<=$dateF || $lastJO)
|
||||
{
|
||||
// Boucle sur les régions
|
||||
for ($i_reg=0; isset($tabReg[$i_reg]) || $lastJO; $i_reg++)
|
||||
{
|
||||
// Recherche par siren
|
||||
if ($siren !== null) {
|
||||
$url = 'http://www.journal-officiel.gouv.fr/association/index.php?ACTION=Rechercher&HI_PAGE=1&HI_COMPTEUR=0&original_method=get&WHAT=&JTH_ID=&JAN_BD_CP=&JRE_ID=&JAN_LIEU_DECL=&JTY_ID='.$region.'&JTY_WALDEC=&JTY_SIREN='.$siren.'&JPA_D_D=&JPA_D_F=&rechercher.x='.rand(1,68).'&rechercher.y='.rand(1,16).'&rechercher=Rechercher';
|
||||
// Cas récup dernier JO
|
||||
} elseif ($lastJO==true) {
|
||||
$region='';
|
||||
$reg5=substr($region,0,5);
|
||||
$url='http://www.journal-officiel.gouv.fr/association/index.php?ACTION=showLast';
|
||||
}
|
||||
// On est pas dans la récupération du JO Assoc Jiur
|
||||
else {
|
||||
$region=$tabReg[$i_reg];
|
||||
$reg5=substr($region,0,5);
|
||||
$dateFmt=str_replace('/', '%2F', WDate::dateT('Ymd', 'd/m/Y',$dateCour));
|
||||
if ($depotComptes)
|
||||
$dateFmt2=str_replace('/', '%2F', WDate::dateT('Ymd', 'd/m/Y',getNextDate($dateCour,0)));
|
||||
else
|
||||
$dateFmt2=str_replace('/', '%2F', WDate::dateT('Ymd', 'd/m/Y',getNextDate($dateCour)));
|
||||
|
||||
$url='http://www.journal-officiel.gouv.fr/association/index.php?ACTION=Rechercher&HI_PAGE=1&HI_COMPTEUR=0&original_method=get&WHAT=&JTH_ID=&JAN_BD_CP=&JRE_ID=&JAN_LIEU_DECL=&JTY_ID='.$region.'&JTY_WALDEC=&JTY_SIREN=&JPA_D_D='. $dateFmt .'&JPA_D_F='. $dateFmt2.'&rechercher.x='.rand(1,68).'&rechercher.y='.rand(1,16).'&rechercher=Rechercher';
|
||||
$strLast='';
|
||||
}
|
||||
|
||||
$page=getUrl($url, '', '', $referer, false, 'www.journal-officiel.gouv.fr');
|
||||
$body=$page['body'];
|
||||
//die(print_r($body));
|
||||
$ctx=@getTextInHtml($body, '<A href="index.php?ctx=', 'ctx=', '&'); // Clé de contexte entre chaque page
|
||||
$nbAnnonces=@getTextInHtml($body, 'Résultat de la recherche :', ' :', 'annonce(s)');
|
||||
$dateDerParution=@getTextInHtml($body, 'Annonce parue entre le :', ' et le ', '<br>'); // Date au format JJ/MM/AAAA
|
||||
// 01/08/2010 et le 01/08/2010<br>
|
||||
$nbPages=ceil($nbAnnonces/25);
|
||||
if ($nbPages>100) {
|
||||
echo date('Y/m/d - H:i:s') .' - ERREUR : Il y a plus de 100 pages d\'annonces !'. EOL;
|
||||
die();
|
||||
}
|
||||
echo date('Y/m/d - H:i:s') ." - Clé de contexte = $ctx".EOL;
|
||||
unset($AnnDb);
|
||||
$nbAnnDb=0;
|
||||
if ($lastJO==true) {
|
||||
echo date('Y/m/d - H:i:s') .' - Derniere parution ASSO le '. $dateDerParution .' de '. $nbAnnonces .' annonces ('. $nbPages .' pages)'. EOL;
|
||||
// On recherche si nous n'avons pas déjà toutes ces annonces en base !
|
||||
$dateDb=substr($dateDerParution,6,4).'-'.substr($dateDerParution,3,2).'-'.substr($dateDerParution,0,2);
|
||||
$AnnDb=$iDb->select('asso', 'count(*) AS nb', "Date_Parution='$dateDb'", false, MYSQL_ASSOC);
|
||||
$nbAnnDb=$AnnDb[0]['nb'];
|
||||
if ($nbAnnDb==$nbAnnonces) {
|
||||
echo date('Y/m/d - H:i:s') .' - Toutes les annonces du '. $dateDerParution .' sont en base !'. EOL;
|
||||
echo date('Y/m/d - H:i:s') .' - FIN du script'. EOL;
|
||||
die();
|
||||
}
|
||||
elseif ($nbAnnDb>0 && $nbAnnDb<$nbAnnonces) {
|
||||
$message=date('Y/m/d - H:i:s') .' - ATTENTION : Il n\'y a que '. $nbAnnDb .' annonces en base sur les '. $nbAnnonces .' annonces présentes au JO Association du '. $dateDerParution .' !'. EOL;
|
||||
echo $message;
|
||||
sendMail('supportdev@scores-decisions.com', 'suivi@scores-decisions.com', 'JO Association', $message);
|
||||
echo date('Y/m/d - H:i:s') .' - Tentative de récupération des annonces...'. EOL;
|
||||
}
|
||||
} else {
|
||||
// On recherche si nous n'avons pas déjà toutes ces annonces en base !
|
||||
$dateDb=substr($dateCour,0,4).'-'.substr($dateCour,4,2).'-'.substr($dateCour,6,2);
|
||||
$dateDerParution=WDate::dateT('Y-m-d', 'd/m/Y',$dateDb);
|
||||
if ($depotComptes) {
|
||||
switch ($region) {
|
||||
case 'ASSOCIATION%2FCOMPTE': $strRegSql=" AND typeAsso='ASS' "; break;
|
||||
case 'FONDATION%2FCOMPTE': $strRegSql=" AND typeAsso='FON' "; break;
|
||||
case 'FONDS+DE+DOTATION%2FCOMPTE': $strRegSql=" AND typeAsso='FOD' "; break;
|
||||
case 'AUTRE%2FCOMPTE': $strRegSql=" AND typeAsso='DIV' "; break;
|
||||
}
|
||||
$AnnDb=$iDb->select('asso_bilans', 'count(*) AS nb', "Assoc_Date_Declaration='$dateDb' $strRegSql", false, MYSQL_ASSOC);
|
||||
$strJO='depôts des comptes associations';
|
||||
} else {
|
||||
$AnnDb=$iDb->select('asso', 'count(*) AS nb', "Date_Parution='$dateDb'", false, MYSQL_ASSOC);
|
||||
$strJO='associations';
|
||||
}
|
||||
$nbAnnDb=$AnnDb[0]['nb'];
|
||||
if ($nbAnnDb>=$nbAnnonces) {
|
||||
echo mysql_error().EOL;
|
||||
echo date('Y/m/d - H:i:s') ." - Les $nbAnnonces annonces $strJO $reg5 du $dateDerParution ($dateDb) sont en base ($nbAnnDb) !". EOL;
|
||||
randsleep($tempsMinEntreRequetes, $tempsMaxEntreRequetes);
|
||||
continue;
|
||||
}
|
||||
elseif ($nbAnnDb>0 && $nbAnnDb<$nbAnnonces) {
|
||||
$message.=date('Y/m/d - H:i:s') ." - ATTENTION : Il n'y a que $nbAnnDb annonce(s) $strJO en base sur les $nbAnnonces annonces présentes au JO du $dateDerParution !". EOL;
|
||||
echo date('Y/m/d - H:i:s') ." - ATTENTION : Il n'y a que $nbAnnDb annonce(s) $strJO en base sur les $nbAnnonces annonces présentes au JO du $dateDerParution !". EOL;
|
||||
echo date('Y/m/d - H:i:s') .' - Tentative de récupération des annonces...'. EOL;
|
||||
}
|
||||
else {
|
||||
$message.=date('Y/m/d - H:i:s') ." - Il y a $nbAnnDb annonce(s) $strJO $reg5 en base sur les $nbAnnonces annonces présentes au JO du $dateDerParution !". EOL;
|
||||
echo date('Y/m/d - H:i:s') ." - Il y a $nbAnnDb annonce(s) $strJO $reg5 en base sur les $nbAnnonces annonces présentes au JO du $dateDerParution !". EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$tabAnnonces=explode('<div class="hr"><hr/></div>', utf8_encode($page['body']));
|
||||
|
||||
for ($j=1; $j<26 && isset($tabAnnonces[$j]); $j++)
|
||||
$tabAnn[$j-1]=$tabAnnonces[$j];
|
||||
randsleep($tempsMinEntreRequetes, $tempsMaxEntreRequetes);
|
||||
$referer=$url;
|
||||
for ($i=2; $i<=$nbPages; $i++)
|
||||
{
|
||||
if (!$lastJO) {
|
||||
$data='';
|
||||
$date1=str_replace('/', '%2F', WDate::dateT('Ymd', 'd/m/Y',$dateCour));
|
||||
if ($depotComptes)
|
||||
$date2=str_replace('/', '%2F', WDate::dateT('Ymd', 'd/m/Y',getNextDate($dateCour,0)));
|
||||
else
|
||||
$date2=str_replace('/', '%2F', WDate::dateT('Ymd', 'd/m/Y',getNextDate($dateCour)));
|
||||
$url='http://www.journal-officiel.gouv.fr/association/index.php?ctx='.$ctx.'&page='.$i.'&JRE_ID='.urlencode($region).'&JPA_D_D='.$date1.'&JPA_D_F='.$date2;
|
||||
|
||||
} else {
|
||||
$date1='';$date2='';$data='1';
|
||||
$url='http://www.journal-officiel.gouv.fr/association/index.php?ctx='.$ctx.'&page='.$i;
|
||||
}
|
||||
|
||||
$page=getUrl($url, '', '', $referer, false, 'www.journal-officiel.gouv.fr');
|
||||
$tabAnnonces=explode('<div class="hr"><hr/></div>', utf8_encode($page['body']));
|
||||
|
||||
|
||||
for ($j=1; $j<26; $j++) {
|
||||
$k=$j+(25*($i-1))-1;
|
||||
if ($k<$nbAnnonces)
|
||||
$tabAnn[$k]=$tabAnnonces[$j];
|
||||
}
|
||||
flush();
|
||||
if ($i==2)
|
||||
echo date('Y/m/d - H:i:s') ." - Page $i/$nbPages";
|
||||
else
|
||||
echo ", $i/$nbPages";
|
||||
if ($i==$nbPages)
|
||||
echo '.'.EOL;
|
||||
else
|
||||
randsleep($tempsMinEntreRequetes, $tempsMaxEntreRequetes);
|
||||
}
|
||||
|
||||
$tabActivites=array();
|
||||
for ($i=0; $i<$nbAnnonces; $i++) {
|
||||
$infoAnnBalo=getInfosAnnonceAsso($tabAnn[$i], $depotComptes);
|
||||
$tabInfos=array();
|
||||
preg_match_all("|<i>(.*)</i>|U", $infoAnnBalo['Annonce_Html'], $tabInfos);
|
||||
$tabInfosGlobal=array_unique(array_merge($tabInfosGlobal, $tabInfos[1]));
|
||||
// On recherche si nous n'avons pas déjà cette annonce en base !
|
||||
if ($depotComptes) {
|
||||
$AnnDb=$iDb->select('asso_bilans', 'count(*) AS nb', "Siren=".$infoAnnBalo['Siren']." AND Waldec='".$infoAnnBalo['Waldec']."' AND dateCloture='".$infoAnnBalo['dateCloture']."'", false, MYSQL_ASSOC);
|
||||
// $AnnDb[0][0]=0;
|
||||
} else {
|
||||
$AnnDb=$iDb->select('asso', 'count(*) AS nb', "Num_Annonce='".$infoAnnBalo['Num_Annonce']."' AND Date_Parution='".$infoAnnBalo['Date_Parution']."' AND Num_Parution='".$infoAnnBalo['Num_Parution']."'", false, MYSQL_ASSOC);
|
||||
$dateAff=$infoAnnBalo['Date_Parution'];
|
||||
}
|
||||
$nbAnnDb=$AnnDb[0]['nb'];
|
||||
$i2=$i+1;
|
||||
$strRegion=', '. $region;
|
||||
|
||||
if ($depotComptes) {
|
||||
$table='asso_bilans';
|
||||
// Si le bilan PDF n'est pas déjà sur le disk, on va le chercher !
|
||||
switch ($region) {
|
||||
case 'ASSOCIATION%2FCOMPTE': $infoAnnBalo['typeAsso']='ASS'; break;
|
||||
case 'FONDATION%2FCOMPTE': $infoAnnBalo['typeAsso']='FON'; break;
|
||||
case 'FONDS+DE+DOTATION%2FCOMPTE': $infoAnnBalo['typeAsso']='FOD'; break;
|
||||
case 'AUTRE%2FCOMPTE':
|
||||
default: $infoAnnBalo['typeAsso']='DIV'; break;
|
||||
}
|
||||
$dateAff=$dateCour.' ('.$infoAnnBalo['dateCloture'].')';
|
||||
$infoAnnBalo['Assoc_Date_Declaration']=$dateCour;
|
||||
$tabPdf=getPdfInfo($repPdfAssoCpt.'/'.basename($infoAnnBalo['pdfLink']));
|
||||
if (!$tabPdf) {
|
||||
$page=getUrl('http://www.journal-officiel.gouv.fr/'.$infoAnnBalo['pdfLink'], '', '', '', false);
|
||||
$fp = fopen($repPdfAssoCpt.'/'.basename($infoAnnBalo['pdfLink']), 'w');
|
||||
if ($fp === false ) {
|
||||
$message.=date('Y/m/d - H:i:s') .' - ERREUR : Problème de création du PDF '. basename($infoAnnBalo['pdfLink']) ." pour la parution du $dateAff $strRegion, Annonce $i2/$nbAnnonces, Association \"". $infoAnnBalo['Assoc_Nom'] .'" !'.EOL;
|
||||
echo date('Y/m/d - H:i:s') .' - ERREUR : Problème de création du PDF '. basename($infoAnnBalo['pdfLink']) ." pour la parution du $dateAff $strRegion, Annonce $i2/$nbAnnonces, Association \"". $infoAnnBalo['Assoc_Nom'] .'" !'.EOL;
|
||||
} else {
|
||||
fwrite($fp, $page['body']);
|
||||
fclose($fp);
|
||||
}
|
||||
$tabPdf=getPdfInfo($repPdfAssoCpt.'/'.basename($infoAnnBalo['pdfLink']));
|
||||
randsleep($tempsMinEntreRequetes, $tempsMaxEntreRequetes);
|
||||
}
|
||||
$infoAnnBalo['pdfSize'] = $tabPdf['pdfSize'];
|
||||
$infoAnnBalo['pdfVer'] = $tabPdf['version'];
|
||||
$infoAnnBalo['pdfPage'] = $tabPdf['nbPages'];
|
||||
} else {
|
||||
$table='asso';
|
||||
$tabTmp=explode('/',$infoAnnBalo['Activite']);
|
||||
$tabActivites=array_merge($tabActivites, $tabTmp);
|
||||
}
|
||||
if ($nbAnnDb==1) {
|
||||
echo date('Y/m/d - H:i:s') ." - Parution du $dateAff $strRegion, Annonce $i2/$nbAnnonces, Association \"". $infoAnnBalo['Assoc_Nom'] .'" déjà en base !'.EOL;
|
||||
// L'annonce est déjà en base !
|
||||
continue;
|
||||
} else {
|
||||
$message.=date('Y/m/d - H:i:s') ." - Parution du $dateAff $strRegion, Annonce $i2/$nbAnnonces, Association \"". $infoAnnBalo['Assoc_Nom'] .'"... enregistrement'.EOL;
|
||||
echo date('Y/m/d - H:i:s') ." - Parution du $dateAff $strRegion, Annonce $i2/$nbAnnonces, Association \"". $infoAnnBalo['Assoc_Nom'] .'"... enregistrement'.EOL;
|
||||
}
|
||||
|
||||
if (!$iDb->insert($table, $infoAnnBalo))
|
||||
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . EOL;
|
||||
}
|
||||
|
||||
if ($lastJO) {
|
||||
print_r($tabInfosGlobal);
|
||||
echo date('Y/m/d - H:i:s') .' - FIN du script'. EOL;
|
||||
die();
|
||||
}
|
||||
unset($tabAnn);
|
||||
} // Fin boucle région
|
||||
if ($depotComptes)
|
||||
$dateCour=getNextDate($dateCour,1);
|
||||
else
|
||||
$dateCour=getNextDate($dateCour);
|
||||
|
||||
} // Fin boucle Data
|
||||
|
||||
if ($depotComptes) {
|
||||
//
|
||||
$AnnDb=$iDb->select('annonces', 'MAX(dateSource) AS dateMAJ', "typeEven=3200", false, MYSQL_ASSOC);
|
||||
$dateMaj=$AnnDb[0]['dateMAJ'];
|
||||
// echo date('Y/m/d - H:i:s') ." - Dernière mise à jour des annonces dépots en collecte en date du $dateMaj.".EOL;
|
||||
|
||||
$AnnDb=$iDb->select('asso_bilans',
|
||||
"Assoc_Nom AS raisonSociale, siren, sirenValide, dateCloture AS dateEffetFinP, Assoc_Date_Declaration AS dateJugement, dateInsert AS dateSource,
|
||||
'3200' AS typeEven, 'DJOFFJ' AS tribunal, 'JS' AS source, Waldec",
|
||||
"dateInsert>'$dateMaj' ORDER BY dateEffetFinP DESC", false, MYSQL_ASSOC);
|
||||
$nbAnnonces=count($AnnDb);
|
||||
$message.=date('Y/m/d - H:i:s') ." - Il y a $nbAnnonces annonces dépots à mettre en collecte en date du $dateMaj.".EOL;
|
||||
echo date('Y/m/d - H:i:s') ." - Il y a $nbAnnonces annonces dépots à mettre en collecte en date du $dateMaj.".EOL;
|
||||
|
||||
foreach ($AnnDb as $i=>$tabInsert) {
|
||||
$tabTmp=$iInsee->getIdentiteLight($tabInsert['siren']);
|
||||
$tabInsert['adresse'] = $tabTmp['Adresse'];
|
||||
$tabInsert['codePostal']= $tabTmp['CP'];
|
||||
$tabInsert['ville'] = $tabTmp['Ville'];
|
||||
$tabInsert['dateInsert']= date('YmdHis');
|
||||
if (trim($tabInsert['Waldec'])<>'')
|
||||
$tabInsert['complement']= 'Identifiant Waldec : '.$tabInsert['Waldec'];
|
||||
unset($tabInsert['Waldec']);
|
||||
//print_r($tabInsert);
|
||||
//die();
|
||||
if (!$iDb->insert('annonces', $tabInsert))
|
||||
echo '';//date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . EOL;
|
||||
}
|
||||
sendMail('supportdev@scores-decisions.com', 'suivi@scores-decisions.com', '[CHARGEMENT] JO Association Comptes', $message);
|
||||
}
|
||||
|
||||
echo date('Y/m/d - H:i:s') .' - FIN du script.'. EOL;
|
@ -1,119 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Récupère les bilans au format PDF
|
||||
* 15 19 * * 1-5 /var/www/batch/fedasoBilans.php -d >> /var/www/log/fedasoBilans.log
|
||||
*/
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
//Options
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(array(
|
||||
'help|?' => "Displays usage information.",
|
||||
'source' => "source (extranet)",
|
||||
'debug' => "Mode debug",
|
||||
));
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if( isset($opts->help) || count($opts->getOptions())==0 )
|
||||
{
|
||||
echo "Gestion des échanges de bilan saisie.\n";
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
$db = Zend_Db::factory($c->profil->db->metier);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||
|
||||
$pathSend = $c->profil->path->shared . '/clients/bilansext/send';
|
||||
$pathBackup = $c->profil->path->shared . '/clients/bilansext/send/done';
|
||||
|
||||
// Lecture du dossier des dépots de bilans à demander en saisie
|
||||
if ($opts->source == 'extranet')
|
||||
{
|
||||
echo date('Y-m-d H:i:s') ." - Chargement bilan source extranet.\n";
|
||||
|
||||
$dh = opendir($pathSend);
|
||||
while (false !== ($filename = readdir($dh)))
|
||||
{
|
||||
if ($filename != '.' && $filename != '..' && substr($filename, -4) == '.pdf')
|
||||
{
|
||||
if (preg_match('/([0-9]{9})_([CNS])([0-9]{8})_([0-9]{2})_([0-9]{1})_([0-9]{1,})_([0-9]{1,}).pdf/', $filename, $t))
|
||||
{
|
||||
$filetime = date('YmdHis', filectime($pathSend.'/'.$filename));
|
||||
|
||||
$siren = $t[1];
|
||||
$format = $t[2];
|
||||
$cloture = $t[3];
|
||||
$duree = $t[4];
|
||||
$confidentiel = $t[5];
|
||||
$userId = $t[6];
|
||||
$extranetId = $t[7];
|
||||
|
||||
if ( false !== ( $file = file_get_contents($pathSend.'/'.$filename) ) )
|
||||
{
|
||||
//Number of page
|
||||
$pages = preg_match_all( "/\/Page\W/", $file, $matches );
|
||||
|
||||
//Pdf size
|
||||
$size = filesize($pathSend.'/'.$filename);
|
||||
}
|
||||
|
||||
$dataInsert = array(
|
||||
'siren' => $siren,
|
||||
'dateCloture' => $cloture,
|
||||
'format' => $format,
|
||||
'duree' => $duree,
|
||||
'confidentiel' => $confidentiel,
|
||||
'idUtilisateur' => $userId,
|
||||
'idExtranet' => $extranetId,
|
||||
'environnement' => '',
|
||||
'refDoc' => $filename,
|
||||
'dateEntree' => $filetime,
|
||||
'dateEnvoi' => date('YmdHis'),
|
||||
'pdfNum' => 0,
|
||||
'pdfSize' => $size,
|
||||
'pdfPage' => $pages,
|
||||
);
|
||||
|
||||
$insertOk = false;
|
||||
try {
|
||||
$db->insert('sdv1.fedaso_bilans', $dataInsert);
|
||||
$insertOk = true;
|
||||
} catch (Zend_Db_Exception $e) {
|
||||
//Doublon
|
||||
if ($e->getCode() == '1062') {
|
||||
$insertOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Copier le fichier
|
||||
if ($insertOk === true) {
|
||||
if (!rename($pathSend.'/'.$filename, $pathBackup.'/'.$filename)) {
|
||||
echo date('Y-m-d H:i:s') ." - Impossible de déplacer le fichier $filename.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo date('Y-m-d H:i:s') ." - FIN du script.\n";
|
@ -1,266 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Chargement des fichiers en provenance de GE FactoFrance
|
||||
* Les fichiers sont disponible dans le répertoire de stockage avec une date pour historisation
|
||||
* Liste des fichiers :
|
||||
* - GESCDACH
|
||||
* - GESCDCLT
|
||||
* - GESCDMVT
|
||||
* Execution entre le 5 et le 8 du mois toutes les 4 heures ?
|
||||
*/
|
||||
ini_set('auto_detect_line_endings', true);
|
||||
|
||||
// --- Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||
|
||||
// --- Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
|
||||
// --- Composer autoload
|
||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||
|
||||
// --- Create application, bootstrap, and run
|
||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||
|
||||
//Options
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(array(
|
||||
'help|?' => "Displays usage information.",
|
||||
'cron' => "Launch in cron",
|
||||
'file=s' => "Specify file name to execute manually",
|
||||
'debug' => "Mode debug",
|
||||
));
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
echo $e->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
//Usage
|
||||
if( isset($opts->help) || count($opts->getOptions())==0 )
|
||||
{
|
||||
echo "Chargement des fichiers en provenance de GE FactoFrance.".PHP_EOL;
|
||||
echo $opts->getUsageMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
$db = Zend_Db::factory($c->profil->db->metier);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||
|
||||
$tabFile = array();
|
||||
|
||||
//Lire le nom du fichier depuis la ligne de commande
|
||||
if ( $opts->file ) {
|
||||
if ( empty($opts->file) ) {
|
||||
echo date('Y-m-d H:i:s') . " - Aucun fichier définit !".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
$tabFile[] = $opts->file;
|
||||
}
|
||||
|
||||
//Lire la table flux_filein (Nom du fichier, nombre de ligne)
|
||||
if ( $opts->cron ) {
|
||||
$fluxinM = new Application_Model_Sdv1FluxFileIn();
|
||||
$sql = $fluxinM->select()
|
||||
->where('client=?', 'gefacto')
|
||||
->where('name=?', 'GEFACTO')
|
||||
->where('depotType=?', 'SFTP')
|
||||
->where('dateExecute=?','0000-00-00 00:00:00')
|
||||
->order('dateInsert DESC');
|
||||
|
||||
$pitems = $fluxinM->fetchAll($sql);
|
||||
foreach ( $pitems as $p ) {
|
||||
$tabFile[] = $p->depotFile;
|
||||
}
|
||||
}
|
||||
|
||||
if ( count($tabFile)==0 ) {
|
||||
echo date('Y-m-d H:i:s') . " - Aucun fichier à traiter !".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once APPLICATION_PATH . '/configs/config.php';
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'framework/mail/sendMail.php';
|
||||
|
||||
foreach ($tabFile as $filename)
|
||||
{
|
||||
$path = $c->profil->path->shared . '/clients/gefacto/send';
|
||||
$file = $path . '/' . $filename;
|
||||
|
||||
//Check fichier
|
||||
if ( file_exists($file) ) {
|
||||
|
||||
$dateFichier = date('YmdHis', filemtime($file));
|
||||
|
||||
echo date('Y-m-d H:i:s') . " - Chargement des Informations de Paiement ".basename($file).PHP_EOL;
|
||||
|
||||
//Ouvrir le fichier
|
||||
$fp = fopen($file, 'r');
|
||||
|
||||
if (!$fp) {
|
||||
echo date('Y-m-d H:i:s') . " - Impossible de lire le fichier !".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
//Calcul du nombre de ligne du fichier
|
||||
$nbLines = 0;
|
||||
while (($buffer = fgets($fp)) !== false)
|
||||
{
|
||||
$nbLines++;
|
||||
|
||||
//Détection de la longueur de la première ligne
|
||||
$lineLength = strlen($buffer);
|
||||
if ( $lineLength<=30 ) {
|
||||
$fileType = 1; $dbTableUpdate = 'ge_cs2';
|
||||
} elseif ( $lineLength==122 ) {
|
||||
$fileType = 0; $dbTableUpdate = 'ge_acheteurs';
|
||||
} elseif ( $lineLength==75 ) {
|
||||
$fileType = 2; $dbTableUpdate = 'ge_paiements';
|
||||
}
|
||||
//Erreur
|
||||
else {
|
||||
echo date('Y-m-d H:i:s') . " - Erreur : Première ligne de taille $lineLength non gérée !".PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($opts->debug) echo date('Y-m-d H:i:s') . " - Ligne $nbLines".PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
//Retour au début du fichier
|
||||
rewind($fp);
|
||||
|
||||
//Executer les chargements
|
||||
|
||||
$iDb = new WDB();
|
||||
$iInsee = new Metier_Insee_MInsee($iDb);
|
||||
|
||||
$iFacto = new Metier_Partenaires_MFacto();
|
||||
$iFacto->setTypeFic($fileType);
|
||||
if ( $fileType==1 ) {
|
||||
$iDb->update('sdv1.'.$dbTableUpdate, array('indTrt'=>0),'1');
|
||||
}
|
||||
|
||||
$nbSiretInvalides = 0;
|
||||
$nbSiretValides = 0;
|
||||
$cptLine = $nbInsert = $nbUpdate = 0;
|
||||
while (($buffer = fgets($fp)) !== false) {
|
||||
$cptLine++;
|
||||
|
||||
if ($opts->debug) echo date('Y-m-d H:i:s') . " - Ligne $cptLine / $nbLines".PHP_EOL;
|
||||
|
||||
$dateInsert = date('YmdHis');
|
||||
|
||||
$a = $iFacto->readFic($buffer);
|
||||
|
||||
//Vérification du Siren/Siret
|
||||
if ( $dbTableUpdate=='sdv1.ge_acheteurs' )
|
||||
{
|
||||
if (!$iInsee->valideSiren($a['SIRENE']))
|
||||
{
|
||||
$a['sirenValide'] = 0;
|
||||
$nbSiretInvalides++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$a['sirenValide'] = 1;
|
||||
$nbSiretValides++;
|
||||
}
|
||||
}
|
||||
|
||||
//Siren pour la table ge_paiements
|
||||
if ( $dbTableUpdate == 'ge_paiements' )
|
||||
{
|
||||
$result = $iDb->select('sdv1.ge_acheteurs', 'SIRENE', 'NUMACH='.$a['NUMACH']);
|
||||
if (count($result) > 0)
|
||||
{
|
||||
$a['siren'] = $result[0]['SIRENE'];
|
||||
}
|
||||
}
|
||||
|
||||
//Insertion dans l'historique
|
||||
if ( $dbTableUpdate == 'ge_cs2' )
|
||||
{
|
||||
$iDb->insert('historiques.'.$dbTableUpdate, array_merge($a, array('dateInsert'=>$dateInsert, 'dateConf'=>$dateFichier)));
|
||||
if (mysql_errno()>0 && mysql_errno()<>1062) die("Table = $dbTableUpdate".PHP_EOL.mysql_error().PHP_EOL);
|
||||
}
|
||||
|
||||
//Insertion dans la table
|
||||
if ( $iDb->insert('sdv1.'.$dbTableUpdate, array_merge($a, array('dateInsert'=>$dateInsert))) )
|
||||
{
|
||||
$nbInsert++;
|
||||
}
|
||||
elseif ( $dbTableUpdate=='ge_cs2' )
|
||||
{
|
||||
$ret = $iDb->select('sdv1.'.$dbTableUpdate, 'cs, dateFin*1 AS dateFin', 'siren='.$a['siren'], false, MYSQL_ASSOC);
|
||||
if ( count($ret)>0 )
|
||||
{
|
||||
$csPre = $ret[0]['cs'];
|
||||
$datePre = $ret[0]['dateFin'];
|
||||
if ($a['cs']<>$csPre || $a['dateFin']<>$datePre) {
|
||||
$iDb->update('sdv1.'.$dbTableUpdate, array_merge($a, array(
|
||||
'dateConf' => $dateFichier,
|
||||
'csPre' => $csPre,
|
||||
'dateCsPre' => $datePre,
|
||||
'dateModifCS' => $dateFichier,
|
||||
'dateUpdate' => $dateInsert,
|
||||
'indTrt'=> 1)
|
||||
),'siren='.$a['siren']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$iDb->update('sdv1.'.$dbTableUpdate, array_merge($a, array(
|
||||
'dateConf'=>$dateFichier,
|
||||
'indTrt'=>1)
|
||||
), 'siren='.$a['siren']);
|
||||
}
|
||||
if (mysql_errno()>0) {
|
||||
if ($opts->debug) echo date('Y-m-d H:i:s') . " - Erreur SQL ".mysql_errno().' : '.mysql_error()." sur $dbTableUpdate pour ".print_r($a);
|
||||
}
|
||||
$nbUpdate++;
|
||||
}
|
||||
}
|
||||
elseif ( $dbTableUpdate=='ge_acheteurs' )
|
||||
{
|
||||
$iDb->update('sdv1.'.$dbTableUpdate, array_merge($a, array('dateUpdate'=>$dateInsert)), 'NUMACH='.$a['NUMACH']);
|
||||
if (mysql_errno()>0) {
|
||||
if ($opts->debug) echo date('Y-m-d H:i:s') . " - Erreur SQL ".mysql_errno().' : '.mysql_error()." sur $dbTableUpdate pour ".print_r($a);
|
||||
}
|
||||
$nbUpdate++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($opts->debug) echo date('Y-m-d H:i:s') . " - Erreur SQL ".mysql_errno().' : '.mysql_error()." sur $dbTableUpdate pour ".print_r($a);
|
||||
}
|
||||
}
|
||||
|
||||
//Fermeture du fichier
|
||||
fclose($fp);
|
||||
|
||||
echo date('Y-m-d H:i:s') . " - $nbLines lignes traitées dont $nbSiretInvalides siren/siret invalides !".PHP_EOL;
|
||||
echo date('Y-m-d H:i:s') . " - Le fichier ".basename($file)." vient d'être chargé : $nbInsert ajouts et $nbUpdate MAJ !".PHP_EOL;
|
||||
if ($dbTableUpdate=='ge_cs2') {
|
||||
$iDb->update('sdv1.'.$dbTableUpdate, array('dateSuppr'=>$dateInsert), 'indTrt=0');
|
||||
}
|
||||
|
||||
$iDb->update('sdv1.flux_filein', array('dateExecute'=>date('YmdHis')), "name='GEFACTO' AND depotFile='".basename($file)."'", false);
|
||||
echo date('Y-m-d H:i:s') . " - Le fichier ".basename($file)." vient d'être marqué traité.".PHP_EOL;
|
||||
|
||||
$message = "Le fichier ".basename($file)." vient d'être chargé :\r\n";
|
||||
$message.= "$nbInsert ajouts et $nbUpdate mises à jours sur $nbLines lignes ($nbSiretInvalides siren/siret invalides).".PHP_EOL;
|
||||
|
||||
sendMail('production@scores-decisions.com', 'support@scores-decisions.com,ylenaour@scores-decisions.com', '[CHARGEMENT] Informations de Paiement', $message);
|
||||
|
||||
echo date('Y-m-d H:i:s') . " - Fin du chargement des Informations de Paiement ".basename($file).PHP_EOL;
|
||||
|
||||
} else {
|
||||
|
||||
echo date('Y-m-d H:i:s') . " - Fichier $file inexistant !".PHP_EOL;
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user