l3.cas-d-astre/commandes.php
2009-05-01 08:39:36 +00:00

130 lines
2.9 KiB
PHP

<?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ées</span>";
//header("Location: listecommandes.php");
}; break;
default: break;
}
$cmdTool=new CmdTool(getFamilleFromAcheteur($_SESSION["userInfo"]->getID()));
$cmdTool->chargeRef();
?>
<div id="contenu">
<h1>Géné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éfé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 à <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();
?>