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,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();
}
}