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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
<?php $formid = "Inventory"; require_once "inc/configure.php";
if(havePermission("STu")==false){ myerror(INVALID.WS.PERMISSION); }
function copyLastStocktake_data($companyid, $bomcategy, $refid){ global $dbh; $LastStocktakeID = inv_getLastStocktakeID($companyid); $CurrentStocktakeID = inv_getCurrentStocktakeID($companyid); $table = inv_getBomcategyTablename($bomcategy); $inv_item = getDB($table, $refid); //use safe value for new stock take $uom_qty = filter_var($_REQUEST['uom_qty'], FILTER_SANITIZE_STRING); $uom_wt = filter_var($_REQUEST['uom_wt'], FILTER_SANITIZE_STRING); if( $bomcategy == "accessory" ){ $price = accessoryUnitPrice($refid); }else if($location==$system_var['COMPANY_OVERSEA']){ $price = (float) filter_var($inv_item['supplier_price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); }else{ $price = (float) filter_var($inv_item['price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); } $uom_price = filter_var($inv_item['uom_price'], FILTER_SANITIZE_STRING); $uom_cy = filter_var($inv_item['uom_cy'], FILTER_SANITIZE_STRING); $createby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); //$invno = filter_var($_REQUEST['invno'], FILTER_SANITIZE_STRING); //$location = filter_var($_REQUEST['location'], FILTER_SANITIZE_STRING); //$location = evl($location, "SAF"); $sql = "SELECT * FROM inv_stocktake_raw WHERE bomcategy = :bomcategy AND itemid = :itemid AND invstocktake_refid = :invstocktake_refid";
$sth = $dbh->prepare($sql); $q= $sth->execute( array(':invstocktake_refid' => $LastStocktakeID, ':bomcategy' => $bomcategy, ':itemid' => $refid) ); /*echo $sth->getSQL( array(':orddtl_refid' => $orddtl_refid, ':qty' => $qty) ); */ pdo_showerror($sth, $q); while($row = $sth->fetch()){ //add record $sql2 = "INSERT into inv_stocktake_raw( invno, location, bomcategy, itemid, input_qty, uom_qty, input_wt, uom_wt, invstocktake_refid, price, uom_price, uom_cy, createby, createdate, lastupby, lastupdate ) VALUES ( :invno, :location, :bomcategy, :itemid, :input_qty, :uom_qty, :input_wt, :uom_wt, :invstocktake_refid, :price, :uom_price, :uom_cy, :createby, GETDATE(), :lastupby, GETDATE() )"; $sth2 = $dbh->prepare($sql2); $q = $sth2->execute( array(':invno'=> $row['invno'], ':location'=> $row['location'], ':bomcategy'=> $bomcategy, ':itemid'=> $refid, ':input_qty'=> $row['input_qty'], ':uom_qty'=> $uom_qty, ':input_wt'=> $row['input_wt'], ':uom_wt'=> $uom_wt, ':createby'=> $createby, ':lastupby'=> $lastupby, ':price'=> $price, ':uom_price'=> $inv_item['uom_price'], ':uom_cy'=> $inv_item['uom_cy'], ':invstocktake_refid'=> $CurrentStocktakeID) ); /* echo $sth2->getSQL( array(':invno'=> $invno, ':location'=> $location, ':bomcategy'=> $bomcategy, ':itemid'=> $refid, ':input_qty'=> $input_qty, ':uom_qty'=> $uom_qty, ':input_wt'=> $input_wt, ':uom_wt'=> $uom_wt, ':createby'=> $createby, ':lastupby'=> $lastupby, ':invstocktake_refid'=> $CurrentStocktakeID) );*/ pdo_showerror($sth2, $q); } }
$companyid = filter_var($_REQUEST['companyid'], FILTER_SANITIZE_STRING); $bomcategy = filter_var($_REQUEST['bomcategy'], FILTER_SANITIZE_STRING); $refid = filter_var($_REQUEST['refid'], FILTER_SANITIZE_NUMBER_INT); //(int)$_REQUEST['productID']; //vdump($_REQUEST); //exit; if( $_REQUEST['action']=="inv_stocktake_rawmat_unchange" && !empty($refid) && !empty($bomcategy) ){ //http://localhost/enza/invstocktake_rawmat_unchanged.php?action=inv_stocktake_rawmat_unchange&bomcategy=stone&refid=1281 $dbh->beginTransaction();
//check if this item has at least one transaction after last stocktake //if( inv_no_movement($bomcategy, $refid) ){ copyLastStocktake_data($companyid, $bomcategy, $refid); //} inv_disableNoStocktake($bomcategy, $refid);
//exit; $dbh->commit(); //header("Location: invstocktake_diamond_modifyform.php?refid=$refid&msg=Saved."); print SAVED; exit; } myerror(INVALID.WS.REQUEST); exit;
?>
|