issue #0002043 : Add option to use incron
This commit is contained in:
parent
0779441f29
commit
3f1610665f
@ -104,6 +104,11 @@ if(isset($opts->install))
|
||||
|
||||
} else {
|
||||
|
||||
//Création configuration incron
|
||||
if ( file_exist('/etc/incron.d') ) {
|
||||
file_put_contents('/etc/incron.d/bilanclient', $c->profil->path->data . "/bilanclient IN_CLOSE_WRITE php /home/vhosts/extranet/scripts/jobs/sendBilanClient.php --file $#");
|
||||
}
|
||||
|
||||
//Création des liens symboliques pour l'impression
|
||||
if (!file_exists($c->profil->path->pages.'/themes/default/images'))
|
||||
passthru('ln -vs '.APPLICATION_PATH.'/../public/themes/default/images '.
|
||||
|
@ -50,6 +50,7 @@ try {
|
||||
'help|?' => "Affiche l'aide.",
|
||||
'list' => "Liste les bilans à saisir",
|
||||
'send' => "Envoi les fichiers par FTP.",
|
||||
'file=s' => "Specify a file to upload",
|
||||
));
|
||||
$opts->parse();
|
||||
} catch (Zend_Console_Getopt_Exception $e) {
|
||||
@ -122,37 +123,64 @@ function sendToFtp($localFile, $remoteFile)
|
||||
$db = Zend_Db::factory($c->profil->db->sdv1);
|
||||
Zend_Db_Table_Abstract::setDefaultAdapter($db);
|
||||
|
||||
/**
|
||||
* Liste les fichiers qui peuvent être traités
|
||||
*/
|
||||
$bilans = new Application_Model_BilanSaisie();
|
||||
$listBilans = $bilans->listBilans();
|
||||
$tabFichier = array();
|
||||
foreach ($listBilans as $infos)
|
||||
{
|
||||
$filename = $infos['ref'].'-'.$infos['siren'];
|
||||
$extValide = array('pdf', 'tiff');
|
||||
$fileExist = false;
|
||||
foreach ($extValide as $ext) {
|
||||
if (file_exists(PATH_DATA.'/bilanclient/'.$filename.'.'.$ext)) {
|
||||
$fileExist = true;
|
||||
$tabFichier[] = array(
|
||||
'ref' => $infos['ref'],
|
||||
'localFile' => $filename.'.'.$ext,
|
||||
'remoteFile' => getRemoteFilename($infos).'.'.$ext,
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Erreur fichier inexistant
|
||||
if (!$fileExist) {
|
||||
$txt = "Fichier manquant, Ref:".$infos['ref'];
|
||||
$report_txt.= $txt."\n";
|
||||
echo date('Y-m-d\TH:i:s')." - ".$txt."\n";
|
||||
}
|
||||
if ( $opts->send ) {
|
||||
|
||||
/**
|
||||
* Liste les fichiers qui peuvent être traités
|
||||
*/
|
||||
$bilans = new Application_Model_BilanSaisie();
|
||||
$listBilans = $bilans->listBilans();
|
||||
foreach ($listBilans as $infos)
|
||||
{
|
||||
$filename = $infos['ref'].'-'.$infos['siren'];
|
||||
$extValide = array('pdf', 'tiff');
|
||||
$fileExist = false;
|
||||
foreach ($extValide as $ext) {
|
||||
if (file_exists(PATH_DATA.'/bilanclient/'.$filename.'.'.$ext)) {
|
||||
$fileExist = true;
|
||||
$tabFichier[] = array(
|
||||
'ref' => $infos['ref'],
|
||||
'localFile' => $filename.'.'.$ext,
|
||||
'remoteFile' => getRemoteFilename($infos).'.'.$ext,
|
||||
);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Erreur fichier inexistant
|
||||
if (!$fileExist) {
|
||||
$txt = "Fichier manquant, Ref:".$infos['ref'];
|
||||
$report_txt.= $txt."\n";
|
||||
echo date('Y-m-d\TH:i:s')." - ".$txt."\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !empty($opts->file) ) {
|
||||
|
||||
$bilans = new Application_Model_BilanSaisie();
|
||||
$sql = $bilans->select()->where('fichier=?', $opts->file);
|
||||
|
||||
$result = $bilans->fetchRow($sql);
|
||||
if ( $result !== null ) {
|
||||
|
||||
$infos = $result->toArray();
|
||||
$path_parts = pathinfo(PATH_DATA . '/' . $opts->file);
|
||||
$ext = $path_parts['extension'];
|
||||
$filename = $infos['ref'].'-'.$infos['siren'];
|
||||
$tabFichier[] = array(
|
||||
'ref' => $infos['ref'],
|
||||
'localFile' => $filename.'.'.$ext,
|
||||
'remoteFile' => getRemoteFilename($infos).'.'.$ext,
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($test) {
|
||||
print_r($tabFichier);
|
||||
exit;
|
||||
|
Loading…
Reference in New Issue
Block a user