Modification batch de méthode d'envoi des mails, issue #0000146
This commit is contained in:
parent
79427a04e5
commit
2495c5c35e
@ -10,78 +10,83 @@ require_once 'dbbootstrap.php';
|
||||
|
||||
/*
|
||||
* Execution du script a 10 heures ?
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
**/
|
||||
|
||||
function listeCmd($statut)
|
||||
{
|
||||
function listeCmd($statut){
|
||||
$q = Doctrine_Query::create()
|
||||
->from('Commandes')
|
||||
->Where('typeCommande = ?', 'C')
|
||||
->andWhere('statutCommande = ?', $statut);
|
||||
|
||||
$listeCmd = $q->execute();
|
||||
|
||||
$output = "<table border=\"1\" style=\"border:1px solid; margin:5px; border-collapse:collapse;\">";
|
||||
$output.= "<thead>";
|
||||
$output.= "<tr>";
|
||||
$output.= "<th>Ref.</th>";
|
||||
$output.= "<th>Siren</th>";
|
||||
$output.= "<th>Ref. Document</th>";
|
||||
$output.= "<th>Date de commande</th>";
|
||||
$output.= "</tr>";
|
||||
$output.= "</thead>";
|
||||
$output.= "<tbody>";
|
||||
foreach($listeCmd as $cmd)
|
||||
{
|
||||
|
||||
if(count($listeCmd)>0){
|
||||
$output = "<table border=\"1\" style=\"border:1px solid; margin:5px; border-collapse:collapse;\">";
|
||||
$output.= "<thead>";
|
||||
$output.= "<tr>";
|
||||
$output.= "<td style=\"padding:5px\">C".$cmd->idCommande."</td>";
|
||||
$output.= "<td style=\"padding:5px\">".$cmd->siren."</td>";
|
||||
$output.= "<td style=\"padding:5px\">".$cmd->refDocument."</td>";
|
||||
$output.= "<td style=\"padding:5px\">".$cmd->dateCommande."</td>";
|
||||
$output.= "<th>Ref.</th>";
|
||||
$output.= "<th>Siren</th>";
|
||||
$output.= "<th>Ref. Document</th>";
|
||||
$output.= "<th>Date de commande</th>";
|
||||
$output.= "</tr>";
|
||||
|
||||
if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) )
|
||||
{
|
||||
$type = 'bilans';
|
||||
}else{
|
||||
$type = 'actes';
|
||||
$output.= "</thead>";
|
||||
$output.= "<tbody>";
|
||||
foreach($listeCmd as $cmd){
|
||||
$output.= "<tr>";
|
||||
$output.= "<td style=\"padding:5px\">C".$cmd->idCommande."</td>";
|
||||
$output.= "<td style=\"padding:5px\">".
|
||||
"<a href=\"http://extranetrec.scores-decisions.com/".
|
||||
"?page=competences&idEntreprise=0&siret=".
|
||||
$cmd->siren."&type=tri\" >".
|
||||
$cmd->siren.
|
||||
"</a></td>";
|
||||
$output.= "<td style=\"padding:5px\">".$cmd->refDocument."</td>";
|
||||
$output.= "<td style=\"padding:5px\">".$cmd->dateCommande."</td>";
|
||||
$output.= "</tr>";
|
||||
|
||||
if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) ){
|
||||
$type = 'bilans';
|
||||
}else{
|
||||
$type = 'actes';
|
||||
}
|
||||
|
||||
$tribunalCode = codeTribunal($cmd->siren);
|
||||
$infoPaiement = infoPaiement($tribunalCode, $type);
|
||||
$txtInfo = "Pas d'information de paiement enregistré dans la base.";
|
||||
if($infoPaiement!==false){
|
||||
$txtInfo =
|
||||
"Chéque de ".$infoPaiement['prix']." ".
|
||||
"à l'ordre de ".$infoPaiement['ordre'];
|
||||
|
||||
if($infoPaiement['enveloppe'])
|
||||
$txtInfo.= ", fournir une enveloppe timbré";
|
||||
}
|
||||
$output.= "<tr>";
|
||||
$output.= "<td> </td>";
|
||||
$output.= "<td colspan=\"3\">".$txtInfo."</td>";
|
||||
$output.= "</tr>";
|
||||
}
|
||||
|
||||
$tribunalCode = codeTribunal($cmd->siren);
|
||||
$infoPaiement = infoPaiement($tribunalCode, $type);
|
||||
$txtInfo = "Pas d'information de paiement enregistré dans la base.";
|
||||
if($infoPaiement!==false)
|
||||
{
|
||||
$txtInfo =
|
||||
"Chéque de ".$infoPaiement['prix']." ".
|
||||
"à l'ordre de ".$infoPaiement['ordre'];
|
||||
|
||||
if($infoPaiement['enveloppe'])
|
||||
$txtInfo.= ", fournir une enveloppe timbré";
|
||||
}
|
||||
$output.= "<tr>";
|
||||
$output.= "<td> </td>";
|
||||
$output.= "<td colspan=\"3\">".$txtInfo."</td>";
|
||||
$output.= "</tr>";
|
||||
$output.= "</tbody>";
|
||||
$output.= "</table>";
|
||||
}else{
|
||||
$output.= "Aucune commande<br/>";
|
||||
}
|
||||
$output.= "</tbody>";
|
||||
$output.= "</table>";
|
||||
return $output;
|
||||
}
|
||||
|
||||
function codeTribunal($siren)
|
||||
{
|
||||
//Connection au webservice
|
||||
$client = new SoapClient(null, array(
|
||||
$client = new SoapClient(null, array(
|
||||
'trace' => 1,
|
||||
'soap_version' => SOAP_1_1,
|
||||
'location' => WEBSERVICE_URL,
|
||||
'uri' => WEBSERVICE_URI,
|
||||
'login' => 'mricois',
|
||||
'password' => 'bj10sx',
|
||||
));
|
||||
));
|
||||
$O = $client->getIdentite($siren, '', false);
|
||||
$tribunalCode = $O['result']['TribunalCode'];
|
||||
return $tribunalCode;
|
||||
@ -93,17 +98,17 @@ function infoPaiement($codeTribunal, $type)
|
||||
->from('CommandesTarifs')
|
||||
->Where('annee = ?', date('Y'))
|
||||
->andWhere('type = ?', $type)
|
||||
->andWhere('codeTribunal = ?', $codeTribunal);
|
||||
->andWhere('codeTribunal = ?', $codeTribunal);
|
||||
$rows = $q->execute();
|
||||
if(count($rows) > 0)
|
||||
{
|
||||
return array(
|
||||
'prix'=> $rows[0]->prix,
|
||||
'prix'=> $rows[0]->prix,
|
||||
'enveloppe' => $rows[0]->enveloppe,
|
||||
'ordre' => $rows[0]->ordre
|
||||
);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -121,24 +126,15 @@ $emailTxt.= "<br/>";
|
||||
$emailTxt.= listeCmd(1);
|
||||
|
||||
//Envoi mail
|
||||
require_once 'phpmailer/class.phpmailer.php';
|
||||
$receptionCmd = array( 'email' =>'pieces@scores-decisions.com', 'nom'=>'Pieces');
|
||||
$mail = new PHPMailer(true);
|
||||
$mail->IsSendmail();
|
||||
try
|
||||
{
|
||||
$body = $emailTxt;
|
||||
$body = eregi_replace("[\]",'',$body);
|
||||
$mail->AddReplyTo('production@scores-decisions.com','Production');
|
||||
$mail->SetFrom('production@scores-decisions.com','Production');
|
||||
$mail->AddAddress($receptionCmd['email'], $receptionCmd['nom']);
|
||||
$mail->Subject = "[COMMANDES PIECES COURRIER] - ".date('d')."/".date('m')."/".date('Y');
|
||||
$mail->MsgHTML($body);
|
||||
$mail->Send();
|
||||
}
|
||||
catch (phpmailerException $e)
|
||||
{
|
||||
//echo $e->errorMessage();
|
||||
} catch (Exception $e) {
|
||||
//echo $e->getMessage();
|
||||
}
|
||||
require_once 'mail/mail.php';
|
||||
|
||||
$sujet = "[COMMANDES PIECES COURRIER] - ".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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user