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 $formid = $_REQUEST['formid']; require_once "inc/configure.php";
if(havePermission("BMu")==false){ myerror("Invalid Permission"); }
$act = filter_var($_REQUEST['act'], FILTER_SANITIZE_STRING); $drawing_no = filter_var($_REQUEST['drawing_no'], FILTER_SANITIZE_STRING);
//vdump($_REQUEST); exit;
if( $_REQUEST['action']=="dgn_extrabom_modify" && !empty($drawing_no) ){ //generals $bomname = filter_var($_REQUEST['bomname'], FILTER_SANITIZE_STRING); $pdt_moldno = filter_var($_REQUEST['pdt_moldno'], FILTER_SANITIZE_STRING); $est_price = (float)filter_var($_REQUEST['est_price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $qtn_price = (float)filter_var($_REQUEST['qtn_price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $createby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
//insert bom header $sql_param = array(':pdt_moldno' => $pdt_moldno, ':drawing_no' => $drawing_no, ':bomname' => $bomname, ':createby' => $createby, ':lastupby' => $lastupby); if(havePermission("PPu")){ $sql_GPu_field="est_price, qtn_price, ";
$sql_GPu_val=":est_price, :qtn_price, "; $sql_param[':est_price'] = $est_price; $sql_param[':qtn_price'] = $qtn_price; } $sql = "INSERT INTO dgn_extra_bom (pdt_moldno, drawing_no, bomname, $sql_GPu_field createby, createdate, lastupby, lastupdate ) Values ( :pdt_moldno, :drawing_no, :bomname, $sql_GPu_val :createby, GETDATE(), :lastupby, GETDATE())"; $sth = $dbh->prepare($sql);
$q= $sth->execute( $sql_param ); //echo $sth->getSQL( $sql_param ); //exit; pdo_showerror($sth, $q); $refid = $dbh->lastInsertId(); // insert bom detail if(!empty($_REQUEST['bom_detail'])){ $sql = "INSERT INTO dgn_extra_bom_dtl (extrabom_refid, bomcategy, itemnoid, qty, uom_qty, price, uom_price, unitprice, createby, createdate, lastupby, lastupdate) Values(:extrabom_refid, :bcategy, :itemnoid, :qty, :uom_qty, :price, :uom_price, :unitprice, :createby, GETDATE(), :lastupby, GETDATE())"; $sth = $dbh->prepare($sql); foreach($_REQUEST['bom_detail'] as $bom_item){ //vdump($bom_item); $q= $sth->execute( array(':extrabom_refid' => $refid, ':bcategy' => $bom_item['bomcategy'], ':itemnoid' => $bom_item['itemnoid'], ':qty' => (float)$bom_item['qty'], ':uom_qty' => $bom_item['uom_qty'], ':price' => 0, ':uom_price' => $bom_item['uom_price'], ':unitprice' => 0, ':createby' => $createby, ':lastupby' => $lastupby) ); pdo_showerror($sth, $q); /* echo $sth->getSQL( array(':mold_refid' => $refid, ':bcategy' => $bom_item['bomcategy'], ':itemnoid' => $bom_item['itemnoid'], ':qty' => $bom_item['qty'], ':uom_qty' => $bom_item['uom_qty'], ':price' => $bom_item['price'], ':uom_price' => $bom_item['uom_price'], ':unitprice' => $bom_item['unitprice'], ':createby' => $createby, ':lastupby' => $lastupby) ) . HTML_EOL;*/ } }
/*// update product to mastermold reference---------------------------
$sql = "SELECT mold_refid from inv_product where refid = :refid"; $sth = $dbh->prepare($sql); $q= $sth->execute( array(':refid'=> $productrefid) ); pdo_showerror($sth, $q); //echo $sth->getSQL( array(':refid'=> $productrefid) ); pdo_showerror($sth, $q); $oldmold = $sth->fetch(); //var_dump($oldmold);
//update mastermold link of all related product $sql = "UPDATE inv_product SET mold_refid = :newrefid where mold_refid = :oldrefid"; $sth = $dbh->prepare($sql);
$q= $sth->execute( array(':newrefid'=> $refid, ':oldrefid'=> $oldmold['mold_refid']) ); //echo $sth->getSQL( array(':newrefid'=> $refid, ':oldrefid'=> $oldmold['mold_refid']) ); pdo_showerror($sth, $q); */
//header("Location: dgn_master_index.php?act=resume&refid=$refid&msg=Saved."); header("Location: iframe_dgn_extrabom_modifyform.php?action=$act&edit=1&refid=$refid&drawing_no=$drawing_no&formid=$formid&msg=Saved."); print "Saved."; exit; } myerror("Invaild request");
?>
|