#!/usr/bin/php -q 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) { $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.= ""; } $output.= ""; $output.= "
Ref.SirenRef. DocumentDate de commande
C".$cmd->idCommande."".$cmd->siren."".$cmd->refDocument."".$cmd->dateCommande."
 ".$txtInfo."
"; return $output; } function codeTribunal($siren) { //Connection au webservice $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; } function infoPaiement($codeTribunal, $type) { $q = Doctrine_Query::create() ->from('CommandesTarifs') ->Where('annee = ?', date('Y')) ->andWhere('type = ?', $type) ->andWhere('codeTribunal = ?', $codeTribunal); $rows = $q->execute(); if(count($rows) > 0) { return array( 'prix'=> $rows[0]->prix, 'enveloppe' => $rows[0]->enveloppe, 'ordre' => $rows[0]->ordre ); } else { return false; } } $emailTxt = ""; //Liste commandes non-traites $emailTxt.= "Liste des commandes courrier non-traités"; $emailTxt.= "
"; $emailTxt.= listeCmd(0); $emailTxt.= "
"; //Liste des commandes en attente de cheques $emailTxt.= "Liste des commandes courrier en attente de chèque"; $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(); }