issue #0002022 : Intégration du batch GE FACTO pour test
This commit is contained in:
parent
a0d4d0955f
commit
94f0d9efd9
@ -10,12 +10,10 @@
|
||||
*/
|
||||
|
||||
// Define path to application directory
|
||||
defined('APPLICATION_PATH')
|
||||
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|
||||
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
|
||||
|
||||
// Define application environment
|
||||
defined('APPLICATION_ENV')
|
||||
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
||||
define('APPLICATION_ENV', 'production');
|
||||
|
||||
// Ensure library/ is on include_path
|
||||
set_include_path(implode(PATH_SEPARATOR, array(
|
||||
@ -35,10 +33,10 @@ $application = new Zend_Application(
|
||||
//Options
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(array(
|
||||
'help|?' => "Displays usage information.",
|
||||
'cron' => "Launch in cron",
|
||||
'file' => "Specify file name to execute manually",
|
||||
'debug' => "Mode debug",
|
||||
'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) {
|
||||
@ -54,24 +52,22 @@ if( isset($opts->help) || count($opts->getOptions())==0 )
|
||||
exit;
|
||||
}
|
||||
|
||||
$c = $application->getOptions();
|
||||
$c = new Zend_Config($application->getOptions());
|
||||
|
||||
$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)
|
||||
else {
|
||||
|
||||
//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')
|
||||
@ -84,7 +80,6 @@ else {
|
||||
foreach ( $pitems as $p ) {
|
||||
$tabFile[] = $p;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( count($tabFile)==0 ) {
|
||||
@ -92,17 +87,22 @@ if ( count($tabFile)==0 ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once APPLICATION_PATH . '/configs/config.php';
|
||||
require_once 'framework/fwk.php';
|
||||
require_once 'Metier/insee/classMInsee.php';
|
||||
require_once 'Metier/partenaires/classMFacto.php';
|
||||
|
||||
foreach ($tabFile as $filename)
|
||||
{
|
||||
$path = $c->profil->path->storage . '/' . 'clients' . '/' . 'gefacto' . '/' . 'send';
|
||||
$path = $c->profil->path->storage . '/clients/gefacto/send';
|
||||
$file = $path . '/' . $filename;
|
||||
|
||||
//Check fichier
|
||||
if ( file_exist($file) ) {
|
||||
if ( file_exists($file) ) {
|
||||
|
||||
$dateFichier = date('YmdHis', filemtime($file));
|
||||
|
||||
echo date('Y-m-d H:i:s') . " - Chargement des Informations de Paiement $file".PHP_EOL;
|
||||
echo date('Y-m-d H:i:s') . " - Chargement des Informations de Paiement ".basename($file).PHP_EOL;
|
||||
|
||||
//Ouvrir le fichier
|
||||
$fp = fopen($file, 'r');
|
||||
@ -121,9 +121,9 @@ foreach ($tabFile as $filename)
|
||||
$lineLength = strlen($buffer);
|
||||
if ( $lineLength<=30 ) {
|
||||
$fileType = 1; $dbTableUpdate = 'ge_cs2';
|
||||
} elseif ( $lineLength==118 ) {
|
||||
} elseif ( $lineLength==119 ) {
|
||||
$fileType = 0; $dbTableUpdate = 'ge_acheteurs';
|
||||
} elseif ( $lineLength==72 ) {
|
||||
} elseif ( $lineLength==73 ) {
|
||||
$fileType = 2; $dbTableUpdate = 'ge_paiements';
|
||||
}
|
||||
//Erreur
|
||||
@ -132,6 +132,8 @@ foreach ($tabFile as $filename)
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($opts->debug) echo date('Y-m-d H:i:s') . " - Ligne $nbLines".PHP_EOL;
|
||||
|
||||
}
|
||||
|
||||
//Retour au début du fichier
|
||||
@ -155,6 +157,8 @@ foreach ($tabFile as $filename)
|
||||
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);
|
||||
@ -231,20 +235,20 @@ foreach ($tabFile as $filename)
|
||||
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 $file vient d'être chargé : $nbInsert ajouts et $nbUpdate MAJ !".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($table, array('dateSuppr'=>$dateInsert), 'indTrt=0');
|
||||
}
|
||||
|
||||
$iDb->update('flux_filein', array('dateExecute'=>date('YmdHis')), "name='GEFACTO' AND depotFile='$file'", false);
|
||||
echo date('Y-m-d H:i:s') . " - Le fichier $file vient d'être marqué traité.".PHP_EOL;
|
||||
$iDb->update('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 $file vient d'être chargé :\r\n";
|
||||
$message.="Le fichier ".basename($file)." vient d'être chargé :\r\n";
|
||||
$message.=" $nbInsert ajouts et $nbUpdate mises à jours sur $nbLignes 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 $file".PHP_EOL;
|
||||
echo date('Y-m-d H:i:s') . " - Fin du chargement des Informations de Paiement ".basename($file).PHP_EOL;
|
||||
|
||||
} else {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user