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
133
134
135
136
137
|
<?php require_once "inc/configure.php";
$refid = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_NUMBER_INT);
//(int)$_REQUEST['productID']; //vdump($_REQUEST); if( $_REQUEST['action']=="material_modifyform" && !empty($refid) ){ $dbh->beginTransaction(); $itemgp = filter_var($_REQUEST['itemgp'], FILTER_SANITIZE_STRING); //$itemno = filter_var($_REQUEST['itemno'], FILTER_SANITIZE_STRING); //$parentBOM = filter_var($_REQUEST['parentBOM'], FILTER_SANITIZE_STRING); $name = filter_var($_REQUEST['name'], FILTER_SANITIZE_STRING); $cname = filter_var($_REQUEST['cname'], FILTER_SANITIZE_STRING); $mattype = filter_var($_REQUEST['mattype'], FILTER_SANITIZE_STRING); $matcolor = filter_var($_REQUEST['matcolor'], FILTER_SANITIZE_STRING); $verified = filter_var($_REQUEST['verified'], FILTER_SANITIZE_STRING); $uom_inventory = 'gr'; $mastersupplier_refid = filter_var($_REQUEST['default_mastersupplier_refid'], FILTER_SANITIZE_NUMBER_INT); $createby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
//$itemno = getMaterialNo($mattype, $matcolor);
getMaterialName($name, $cname, $mattype, $matcolor); $itemno = $name; // check existance of itemno before insert $sql = "SELECT count(*) as count from inv_material where itemno=:itemno AND refid!=:refid "; $sth = $dbh->prepare($sql); $sth->execute( array(':itemno'=> $itemno, ':refid'=> $refid) ); $row = $sth->fetch(); if( $row['count']>0 ){ $msg="Item Number already existed"; header("Location: inv_material_index.php?error=$msg"); exit; } unset($sth); //modify stone $sql = "UPDATE inv_material SET itemgp = :itemgp, name_en = :name, name_sc = :cname, mattype = :mattype, matcolor = :matcolor, uom_inventory = :uom_inventory, verified = :verified, lastupby = :lastupby, lastupdate = GETDATE() WHERE refid = :refid"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':itemgp' => $itemgp, ':name' => $name, ':cname' => $cname, ':mattype' => $mattype, ':matcolor' => $matcolor, ':uom_inventory' => $uom_inventory, ':verified' => $verified, ':lastupby' => $lastupby, ':refid' => $refid) ); pdo_showerror($sth, $q); /*echo $sth->getSQL( array(':itemgp' => $itemgp, ':itemno' => $itemno, ':name' => $name, ':cname' => $cname, ':mattype' => $mattype, ':matcolor' => $matcolor, ':verified' => $verified, ':lastupby' => $lastupby, ':refid' => $refid) ) . HTML_EOL;*/ // //exit;
//remove rows form supplier_item where itemnoid=40 and bomcategy=diamond $sql = "DELETE from master_supplier_item WHERE itemnoid=:itemnoid AND bomcategy=:bomcategy"; $sth = $dbh->prepare($sql); $sth->execute( array(':itemnoid'=> $refid, ':bomcategy'=> 'material') ); /* echo $sth->getSQL( array(':itemnoid'=> $refid, ':bomcategy'=> 'material') ); */ if(is_array($_REQUEST['supplier'])){ foreach((array)$_REQUEST['supplier'] as $key=>$supplier){ //insert rows if($key>0){ $sql = "INSERT into master_supplier_item ( mastersupplier_refid, itemnoid, itemno, bomcategy, price, uom_cy, uom_qty, supplier_ref, byfactory, createby, createdate, lastupby, lastupdate ) VALUES( :mastersupplier_refid, :itemnoid, :itemno, :bomcategy, :price, :uom_cy, :uom_qty, :supplier_ref, :byfactory, :createby, GETDATE(), :lastupby, GETDATE() )"; $sth = $dbh->prepare($sql); $byfactory = ($supplier['byfactory']==1)? 1:0; $sth->execute( array(':mastersupplier_refid'=> $supplier['mastersupplier_refid'], ':byfactory'=> $byfactory, ':itemnoid'=> $refid, ':itemno'=> $itemno, ':bomcategy'=> 'material', ':price'=> (float) filter_var($supplier['price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION), ':uom_cy'=> filter_var($supplier['uom_cy'], FILTER_SANITIZE_STRING), ':uom_qty'=> filter_var($supplier['uom_qty'], FILTER_SANITIZE_STRING), ':supplier_ref'=> filter_var($supplier['supplier_ref'], FILTER_SANITIZE_STRING), ':createby'=> $createby, ':lastupby'=> $lastupby) ); /* echo $sth->getSQL( array(':mastersupplier_refid'=> $supplier['mastersupplier_refid'], ':itemnoid'=> $refid, ':itemno'=> $itemno, ':bomcategy'=> 'material', ':price'=> (float) filter_var($supplier['price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION), ':uom_cy'=> $supplier['uom_cy'], ':uom_qty'=> $supplier['uom_qty'], ':createby'=> $createby, ':lastupby'=> $lastupby) );*/ } } }
$dbh->commit(); //header("Location: inv_material_index.php?act=resume&refid=$refid&msg=Saved."); form_dest($_REQUEST['godest'], $_REQUEST['formdest']); header("Location: inv_material_modifyform.php?refid=$refid&msg=Saved."); print "Saved."; exit; } print "Invalid Request";
?>
|