/var/www/enzatesting.onesolution.hk/01_20240711_full_backup/ord_fild_deptrpt.php


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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<?php 
$formid 
"Order";
require_once 
"inc/configure.php";

$opr_param['opr_code']    = "FILO";

//default is month start
$_REQUEST['checkin_start'] = setDefaultReqVar("checkin_start"date('Y-m-d') );
//vdump($_REQUEST);

function table_summary(&$ttl$row){
    foreach(
$row as $f=>$v){
        if( 
is_numeric($v) ){
            
$ttl$f ] += $row$f ];
        }
    }
}

function 
filo_getAccessoryCheckinWeight($refid$ordroute_refid){
    
//return $ordroute_refid;
    
global $dbh;
      
//get itemno in FILA
    
$sql "SELECT
          dbo.ord_subroute.refid,
          dbo.ord_subroute.orddtl_refid,
          dbo.ord_subroute.itemno
          
          FROM
          dbo.ord_subroute
          WHERE
          dbo.ord_subroute.opr_code = 'FILA' AND
          dbo.ord_subroute.ordroute_refid = :refid"
;
    
$sth $dbh->prepare($sql);
    
$sth->execute( array(':refid' => $ordroute_refid) );
    
    
//get last checkout weight
    
$tx getLastTx($refid);  
    
$checkin_weight weightConv($tx['ttlwt'], $tx['uom_wt'], "gr");
    
$pickedallFILA true;
    while(
$r $sth->fetch()){
      
//find the itemno in different BOM Cat
      
$bomcat getBomcategy($r['itemno']);
      if(
$bomcat){
      
//get details by itemno and bomcat
            
$sql2="SELECT
                dbo.ord_subroute.refid,
                dbo.ord_subroute.orddtl_refid,
                dbo.ord_subroute.opr_nbr,
                dbo.ord_subroute.opr_code,
                dbo.ord_subroute.ordroute_refid,
                dbo.ord_subroute.opr_svc,
                dbo.ord_subroute.uom_svc,
                dbo.ord_dtl.qty,
                dbo.ord_dtl.product_refid,
                dbo.inv_
$bomcat.itemno,
                dbo.inv_
$bomcat.name_en,
                dbo.inv_
$bomcat.name_sc,
                Sum(dbo.ord_item_bom.weight* dbo.ord_item_bom.qty) * dbo.ord_dtl.qty AS weight,
                dbo.ord_item_bom.uom_wt,
                Sum(dbo.ord_item_bom.actual_qty) AS actual_qty
                
                FROM
                dbo.ord_subroute
                INNER JOIN dbo.ord_dtl ON dbo.ord_subroute.orddtl_refid = dbo.ord_dtl.refid
                INNER JOIN dbo.inv_
$bomcat ON dbo.ord_subroute.itemno = dbo.inv_$bomcat.itemno
                INNER JOIN dbo.ord_item_bom ON dbo.inv_
$bomcat.refid = dbo.ord_item_bom.itemnoid AND dbo.ord_item_bom.orddtl_refid = dbo.ord_dtl.refid
                WHERE
                dbo.ord_subroute.opr_code = 'FILA' AND
                dbo.ord_subroute.itemno = :itemno AND
                dbo.ord_dtl.refid = :refid
                GROUP BY
                dbo.ord_subroute.refid,
                dbo.ord_subroute.orddtl_refid,
                dbo.ord_subroute.opr_nbr,
                dbo.ord_subroute.opr_code,
                dbo.ord_subroute.ordroute_refid,
                dbo.ord_subroute.opr_svc,
                dbo.ord_subroute.uom_svc,
                dbo.ord_dtl.qty,
                dbo.ord_dtl.product_refid,
                dbo.inv_
$bomcat.itemno,
                dbo.inv_
$bomcat.name_en,
                dbo.inv_
$bomcat.name_sc,
                dbo.ord_item_bom.uom_wt
                "
;                  
          
$sth2 $dbh->prepare($sql2);
          
$sth2->execute( array(':refid' => $refid':itemno' => $r['itemno']) );
          
//echo $sth2->getSQL( array(':refid' => $refid, ':itemno' => $r['itemno']) ).HTML_EOL;
          
while($fp $sth2->fetch()){
              if(
$fp['actual_qty']<=0){
                
$pickedallFILA false;  
              }
              
//convert actual weight to unit of gram
              
$fp['act_wt'] = weightConv($fp['actual_qty'], $fp['uom_wt'], "gr");
             
// $fill_part[] = $fp;
              //$checkin_weight += $fp['act_wt'];
              
$acc_act_wt += $fp['act_wt'];
          }
      }
      unset(
$bomcat);
    }
    return 
$acc_act_wt
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?=$system_var['COMPANY_NAME']?></title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<?php require_once "inc/jsheader.php"?>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
</head>
<script>
$(document).ready(function() {
    $( "#checkin_start" ).datepicker({
        dateFormat: "yy-mm-dd",
        showOn: "both",
/*        buttonImage: "images/calendar.gif",
        buttonImageOnly: true,*/
        defaultDate: "<?=$_REQUEST['checkin_start']?>"
    });
    
    $( "#checkin_end" ).datepicker({
        dateFormat: "yy-mm-dd",
        showOn: "both",
/*        buttonImage: "images/calendar.gif",
        buttonImageOnly: true,*/
        defaultDate: "<?=$_REQUEST['checkin_end']?>"
    });

    $( "#checkout_start" ).datepicker({
        dateFormat: "yy-mm-dd",
        showOn: "both",
/*        buttonImage: "images/calendar.gif",
        buttonImageOnly: true,*/
        defaultDate: "<?=$_REQUEST['checkout_start']?>"
    });
    
    $( "#checkout_end" ).datepicker({
        dateFormat: "yy-mm-dd",
        showOn: "both",
/*        buttonImage: "images/calendar.gif",
        buttonImageOnly: true,*/
        defaultDate: "<?=$_REQUEST['checkout_end']?>"
    });                    
    
});    
</script>
<?php //if($halt){ exit; } ?>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top" class="top"><?php require"mod_webhead.php"?></td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="200" valign="top" class="menu_bg"><?php require"mod_menu.php"?>            <br/>
            <span class="mod_menu"><a href="ord_deptcheckinform.php?dept=<?=$opr_param['opr_code']?>" target="_new" class="fboxs uibutton" ><?=DEPARTMENT?><?=WS?><?=CHECKIN?></a></span>
            
            <form action="ord_fild_index.php" name="myform" id="myform" method="post" enctype="multipart/form-data">
                <span class="stext1"><br/><?=JOB_CARD?>:</span><br/>
                <input type="text" name="barcode" class="focus shortfield"  />
                <input type="submit" name="S" value="<?=SUBMIT?>" />
            </form>
            </td>
        <td valign="top" class="padding1">
        
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr></tr>
          <tr>
            <td class="c1_bg">
            <form action="ord_fild_deptrpt.php" method="post">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="search">
              <tr>
                <td width="120" valign="top" ><?=resolveCode_master_operation($opr_param['opr_code'])?>:<br />
                  <span class="stext1"><?=DEPARTMENT.WS.REPORT?>:</span></td>
                <td valign="top">                
                
                <table>
                <tr>
                <td class="stext2"><?=WORKER?></td>
                <td class="stext2" colspan="2"><span id="spryselect1">
                    <select name="worker" id="worker">
                        <option value=""></option>
                        <?=input_masterWorker_option($_REQUEST['worker'], ture'FILD')?>
                    </select></span></td>
                </tr>
                <tr>
                <td class="stext2"><?=CHECKIN?></td>
                <td class="stext2"><input type="text" name="checkin_start" id="checkin_start" value="<?=$_REQUEST['checkin_start']?>" class="shortfield" /></td>
                <td class="stext2"><input type="text" name="checkin_end" id="checkin_end" value="<?=$_REQUEST['checkin_end']?>" class="shortfield" /></td>
                </tr>
                <tr>
                <td class="stext2"><?=CHECKOUT?></td>
                <td class="stext2"><input type="text" name="checkout_start" id="checkout_start" value="<?=$_REQUEST['checkout_start']?>" class="shortfield" /></td>
                <td class="stext2"><input type="text" name="checkout_end" id="checkout_end" value="<?=$_REQUEST['checkout_end']?>" class="shortfield" /></td>
                </tr>                
               
                </table>
</td>
                <td align="right" valign="top"><input type="image" src="image/btn_search.jpg" width="64" height="20" />&nbsp; <!--<a href="ord_dtl_addform.php" ><img src="image/btn_new.jpg" width="52" height="20" /></a>&nbsp;--><a href="<?=basename($_SERVER['PHP_SELF'])?>" title="<?=CLEAR?>"><img src="image/icon_close.jpg" width="20" height="20" align="top" alt="<?=CLEAR?>" /></a></td>
              </tr>

            </table></form>
            </td>
          </tr>
          <tr>
            <td valign="top" class="c2_bg"><table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr>
                <td valign="top">
                <table width="100%" id="product_table" border="0" cellpadding="0" cellspacing="0" class="tablelist floathead">
                  <thead><tr>
                          <th><?=JOB_CARD?></th>
                          <th><?=ORDER?><?=WS?><?=NUMBER?></th>
                        <th><?=CUSTOMER?><?=WS?><?=NAME?></th>
                        <th><?=ITEMNO?></th>
                        <th><?=CHECKIN?><?=WS?><?=TIME?></th>
                        <th><?=CHECKOUT?><?=WS?><?=TIME?></th>
                        <th><?=QTY?></th>
                        <th><?=MATTYPE?></th>
                        <th><?=WEIGHT.WS.IN?></th>
                        <th><?=ACCESSORY.WS.WEIGHT.WS.IN?></th>
                        <th><?=CAST.WS.WEIGHT.WS.OUT?></th>
                        <th><?=ACCESSORY.WS.WEIGHT.WS.OUT?></th>
                        <th><?=WEIGHT.WS.OUT?></th>
                        <th><?=TIME?></th>
                    </tr></thead>
                                                        
<?php
if(true || $_REQUEST['worker']){

    
$sql_clause='';
    if( !empty(
$_REQUEST['worker']) ){
        if(!empty(
$sql_clause)) $sql_clause .= ' AND ';
        
$sql_clause .= 'ord_txfilo.worker = :worker ';
        
$sql_param[':worker'] = $_REQUEST['worker'];            
    }    
    if( !empty(
$_REQUEST['checkin_start']) ){
        if(!empty(
$sql_clause)) $sql_clause .= ' AND ';
        
$sql_clause .= ' ord_txfilo.checkin_time >= :checkin_start ';
        
$sql_param[':checkin_start'] = $_REQUEST['checkin_start'];            
    }    
    if( !empty(
$_REQUEST['checkin_end']) ){
        if(!empty(
$sql_clause)) $sql_clause .= ' AND ';
        
$sql_clause .= ' ord_txfilo.checkin_time <= :checkin_end ';
        
$sql_param[':checkin_end'] = $_REQUEST['checkin_end'];            
    }    
    if( !empty(
$_REQUEST['checkout_start']) ){
        if(!empty(
$sql_clause)) $sql_clause .= ' AND ';
        
$sql_clause .= ' ord_txfilo.checkout_time >= :checkout_start ';
        
$sql_param[':checkout_start'] = $_REQUEST['checkout_start'];            
    }    
    if( !empty(
$_REQUEST['checkout_end']) ){
        if(!empty(
$sql_clause)) $sql_clause .= ' AND ';
        
$sql_clause .= ' ord_txfilo.checkout_time <= :checkout_end ';
        
$sql_param[':checkout_end'] = $_REQUEST['checkout_end'];            
    }        

    
$sql="SELECT
dbo.ord_main.order_nbr,
dbo.ord_main.custcode,
dbo.ord_main.refid as ord_refid,
dbo.ord_dtl.itemno,
dbo.ord_dtl.qty,
dbo.ord_txmain.ttlwt,
dbo.ord_txmain.orddtl_refid,
dbo.ord_route.refid AS ordroute_refid,
dbo.ord_txfilo.*

FROM
dbo.ord_txfilo
INNER JOIN dbo.ord_txmain ON dbo.ord_txfilo.txmain_refid = dbo.ord_txmain.refid
INNER JOIN dbo.ord_dtl ON dbo.ord_txmain.orddtl_refid = dbo.ord_dtl.refid
INNER JOIN dbo.ord_main ON dbo.ord_dtl.main_refid = dbo.ord_main.refid
INNER JOIN dbo.ord_route ON dbo.ord_route.ordtxmain_refid = dbo.ord_txmain.refid
WHERE 
$sql_clause
ORDER BY dbo.ord_txfilo.checkin_time ASC"
;    
    
    
$sth $dbh->prepare($sql);
    
$q $sth->execute$sql_param );
//echo $sth->getSQL( $sql_param ) . HTML_EOL;
    
pdo_showerror($sth$q);
    
$ttl= array();            
    while(
$row $sth->fetch()) {    
        if(
$row['checkoutgold_wt']>0){
            
$row['checkoutacc_wt'] = $row['checkout_wt']-$row['checkoutgold_wt'];
        }else{
            
$row['checkoutacc_wt'] = 0;    
            
$row['checkoutgold_wt'] = $row['checkout_wt'];
        }
        
$row['checkinacc_wt'] = filo_getAccessoryCheckinWeight($row['orddtl_refid'], $row['ordroute_refid']);
        
table_summary($ttl$row);?>
                  <tr>
                        <td class="code"><?=ord_htmllink_jobcard($row['orddtl_refid'], false'class="fbox"')?></td>
                        <td class="code"><?=ord_htmllink_order($row['ord_refid'], $row['order_nbr'], 'class="fbox"')?></td>
                        <td><?=resolveCode_masterCustomer($row['custcode'])?></td>
                        <td class="code"><span class="ctip" ctip="ajax_thumb_inv_product.php?itemno=<?=$row['itemno']?>&formid=<?=$formid?>"><?=$row['itemno']?></span></td>
                        <td><?=datef($row['checkin_time'])?></td>
                        <td><?=datef($row['checkout_time'])?></td>
                        <td class="tdalignright"><?=numf($row['qty'])?></td>
                        <td class="tdalignmid"><?=master::resolveMattypeorddtl_getMattype($row['orddtl_refid']) )?></td>
                        <td class="tdalignright"><?=numf($row['checkin_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($row['checkinacc_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($row['checkoutgold_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($row['checkoutacc_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($row['checkout_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($row['act_svc_duration'],3)?></td>
                  </tr>
            <?php ?>
<?php 
} else{
 
//echo MISSING.WS.WORKER;    
//vdump($ttl);?>            
                <!--summary row-->
                <tfoot class="xfont">
                  <tr>
                        <td><?=TOTAL?></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td class="tdalignright"><?=numf($ttl['qty'])?></td>
                        <td>&nbsp;</td>
                        <td class="tdalignright"><?=numf($ttl['checkin_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($ttl['checkinacc_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($ttl['checkoutgold_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($ttl['checkoutacc_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($ttl['checkout_wt'],3)?></td>
                        <td class="tdalignright"><?=numf($ttl['act_svc_duration'],3)?></td>
                  </tr>
                </tfoot>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<script type="text/javascript">
//var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["blur", "change"]});
</script>
</body>
</html>