1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
<? require("inc/configure.php"); require("inc/global.php"); require("inc/checklogin.php"); if ($logged_in == 0) { //echo 'Not logged in. <a href="login.php">Login</a>'; header('Window-target: _parent'); header('Location: login.php'); exit(); } if (checkObject(3) <> 1){ die("Unauthorized Access"); exit(); } ?> <? $n = $_POST['n']; $creationdate = date("YmdGis"); $creationby = "";
for($i = 0; $i < $n; $i++) { $qty[0] = "qty".($i+1); $id[0] = "id".($i+1); //echo "1".$qty[0]; //echo $_POST[$id[$i]]." ".$_POST[$qty[$i]];
$sql = "insert into INV_STOCK_TRANSACTION (prodid, qty, uomid, stocktrantypeid, sign, docno, lineno, cost, creationdate, creationby) SELECT prodid, ".$_POST[$qty[$i]].", uomid, 1, 1, pono, lineno, cost-(discount/qty), '".$creationdate."', '".$creationby."' from AP_PURCHASE_DTL where id = ". $_POST[$id[$i]] .""; $result = mysql_query($sql); if (!$result) { die('Invalid query: ' . mysql_error()); } $r = "?msg=Transaction Confirm!"; } /* if (strlen($cost) == 0) $cost = 0;
$creationdate = date("YmdGis"); $r = ""; if ($prodid == "") { //header("Location: stockin.php?"); $r = "?prodid=$prodid&qty=$qty&msg=Product not found!"; } else { $sql = "select typeid from INV_PRODUCT where prodid = $prodid"; $result = mysql_query($sql); if ($row = mysql_fetch_array($result,MYSQL_ASSOC)) { if ($row{'typeid'} == 2) { //header("Location: stockin.php?prodid=$prodid&qty=$qty&msg=Product type error!"); $r = "?prodid=$prodid&qty=$qty&msg=Product type error!"; } else { $sql = "insert into INV_STOCK_TRANSACTION (prodid, qty, uomid, stocktrantypeid, sign, docno, cost, creationdate, creationby) values($prodid, $qty, $uomid, 1, 1, '$docno', $cost, '$creationdate', '$creationby')"; $result = mysql_query($sql);
if (!$result) { die('Invalid query: ' . mysql_error()); } $r = "?msg=Transaction Confirm!"; } } else { //header("Location: stockin.php?prodid=$prodid&qty=$qty&msg=Product not found!"); $r = "?prodid=$prodid&qty=$qty&msg=Product not found!"; } }
*/ header("Location: purchasestockin.php$r"); ?>
|