143 lines
3.6 KiB
PHP
143 lines
3.6 KiB
PHP
#!/usr/bin/php -q
|
|
<?php
|
|
$version = '0.1';
|
|
$argc = $_SERVER['argc'];
|
|
$argv = $_SERVER['argv'];
|
|
|
|
require_once '../config/prepend.php';
|
|
//Inclure la base de données
|
|
require_once 'dbbootstrap.php';
|
|
|
|
/*
|
|
* Execution du script a 10 heures ?
|
|
*
|
|
*
|
|
**/
|
|
|
|
function listeCmd($statut){
|
|
$q = Doctrine_Query::create()
|
|
->from('Commandes')
|
|
->Where('typeCommande = ?', 'C')
|
|
->andWhere('statutCommande = ?', $statut);
|
|
|
|
$listeCmd = $q->execute();
|
|
|
|
if(count($listeCmd)>0){
|
|
$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){
|
|
$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>";
|
|
}
|
|
$output.= "</tbody>";
|
|
$output.= "</table>";
|
|
}else{
|
|
$output.= "Aucune commande<br/>";
|
|
}
|
|
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.= "<b><u>Liste des commandes courrier non-traités</u></b>";
|
|
$emailTxt.= "<br/>";
|
|
$emailTxt.= listeCmd(0);
|
|
$emailTxt.= "<br/>";
|
|
//Liste des commandes en attente de cheques
|
|
$emailTxt.= "<b><u>Liste des commandes courrier en attente de chèque</u></b>";
|
|
$emailTxt.= "<br/>";
|
|
$emailTxt.= listeCmd(1);
|
|
|
|
$emailtTxt = utf8_encode($emailTxt);
|
|
|
|
//Envoi mail
|
|
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'=> 'production@scores-decisions.com',
|
|
'name' => 'Pieces'));
|
|
|
|
sendMail($sujet, $emailTxt, $from, $to);
|
|
|