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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
<?php $formid = "Order"; require_once "inc/configure.php";
/* deprecated functions */ function splitFinishedCheckout($orddtl_refid){ global $dbh; $sql = "SELECT Count(dbo.ord_txseto.refid) as counter FROM dbo.ord_txmain INNER JOIN dbo.ord_txseto ON dbo.ord_txseto.txmain_refid = dbo.ord_txmain.refid WHERE dbo.ord_txmain.orddtl_refid = :refid AND dbo.ord_txmain.opr_code = 'SETO' AND (dbo.ord_txseto.checkout_time IS NULL OR dbo.ord_txseto.checkout_time = '')"; $sth = $dbh->prepare($sql); $q = $sth->execute( array( ':refid' => $orddtl_refid) ); /*echo $sth->getSQL( array( ':refid' => $orddtl_refid) ).HTML_EOL; */ $row = $sth->fetch(); return $row['counter']==0; }
function seto_getTxsetoSummary($refid, $opr_param){ global $dbh; // get the split weight from subtable $sql = "SELECT Sum(dbo.ord_txseto.checkout_wt) AS ttl_wt, Sum(dbo.ord_txseto.act_svc_duration) AS ttl_duration, Sum(dbo.ord_txseto.txqty) as ttl_qty FROM dbo.ord_txseto WHERE dbo.ord_txseto.txmain_refid = :refid "; $sth = $dbh->prepare($sql); $q = $sth->execute( array( ':refid' => $opr_param['txmain_refid']) ); /* $ttl_wt = 0; while($row=$sth->fetch()){ $ttl_wt += $row['checkout_wt']; }*/ $row=$sth->fetch(); //vdump($row); return $row; }
function getTxseto($refid){ global $dbh; $sql = "SELECT * FROM dbo.ord_txseto WHERE refid = :refid "; $sth = $dbh->prepare($sql); $q = $sth->execute( array( ':refid' => $refid) ); $row=$sth->fetch(); return $row; }
function updateTxmain($orddtl_refid){} /* end of deprecated functions */
function getTxsetoByGroup($groupsig, $moldno){ global $dbh; $sql = "SELECT * FROM dbo.ord_txseto WHERE moldno = :moldno AND groupsig = :groupsig"; $sth = $dbh->prepare($sql); $q = $sth->execute( array( ':groupsig' => $groupsig, ':moldno' => $moldno) ); //echo $sth->getSQL( array( ':groupsig' => $groupsig, ':moldno' => $moldno) ); $rows=$sth->fetchAll(); //vdump($rows); return $rows; }
function seto_checkoutPartial($orddtl_refid, $opr_param){ //write tx details to subtable global $dbh; foreach($opr_param['tx'] as $tx){ $summary = $opr_param['summary'][$tx['moldno']]; //vdump($tx['moldno'], $summary); if( $summary['checkout'] && $summary['checkout_wt']>0&& !empty($summary['groupsig']) && !empty($tx['moldno']) && !empty($tx['groupsig']) && $tx['validforcheckout']>0 && $summary['groupsig']==$tx['groupsig'] ){ // submold and groupsign required //vdump($tx); $sql = "UPDATE ord_txseto SET act_svc_duration = :act_svc_duration, checkout_wt = :checkout_wt, checkout_time = GETDATE(), lastupby = :lastupby, lastupdate = GETDATE() WHERE checkout_time IS NULL AND moldno = :moldno AND groupsig = :groupsig"; $sth = $dbh->prepare($sql); $q = $sth->execute( array(':act_svc_duration' => (float)filter_var($summary['act_svc_duration'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), ':checkout_wt' => (float)filter_var($summary['checkout_wt'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), ':moldno' => filter_var($tx['moldno'], FILTER_SANITIZE_STRING), ':groupsig' => filter_var($summary['groupsig'], FILTER_SANITIZE_STRING), ':lastupby' => $opr_param['lastupby']) ); /* echo $sth->getSQL( array( ':refid' => (int)filter_var($tx['refid'], FILTER_SANITIZE_STRING), ':act_svc_duration' => (float)filter_var($summary['act_svc_duration'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), ':checkout_wt' => (float)filter_var($summary['checkout_wt'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), ':moldno' => filter_var($tx['moldno'], FILTER_SANITIZE_STRING), ':groupsig' => filter_var($summary['groupsig'], FILTER_SANITIZE_STRING), ':lastupby' => $opr_param['lastupby']) ).HTML_EOL;*/ pdo_showerror($sth, $q); if($sth->rowCount()>0){ //add qty back to subroute as act_opr_svc (require extra hidden field in the checkout form $tx['ordsubroute_refid']) if( $txseto = getTxsetoByGroup(filter_var($summary['groupsig'], FILTER_SANITIZE_STRING), filter_var($tx['moldno'], FILTER_SANITIZE_STRING)) ){ if(is_array($txseto)){ foreach($txseto as $row){ //vdump($row); $sql = "UPDATE ord_subroute SET act_opr_svc = ISNULL(act_opr_svc, 0) + :qty, lastupdate = GETDATE(), lastupby = :lastupby WHERE refid = :refid"; $sth = $dbh->prepare($sql); $q = $sth->execute( array( ':refid' => (int)filter_var($row['ordsubroute_refid'], FILTER_SANITIZE_STRING), ':qty' => filter_var($row['txqty'], FILTER_SANITIZE_STRING), ':lastupby' => $opr_param['lastupby']) ); /* echo $sth->getSQL( array( ':refid' => (int)filter_var($row['ordsubroute_refid'], FILTER_SANITIZE_STRING), ':qty' => filter_var($row['txqty'], FILTER_SANITIZE_STRING), ':lastupby' => $opr_param['lastupby']) ).HTML_EOL;*/ pdo_showerror($sth, $q); } } } } } } }
$refid = (int) filter_var($_REQUEST['refid'], FILTER_SANITIZE_STRING); //$txmain_refid = (int) filter_var($_REQUEST['txmain_refid'], FILTER_SANITIZE_STRING); if( $_POST['action']=="ord_setd_split_checkout" && !empty($refid) ){ //vdump($_REQUEST); exit; $opr_param['opr_code'] = "SETO"; //check the job card status to ensure the JC is ready to checkin $opr = oprReadyForCheckout($refid, $opr_param, $status); $opr_param['subtable'] = "ord_txseto"; //$opr_param['php_function'] = "seto_checkin"; $opr_param['summary'] = $_REQUEST['mold']; //array $opr_param['tx'] = $_REQUEST['submold']; //array $opr_param['checkout_wt'] = (float)filter_var($_REQUEST['checkout_wt'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); $opr_param['createby'] = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $opr_param['lastupby'] = filter_var($_SESSION['user'], FILTER_SANITIZE_STRING); $opr_param['txmain_refid'] = (int) filter_var($opr['ordtxmain_refid'], FILTER_SANITIZE_STRING); //vdump($opr_param); //exit; if($status=="OK"){ echo"checkout now"; //update some submold details $dbh->beginTransaction(); seto_checkoutPartial($orddtl_refid, $opr_param);
//exit; $dbh->commit(); form_dest($_REQUEST['godest'], $_REQUEST['formdest']); header("Location: ord_setd_split_checkoutform.php?refid=$refid&msg=Saved."); print "Saved."; exit; } if($opr === false){ myerror("Unable to checkout: " . $msg); exit; header("Location: ord_setd_modifyform.php?refid=$refid"); } else{
/* var_dump($opr); exit; $dbh->beginTransaction(); $checkin_time = ord_checkin($refid, $opr['refid'], $opr_param); //exit; $dbh->commit(); //exit; header("Location: ord_fild_index.php?refid=$refid&msg=Saved."); print "Saved.";*/ myerror("Invalid Request"); exit; } } myerror("Invalid Request");
?>
|