Borykam się z problemem - mianowicie - napisałem progrogram do obsługi firmy - faktury juz ładnie działają, magazyn również ale tutaj pojawia sie problem
Chodzi o dwa pliki - wybór produktu na pz, oraz dodanie go do pz ( lub wz, nie ma znaczenia)
Pytanie moje jest takie jak ograniczyć taką sytacje - użytkownik wybiera produkt wpisuje ilosc itd - przechodzi do dodaj_do_pz.php ... produkt jest wpisywany i ok , ale co jeśli teraz da wstecz na przegladarce..
może problem tkwi w tym jak to napisalem, wklejam kod :
To jest akurat do edycji bo z tym miałem problem
wybierz_produkt_edycja_wz.php :
if (!$db) {
print "wystąpił błąd w połączeniu"; }
function ShowSel() {
$result = mysql_query("select nazwa from produkty order by nazwa asc"); echo '<option value="'.$dane[0].'">'.$dane[0].'</option>';
}
}
if(isset($_POST["hid"]) && !empty($_POST["hid"]) && $_POST["hid"]!="--") { $res = mysql_query("select * from magazyn_biezacy_polgames where nazwa='".$_POST["s"]."'");
} else {
}
$_SESSION['nazwa'] = $dane[0];
?>
<title>Dodaj produkt</title><body bgcolor="#efefefe" text="#000000" leftmargin="0" topmargin="0" vlink="#000000" alink="#000000">
<STYLE TYPE="TEXT/CSS"><!--
A:link {
color:#000000;
font-family:verdana;
font-style:normal;
font-weight:normal;
text-decoration:none;
cursor:hand;
}
A:visited {
color:#000000;
font-family:verdana;
font-style:normal;
font-weight:normal;
text-decoration:none;
cursor:hand;
}
A:hover {
color:#000000;
font-family:verdana;
font-style:normal;
font-weight:bold;
text-decoration:underline;
cursor:hand;
}
//--></STYLE>
<form action="wybierz_produkt_edycja_wz.php " method="post">
<table height="15" width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#efefefef" bgcolor="#000000">
<tr>
<td>
<div align="left"><b><font size="2" color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">System
obsługi firmy JAKAR</font></b></div>
</td>
<td><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1">|
ver. 1.0 | wykonanie : Leonard Pociask |</font></td>
</tr>
</table>
<table height="10" width="10%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
| <a href="../index.php">Główna</a> </font>
</td>
</tr>
</table>
<table height="10" width="20%" border="0" cellspacing="0" cellpadding="0" align="left" bordercolor="#000000">
<tr>
<td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
| <a href="poczatek.php">Magazyn towarów</a> </font>
</td>
</tr>
</table>
<table height="10" width="23%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
| Dodaj produkt</font></td>
</tr>
</table>
<br>
<table width="100%" border="1" align="center" bordercolor="#efefef" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#990000">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC">Dodaj
produkt do dokumentu WZ
<? echo $_SESSION['id'];?> </font></div>
</td>
</tr>
</table>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font size="1">
</font></b></font></p>
<table width="52%" border="1" align="center" height="181" bordercolor="#666666">
<tr>
<td height="28" bgcolor="#CCCCCC" colspan="2"><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font size="1">Wybierz
produkt :</font></b></font></td>
</tr>
<tr>
<td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">|
Wybierz :</font> <font color="#000000"> </font></td>
<td width="62%"><font color="#000000">
<select id="s" name="s" onChange="document.getElementById('hid').value='submit';this.form.submit()">
<option value="--">--</option>
<?php ShowSel(); ?>
</select>
<input id="hid" name="hid" type="hidden" value="<?$_POST["s"]?>" />
</font></font></td>
</tr>
<tr>
<td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">|
Produkt :</font></td>
<td width="62%">
</td>
</tr>
<tr>
<td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">|
Zapas: magazyn biezacy :</font></td>
<td width="62%">
</td>
</tr>
<tr>
<td width="38%"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">|
Ostatnie przyjecie :</font></td>
<td width="62%">
</td>
</tr>
</tr>
<tr>
<td width="38%" height="24"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">|
Ilosc:</font></td>
<td width="62%" height="24">
<input type="text" id="ilosc" name="t13" value="0" />
</td>
</tr>
<tr>
<td colspan="2" height="53">
<center>
<font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif"><a href="java script:przeladuj()" id="przeladuj">utwórz
dokument</a> </font>
</center>
<script language="javascript">
function przeladuj(){
location = 'dodaj_produkt_wz_edycja.php?ilosc='+document.getElementById('ilosc').value;
}
</script>
</tr>
</table>
</form>
</body>
</html>
Tutaj po wyborze produktu strona sie przeładowywuje i wyświetla informacje o prod - miałem problem z przekazaniem wybranych wartosci do dodaj_produkt_edycja_wz
Ponizej wkleje kod 2 pliku
Problem w tym że poprostu sciąga mi produkt z magazynu z zapasu - a wcale nie ma go tyle na wydaniach jak robie zestawienie :/
dodaj_produkt_wz_edycja.php
$nrwz = $_SESSION['id'];
if (!$db) {
print "wystąpił błąd w połączeniu"; }
$nazwa=$_SESSION['nazwa'];
$ilosc=($_GET['ilosc']);
$magazyn= "biezacy";
if ($magazyn == "biezacy") {
$wpis= 'magazyn_biezacy_polgames';
} else {
$wpis = 'magazyn_serwis';
}
$res = mysql_query("select zapas from $wpis where nazwa='$nazwa' ") ;
$aktualny_zapas= $row[0];
}
if ($aktualny_zapas<$ilosc-1) {
print "Zapas '".$nazwa."' jest mniejszy niż proponowana ilosc do wydania - brak towaru na magazynie"; echo ' <center><input type="button" value="Powrot" onclick="history.back();"></center> '; }
if(($ilosc) == 0 && ($ilosc) == 0.0)
{
echo '<font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC"> Nie zostały wypełnione obowiazkowe pola'; echo '<center><input type="button" value="Powrot" onclick="history.back();"></center>'; }
$result = mysql_query( "insert into wz_towar_polgames values ('".$nrwz."', '".$nazwa."', '".$ilosc."')")or
die(mysql_error());
$result = mysql_query( "UPDATE $wpis SET zapas=zapas - $ilosc, ost_data='".$data."' where nazwa= '".$nazwa."' ")or
die(mysql_error());
?>
<title>Produkt dodany</title><body bgcolor="#efefefe" text="#000000" leftmargin="0" topmargin="0" vlink="#000000" alink="#000000">
<STYLE TYPE="TEXT/CSS"><!--
A:link {
color:#000000;
font-family:verdana;
font-style:normal;
font-weight:normal;
text-decoration:none;
cursor:hand;
}
A:visited {
color:#000000;
font-family:verdana;
font-style:normal;
font-weight:normal;
text-decoration:none;
cursor:hand;
}
A:hover {
color:#000000;
font-family:verdana;
font-style:normal;
font-weight:bold;
text-decoration:underline;
cursor:hand;
}
//--></STYLE>
<table height="15" width="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#efefefef" bgcolor="#000000">
<tr>
<td>
<div align="left"><b><font size="2" color="#FF0000" face="Verdana, Arial, Helvetica, sans-serif">System
obsługi firmy JAKAR</font></b></div>
</td>
<td><font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1">|
ver. 1.0 | wykonanie : Leonard Pociask |</font></td>
</tr>
</table>
<table height="10" width="10%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
| <a href="../index.php">Główna</a> </font>
</td>
</tr>
</table>
<table height="10" width="20%" border="0" cellspacing="0" cellpadding="0" align="left" bordercolor="#000000">
<tr>
<td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
| <a href="poczatek.php">Zestawienie faktur</a> </font>
</td>
</tr>
</table>
<table height="10" width="26%" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td bgcolor="#efefefe"><font size="2" color="#000000" face="Verdana, Arial, Helvetica, sans-serif">
| Dodaj produkt</font> </td>
</tr>
</table>
<br>
<table width="100%" border="1" align="center" bordercolor="#efefef" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#990000">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC">Dodano
<? $nazwa?> </font><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#CCCCCC">
do dokumentu WZ
<? echo $nrwz; ?> </font></div>
</td>
</tr>
</table>
<br>
<table width="20%" border="1" align="center" cellspacing="0" cellpadding="0" bordercolor="#999999" height="47">
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">-> <a href="wybierz_produkt_edycja_wz.php">dodaj
kolejny produkt</a></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">-> <a href="utworzona_wz_gotowa_podglad2.php">podglad</a></font></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif" size="2">-> <a href="poczatek_wz.php">zakoncz</a></font></td>
</tr>
</table>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b><font size="1">
</font></b></font></p>
</body>
</html>
Ten post edytował Lonas 26.08.2006, 13:15:58