From 2495c5c35ec8c60e9721f8f94e8e9c1ba6c27c23 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Thu, 11 Mar 2010 16:23:06 +0000 Subject: [PATCH] =?UTF-8?q?Modification=20batch=20de=20m=C3=A9thode=20d'en?= =?UTF-8?q?voi=20des=20mails,=20issue=20#0000146?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- batch/greffeCmdCourrier.php | 140 ++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 72 deletions(-) diff --git a/batch/greffeCmdCourrier.php b/batch/greffeCmdCourrier.php index ea46971aa..4fd420cdc 100644 --- a/batch/greffeCmdCourrier.php +++ b/batch/greffeCmdCourrier.php @@ -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 = ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - foreach($listeCmd as $cmd) - { + + if(count($listeCmd)>0){ + $output = "
Ref.SirenRef. DocumentDate de commande
"; + $output.= ""; $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; - $output.= ""; + $output.= ""; + $output.= ""; + $output.= ""; + $output.= ""; $output.= ""; - - if( preg_match('/^([0-9]{4}_).*?$/', $cmd->refDocument, $matches) ) - { - $type = 'bilans'; - }else{ - $type = 'actes'; + $output.= ""; + $output.= ""; + foreach($listeCmd as $cmd){ + $output.= ""; + $output.= ""; + $output.= ""; + $output.= ""; + $output.= ""; + $output.= ""; + + 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.= ""; + $output.= ""; + $output.= ""; + $output.= ""; } - - $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.= ""; - $output.= ""; - $output.= ""; - $output.= ""; + $output.= ""; + $output.= "
C".$cmd->idCommande."".$cmd->siren."".$cmd->refDocument."".$cmd->dateCommande."Ref.SirenRef. DocumentDate de commande
C".$cmd->idCommande."". + "siren."&type=tri\" >". + $cmd->siren. + "".$cmd->refDocument."".$cmd->dateCommande."
 ".$txtInfo."
 ".$txtInfo."
"; + }else{ + $output.= "Aucune commande
"; } - $output.= ""; - $output.= ""; 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.= "
"; $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); +