diff --git a/fileConfig.php b/fileConfig.php index 790b52f..a9ea86b 100644 --- a/fileConfig.php +++ b/fileConfig.php @@ -5,7 +5,10 @@ return array( array( 'name' => 'FICH_RCE', 'type' => 'SFTP', - 'options' => array(), + 'in' => array( + 'CopyDeleteAfter' => true, + ), + 'out' => array(), ), ), ), @@ -14,11 +17,12 @@ return array( array( 'name' => 'GEFACTO', 'type' => 'SFTP', - 'options' => array( + 'in' => array( 'RunWithEndFile' => true, 'CopyAddDate' => true, 'CopyDeleteAfter' => true, ), + 'out' => array(), ), ), ), @@ -27,9 +31,10 @@ return array( array( 'name' => 'RAPPORT', 'type' => 'FTP', - 'options' => array( + 'in' => array( 'CopyDeleteAfter' => true, ), + 'out' => array(), ), ), ), @@ -38,10 +43,11 @@ return array( array( 'name' => 'EXTRANET', 'type' => 'FTP', - 'options' => array( + 'in' => array( 'CopyDeleteAfter' => true, 'NoLog' => true, ), + 'out' => array(), ), ), ), @@ -50,7 +56,8 @@ return array( array( 'name' => 'HEXAVIA', 'type' => 'FTP', - 'options' => array(), + 'in' => array(), + 'out' => array(), ), ), ), @@ -59,11 +66,27 @@ return array( array( 'name' => 'PDF', 'type' => 'FTP', - 'options' => array( + 'in' => array( 'CopyDeleteAfter' => true, - 'NoLog' => true, ), + 'out' => array(), ), ), ), + 'orone' => array( + 'prestations' => array( + array( + 'name' => 'XML', + 'type' => 'FTP', + 'in' => array(), + 'out' => array(), + ), + array( + 'name' => 'PDF', + 'type' => 'FTP', + 'in' => array(), + 'out' => array(), + ), + ), + ) ); diff --git a/fileRecv.php b/fileRecv.php index 71faefc..88645bb 100644 --- a/fileRecv.php +++ b/fileRecv.php @@ -106,28 +106,37 @@ if ( $result->count() > 0 ) { $optionsRunWithEndFile = false; $optionsNoLog = false; - // Match prestation - $prestations = include __DIR__ . '/fileConfig.php'; - if (array_key_exists($client, $prestations)) - { - $clientPrestations = $prestations[$client]['prestations']; - foreach ($clientPrestations as $i => $p) - { - if ($item->depotType == $p['type'] && $item->name == $p['name']) - { - // Set option - if (array_key_exists('options', $p) && count($p['options']) > 0) - { - foreach ($p['options'] as $option => $value) - { - ${'options'.$option} = $value; - } - } - - break; - } - } - } + // Match prestation + $prestations = include __DIR__ . '/fileConfig.php'; + $prestation = null; + if (array_key_exists($item->client, $prestations)) + { + $clientPrestations = $prestations[$item->client]['prestations']; + foreach ($clientPrestations as $i => $p) + { + // Not default repository dir + if (array_key_exists('directory', $p) && !empty($p['directory'])) + { + $repositoryDir = $p['directory']; + } + + if ($item->depotType == $p['type'] && $fluxRepository == $repositoryDir) + { + $prestation = $p['name']; + + // Set option + if (array_key_exists('out', $p) && count($p['out']) > 0) + { + foreach ($p['out'] as $option => $value) + { + ${'options'.$option} = $value; + } + } + + break; + } + } + } // --- Copy du fichier if ( copy($source, $dest) ) { diff --git a/fileSend.php b/fileSend.php index 06e7edd..8dd13d8 100644 --- a/fileSend.php +++ b/fileSend.php @@ -94,22 +94,22 @@ if ( isset($opts->file) ) if (array_key_exists($client, $prestations)) { $clientPrestations = $prestations[$client]['prestations']; - foreach ($clientPrestations as $i => $item) + foreach ($clientPrestations as $i => $p) { // Not default repository dir - if (array_key_exists('directory', $item) && !empty($item['directory'])) + if (array_key_exists('directory', $p) && !empty($p['directory'])) { - $repositoryDir = $item['directory']; + $repositoryDir = $p['directory']; } - if ($type == $item['type'] && $fluxRepository == $repositoryDir) + if ($type == $p['type'] && $fluxRepository == $repositoryDir) { - $prestation = $item['name']; + $prestation = $p['name']; // Set option - if (array_key_exists('options', $item) && count($item['options']) > 0) + if (array_key_exists('in', $p) && count($p['in']) > 0) { - foreach ($item['options'] as $option => $value) + foreach ($p['in'] as $option => $value) { ${'options'.$option} = $value; } @@ -237,8 +237,9 @@ if ( isset($opts->file) ) { echo date('Y-m-d H:i:s')." - Copie du fichier $filenameIn dans $destDir\n"; - //Execute - if ($optionsNoLog === false) { + // --- Execute + if ($optionsNoLog === false) + { $db = Zend_Db::factory($c->profil->db->metier); Zend_Db_Table::setDefaultAdapter($db); try { @@ -250,7 +251,7 @@ if ( isset($opts->file) ) 'depotDate' => $dateFile, 'depotFile' => $filenameOut, 'nbLines' => $nbLines, - 'size' => $size, + 'depotFileSize' => $size, 'dateInsert' => date('YmdHis'), 'dateExecute' => '0000-00-00 00:00:00', // @todo : dateExecute )); @@ -262,7 +263,7 @@ if ( isset($opts->file) ) } } - //Suppression des fichiers + // --- Suppression des fichiers if ($optionsCopyDeleteAfter) { unlink( $fluxBasePath . '/' . $filenameIn ); diff --git a/scripts/build/etc/cron.d/batchflux b/scripts/build/etc/cron.d/batchflux new file mode 100644 index 0000000..4c02454 --- /dev/null +++ b/scripts/build/etc/cron.d/batchflux @@ -0,0 +1,3 @@ + +# Gestion des flux a envoyer au client +*/20 4-18 * * * root php /home/batchFlux/fileRecv.php --cron >> /home/log/recv.log 2>&1 \ No newline at end of file diff --git a/scripts/build/etc/cron.d/fluxrecv b/scripts/build/etc/cron.d/fluxrecv deleted file mode 100644 index 0284e2f..0000000 --- a/scripts/build/etc/cron.d/fluxrecv +++ /dev/null @@ -1,3 +0,0 @@ -# Gestion des flux a envoyer au client - -*/10 4-12 * * * root php /home/batchFlux/fileRecv.php --cron \ No newline at end of file