PHP-CS-Fixer
This commit is contained in:
parent
ce9b83194a
commit
7744e97ac0
@ -1,60 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Crontab
|
* Crontab
|
||||||
* 0 6 * * * /home/scores/batch/scripts/majBilansPostes.php >> /home/scores/batch/shared/sources/log/majBilansPostes.log
|
* 0 6 * * * /home/scores/batch/scripts/majBilansPostes.php >> /home/scores/batch/shared/sources/log/majBilansPostes.log
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_WARNING & ~E_DEPRECATED);
|
||||||
|
|
||||||
// --- Define path to application directory
|
// --- Define path to application directory
|
||||||
defined('APPLICATION_PATH')
|
defined('APPLICATION_PATH')
|
||||||
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
|| define('APPLICATION_PATH', realpath(__DIR__ . '/../application'));
|
||||||
|
|
||||||
// --- Define application environment
|
// --- Define application environment
|
||||||
defined('APPLICATION_ENV')
|
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
|
// --- Composer autoload
|
||||||
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
require_once realpath(__DIR__ . '/../vendor/autoload.php');
|
||||||
|
|
||||||
// --- Create application, bootstrap, and run
|
// --- Create application, bootstrap, and run
|
||||||
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
|
||||||
|
|
||||||
$c = new Zend_Config($application->getOptions());
|
$c = new Zend_Config($application->getOptions());
|
||||||
Zend_Registry::set('config', $c);
|
Zend_Registry::set('config', $c);
|
||||||
$db = Zend_Db::factory($c->profil->db->metier);
|
$db = Zend_Db::factory($c->profil->db->metier);
|
||||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||||
|
|
||||||
// Database
|
// Database
|
||||||
$config = new \Doctrine\DBAL\Configuration();
|
$config = new \Doctrine\DBAL\Configuration();
|
||||||
$connectionParams = array(
|
$connectionParams = array(
|
||||||
'dbname' => $c->profil->db->metier->params->dbname,
|
'dbname' => $c->profil->db->metier->params->dbname,
|
||||||
'user' => $c->profil->db->metier->params->username,
|
'user' => $c->profil->db->metier->params->username,
|
||||||
'password' => $c->profil->db->metier->params->password,
|
'password' => $c->profil->db->metier->params->password,
|
||||||
'host' => $c->profil->db->metier->params->host,
|
'host' => $c->profil->db->metier->params->host,
|
||||||
'charset' => 'utf8',
|
'charset' => 'utf8',
|
||||||
'driver' => 'pdo_mysql',
|
'driver' => 'pdo_mysql',
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
|
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
|
||||||
Zend_Registry::set('doctrine', $conn);
|
Zend_Registry::set('doctrine', $conn);
|
||||||
} catch (\Doctrine\DBAL\DBALException $e) {
|
} catch (\Doctrine\DBAL\DBALException $e) {
|
||||||
echo "Connection Database impossible.\n";
|
echo "Connection Database impossible.\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once APPLICATION_PATH.'/configs/config.php';
|
require_once APPLICATION_PATH.'/configs/config.php';
|
||||||
|
|
||||||
$tabPostes = array('AA','AA2','AB','AC','AC1','AD','AE','AE1','AF','AG','AG1','AH','AI','AI1','AJ','AK','AK1','AL','AM','AM1','AN','AO','AO1','AP','AQ','AQ1','AR','AS','AS1','AT','AU','AU1','AV','AW','AW1','AX','AY','AY1','CS','CT','CT1','CU','CV','CV1','BB','BC','BC1','BD','BE','BE1','BF','BG','BG1','BH','BI','BI1','BJ','BK','BK1','BL','BM','BM1','BN','BO','BO1','BP','BQ','BQ1','BR','BS','BS1','BT','BU','BU1','BV','BW','BW1','BX','BY','BY1','BZ','CA','CA1','CB','CC','CC1','CD','CE','CE1','CF','CG','CG1','CH','CI','CI1','CJ','CK','CK1','CL','CL2','CM','CM2','CN','CN2','CO','1A','1A1','CP','CR','DA','DB','EK','DC','DD','DE','B1','DF','EJ','DG','DH','DI','DJ','DK','DL','DM','DN','DO','DP','DQ','DR','DS','DT','DU','DV','DW','DX','DY','DZ','EA','EB','EC','ED','EE','EF','EG','EH','EI','FA','FB','FC','FD','FE','FF','FG','FH','FI','FJ','FK','FL','FM','FN','FO','FP','FQ','FR','FS','FT','FU','FV','FW','FX','FY','FZ','GA','GB','GC','GD','GE','GF','GG','GH','GI','GJ','GK','GL','GM','GN','GO','GP','GQ','GR','GS','GT','GU','GV','GW','HA','HB','HC','HD','HE','HF','HG','HH','HI','HJ','HK','HL','HM','HN','HP','HQ','A1','A2','A3','A4','A6','A9','KA','KB','KC','KD','KE','KF','LN','LO','LP','LQ','LR','LS','0G','0H','0J','NL','LT','LU','1W','N0','LV','LW','1X','MY','MZ','NA','NB','NC','ND','NE','NF','NN','NG','NH','NI','I2','2E','2F','2G','NM','NJ','NK','2H','NP','0K','0L','0M','PA','PB','PC','PD','PE','PF','PG','PH','QU','QV','QW','QX','0N','0P','0Q','0R','SM0','SI','SM','SN','SP0','SO','SP','SR','3X','TM','TN','TO','3Z','TS','TT','TU','4A','4B','4C','4D','4E','4F','4G','4H','4J','4K','4L','4M','4N','4P','4R','4S','4T','4U','4V','4W','4X','4Y','4Z','5A','5B','5C','5D','5E','5F','5G','5J','5K','5L','5M','5N','5P','5R','5S','5T','5U','5V','5W','5X','5Y','5Z','TV','TW','TX','6A','6B','6C','6D','6E','6F','6G','6H','02','03','04','05','9U','9V','9W','9X','06','07','08','09','6N','6P','6R','6S','6T','6U','6V','6W','6X','6Y','6Z','7A','7B','TY','TZ','UA','7C','UB','UC','UD','UE','UF','UG','UH','UJ','UK','UL','UM','UN','UP','UR','US','UT','UV','UW','VA','VA1','VA2','UX','UX1','UX2','UQ','U0','UU','UU1','UU2','UY','UY1','UY2','UZ','UZ1','UZ2','VM','VM1','VM2','VB','VB1','VB2','VN','VN1','VN2','VP','VP1','VP2','VC','VC1','VC2','VR','VR1','VR2','VS','VS1','VS2','VT','VU','VV','7Y','7Y1','7Y2','7Y3','7Z','7Z1','7Z2','7Z3','VG','VG1','VG2','VG3','VH','VH1','VH2','VH3','8A','8A1','8A2','8A3','8B','8B1','8B2','8B3','8C','8C1','8C2','8C3','8D','8D1','8D2','8D3','8E','8E1','8E2','8E3','VW','VW1','VW2','VW3','VX','VX1','VX2','VX3','VQ','VQ1','VQ2','VQ3','8J','8J1','8J2','8J3','VI','VI1','VI2','VI3','8K','8K1','8K2','8K3','SZ','SZ1','SZ2','SZ3','8L','8L1','8L2','8L3','VY','VZ','VZ1','VZ2','VJ','VL','VK','ZE','YQ','YR','YS','YT','XQ','YU','SS','YV','ST','ZJ','YW','9Z','YX','YY','YZ','YP','ZR');
|
$tabPostes = array('AA','AA2','AB','AC','AC1','AD','AE','AE1','AF','AG','AG1','AH','AI','AI1','AJ','AK','AK1','AL','AM','AM1','AN','AO','AO1','AP','AQ','AQ1','AR','AS','AS1','AT','AU','AU1','AV','AW','AW1','AX','AY','AY1','CS','CT','CT1','CU','CV','CV1','BB','BC','BC1','BD','BE','BE1','BF','BG','BG1','BH','BI','BI1','BJ','BK','BK1','BL','BM','BM1','BN','BO','BO1','BP','BQ','BQ1','BR','BS','BS1','BT','BU','BU1','BV','BW','BW1','BX','BY','BY1','BZ','CA','CA1','CB','CC','CC1','CD','CE','CE1','CF','CG','CG1','CH','CI','CI1','CJ','CK','CK1','CL','CL2','CM','CM2','CN','CN2','CO','1A','1A1','CP','CR','DA','DB','EK','DC','DD','DE','B1','DF','EJ','DG','DH','DI','DJ','DK','DL','DM','DN','DO','DP','DQ','DR','DS','DT','DU','DV','DW','DX','DY','DZ','EA','EB','EC','ED','EE','EF','EG','EH','EI','FA','FB','FC','FD','FE','FF','FG','FH','FI','FJ','FK','FL','FM','FN','FO','FP','FQ','FR','FS','FT','FU','FV','FW','FX','FY','FZ','GA','GB','GC','GD','GE','GF','GG','GH','GI','GJ','GK','GL','GM','GN','GO','GP','GQ','GR','GS','GT','GU','GV','GW','HA','HB','HC','HD','HE','HF','HG','HH','HI','HJ','HK','HL','HM','HN','HP','HQ','A1','A2','A3','A4','A6','A9','KA','KB','KC','KD','KE','KF','LN','LO','LP','LQ','LR','LS','0G','0H','0J','NL','LT','LU','1W','N0','LV','LW','1X','MY','MZ','NA','NB','NC','ND','NE','NF','NN','NG','NH','NI','I2','2E','2F','2G','NM','NJ','NK','2H','NP','0K','0L','0M','PA','PB','PC','PD','PE','PF','PG','PH','QU','QV','QW','QX','0N','0P','0Q','0R','SM0','SI','SM','SN','SP0','SO','SP','SR','3X','TM','TN','TO','3Z','TS','TT','TU','4A','4B','4C','4D','4E','4F','4G','4H','4J','4K','4L','4M','4N','4P','4R','4S','4T','4U','4V','4W','4X','4Y','4Z','5A','5B','5C','5D','5E','5F','5G','5J','5K','5L','5M','5N','5P','5R','5S','5T','5U','5V','5W','5X','5Y','5Z','TV','TW','TX','6A','6B','6C','6D','6E','6F','6G','6H','02','03','04','05','9U','9V','9W','9X','06','07','08','09','6N','6P','6R','6S','6T','6U','6V','6W','6X','6Y','6Z','7A','7B','TY','TZ','UA','7C','UB','UC','UD','UE','UF','UG','UH','UJ','UK','UL','UM','UN','UP','UR','US','UT','UV','UW','VA','VA1','VA2','UX','UX1','UX2','UQ','U0','UU','UU1','UU2','UY','UY1','UY2','UZ','UZ1','UZ2','VM','VM1','VM2','VB','VB1','VB2','VN','VN1','VN2','VP','VP1','VP2','VC','VC1','VC2','VR','VR1','VR2','VS','VS1','VS2','VT','VU','VV','7Y','7Y1','7Y2','7Y3','7Z','7Z1','7Z2','7Z3','VG','VG1','VG2','VG3','VH','VH1','VH2','VH3','8A','8A1','8A2','8A3','8B','8B1','8B2','8B3','8C','8C1','8C2','8C3','8D','8D1','8D2','8D3','8E','8E1','8E2','8E3','VW','VW1','VW2','VW3','VX','VX1','VX2','VX3','VQ','VQ1','VQ2','VQ3','8J','8J1','8J2','8J3','VI','VI1','VI2','VI3','8K','8K1','8K2','8K3','SZ','SZ1','SZ2','SZ3','8L','8L1','8L2','8L3','VY','VZ','VZ1','VZ2','VJ','VL','VK','ZE','YQ','YR','YS','YT','XQ','YU','SS','YV','ST','ZJ','YW','9Z','YX','YY','YZ','YP','ZR');
|
||||||
|
|
||||||
$iDb=new Metier_Util_Db();
|
$iDb=new Metier_Util_Db();
|
||||||
$iInsee=new Metier_Insee_MInsee($iDb);
|
$iInsee=new Metier_Insee_MInsee($iDb);
|
||||||
|
|
||||||
$stock=false;
|
$stock=false;
|
||||||
$strReprise='';
|
$strReprise='';
|
||||||
$date=date('Ymd');
|
$date=date('Ymd');
|
||||||
$sirenReprise=$lastInsert=false;
|
$sirenReprise=$lastInsert=false;
|
||||||
|
|
||||||
$strInfoScript='Usage : '.basename($argv[0]). " [OPTION]
|
$strInfoScript='Usage : '.basename($argv[0]). " [OPTION]
|
||||||
Mise a jour de la table des postes du bilan
|
Mise a jour de la table des postes du bilan
|
||||||
|
|
||||||
@ -64,195 +64,193 @@ Options :
|
|||||||
-d:SSAAMMJJ Date de derniere reprise des bilans
|
-d:SSAAMMJJ Date de derniere reprise des bilans
|
||||||
-m:N Nombre de mois à reprendre de la date de derniere repise à N mois (avec -d)
|
-m:N Nombre de mois à reprendre de la date de derniere repise à N mois (avec -d)
|
||||||
-v Verbosite maximum
|
-v Verbosite maximum
|
||||||
";
|
";
|
||||||
|
|
||||||
$nbMois = 0;
|
$nbMois = 0;
|
||||||
|
|
||||||
$argv=$_SERVER['argv'];
|
$argv=$_SERVER['argv'];
|
||||||
if ($_SERVER['argc']>1)
|
if ($_SERVER['argc']>1) {
|
||||||
{
|
for ($i=1; isset($argv[$i]); $i++) {
|
||||||
for ($i=1; isset($argv[$i]); $i++) {
|
if (substr($argv[$i], 0, 1)=='-') {
|
||||||
if (substr($argv[$i],0,1)=='-') {
|
switch (strtolower(substr($argv[$i], 1, 1))) {
|
||||||
switch (strtolower(substr($argv[$i],1,1))) {
|
case 's': $stock=true; break;
|
||||||
case 's': $stock=true; break;
|
case 'r': $sirenReprise = substr($argv[$i], 3); break;
|
||||||
case 'r': $sirenReprise = substr($argv[$i],3); break;
|
case 'd': $lastInsert = substr($argv[$i], 3); break;
|
||||||
case 'd': $lastInsert = substr($argv[$i],3); break;
|
case 'm': $nbMois = substr($argv[$i], 3); break;
|
||||||
case 'm': $nbMois = substr($argv[$i],3); break;
|
case '-':
|
||||||
case '-':
|
case '?': die($strInfoScript); break;
|
||||||
case '?': die($strInfoScript); break;
|
default: die('Option '. $argv[$i] . " inconnue !\n"); break;
|
||||||
default: die('Option '. $argv[$i] . " inconnue !\n"); break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
//=> Start
|
||||||
//=> Start
|
$toInsert = null;
|
||||||
$toInsert = null;
|
|
||||||
|
$execRef = new Scores_Exec_Ref('BILANPOSTES');
|
||||||
$execRef = new Scores_Exec_Ref('BILANPOSTES');
|
$execId = $execRef->start();
|
||||||
$execId = $execRef->start();
|
|
||||||
|
if ($stock) {
|
||||||
if ($stock) {
|
$sql = $db->select()->from('bilans', array(new Zend_Db_Expr('DISTINCT siren AS siren')), 'jo');
|
||||||
$sql = $db->select()->from('bilans', array(new Zend_Db_Expr('DISTINCT siren AS siren')), 'jo');
|
if (!empty($sirenReprise)) {
|
||||||
if (!empty($sirenReprise)) {
|
$sql->where('siren >= ?', $sirenReprise);
|
||||||
$sql->where('siren >= ?', $sirenReprise);
|
}
|
||||||
}
|
$result = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
|
||||||
$result = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
|
$unitTotal = count($result);
|
||||||
$unitTotal = count($result);
|
} else {
|
||||||
} else {
|
// --- Dernière execution
|
||||||
// --- Dernière execution
|
if ($lastInsert) {
|
||||||
if ($lastInsert) {
|
$lastInsert = Metier_Util_Date::dateT('Ymd', 'Y-m-d', $lastInsert);
|
||||||
$lastInsert = Metier_Util_Date::dateT('Ymd','Y-m-d',$lastInsert);
|
} else {
|
||||||
} else {
|
$sql = $db->select()->from('bilans_postes', array(new Zend_Db_Expr('MAX(dateInsert) AS lastInsert')), 'jo');
|
||||||
$sql = $db->select()->from('bilans_postes', array(new Zend_Db_Expr('MAX(dateInsert) AS lastInsert')), 'jo');
|
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_ASSOC);
|
||||||
$result = $db->fetchRow($sql, null, Zend_Db::FETCH_ASSOC);
|
$lastInsert = $result['lastInsert'];
|
||||||
$lastInsert = $result['lastInsert'];
|
}
|
||||||
}
|
echo date('Y/m/d - H:i:s') ." - Derniere MAJ des postes des bilans : $lastInsert\n";
|
||||||
echo date('Y/m/d - H:i:s') ." - Derniere MAJ des postes des bilans : $lastInsert\n";
|
|
||||||
|
// --- Date Interval
|
||||||
// --- Date Interval
|
if ($lastInsert && intval($nbMois)>0) {
|
||||||
if ( $lastInsert && intval($nbMois)>0 ) {
|
$date = DateTime::createFromFormat('Ymd', $lastInsert);
|
||||||
$date = DateTime::createFromFormat('Ymd', $lastInsert);
|
$date = new DateTime();
|
||||||
$date = new DateTime();
|
$date->add(new DateInterval('P'.$nbMois.'M'));
|
||||||
$date->add(new DateInterval('P'.$nbMois.'M'));
|
$date->setTime(0, 0, 0);
|
||||||
$date->setTime(0, 0, 0);
|
$toInsert = $date->format('Y-m-d');
|
||||||
$toInsert = $date->format('Y-m-d');
|
echo date('Y/m/d - H:i:s') ." - jusqu'au $toInsert\n";
|
||||||
echo date('Y/m/d - H:i:s') ." - jusqu'au $toInsert\n";
|
}
|
||||||
}
|
|
||||||
|
// --- A partir d'une date, jusqu'à aujourdhui
|
||||||
// --- A partir d'une date, jusqu'à aujourdhui
|
if ($toInsert === null) {
|
||||||
if ( $toInsert === null ) {
|
$sql = $db->select()->from('bilans', array(new Zend_Db_Expr('DISTINCT siren AS siren')), 'jo')
|
||||||
$sql = $db->select()->from('bilans', array(new Zend_Db_Expr('DISTINCT siren AS siren')), 'jo')
|
->where('dateInsert >= ?', $lastInsert);
|
||||||
->where('dateInsert >= ?', $lastInsert);
|
if (!empty($sirenReprise)) {
|
||||||
if (!empty($sirenReprise)) {
|
$sql->where('siren >= ?', $sirenReprise);
|
||||||
$sql->where('siren >= ?', $sirenReprise);
|
}
|
||||||
}
|
}
|
||||||
}
|
// --- Date intervalle
|
||||||
// --- Date intervalle
|
else {
|
||||||
else {
|
$sql = $db->select()->from('bilans', array(new Zend_Db_Expr('DISTINCT siren AS siren')), 'jo')
|
||||||
$sql = $db->select()->from('bilans', array(new Zend_Db_Expr('DISTINCT siren AS siren')), 'jo')
|
->where('dateInsert BETWEEN "'.$lastInsert.' 00:00:00" AND "'.$toInsert.' 23:59:59"');
|
||||||
->where('dateInsert BETWEEN "'.$lastInsert.' 00:00:00" AND "'.$toInsert.' 23:59:59"');
|
if (!empty($sirenReprise)) {
|
||||||
if (!empty($sirenReprise)) {
|
$sql->where('siren >= ?', $sirenReprise);
|
||||||
$sql->where('siren >= ?', $sirenReprise);
|
}
|
||||||
}
|
}
|
||||||
}
|
$sql->order('siren ASC');
|
||||||
$sql->order('siren ASC');
|
$result = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
|
||||||
$result = $db->fetchAll($sql, null, Zend_Db::FETCH_ASSOC);
|
$unitTotal = count($result);
|
||||||
$unitTotal = count($result);
|
}
|
||||||
}
|
echo date('Y/m/d - H:i:s') ." - Il y a $unitTotal siren avec Bilan à mettre à jour...\n";
|
||||||
echo date('Y/m/d - H:i:s') ." - Il y a $unitTotal siren avec Bilan à mettre à jour...\n";
|
if ($execId !== null) {
|
||||||
if ($execId !== null) {
|
$execRef->total($execId, $unitTotal);
|
||||||
$execRef->total($execId, $unitTotal);
|
}
|
||||||
}
|
$unitSiren = $unitInc = $unitExec = 0;
|
||||||
$unitSiren = $unitInc = $unitExec = 0;
|
|
||||||
|
// --- Pour chaque siren
|
||||||
// --- Pour chaque siren
|
foreach ($result as $tabTmp) {
|
||||||
foreach ($result as $tabTmp) {
|
$siren = $tabTmp['siren'];
|
||||||
$siren = $tabTmp['siren'];
|
$tabId = $iInsee->getIdentiteLight($siren);
|
||||||
$tabId = $iInsee->getIdentiteLight($siren);
|
$unitSiren++;
|
||||||
$unitSiren++;
|
if (count($tabId) == 0) {
|
||||||
if (count($tabId) == 0) {
|
echo date('Y/m/d - H:i:s') ." - $unitSiren/$unitTotal : $siren sans identite\n";
|
||||||
echo date('Y/m/d - H:i:s') ." - $unitSiren/$unitTotal : $siren sans identite\n";
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
$mBil = new Metier_Partenaires_MBilans($siren);
|
||||||
$mBil = new Metier_Partenaires_MBilans($siren);
|
$tabBilans = $mBil->listeBilans();
|
||||||
$tabBilans = $mBil->listeBilans();
|
// Pour chaque bilans
|
||||||
// Pour chaque bilans
|
if (count($tabBilans) > 0) {
|
||||||
if (count($tabBilans) > 0) {
|
foreach ($tabBilans as $idxBilan => $derBilan) {
|
||||||
foreach ($tabBilans as $idxBilan => $derBilan) {
|
$unitInc++;
|
||||||
$unitInc++;
|
$p = $mBil->getBilan(Metier_Util_Date::dateT('Ymd', 'd/m/Y', $derBilan['dateExercice']), $derBilan['typeBilan']);
|
||||||
$p = $mBil->getBilan(Metier_Util_Date::dateT('Ymd','d/m/Y', $derBilan['dateExercice']), $derBilan['typeBilan']);
|
$conso = 0;
|
||||||
$conso = 0;
|
$liasse = 2050;
|
||||||
$liasse = 2050;
|
if ($p['CONSOLIDE'] == 'C') {
|
||||||
if ($p['CONSOLIDE'] == 'C') {
|
$conso = 1;
|
||||||
$conso = 1;
|
} elseif ($p['CONSOLIDE'] == 'S') {
|
||||||
}
|
$liasse = 2033;
|
||||||
elseif ($p['CONSOLIDE'] == 'S') {
|
}
|
||||||
$liasse = 2033;
|
|
||||||
}
|
$tabInsert = array(
|
||||||
|
'siren' => $siren,
|
||||||
$tabInsert = array(
|
'dateProvPartenaire' => $p['DATE_FRAICHE_BILAN'],
|
||||||
'siren' => $siren,
|
'dateExercice' => $p['DATE_CLOTURE'],
|
||||||
'dateProvPartenaire' => $p['DATE_FRAICHE_BILAN'],
|
'consolide' => $conso,
|
||||||
'dateExercice' => $p['DATE_CLOTURE'],
|
'liasse' => $liasse,
|
||||||
'consolide' => $conso,
|
'dureeExercice' => $p['DUREE_MOIS'],
|
||||||
'liasse' => $liasse,
|
'monnaie' => $p['MONNAIE'],
|
||||||
'dureeExercice' => $p['DUREE_MOIS'],
|
'partenaire' => $p['SOURCE'],
|
||||||
'monnaie' => $p['MONNAIE'],
|
'confidentiel' => $p['TOP_CONFIDENTIEL'],
|
||||||
'partenaire' => $p['SOURCE'],
|
'dateInsert' => $p['DATE_BILAN_SD'],
|
||||||
'confidentiel' => $p['TOP_CONFIDENTIEL'],
|
'apen' => $tabId['NafEnt'],
|
||||||
'dateInsert' => $p['DATE_BILAN_SD'],
|
'fjur' => $tabId['FJ'],
|
||||||
'apen' => $tabId['NafEnt'],
|
'tca' => $tabId['TrancheCA'],
|
||||||
'fjur' => $tabId['FJ'],
|
'teffen' => $tabId['EffEnTr'],
|
||||||
'tca' => $tabId['TrancheCA'],
|
);
|
||||||
'teffen' => $tabId['EffEnTr'],
|
|
||||||
);
|
if ($liasse == 2033) {
|
||||||
|
$p = $mBil->bilanSimplifie2Normal($p);
|
||||||
if ($liasse == 2033) {
|
}
|
||||||
$p = $mBil->bilanSimplifie2Normal($p);
|
|
||||||
}
|
// Pour chaque poste
|
||||||
|
foreach ($tabPostes as $poste) {
|
||||||
// Pour chaque poste
|
//$tabInsert[$poste] = 'NULL';
|
||||||
foreach ($tabPostes as $poste) {
|
if (in_array($poste, $p)) {
|
||||||
//$tabInsert[$poste] = 'NULL';
|
if (!is_int($p[$poste]) && empty($p[$poste])) {
|
||||||
if (in_array($poste, $p)) {
|
$tabInsert[$poste] = 'NULL';
|
||||||
if (!is_int($p[$poste]) && empty($p[$poste])) {
|
} else {
|
||||||
$tabInsert[$poste] = 'NULL';
|
$tabInsert[$poste] = $p[$poste];
|
||||||
} else {
|
}
|
||||||
$tabInsert[$poste] = $p[$poste];
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
// Gestion de l'enregistrement
|
||||||
|
$error = false;
|
||||||
// Gestion de l'enregistrement
|
try {
|
||||||
$error = false;
|
$bilanpSql = $db->select()->from('jo.bilans_postes')->where('id=?', $p['ID_BILAN_SD']);
|
||||||
try {
|
$bilanpResult = $db->fetchRow($bilanpSql, array(), Zend_Db::FETCH_OBJ);
|
||||||
$bilanpSql = $db->select()->from('jo.bilans_postes')->where('id=?', $p['ID_BILAN_SD']);
|
// Insert
|
||||||
$bilanpResult = $db->fetchRow($bilanpSql, array(), Zend_Db::FETCH_OBJ);
|
if ($bilanpResult === null) {
|
||||||
// Insert
|
$tabInsert['id'] = $p['ID_BILAN_SD'];
|
||||||
if ($bilanpResult === null) {
|
try {
|
||||||
$tabInsert['id'] = $p['ID_BILAN_SD'];
|
$db->insert('jo.bilans_postes', $tabInsert);
|
||||||
try {
|
} catch (Zend_Db_Exception $e) {
|
||||||
$db->insert('jo.bilans_postes', $tabInsert);
|
$error = true;
|
||||||
} catch (Zend_Db_Exception $e ) {
|
$errMsg = $e->getMessage();
|
||||||
$error = true;
|
echo date('Y/m/d - H:i:s') . " - $unitSiren/$unitTotal siren $siren - insert : " . $errMsg ."\n";
|
||||||
$errMsg = $e->getMessage();
|
}
|
||||||
echo date('Y/m/d - H:i:s') . " - $unitSiren/$unitTotal siren $siren - insert : " . $errMsg ."\n";
|
}
|
||||||
}
|
// Update
|
||||||
}
|
else {
|
||||||
// Update
|
try {
|
||||||
else {
|
$db->update('jo.bilans_postes', $tabInsert, 'id='.$p['ID_BILAN_SD']);
|
||||||
try {
|
} catch (Zend_Db_Exception $e) {
|
||||||
$db->update('jo.bilans_postes', $tabInsert, 'id='.$p['ID_BILAN_SD']);
|
$error = true;
|
||||||
} catch (Zend_Db_Exception $e ) {
|
$errMsg = $e->getMessage();
|
||||||
$error = true;
|
echo date('Y/m/d - H:i:s') . " - $unitSiren/$unitTotal siren $siren - update : " .$errMsg ."\n";
|
||||||
$errMsg = $e->getMessage();
|
}
|
||||||
echo date('Y/m/d - H:i:s') . " - $unitSiren/$unitTotal siren $siren - update : " .$errMsg ."\n";
|
}
|
||||||
}
|
|
||||||
}
|
if ($error) {
|
||||||
|
$mail = new Metier_Util_Mail();
|
||||||
if ($error) {
|
$mail->send('production@scores-decisions.com', 'suivi@scores-decisions.com',
|
||||||
$mail = new Metier_Util_Mail();
|
'Bilan Postes - ERREUR', $errMsg."\n\n".print_r($tabInsert, true));
|
||||||
$mail->send('production@scores-decisions.com', 'suivi@scores-decisions.com',
|
} else {
|
||||||
'Bilan Postes - ERREUR', $errMsg."\n\n".print_r($tabInsert,true));
|
$unitExec++;
|
||||||
} else {
|
if ($execId !== null) {
|
||||||
$unitExec++;
|
$execRef->increment($execId, $unitExec);
|
||||||
if ($execId !== null) {
|
}
|
||||||
$execRef->increment($execId, $unitExec);
|
}
|
||||||
}
|
} catch (Zend_Db_Exception $e) {
|
||||||
}
|
echo date('Y/m/d - H:i:s') . " - $unitSiren/$unitTotal siren $siren - ".$p['ID_BILAN_SD']." : " . $e->getMessage()."\n";
|
||||||
} catch (Zend_Db_Exception $e ) {
|
}
|
||||||
echo date('Y/m/d - H:i:s') . " - $unitSiren/$unitTotal siren $siren - ".$p['ID_BILAN_SD']." : " . $e->getMessage()."\n";
|
}
|
||||||
}
|
}
|
||||||
}
|
if ($unitSiren%1000==0) {
|
||||||
}
|
echo date('Y/m/d - H:i:s') ." - $unitSiren/$unitTotal siren traités ($siren)...\n";
|
||||||
if ($unitSiren%1000==0) {
|
}
|
||||||
echo date('Y/m/d - H:i:s') ." - $unitSiren/$unitTotal siren traités ($siren)...\n";
|
}
|
||||||
}
|
|
||||||
}
|
if ($execId !== null) {
|
||||||
|
$execRef->end($execId);
|
||||||
if ($execId !== null) {
|
}
|
||||||
$execRef->end($execId);
|
|
||||||
}
|
echo date('Y/m/d - H:i:s') ." - Fin\n";
|
||||||
|
|
||||||
echo date('Y/m/d - H:i:s') ." - Fin\n";
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user