2010-06-28 14:22:27 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Liste les commandes non envoyés du mois dernier
|
|
|
|
* */
|
|
|
|
|
|
|
|
// Paramètres
|
2010-06-28 14:47:47 +00:00
|
|
|
if ( in_array($argv[1], array('--help', '-help', '-h', '-?')) ) {
|
2010-06-28 14:22:27 +00:00
|
|
|
?>
|
|
|
|
Liste les actes non envoyés du mois dernier
|
|
|
|
Avec les options --help, -help, -h, et -?, vous obtiendrez cette aide.
|
|
|
|
|
|
|
|
Sans aucun paramètre, envoi de la liste par mail pour le mois précédent.
|
|
|
|
Utilisation :
|
|
|
|
<?php echo $argv[0]; ?> [AAAAMM] >> /vers/fichier.log
|
|
|
|
<?php
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once '../config/prepend.php';
|
|
|
|
//Inclure la base de données
|
|
|
|
require_once 'dbbootstrap.php';
|
|
|
|
require_once 'mail/mail.php';
|
|
|
|
|
|
|
|
function listCmdMois($statut, $date){
|
2010-06-28 14:47:47 +00:00
|
|
|
setDbConn('sdv1');
|
2010-06-28 14:22:27 +00:00
|
|
|
$q = Doctrine_Query::create()
|
|
|
|
->from('Commandes')
|
|
|
|
->Where('typeCommande = ?', 'G')
|
|
|
|
->andWhere('statutCommande = ?', $statut)
|
|
|
|
->andWhere('dateCommande LIKE ?', $date.'%')
|
|
|
|
->andWhere('dateReception = ?', '0000-00-00 00:00:00');
|
2010-06-28 14:47:47 +00:00
|
|
|
echo $q->getSqlQuery();
|
|
|
|
print_r($q->getFlattenedParams());
|
2010-06-28 14:22:27 +00:00
|
|
|
$listeCmd = $q->execute();
|
|
|
|
return $listeCmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=> Debut
|
|
|
|
if ( empty($argv[1]) ) {
|
|
|
|
$timeMoisPrecedent = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
|
|
|
|
$moisPrecedent = date('Y-m', $timeMoisPrecedent);
|
|
|
|
} else {
|
2010-06-28 14:47:47 +00:00
|
|
|
$moisPrecedent = substr($argv[1],0,4).'-'.substr($argv[1],4,2);
|
2010-06-28 14:22:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$listeCmd = listCmdMois(0, $moisPrecedent);
|
|
|
|
|
|
|
|
$emailTxt = "";
|
|
|
|
//Liste commandes non-traites
|
|
|
|
$emailTxt.= "<b><u>Commandes greffe non receptionné</u></b>";
|
|
|
|
$emailTxt.= "<br/>";
|
|
|
|
if(count($listeCmd)>0){
|
|
|
|
$emailTxt.= "<table border=\"1\" style=\"border:1px solid; margin:5px; border-collapse:collapse;\">";
|
|
|
|
$emailTxt.= "<thead>";
|
|
|
|
$emailTxt.= "<tr>";
|
|
|
|
$emailTxt.= "<th>Ref.</th>";
|
|
|
|
$emailTxt.= "<th>Siren</th>";
|
|
|
|
$emailTxt.= "<th>Ref. Document</th>";
|
|
|
|
$emailTxt.= "<th>Date de commande</th>";
|
|
|
|
$emailTxt.= "</tr>";
|
|
|
|
$emailTxt.= "</thead>";
|
|
|
|
$emailTxt.= "<tbody>";
|
|
|
|
foreach($listeCmd as $cmd){
|
|
|
|
$emailTxt.= "<tr>";
|
|
|
|
$emailTxt.= "<td style=\"padding:5px\">G".$cmd->idCommande."</td>";
|
|
|
|
$emailTxt.= "<td style=\"padding:5px\">".$cmd->siren."</a></td>";
|
|
|
|
if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) ){
|
|
|
|
$type = 'bilans';
|
|
|
|
}else{
|
|
|
|
$type = 'actes';
|
|
|
|
}
|
|
|
|
$emailTxt.= "<td style=\"padding:5px\"><a href=\"/?page=greffes&vue=".$type."&siret=".$cmd->siren."\">".$cmd->refDocument."</a></td>";
|
|
|
|
$emailTxt.= "<td style=\"padding:5px\">".$cmd->dateCommande."</td>";
|
|
|
|
$emailTxt.= "</tr>";
|
|
|
|
}
|
|
|
|
$emailTxt.= "</tbody>";
|
|
|
|
$emailTxt.= "</table>";
|
|
|
|
}else{
|
|
|
|
$emailTxt.= "Aucune commande<br/>";
|
|
|
|
}
|
|
|
|
$emailTxt.= "<br/>";
|
|
|
|
$emailtTxt = utf8_encode($emailTxt);
|
|
|
|
|
|
|
|
//Envoi mail
|
|
|
|
$sujet = "[Commandes greffe non receptionné] - ".date('d')."/".date('m')."/".date('Y');
|
|
|
|
$from = array(
|
|
|
|
'email' => 'production@scores-decisions.com',
|
|
|
|
'name' => 'Production'
|
|
|
|
);
|
|
|
|
$to = array(
|
|
|
|
0 => array(
|
|
|
|
'email'=> 'mricois@scores-decisions.com',
|
|
|
|
'name' => 'Pieces')
|
|
|
|
);
|
|
|
|
|
|
|
|
sendMail($sujet, $emailTxt, $from, $to);
|
|
|
|
|
|
|
|
|
|
|
|
|