Detection prestation avec options

This commit is contained in:
Michael RICOIS 2015-03-30 13:54:20 +00:00
parent 756c1b68af
commit 7ea58800b4

View File

@ -100,26 +100,63 @@ if ( $result->count() > 0 ) {
break; 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) ) { if ( copy($source, $dest) ) {
// --- Detail du fichier
$nbLines = 0;
if ( strtolower(substr(basename($source), -3)) == 'csv' ) {
$lines = file($source); $lines = file($source);
$nbLines = count($lines); $nbLines = count($lines);
}
$size = filesize($source);
if ($item->depotType == 'FTP') // --- Permission du depot
{ if ($item->depotType == 'FTP') {
chown($dest, 'ftpuser'); chown($dest, 'ftpuser');
chgrp($dest, 'ftpgroup'); chgrp($dest, 'ftpgroup');
} }
elseif($item->depotType == 'SFTP') elseif($item->depotType == 'SFTP') {
{
chown($dest, $item->client); chown($dest, $item->client);
} }
// --- Mise à jour information de remise
$fluxM->update(array( $fluxM->update(array(
'depotFileSize' => $size,
'depotDate' => date('YmdHis'), 'depotDate' => date('YmdHis'),
), 'id='.$item->id); ), 'id='.$item->id);
// --- Envoi email
if ($optionsNoLog === false) {
$subject = "[Flux] - Envoi d'un fichier " . $item->client; $subject = "[Flux] - Envoi d'un fichier " . $item->client;
$txt = "Envoi d'un fichier après traitement\n"; $txt = "Envoi d'un fichier après traitement\n";
$txt.= "Client : ".$item->client."\n"; $txt.= "Client : ".$item->client."\n";
@ -135,6 +172,7 @@ if ( $result->count() > 0 ) {
$mail->addTo('suivi@scores-decisions.com', 'Suivi'); $mail->addTo('suivi@scores-decisions.com', 'Suivi');
$mail->setSubject($subject); $mail->setSubject($subject);
$mail->send(); $mail->send();
}
} }