182 lines
5.2 KiB
PHP
182 lines
5.2 KiB
PHP
#!/usr/bin/php -q
|
|
<?php
|
|
// Define path to application directory
|
|
defined('APPLICATION_PATH')
|
|
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../../application'));
|
|
|
|
// Define application environment
|
|
defined('APPLICATION_ENV')
|
|
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
|
|
|
|
// Ensure library/ is on include_path
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
realpath(APPLICATION_PATH . '/../library'),
|
|
get_include_path(),
|
|
)));
|
|
|
|
//Use classmap autoloader - useful with opcode and realpath cache
|
|
require_once 'Zend/Loader/AutoloaderFactory.php';
|
|
require_once 'Zend/Loader/ClassMapAutoloader.php';
|
|
Zend_Loader_AutoloaderFactory::factory(array(
|
|
'Zend_Loader_ClassMapAutoloader' => array(
|
|
__DIR__ . '/../../library/Zend/autoload_classmap.php',
|
|
__DIR__ . '/../../library/Application/autoload_classmap.php',
|
|
__DIR__ . '/../../library/Scores/autoload_classmap.php',
|
|
__DIR__ . '/../../application/autoload_classmap.php',
|
|
),
|
|
'Zend_Loader_StandardAutoloader' => array(
|
|
'prefixes' => array(
|
|
'Zend' => __DIR__ . '/../../library/Zend',
|
|
'Application' => __DIR__ . '/../../library/Application',
|
|
'Scores' => __DIR__ . '/../../library/Scores',
|
|
'Metier' => __DIR__ . '/../../library/Metier',
|
|
),
|
|
'fallback_autoloader' => true
|
|
)
|
|
));
|
|
|
|
// Zend_Application - Use it if you don't have autoloaders
|
|
//require_once 'Zend/Application.php';
|
|
|
|
// Create application, bootstrap, and run
|
|
$application = new Zend_Application(
|
|
APPLICATION_ENV,
|
|
APPLICATION_PATH . '/configs/application.ini'
|
|
);
|
|
|
|
try {
|
|
$opts = new Zend_Console_Getopt(
|
|
//Options
|
|
array(
|
|
'help|?' => "Affiche l'aide.",
|
|
));
|
|
$opts->parse();
|
|
} catch (Zend_Console_Getopt_Exception $e) {
|
|
echo $e->getUsageMessage();
|
|
exit;
|
|
}
|
|
|
|
//Usage
|
|
if(isset($opts->help))
|
|
{
|
|
echo "Liste les commandes courrier traités";
|
|
echo "\n\n";
|
|
echo $opts->getUsageMessage();
|
|
echo "\n";
|
|
exit;
|
|
}
|
|
|
|
$c = new Zend_Config($application->getOptions());
|
|
Zend_Registry::set('config', $c);
|
|
|
|
require_once 'Scores/WsScores.php';
|
|
|
|
define('LOGIN', 'mricois');
|
|
define('PASSWORD', '');
|
|
|
|
function listeCmd($statut)
|
|
{
|
|
$commandes = new Application_Model_Commandes();
|
|
$sql = $commandes->select()
|
|
->where('typeCommande = ?', 'C')
|
|
->where('statutCommande = ?', $statut);
|
|
$listeCmd = $commandes->fetchAll($sql);
|
|
|
|
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)
|
|
{
|
|
$ws = new WsScores(LOGIN, PASSWORD);
|
|
$identite = $ws->getIdentite($siren, 0);
|
|
return $identite->TribunalCode;
|
|
}
|
|
|
|
function infoPaiement($codeTribunal, $type)
|
|
{
|
|
$tarifs = new Application_Model_CommandesTarifs();
|
|
$sql = $tarifs->select()
|
|
->where('annee = ?', date('Y'))
|
|
->where('type = ?', $type)
|
|
->where('codeTribunal = ?', $codeTribunal);
|
|
$rows = $tarifs->fetchAll($sql);
|
|
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);
|
|
|
|
//Envoi mail
|
|
$mail = new Scores_Mail_Method();
|
|
$mail->setFromKey('production');
|
|
$mail->addTo('support@scores-decisions.com', 'Pieces');
|
|
$mail->setSubject("[COMMANDES PIECES COURRIER] - ".date('d')."/".date('m')."/".date('Y'));
|
|
$mail->setBodyHtml($emailTxt);
|
|
$mail->execute(); |