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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
<?php $formid = "Order"; require_once "inc/configure.php";
function getIvcSummary($refid){ global $dbh; $sql = "SELECT sum(dbo.ivc_rawmat_dtl.unit_price * dbo.ivc_rawmat_dtl.qty) as ttl_price FROM dbo.ivc_rawmat_dtl WHERE dbo.ivc_rawmat_dtl.ivcrawmatmain_refid = :refid"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':refid' => $refid) ); //echo $sth->getSQL( array(':refid' => $refid) ); $row = $sth->fetch(); pdo_showerror($sth, $q);
return $row; } //getIvcSummary(5); //exit;
function updateIvcSummary($refid){ global $dbh; $summary = getIvcSummary($refid); $sql = "UPDATE ivc_rawmat_main SET ttl_price = :ttl_price, uom_cy = :uom_cy, lastupby = :lastupby, lastupdate = GETDATE() WHERE refid = :refid"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':ttl_price' => (float)filter_var($summary['ttl_price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION), ':uom_cy' => filter_var('USD', FILTER_SANITIZE_STRING), ':lastupby' => filter_var($_SESSION['user'], FILTER_SANITIZE_STRING), ':refid' => $refid) ); pdo_showerror($sth, $q); }
$ivc_customer = filter_var($_REQUEST['ivc_customer'], FILTER_SANITIZE_STRING);
if( $_POST['action']=="ivc_rawmat_addform" && !empty($ivc_customer) ){ //vdump($_REQUEST);// exit;
$status = filter_var($_REQUEST['status'], FILTER_SANITIZE_STRING); $launch_date = filter_var($_REQUEST['launch_date'], FILTER_SANITIZE_STRING); $due_date = filter_var($_REQUEST['due_date'], FILTER_SANITIZE_STRING); $companyid = filter_var($_REQUEST['companyid'], FILTER_SANITIZE_STRING); $createby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $lastupby = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING);
//$ivc_nbr = generateIvcftyNbr($ivc_customer); $issue_ivcnbr = filter_var($_REQUEST['issue_ivcnbr'], FILTER_SANITIZE_STRING); if($issue_ivcnbr){ list($ivc_nbr, $seq) = cusivc_getNewIvcNbrSeq("ivc_rawmat", $companyid); }
$dbh->beginTransaction(); //create new invoice $sql = "INSERT into ivc_rawmat_main( ivc_nbr, ivc_customer, launch_date, due_date, status, companyid, createby, createdate, lastupby, lastupdate, seq ) VALUES ( :ivc_nbr, :ivc_customer, :launch_date, :due_date, :status, :companyid, :createby, GETDATE(), :lastupby, GETDATE(), :seq )"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':ivc_nbr' => $ivc_nbr, ':seq' => $seq, ':ivc_customer' => $ivc_customer, ':launch_date' => $launch_date, ':due_date' => $due_date, ':companyid' => $companyid, ':status' => $status, ':createby' => $createby, ':lastupby' => $lastupby) ); /*echo $sth->getSQL( array(':ivc_nbr' => $ivc_nbr, ':ivc_customer' => $ivc_customer, ':launch_date' => $launch_date, ':due_date' => $due_date, ':status' => $status, ':createby' => $createby, ':lastupby' => $lastupby) );*/ pdo_showerror($sth, $q); $refid = $dbh->lastInsertId();
//vdump($seq, $ivc_nbr);
foreach ($_REQUEST['invoice_check'] as $key => $value){ if($key>0 && !empty($value) && $value['checked'] && $value['qty']>0){ //vdump($value); //continue; $po_dtl = getDB("ord_podtl", $value['refid']); $po_main = getDB("ord_pomain", $po_dtl['pomain_refid']); //vdump($po_main['pono']); $table = inv_getBomcategyTablename($po_dtl['bomcategy']); $item = getDB($table, $po_dtl['itemnoid']);
if($po_dtl['uom_qty']==$item['uom_wt']){ $received = poset_getReceivedPOWt($po_dtl['refid']); } else { $received = poset_getReceivedPOQty($po_dtl['refid']); } $qty = (float)filter_var($value['qty'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); $unit_price = (float)filter_var($value['unit_price'], FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); //update txpako status to OCCUPIED $sql = "INSERT INTO ivc_rawmat_dtl( ivcrawmatmain_refid, ordpodtl_refid, itemno, bomcategy, itemnoid, qty, uom_qty, wt, uom_wt, status, unit_price, uom_cy, uom_unitprice, buyer_reference, createby, createdate, lastupby, lastupdate, companyid ) VALUES ( :ivcrawmatmain_refid, :ordpodtl_refid, :itemno, :bomcategy, :itemnoid, :qty, :uom_qty, :wt, :uom_wt, :status, :unit_price, :uom_cy, :uom_unitprice, :buyer_reference, :createby, GETDATE(), :lastupby, GETDATE(), :companyid )"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':ivcrawmatmain_refid' => $refid, ':ordpodtl_refid' => $po_dtl['refid'], ':itemnoid' => $item['refid'], ':itemno' => $item['itemno'], ':bomcategy' => $po_dtl['bomcategy'], ':qty' => $qty, ':uom_qty' => $po_dtl['uom_qty'], ':wt' => $po_dtl['wt'], ':uom_wt' => $po_dtl['uom_wt'], ':status' => 'NEW', ':unit_price' => $unit_price, ':uom_cy' => $po_dtl['uom_cy'], ':uom_unitprice' => $po_dtl['uom_unitprice'], ':buyer_reference' => $po_main['pono'], ':createby' => $createby, ':lastupby' => $lastupby, ':companyid' => $companyid) ); /* echo $sth->getSQL( array(':ivcrawmatmain_refid' => $refid, ':ordpodtl_refid' => $po_dtl['refid'], ':itemnoid' => $item['refid'], ':itemno' => $item['itemno'], ':bomcategy' => $po_dtl['bomcategy'], ':qty' => $received, ':uom_qty' => $po_dtl['uom_qty'], ':wt' => $po_dtl['wt'], ':uom_wt' => $po_dtl['uom_wt'], ':status' => 'NEW', ':unit_price' => $unit_price, ':uom_cy' => $po_dtl['uom_cy'], ':uom_unitprice' => $po_dtl['uom_unitprice'], ':buyer_reference' => $po_main['pono'], ':createby' => $createby, ':lastupby' => $lastupby, ':companyid' => $companyid) ); */ pdo_showerror($sth, $q); } }
updateIvcSummary($refid);
//exit; $dbh->commit();
//echo "msg=$msg"; //exit; form_dest($_REQUEST['godest'], $_REQUEST['formdest']); header("Location: ivc_rawmat_modifyform.php?refid=$refid&msg=Saved."); print "Saved."; exit; } print INVAILD.WS.REQUEST;
?>
|