l3.cas-d-astre/commandes.php

131 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2009-05-01 08:39:36 +00:00
<?php
include("includes.inc.php");
$page=new Page(__FILE__);
$_SESSION["referer"]=basename(__FILE__);
$page->logCheck();
$page->startScript();
?>
// prod_ref.options[makeselector.selectedIndex].text; */
function showDA(prod_ref){
var refSelected=document.forms["cmd_gen"].reference.value;
var lgth = document.forms["cmd_gen"].reference.options.length;
for (i=0;i<lgth;i++){
refHide=document.forms["cmd_gen"].reference.options[i].value;
objHide=document.getElementById(refHide);
objHide.style.display="none";
objHide.style.visibility="hidden";
}
objVisible=document.getElementById(refSelected);
objVisible.style.display="block";
objVisible.style.visibility="visible";
}
<?php
$page->endScript();
$page->startContent();
switch($_POST["action"]){
case "Ajouter": {
$refprod=$_POST["reference"];
$fournisseur=$_POST["fourn_$refprod"];
$LDAtab=&$_POST["da_$refprod"];
if (!isset($_SESSION["commande"])){
$_SESSION["commande"]=new Commande(
$_SESSION["userInfo"]->getID()
);
}
$_SESSION["commande"]->ajouteLC($refprod,$LDAtab,$fournisseur);
}; break;
case "Supprimer": {
if (isset($_SESSION["commande"])){
$_SESSION["commande"]->supprimeLC($_POST["ligneCom"]);
}
}; break;
case "Valider": {
$_SESSION["commande"]->valideLC();
unset($_SESSION["commande"]);
print "<span class='error'>Commandes effectu<74>es</span>";
//header("Location: listecommandes.php");
}; break;
default: break;
}
$cmdTool=new CmdTool(getFamilleFromAcheteur($_SESSION["userInfo"]->getID()));
$cmdTool->chargeRef();
?>
<div id="contenu">
<h1>G<EFBFBD>n<EFBFBD>rer des commandes</h1>
<form name="cmd_gen"
method="post"
action="commandes.php"
enctype="application/x-www-form-urlencoded">
<fieldset>
<legend>Lignes d'Achat en attente</legend>
<p>R<EFBFBD>f<EFBFBD>rences des produits :
<select name="reference"
onClick="showDA(); false;" >
<?php print $cmdTool->ReftoHTML(); ?>
</select>
</p>
<?php
for ($i=0;$i<count($cmdTool->_ref_in);$i++){
$ref=$cmdTool->_ref_in[$i];
print "<p id=\"$ref\" name=\"$ref\" "
."style=\"display: none; visibility:hidden;\" >";
print "<span style='display:block'>";
print "Demande d'achats correspondant <20> <b>$ref</b>";
print "</span>";
print "<span style='display:block'>";
print $cmdTool->LDAtoHTML($ref);
print "</span>";
print "<span style='display:block'>";
print "Fournisseur disponibles pour <b>$ref</b> ";
print "</span>";
print "<span style='display:block'>";
print $cmdTool->FournToHTML($ref);
print "</span>";
print "</p>";
}
?>
<input type="submit" id="action" name="action" value="Ajouter" />
</fieldset>
<br />
<?php
if (isset($_SESSION["commande"])){
print "<fieldset>";
print "<legend>Commandes en cours</legend>";
print $_SESSION["commande"]->toHTML();
}
?>
</fieldset>
<?php
if (isset($_SESSION["commande"])){
print "<input type=\"submit\" name=\"action\" id=\"action\" value=\"Valider\" />";
}
?>
</form>
</div> <!-- contenu !-->
<?php
$page->endContent();
print $page->toHTML();
?>