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
|
<?php require_once "inc/configure.php";
//$refid = filter_var($_REQUEST['refid'], FILTER_SANITIZE_NUMBER_INT);
//(int)$_REQUEST['productID']; //vdump($_REQUEST); if( $_REQUEST['action']=="material_addform"){ // && !empty($refid) ){ $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'; $weight = (float) filter_var($_REQUEST['weight'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $uom_wt = filter_var($_REQUEST['uom_wt'], FILTER_SANITIZE_STRING); $price = (float) filter_var($_REQUEST['price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $uom_cy = filter_var($_REQUEST['uom_cy'], FILTER_SANITIZE_STRING); /* $thickness = filter_var($_REQUEST['thickness'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $uom_di = filter_var($_REQUEST['uom_di'], FILTER_SANITIZE_STRING); */ $owner = filter_var($_REQUEST['owner'], FILTER_SANITIZE_STRING); $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 "; $sth = $dbh->prepare($sql); $sth->execute( array(':itemno'=> $itemno) ); $row = $sth->fetch(); if( $row['count']>0 ){ $msg="Item Number already existed"; header("Location: inv_material_index.php?error=$msg"); exit; } unset($sth); //add stone $sql = "INSERT INTO inv_material SET itemgp = :itemgp, itemno = :itemno, name_en = :name, name_sc = :cname, mattype = :mattype, matcolor = :matcolor, uom_inventory = :uom_inventory, verified = :verified, createby = :createby, createdate = NOW(), lastupby = :lastupby, lastupdate = NOW()"; if (defined("MSSQL")) { $sql = "INSERT INTO inv_material ( itemgp, itemno, name_en, name_sc, mattype, matcolor, uom_inventory, verified, createby, createdate, lastupby, lastupdate ) Values ( :itemgp, :itemno, :name, :cname, :mattype, :matcolor, :uom_inventory, :verified, :createby, GETDATE(), :lastupby, GETDATE() )"; } $sth = $dbh->prepare($sql); $q = $sth->execute( array(':itemgp' => $itemgp, ':itemno' => $itemno, ':name' => $name, ':cname' => $cname, ':mattype' => $mattype, ':matcolor' => $matcolor, ':uom_inventory' => $uom_inventory, ':verified' => $verified, ':createby' => $createby, ':lastupby' => $lastupby) ); pdo_showerror($sth, $q); $refid = $dbh->lastInsertId(); /*echo $sth->getSQL( array(':itemgp' => $itemgp, ':itemno' => $itemno, ':name' => $name, ':cname' => $cname, ':mattype' => $mattype, ':matcolor' => $matcolor, ':uom_inventory' => $uom_inventory, ':verified' => $verified, ':createby' => $createby, ':lastupby' => $lastupby) ) . HTML_EOL; //exit; */ //header("Location: inv_material_index.php?act=resume&msg=Saved."); form_dest($_REQUEST['godest'], $_REQUEST['formdest']); header("Location: inv_material_modifyform.php?refid=$refid&msg=Saved."); print "Saved."; exit; } print "Invalid Request";
|