2010-08-31 13:55:19 +00:00
|
|
|
<?php
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// international_commandes.php
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if (isset($_POST['action']) == true) {
|
|
|
|
$action = $_POST['action'];
|
|
|
|
$commande_id = $_POST['commande_id'];
|
|
|
|
} else {
|
|
|
|
$action = '';
|
|
|
|
}
|
|
|
|
if (isset($_REQUEST['etat_enq']) == false) {
|
|
|
|
$etat_enq = 'Toutes';
|
|
|
|
} else {
|
|
|
|
$etat_enq = $_REQUEST['etat_enq'];
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once 'dbbootstrap.php';
|
|
|
|
setDbConn('giantclient');
|
|
|
|
|
|
|
|
$etatsEnq = array('Toutes' => 'Toutes',
|
2010-10-07 13:20:24 +00:00
|
|
|
'Pending' => 'En attente ', // Espace pour le pluriel
|
2010-08-31 13:55:19 +00:00
|
|
|
'Completed' => 'Completées',
|
|
|
|
'Delivered' => 'Délivrées',
|
|
|
|
'Undeliverable' => 'Non délivrables',
|
|
|
|
'NonD' => 'Non délivrées');
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// afficheElem
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
function afficheElem($obj, $retrait = '')
|
|
|
|
{
|
|
|
|
if (is_object($obj) == true) {
|
|
|
|
$tab = get_object_vars($obj);
|
|
|
|
} else if (is_array($obj) == true) {
|
|
|
|
$tab = $obj;
|
|
|
|
} else {
|
|
|
|
$obj = str_replace('&', '&', $obj);
|
|
|
|
print "$retrait$obj\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
foreach ($tab as $label => $valeur) {
|
|
|
|
if (is_object($valeur) == true) {
|
|
|
|
print "$retrait<$label>\n";
|
|
|
|
afficheElem($valeur, $retrait.' ');
|
|
|
|
print "$retrait</$label>\n";
|
|
|
|
} else if (is_array($valeur) == true) {
|
|
|
|
foreach ($valeur as $indice => $elem) {
|
|
|
|
print "$retrait<$label>\n";
|
|
|
|
afficheElem($elem, $retrait.' ');
|
|
|
|
print "$retrait</$label>\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$valeur = str_replace('&', '&', $valeur);
|
|
|
|
print "$retrait<$label>$valeur</$label>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Affichage du document
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if ($action == 'xml' ||
|
|
|
|
$action == 'txt') {
|
|
|
|
$commande = Doctrine_Query::create()
|
|
|
|
->from('Commandes')
|
|
|
|
->where('OrderId = ?', $commande_id)
|
2010-09-10 08:01:18 +00:00
|
|
|
->andWhere('User = ?', $_SESSION['tabInfo']['login'])
|
2010-08-31 13:55:19 +00:00
|
|
|
->fetchOne();
|
|
|
|
$nom = $commande->CompanyName.'.'.$action;
|
|
|
|
$rapport = Doctrine_Query::create()
|
|
|
|
->from('Rapports')
|
|
|
|
->where('OrderId = ?', $commande_id)
|
2010-09-10 08:01:18 +00:00
|
|
|
->andWhere('User = ?', $_SESSION['tabInfo']['login'])
|
2010-08-31 13:55:19 +00:00
|
|
|
->fetchOne();
|
|
|
|
$obj = unserialize($rapport->DataSet);
|
|
|
|
if ($action == 'xml') {
|
|
|
|
header('Content-type: text/xml');
|
|
|
|
header('Content-Disposition: attachment; filename="'.$nom.'"');
|
|
|
|
afficheElem($obj);
|
|
|
|
} else {
|
|
|
|
header('Content-type: text/plain');
|
|
|
|
header('Content-Disposition: attachment; filename="'.$nom.'"');
|
|
|
|
print_r($obj);
|
|
|
|
}
|
|
|
|
if ($commande->OrderStatus == 'Completed') {
|
|
|
|
$commande->OrderStatus = 'Delivered';
|
|
|
|
$commande->save();
|
|
|
|
}
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Affichage du document HTML
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if ($action == 'html') {
|
2010-09-21 10:14:44 +00:00
|
|
|
$commande = Doctrine_Query::create()
|
|
|
|
->from('Commandes')
|
|
|
|
->where('OrderId = ?', $commande_id)
|
|
|
|
->andWhere('User = ?', $_SESSION['tabInfo']['login'])
|
|
|
|
->fetchOne();
|
|
|
|
if ($commande->OrderStatus == 'Completed') {
|
|
|
|
$commande->OrderStatus = 'Delivered';
|
|
|
|
$commande->save();
|
|
|
|
}
|
2010-08-31 13:55:19 +00:00
|
|
|
$r = Doctrine_Query::create()
|
|
|
|
->from('Rapports')
|
|
|
|
->where('OrderId = ?', $commande_id)
|
2010-09-10 08:01:18 +00:00
|
|
|
->andWhere('User = ?', $_SESSION['tabInfo']['login'])
|
2010-08-31 13:55:19 +00:00
|
|
|
->fetchOne();
|
2010-10-13 10:20:01 +00:00
|
|
|
header('Location: /?page=giant_rapport&OrderId='.$commande_id);
|
|
|
|
print '<a href="/?page=giant_rapport&OrderId='.$commande_id.
|
|
|
|
'">Veuillez suivre ce lien</a>';
|
2010-08-31 13:55:19 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
<div id="center" style="width:625px">
|
|
|
|
<h1>Commandes Internationales</h1>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Suppression
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if ($action == 'Supprimer') {
|
|
|
|
Doctrine_Query::create()
|
|
|
|
->update('Commandes')
|
|
|
|
->set('OrderStatus', '?', 'Unlinked')
|
|
|
|
->where('OrderId = ?', $commande_id)
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Choix de l'etat des commandes a afficher
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if (isset($_GET['OrderId']) == false) {
|
2010-10-06 07:46:02 +00:00
|
|
|
print '<form method="post" action="?page=giant_commandes">';
|
2010-08-31 13:55:19 +00:00
|
|
|
print '<label> Enquêtes:</label>';
|
|
|
|
print '<select name="etat_enq" onchange="this.form.submit();">';
|
|
|
|
foreach ($etatsEnq as $index => $valeur) {
|
|
|
|
print '<option value="'.$index.'"';
|
|
|
|
if ($etat_enq == $index) {
|
|
|
|
print ' selected';
|
|
|
|
}
|
|
|
|
print '>'.$etatsEnq[$index].'</option>';
|
|
|
|
}
|
|
|
|
print '</select>';
|
|
|
|
print '</form>';
|
|
|
|
print '<br/>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// tableDebut
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-10-06 07:46:02 +00:00
|
|
|
function tableDebut()
|
|
|
|
{
|
2010-08-31 13:55:19 +00:00
|
|
|
print '<table>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// tableLigne
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-10-06 07:46:02 +00:00
|
|
|
function tableLigne($c1, $c2)
|
|
|
|
{
|
2010-08-31 13:55:19 +00:00
|
|
|
print '<tr><td>'.$c1.'</td><td>'.$c2.'</td></tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// tableFin
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-10-06 07:46:02 +00:00
|
|
|
function tableFin()
|
|
|
|
{
|
2010-08-31 13:55:19 +00:00
|
|
|
print '</table>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// boutonPost
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-10-06 07:46:02 +00:00
|
|
|
function boutonPost($action, $nom, $valeur, $etat_enq)
|
|
|
|
{
|
|
|
|
if ($action == 'xml' ||
|
|
|
|
$action == 'txt') {
|
|
|
|
print '<form method="post" action="pages/giant_commandes.php" ';
|
|
|
|
} else {
|
|
|
|
print '<form method="post" action="./?page=giant_commandes" ';
|
|
|
|
}
|
|
|
|
print 'style="float:left">'.
|
2010-08-31 13:55:19 +00:00
|
|
|
'<input type="hidden" name="action" value="'.$action.'" />'.
|
|
|
|
'<input type="hidden" name="'.$nom.'" value="'.$valeur.'" />'.
|
|
|
|
'<input type="hidden" name="etat_enq" value="'.$etat_enq.'" />'.
|
|
|
|
'<input type="submit" value="'.
|
|
|
|
((ctype_lower($action)) ? strtoupper($action) : $action).'" />'.
|
|
|
|
'</form>';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// datetime2date
|
|
|
|
// --------------------------------------------------------------------------- //
|
2010-10-06 07:46:02 +00:00
|
|
|
function datetime2date($datetime)
|
|
|
|
{
|
2010-08-31 13:55:19 +00:00
|
|
|
return preg_replace('/([0-9]{4}-[0-9]{2}-[0-9]{2}).*$/', '$1',
|
|
|
|
$datetime);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
// Affichage des commandes
|
|
|
|
// --------------------------------------------------------------------------- //
|
|
|
|
if (isset($_GET['OrderId']) == true) {
|
|
|
|
$tabCommandes = Doctrine_Query::create()
|
|
|
|
->from('Commandes')
|
2010-09-10 08:01:18 +00:00
|
|
|
->where('OrderId = ?', $_GET['OrderId'])
|
|
|
|
->andWhere('User = ?', $_SESSION['tabInfo']['login'])
|
2010-08-31 13:55:19 +00:00
|
|
|
->execute();
|
|
|
|
} else {
|
|
|
|
$tabCommandes = Doctrine_Query::create()
|
|
|
|
->from('Commandes')
|
|
|
|
->where('User = ?', $_SESSION['tabInfo']['login'])
|
|
|
|
->orderby('OrderId')
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
foreach ($tabCommandes as $commande) {
|
|
|
|
if (($etat_enq != 'Toutes' &&
|
|
|
|
$etat_enq != 'NonD' &&
|
|
|
|
$etat_enq != $commande->OrderStatus) ||
|
|
|
|
($etat_enq == 'NonD' &&
|
|
|
|
$commande->OrderStatus == 'Delivered') ||
|
|
|
|
$commande->OrderStatus == 'Unlinked') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ($commande->OrderStatus == 'Completed' ||
|
|
|
|
$commande->OrderStatus == 'Delivered') {
|
|
|
|
$delivree = true;
|
|
|
|
} else {
|
|
|
|
$delivree = false;
|
|
|
|
}
|
|
|
|
print '<table border="1" cellspacing="0"'.
|
|
|
|
' style="margin:10px;background-color:#E7EFF8">'.
|
|
|
|
'<td width="390px" valign="top">';
|
|
|
|
if ($delivree == true) {
|
|
|
|
print '<font color="#000000"><b>';
|
|
|
|
}
|
|
|
|
print $commande->CompanyName;
|
|
|
|
if ($delivree == true) {
|
|
|
|
print '</b></font>';
|
|
|
|
}
|
2010-10-13 12:46:35 +00:00
|
|
|
print '<br/>'.
|
|
|
|
'Type d\'enquête: '.
|
|
|
|
'<i>'.$commande->ServiceLevelName.'</i>, '.
|
|
|
|
'<i>'.$commande->DataSetType.'</i>. '.
|
|
|
|
'Langage: '.
|
|
|
|
'<i>'.$commande->LanguageCode.'</i><br/>'.
|
2010-08-31 13:55:19 +00:00
|
|
|
'État: ';
|
|
|
|
if ($delivree == true) {
|
|
|
|
print '<font color="#31659C"><b>';
|
|
|
|
}
|
|
|
|
print substr($etatsEnq[$commande->OrderStatus], 0, -1);
|
|
|
|
if ($delivree == true) {
|
|
|
|
print '</b></font><br/>';
|
|
|
|
$reports = Doctrine_Query::create()
|
|
|
|
->from('Rapports')
|
|
|
|
->where('OrderId = ?', $commande->OrderId)
|
2010-09-10 08:01:18 +00:00
|
|
|
->andWhere('User = ?', $_SESSION['tabInfo']['login'])
|
2010-08-31 13:55:19 +00:00
|
|
|
->orderby('ReportId')
|
|
|
|
->execute();
|
|
|
|
foreach ($reports as $report) {
|
|
|
|
boutonPost('html', 'commande_id',
|
|
|
|
$commande->OrderId, $etat_enq);
|
|
|
|
boutonPost('xml', 'commande_id',
|
|
|
|
$commande->OrderId, $etat_enq);
|
|
|
|
boutonPost('txt', 'commande_id',
|
|
|
|
$commande->OrderId, $etat_enq);
|
|
|
|
}
|
|
|
|
if (count($reports) > 0) {
|
|
|
|
boutonPost('Supprimer', 'commande_id',
|
|
|
|
$commande->OrderId, $etat_enq);
|
|
|
|
} else {
|
|
|
|
$delivree = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
print '</td><td valign="top">';
|
|
|
|
tableDebut();
|
|
|
|
tableLigne('Date de commande:', datetime2date($commande->OrderDateTime));
|
|
|
|
if ($commande->DueDateTime == '0000-00-00 00:00:00' &&
|
|
|
|
$commande->ServiceLevelName != 'Immediate') {
|
|
|
|
$datedue = '<a href="?page=international_commandes&maj='.
|
|
|
|
$commande->OrderId.'&etat_enq='.$etat_enq.'">MàJ</a>';
|
|
|
|
} else {
|
|
|
|
$datedue = datetime2date($commande->DueDateTime);
|
|
|
|
}
|
|
|
|
tableLigne('Date de réception prévue:', $datedue);
|
|
|
|
if ($delivree == true) {
|
|
|
|
tableLigne('Date de mise à jour:',
|
|
|
|
datetime2date($commande->DateTimeCompleted));
|
|
|
|
}
|
|
|
|
tableFin();
|
|
|
|
print '</td></table>';
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
|
|
|
</div>
|