diff --git a/README b/README index 6bcc4f5..70b03e8 100644 --- a/README +++ b/README @@ -120,7 +120,9 @@ Send Options list (in) ftp sftp mail +- FilterName - Filtre par nom de prestation (true) ou par nom défini Recv Options list (out) ----------------------- -- Log - Log read disable by default \ No newline at end of file +- Log - Log read disable by default + diff --git a/fileSend.php b/fileSend.php index d581c86..9c7c6e4 100644 --- a/fileSend.php +++ b/fileSend.php @@ -23,18 +23,18 @@ require_once 'Zend/Application.php'; // --- Create application, bootstrap, and run $application = new Zend_Application( - APPLICATION_ENV, - APPLICATION_PATH . '/configs/application.ini' + APPLICATION_ENV, + APPLICATION_PATH . '/configs/application.ini' ); try { $opts = new Zend_Console_Getopt( // --- Options array( - 'help|?' => "Displays usage information.", - 'file|f=s' => "Give the full file path to integrate", - 'mail' => "Only send a mail when a file is write", - 'debug' => "Send a mail for debug", + 'help|?' => "Displays usage information.", + 'file|f=s' => "Give the full file path to integrate", + 'mail' => "Only send a mail when a file is write", + 'debug' => "Send a mail for debug", ) ); $opts->parse(); @@ -59,6 +59,7 @@ if ( isset($opts->file) ) $optionsRunWithEndFile = false; $optionsLog = false; $optionsRoute = array(); + $optionsFilterName = false; $repositoryDir = 'send'; $c = new Zend_Config($application->getOptions()); @@ -103,11 +104,12 @@ if ( isset($opts->file) ) $repositoryDir = $p['directory']; } + // --- Match prestation if ($type == $p['type'] && $fluxRepository == $repositoryDir) { $prestation = $p['name']; - // --- Set option + // --- Set options if (array_key_exists('in', $p) && count($p['in']) > 0) { foreach ($p['in'] as $option => $value) @@ -116,6 +118,18 @@ if ( isset($opts->file) ) } } + // --- Filters + if ($optionsFilterName === true) { + if ( strpos($filenameIn, $prestation) === false ) { + exit; + } + } + if (is_string($optionsFilterName) && strlen($optionsFilterName) > 0) { + if (strpos($filenameIn, $optionsFilterName) === false) { + exit; + } + } + break; } } @@ -172,6 +186,8 @@ if ( isset($opts->file) ) } } + // --- + // --- Detail du fichier $nbLines = 0; if ( strtolower(substr($filenameIn, -3)) == 'csv' ) { @@ -251,7 +267,7 @@ if ( isset($opts->file) ) foreach ($optionsRoute as $tr => $value) { switch($tr) { case 'cp': - if (copy($fluxBasePath . '/' . $filenameIn, $value. '/' . $filenameOut)) { + if (copy($fluxBasePath . '/' . $filenameIn, $value . '/' . $filenameOut)) { echo date('Y-m-d H:i:s')." - Copie du fichier $filenameIn dans $value\n"; } break; @@ -279,15 +295,15 @@ if ( isset($opts->file) ) try { $fluxM = new Application_Model_Sdv1FluxFileIn(); $fluxM->insert(array( - 'client' => $client, - 'name' => $prestation, - 'depotType' => $type, - 'depotDate' => $dateFile, - 'depotFile' => $filenameOut, - 'nbLines' => $nbLines, - 'depotFileSize' => $size, - 'dateInsert' => date('YmdHis'), - 'dateExecute' => '0000-00-00 00:00:00', // @todo : dateExecute + 'client' => $client, + 'name' => $prestation, + 'depotType' => $type, + 'depotDate' => $dateFile, + 'depotFile' => $filenameOut, + 'nbLines' => $nbLines, + 'depotFileSize' => $size, + 'dateInsert' => date('YmdHis'), + 'dateExecute' => '0000-00-00 00:00:00', // @todo : dateExecute )); echo date('Y-m-d H:i:s')." - Enregistrement client:$client fichier:$filenameOut\n"; }