From 7ea58800b494bbc384816d72b4e56ab904ed3972 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Mon, 30 Mar 2015 13:54:20 +0000 Subject: [PATCH] Detection prestation avec options --- fileRecv.php | 86 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 24 deletions(-) diff --git a/fileRecv.php b/fileRecv.php index 81e8c2f..71faefc 100644 --- a/fileRecv.php +++ b/fileRecv.php @@ -100,41 +100,79 @@ if ( $result->count() > 0 ) { break; } + // --- Options + $optionsCopyAddDate = false; + $optionsCopyDeleteAfter = false; + $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; + } + } + } + + // --- Copy du fichier if ( copy($source, $dest) ) { + + // --- Detail du fichier + $nbLines = 0; + if ( strtolower(substr(basename($source), -3)) == 'csv' ) { + $lines = file($source); + $nbLines = count($lines); + } + $size = filesize($source); - $lines = file($source); - $nbLines = count($lines); - - if ($item->depotType == 'FTP') - { + // --- Permission du depot + if ($item->depotType == 'FTP') { chown($dest, 'ftpuser'); chgrp($dest, 'ftpgroup'); } - elseif($item->depotType == 'SFTP') - { + elseif($item->depotType == 'SFTP') { chown($dest, $item->client); } - - + + // --- Mise à jour information de remise $fluxM->update(array( + 'depotFileSize' => $size, 'depotDate' => date('YmdHis'), ), 'id='.$item->id); - $subject = "[Flux] - Envoi d'un fichier " . $item->client; - $txt = "Envoi d'un fichier après traitement\n"; - $txt.= "Client : ".$item->client."\n"; - $txt.= "Mode de transmission : ".$item->depotType."\n"; - $txt.= "Fichier : ".$item->fileOut."\n"; - $txt.= "Nombre de Lignes : $nbLines\n"; - - $mail = new Zend_Mail('UTF-8'); - $tr = new Zend_Mail_Transport_Sendmail(); - $mail->setDefaultTransport($tr); - $mail->setBodyText($txt); - $mail->setFrom('supportdev@scores-decisions.com', 'Machine'); - $mail->addTo('suivi@scores-decisions.com', 'Suivi'); - $mail->setSubject($subject); - $mail->send(); + // --- Envoi email + if ($optionsNoLog === false) { + $subject = "[Flux] - Envoi d'un fichier " . $item->client; + $txt = "Envoi d'un fichier après traitement\n"; + $txt.= "Client : ".$item->client."\n"; + $txt.= "Mode de transmission : ".$item->depotType."\n"; + $txt.= "Fichier : ".$item->fileOut."\n"; + $txt.= "Nombre de Lignes : $nbLines\n"; + + $mail = new Zend_Mail('UTF-8'); + $tr = new Zend_Mail_Transport_Sendmail(); + $mail->setDefaultTransport($tr); + $mail->setBodyText($txt); + $mail->setFrom('supportdev@scores-decisions.com', 'Machine'); + $mail->addTo('suivi@scores-decisions.com', 'Suivi'); + $mail->setSubject($subject); + $mail->send(); + } }