264 lines
7.0 KiB
PHP
Raw Normal View History

<script language="javascript">
function download(id, format) {
location.href = 'modules/graydon/export.php?id=' + id + '&format=' + format;
}
</script>
<form name="tri" action="./index.php?q=graydon/commandes" method="post">
<input type="hidden" name="mode" value="search" />
<table border="0" width="50%" cellspacing="2" cellpadding="3">
<tr>
<td>
<select name="country">
<option value="">Tri par pays</option>
<?php echo affiche_pays();?>
</select>
</td>
<td>&nbsp;</td>
<td>Reference : <input type="text" name="reference" /></td>
</tr>
<tr>
<td>
<select name="servicespeed">
<option value="">Tri par type de commande</option>
<option value="immediate">Immediate</option>
<option value="normal">Normal</option>
<option value="Express">Rapide</option>
</select>
</td>
<td>&nbsp;</td>
<td>
<select name="status">
<option value="">Tri par <EFBFBD>tat de la commande</option>
<option value="Completed">Completed</option>
<option value="Assigned">Assigned</option>
<option value="InError">InError</option>
<option value="Initialised">Initialised</option>
<option value="Delivered">Delivered</option>
<option value="Notified">Notified</option>
<option value="ReCompleted">ReCompleted</option>
<option value="SendError">SendError</option>
</select>
</td>
</tr>
<tr>
<td colspan="3">De <input type="text" name="dateFrom" />
<EFBFBD> <input type="text" name="dateTo" /> (Format : AAAA-MM-JJ)
</td>
</tr>
<tr>
<td align="center" colspan="3"><input type="submit" value="Rechercher" /></td>
</tr>
</table>
2009-05-06 17:01:50 +00:00
</form>
2009-06-04 10:35:53 +00:00
<table>
2009-05-06 17:01:50 +00:00
<tr>
<th>Date de la commande</th>
<th>Reference</th>
2009-05-06 17:01:50 +00:00
<th>Pays</th>
<th>Reference</th>
<th>Service command<EFBFBD></th>
<th>Prix de la commande</th>
2009-05-06 17:01:50 +00:00
<th>Status de la commande</th>
<th>Date due</th>
<th>Actions</th>
</tr>
<?php
$mode = $_REQUEST['mode'];
switch ($mode) {
case "search" :
if (sizeof($_POST) > 0) {
$search = $_POST;
/*
echo "<pre>";
print_r($search);
exit;
*/
affiche_liste_commandes();
}
break;
default :
affiche_liste_commandes();
break;
break;
}
/******************************************************************************
* FONCTIONS
*****************************************************************************/
/*
* Fonction affiche la liste des commandes
*/
function affiche_liste_commandes() {
global $search;
include("../mysql_inc.php");
$WHERE = "";
if(!empty($search['reference'])) { $WHERE .= " AND cmd.reference = '".$search['reference']."'";}
if(!empty($search['country'])) { $WHERE .= " AND cmd.country_id = '".$search['country']."'";}
if(!empty($search['servicespeed'])) { $WHERE .= " AND cmd.servicespeed = '".$search['servicespeed']."'";}
if(!empty($search['status'])) { $WHERE .= " AND cmd.orderstate = '".$search['status']."'";}
if(!empty($search['dateFrom']) && !empty($search['dateTo'])) {
if (preg_match("#^([0-9]{4})(-[0-9]{2}){2}$#", $search['dateFrom']) &&
preg_match("#^([0-9]{4})(-[0-9]{2}){2}$#", $search['dateTo'])) {
$WHERE .= " AND cmd.dateordered BETWEEN '".$search['dateFrom']."' AND '".$search['dateTo']."'";
}
}
$result_commande = mysql_query("
SELECT cmd.*
, cntr.graydon_country
, cmdd.*
, rpt.id as id_rapport, rpt.content, rpt.format, rpt.order_id
FROM commandes cmd
LEFT JOIN country cntr
ON cntr.id = cmd.country_id
LEFT JOIN commandes_detail cmdd
ON cmdd.commandes_id = cmd.id
LEFT JOIN report rpt
ON rpt.order_id = cmd.id
WHERE 1 $WHERE
ORDER by dateordered
");
if(mysql_num_rows($result_commande) == 0) {
echo "<tr><td colspan=\"8\"><p>Aucune commande n'est enregistr<74>e.</p></td></tr>";
}
while($commande = mysql_fetch_object($result_commande)) {
2009-05-06 17:01:50 +00:00
?>
<script type="text/javascript">
$(document).ready(function(){
$("a.detailsBtn<?=$commande->id;?>").click(function () {
$("a.detailsBtn<?=$commande->id;?>").toggle();
$("a.closeBtn<?=$commande->id;?>").toggle();
$("div#advanceBtn<?=$commande->id;?>").slideToggle("slow");
});
$("a.closeBtn<?=$commande->id;?>").click(function () {
$("a.detailsBtn<?=$commande->id;?>").toggle();
$("a.closeBtn<?=$commande->id;?>").toggle();
$("div#advanceBtn<?=$commande->id;?>").slideToggle("slow");
});
});
</script>
<style type="text/css">
.detailsBtn<?=$commande->id;?> {
margin-left: 10px;
}
.closeBtn<?=$commande->id;?> {
margin-left: 10px;
display:none;
}
#advanceBtn<?=$commande->id;?> {
display:none;
width:350px;
}
</style>
2009-05-06 17:01:50 +00:00
<tr>
<td><?=$commande->dateordered;?></td>
<td><?=$commande->reference;?></td>
<td><?=$commande->graydon_country;?></td>
<td><?=$commande->reference;?></td>
<td><?=$commande->servicespeed;?></td>
<td><?=$commande->prix;?></td>
<td><?=$commande->orderstate;?></td>
<td><?=$commande->datedue;?></td>
2009-05-06 17:01:50 +00:00
<td>
<?php
if(is_null($commande->commandes_id)) {
echo "&nbsp;&nbsp;<font color=\"gray\">Afficher D<>tails</font>";
}
else {
?>
<a href="Javascript:;" class="detailsBtn<?=$commande->id;?>">Afficher D<EFBFBD>tails</a>
<a href="Javascript:;" class="closeBtn<?=$commande->id;?>">Masquer D<EFBFBD>tails</a>
<?php } ?>
| <?php
if(is_null($commande->order_id)) {
echo "<font color=\"gray\">Rapport</font>";
}
else {
?>
<a href="Javascript:download('<?=$commande->id_rapport?>', '<?=$commande->format?>');">Rapport</a>
<?php } ?>
2009-05-06 17:01:50 +00:00
</td>
</tr>
<tr>
<td colspan="6">&nbsp;</td>
<td colspan="3">
<div id="advanceBtn<?=$commande->id;?>">
<?php
echo "<b>dIdentite :</b> ".$commande->dIdentite."<br />";
echo "<b>dTelephone :</b> ".$commande->dTelephone."<br />";
echo "<b>dEmail :</b> ".$commande->dEmail."<br />";
echo "<b>dFax :</b> ".$commande->dFax."<br />";
echo "<b>eLanguageCode :</b> ".$commande->eLanguageCode."<br />";
echo "<b>eName :</b> ".$commande->eName;
echo "<b>eIdentifiers :</b> ".$commande->eIdentifiers."<br />";
echo "<b>eAdresse :</b> ".$commande->eAdresse."<br />";
echo "<b>eTelephone :</b> ".$commande->eTelephone."<br />";
echo "<b>eCreditOpinionCurrency :</b> ".$commande->eCreditOpinionCurrency."<br />";
echo "<b>eCreditOpinionPeriod :</b> ".$commande->eCreditOpinionPeriod."<br />";
echo "<b>eBankers :</b> ".$commande->eBankers."<br />";
echo "<b>eAttentionOf :</b> ".$commande->eAttentionOf."<br />";
echo "<b>eSpecialRemarks :</b> ".$commande->eSpecialRemarks."<br />";
echo "<b>commandes_id :</b> ".$commande->commandes_id."<br />";
echo "<b>CreditOpinionPeriod :</b> ".$commande->eCreditOpinionPeriod."<br />";
echo "<b>Date de commande :</b> ".$commande->created_at;
?>
</div></td>
</tr>
<?php
} // Fin de la boucle
mysql_free_result($result_commande);
mysql_close($connexion);
2009-05-06 17:01:50 +00:00
}
/*
* Fonction affiche la liste des pays qui ont un status actif
*/
function affiche_pays() {
include("../mysql_inc.php");
$result_pays = mysql_query("SELECT id, graydon_country FROM country WHERE status = 'actif'");
while($pays = mysql_fetch_array($result_pays, MYSQL_ASSOC)) {
echo "<option value=\"".$pays['id']."\">".$pays['graydon_country']."</option>";
}
mysql_free_result($result_pays);
mysql_close($connexion);
}
?>
</table>