#!/usr/bin/php -q
"Affiche l'aide.",
));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit;
}
//Usage
if(isset($opts->help))
{
echo "Liste les commandes non envoyées du mois dernier";
echo "\n\n";
echo $opts->getUsageMessage();
echo "\n";
echo $argv[0] . ' [AAAAMM] >> /vers/fichier.log';
echo "\n";
exit;
}
$args = $opts->getRemainingArgs();
$c = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $c);
/**
* Connexion à la base de données
*/
$db = Zend_Db::factory($c->profil->db->sdv1);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
function listCmdMois($statut, $date)
{
$commandes = new Application_Model_Commandes();
$sql = $commandes->select()
->where('typeCommande = ?', 'G')
->where('statutCommande = ?', $statut)
->where('dateCommande LIKE ?', $date.'%')
->where('dateReception = ?', '0000-00-00 00:00:00');
return $commandes->fetchAll($sql);
}
//=> Debut
if (count($args)>1){
echo "Erreur\n";
exit;
} elseif (count($args)==0){
$timeMoisPrecedent = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
$moisPrecedent = date('Y-m', $timeMoisPrecedent);
} else {
$moisPrecedent = substr($args[0],0,4).'-'.substr($args[0],4,2);
}
$listeCmd = listCmdMois(0, $moisPrecedent);
$emailTxt = '';
//Liste commandes non-traites
$emailTxt.= 'Commandes greffe non receptionné';
$emailTxt.= '
';
if(count($listeCmd)>0){
$emailTxt.= '
Ref. | '; $emailTxt.= 'Siren | '; $emailTxt.= 'Ref. Document | '; $emailTxt.= 'Date de commande | '; $emailTxt.= '
---|---|---|---|
G'.$cmd->idCommande.' | '; $emailTxt.= ''.$cmd->siren.' | '; if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) ){ $type = 'bilans'; }else{ $type = 'actes'; } $emailTxt.= ''.$cmd->refDocument.' | '; $emailTxt.= ''.$cmd->dateCommande.' | '; $emailTxt.= '