/var/www/enzatesting.onesolution.hk/ord_fild_split_checkoutform.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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
<?php 
$formid 
"Order";
require_once 
"inc/configure.php";

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

$refid = (int)setDefaultReqVar("refid"'');
$barcode setDefaultReqVar("barcode"'');

if(
$barcode){
    
$refid = (int)parseJCBarcode($barcode);
    
//echo"BC";
}

if(
$refid){    
    
    
$checkout_info oprReadyForCheckout($refid$opr_param);
    
    
$sql="SELECT
            dbo.ord_dtl.refid,
            dbo.ord_main.refid AS main_refid,
            dbo.ord_main.order_nbr,
            dbo.master_customer.custname_en,
            dbo.master_customer.custname_sc,
            dbo.ord_main.launch_date,
            dbo.ord_main.del_date,
            dbo.ord_dtl.itemno,
            dbo.ord_dtl.qty,
            dbo.ord_dtl.[size],
            dbo.ord_dtl.remark,
            dbo.ord_route.checkin_time,
            dbo.ord_route.checkout_time,
            dbo.ord_txfilo.checkin_wt,
            dbo.ord_txfilo.worker,
            dbo.ord_txfilo.worker_sign,
            dbo.ord_txfilo.checkinacc_wt
            
            FROM
            dbo.ord_main
            INNER JOIN dbo.ord_dtl ON dbo.ord_dtl.main_refid = dbo.ord_main.refid
            INNER JOIN dbo.master_customer ON dbo.ord_main.custcode = dbo.master_customer.custcode
            INNER JOIN dbo.ord_route ON dbo.ord_route.orddtl_refid = dbo.ord_dtl.refid
            INNER JOIN dbo.ord_txmain ON dbo.ord_route.ordtxmain_refid = dbo.ord_txmain.refid
            INNER JOIN dbo.ord_txfilo ON dbo.ord_txfilo.txmain_refid = dbo.ord_txmain.refid
            WHERE
            dbo.ord_dtl.refid = :refid AND
            dbo.ord_route.refid = :opr_refid"
;


    
$sth $dbh->prepare($sql);
    
$sth->execute(  array(':refid' => $refid':opr_refid' => $checkout_info['refid']) );
    
//echo $sth->getSQL(  array(':refid' => $refid) );    
    
$row $sth->fetch();        
    
    
//vdump($checkout_info);
    //checkin time of the whole Job card
/*    $checkout_time = new DateTime($checkout_info['checkin_time']);
    $checkout_duration = $checkout_time->diff( new DateTime("now") ); //compared to NOW
    $act_svc_duration = numf(dateintervalToHour($checkout_duration));*/    



if(
$checkout_info){
  
//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.orddtl_refid = :refid"
;
  
$sth $dbh->prepare($sql);
  
$sth->execute( array(':refid' => $refid) );
  
//get last checkin weight
//$tx = getLastTx($refid);  
//$checkin_weight = weightConv($tx['ttlwt'], $tx['uom_wt'], "gr");

  
while($r $sth->fetch()){
      
//vdump($r);
      //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']) );
          
while($fp $sth2->fetch()){
              
//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'];
          
}
      }
      unset(
$bomcat);
  }
}
else{
    
myerror($msg);
    exit;
    
//header("Location: ord_fild_index.php");
}    


?><!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>ENZA</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<?php require_once "inc/jsheader.php"?>
<script>

$(document).ready(function() {

    $( "#checkout-form" ).dialog({
        autoOpen: false,
        modal: true
    });
    $( "#checkout_trig" ).click(function() {
        $( "#checkout-form" ).dialog( "open" );
    });
    
    $(".focus").focus();
    

/*      $('.sigPad').signaturePad({
          drawOnly:true,
          bgColour: '#EEE',
          lineColour: '#AAA',
          lineTop:500,
          output: '.sign'
      });
      
      var sign_display = $('.sign_display').signaturePad({displayOnly:true});
      
      $('#submit').click(function(){
          alert( $('.sign').val() );
          sign_display.regenerate( $('.sign').val() );
      });*/
      
     
    
});    


function localbind(){
    $('.co_wt').unbind("change, blur");
    $(".co_wt").bind("change, blur", CalculateGrandtotal);
    
    $('.co_time').unbind("change, blur");
    $(".co_time").bind("change, blur", CalculateTime);    
}

function confirmCheckout(){
    return confirm("Are you sure you want to checkout now?");
}

function CalculateGrandtotal(){
    
    var gt=new Number(0);
 
    $( ".co_wt" ).each( function() {
        
        var num = new Number($(this).val());
        gt = gt + num;
    } );
    $("#checkout_wt").val(gt.toFixed(2));    


function CalculateTime(){
    
    var gtime=new Number(0);
 
    $( ".co_time" ).each( function() {
        
        var num = new Number($(this).val());
        //alert(num);
        gtime = gtime + num;
    } );
    //alert(gtime);
    $("#ttl_duration").val(gtime.toFixed(2));    

</script>
</head>
<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 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">    
<?php if($row) { ?> 
            <!--<form action="ord_fild_checkout.php" name="myform" id="myform" method="post" enctype="multipart/form-data" onsubmit="return confirmCheckout()">-->
                          <input type="hidden" name="action" value="ord_fild_checkout" />   
            <?php //if(!empty($row)){ ?><table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr></tr>
                <tr>
                  <td class="c3_bg"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <!--<td width="20" class="separator"><input type="image" src="image/icon_save.jpg" width="20" height="20" /></td>
                        <td width="20" class="separator"><a href="<?=basename($_SERVER['REQUEST_URI'])?>?barcode=<?=$barcode?>"><img src="image/icon_undo.jpg" width="20" height="20" /></a></td>
                     -->

                        <!--<td width="20" class="separator"><img src="image/icon_redo.jpg" width="20" height="20" /></td>
                <td width="20" class="separator"><img src="image/icon_delete.jpg" width="20" height="20" /></td>--> 
                        <!--<td width="20" class="separator"><a href="#" id="print_trig"><span class="ui-icon0 ui-icon-print" ><?=PRINT_?></span></a></td>-->

                        <!--<td width="20" class="separator"><a href="dgn_drawing_print.php?refid=<?=$row['refid']?>" target="_new"><?=PRINT_?></a></td>-->
                        <td class="separator stext1"><?=FILD?>
                          - <span>
                          <?=CHECKOUT?>
                          </span></td>
                        <td class="separator etext1"><?=generateJCBarcode($row['refid'])?>
                          - <span>
                          <?=$row['itemno']?>
                          </span></td>
                        <td width="200" align="right" class="separator etext2"><?=CHECKOUT?>:
                          <?=''//datef($checkout_info['checkin_time'])?></td>
                        <td width="80" align="right" class="separator etext2"><a href="ord_fild_index.php?act=resume" onclick0="return ConfirmClose()"><img src="image/icon_close.jpg" width="20" height="20" align="absmiddle" /><?=CLOSE?></a></td>
                      </tr>
                    </table></td>
                </tr>
                <tr>
                  <td valign="top" class="c2_bg"><!--main form--> 
                    
                    
                    
                    <div id="tabs" class="ui-tabs">
                      <ul>
                        <li><a href="#tabs-2">
                          <?=GENERAL?>
                          </a></li>
                        <li><a href="#tabs-4">
                          <?=DETAIL?>
                          </a></li>
                      </ul>
                      <div id="scontent">
                        
                          <div id="tabs-2">
                            <table width="100%" border="0">
                              <tr>
                                <td><?=DATE?><?=date("Y-m-d")?></td>
                                <td><?=STATUS?>
                            <?php if($status=="INVALID"){ ?>
                                <span class="ui-state-error xlfont"><?=$msg?></span>
                                <script>
                                $(document).ready(function() {
                                    alert('<?=$msg?>');
                                });
                                </script>    
                            <?php } else {
                                print 
$msg
                            }
?></td>
                                <td><?=CHECKIN?><?=WS?><?=WEIGHT?><?=qtyf($row['checkin_wt'])?>gr</td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td colspan="4">&nbsp;</td>
                              </tr>
                              <tr>
                                <td><?=ORDER?><?=WS?><?=NUMBER?></td>
                                <td><?=ITEMNO?></td>
                                <td><?=QTY?></td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td><?=$row['order_nbr']?></td>
                                <td><a href="#" class="ctip" name="product[itemno]" id="product[itemno]" ctip="ajax_thumb_inv_product.php?itemno=<?=$row['itemno']?>&formid=<?=$formid?>"><?=$row['itemno']?></a></td>
                                <td><?=numf($row['qty'])?></td>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td colspan="4">&nbsp;</td>
                              </tr>
                              <tr>
                                <td colspan="4"><table border="1">        
         <tr>
            <th><?=MOLDNO?></th>
            <th><?=WORKER?></th>
            <th><?=CHECKIN?><?=WS?><?=TIME?></th>            
            <th><?=CHECKIN?><?=WS?><?=WEIGHT?></th>
            <th><?=CHECKOUT?><?=WS?><?=WEIGHT?></th>
            
            <th><?=TIME?></th>
            <th><?=CHECKOUT?></th>
        </tr><?php
                                      
//get more data from database
        
$sql="SELECT
                dbo.ord_txfilo.moldno,
                dbo.ord_txfilo.refid AS txfilo_refid,
                dbo.ord_txfilo.worker,
                dbo.ord_txfilo.worker_sign,
                dbo.ord_txfilo.checkout_time,
                dbo.ord_txfilo.checkin_time,
                dbo.ord_txfilo.checkin_wt,
                dbo.ord_txfilo.checkinacc_wt,
                dbo.ord_txfilo.checkout_wt,
                dbo.ord_txfilo.checkinacc_wt,
                dbo.ord_txfilo.act_svc_duration                    
                FROM
                dbo.ord_txmain
                INNER JOIN dbo.ord_txfilo ON dbo.ord_txfilo.txmain_refid = dbo.ord_txmain.refid
                WHERE
                dbo.ord_txmain.orddtl_refid = :refid AND
                dbo.ord_txmain.opr_code = 'FILO'
                "
;
        
$sth_opr $dbh->prepare($sql);
        
$sth_opr->execute(  array(':refid' => $refid) );
        
//echo $sth_opr->getSQL(  array(':refid' => $refid) );
        
$mnum=0;
        
$ttl_wt=0;
        
$ttl_duration=0;
        while(
$mold=$sth_opr->fetch()){
            
$mnum++;
            
//$ttl_wt += numf($mold['checkin_wt']+$mold['checkinacc_wt']);
            //calculate actual duration of each worker/mold
//vdump($mold);
            
if($mold['checkout_time']){
                
$isfinished true;
                
$act_svc_duration $mold['act_svc_duration'];
            } else {
                
$isfinished false;
                
$checkout_time = new DateTime($mold['checkin_time']);
                
$checkout_duration $checkout_time->diff( new DateTime("now") ); //compared to NOW
                
$act_svc_duration numf(dateintervalToHour($checkout_duration));
            }
            
$ttl_duration += numf($act_svc_duration);    
 
?> 
        <tr>
        <form action="ord_fild_split_checkout.php" method="post">
        <input type="hidden" name="action" value="ord_fild_split_checkout" />   
        <input type="hidden" name="refid" value="<?=$refid?>" />
            <td align="left"><?=$mold['moldno']?><input type="hidden" name="submold[<?=$mnum?>][moldno]" value="<?=$mold['moldno']?>" readonly="readonly" class="shortfield" />
              <input type="hidden" name="submold[<?=$mnum?>][txfilo_refid]" value="<?=$mold['txfilo_refid']?>" readonly="readonly" class="microfield" /><br/>
              <?=showThumb(getSubmoldImg($refid$mold['moldno']))?></td>
            <td><?=$mold['worker']?><input type="hidden" name="submold[<?=$mnum?>][worker]" value="<?=$mold['worker']?>" class="shortfield" readonly="readonly" /></td>
            <td align="center"><?=datef($mold['checkin_time'])?></td>
            <td align="center"><?=numf($mold['checkin_wt']+$mold['checkinacc_wt'])?>gr</td>
            <td><input type="text" name="submold[<?=$mnum?>][checkout_wt]" value="<?=evl(qtyf($mold['checkout_wt']),"0.00")?>" class="positive shortfield co_wt" <?=$input_attr?> />gr</td>
            
            <td><input type="text" name="submold[<?=$mnum?>][act_svc_duration]" value="<?=numf($act_svc_duration)?>" class="positive shortfield co_time" <?=$input_attr?> />hr</td>
             <td><?php if(!$isfinished) {?><input type="submit" value="<?=CHECKOUT?>" class="uibutton pressnhide2" /><?php } else {?><?=datef($mold['checkout_time'])?><?php ?></td>
        </form>
        </tr> <?php ?></table></td>
                              </tr>
                              <tr>
                                <td colspan="4"><!--signature-->&nbsp;
                                </td>
                              </tr> 
                              <tr>
                                <td colspan="4"><?=CHECKOUT?><?=WS?><?=WEIGHT?>: <input type="text" name="ttl_wt" value="0" id="checkout_wt" class="positive shortfield" tabindex="10" />
                                gr<input type="hidden" name="uom_wt" value="gr" readonly="readonly" class="microfield" /></td>
                              </tr> 
                              <tr>
                                <td colspan="4"><?=TIME?>: <input type="text" name="act_svc_duration" value="<?=numf($ttl_duration)?>" id="ttl_duration" class="positive shortfield" readonly="readonly" /><?=HOUR?></td>
                              </tr>  
                              <tr><td>&nbsp;</td></tr>
                              <tr>
                                <td colspan="4">
                                <?php if($fill_part){ ?>
                                <table border="1"><caption class="xlfont0"><b><?=ACCESSORY?></b></caption><tr><th><?=ITEMNO?></th><th><?=NAME?></th><th><?=QTY?></th><th><?=WEIGHT?></th></tr>        
                                        <?php foreach ($fill_part as $p){ ?>

                                <tr>
                                    <td><?=$p['itemno']?></td>
                                    <td><?=$p['name_'.SYS_LANG]?></td>
                                    <td><?=numf($p['opr_svc']*$row['qty'])?><?=$p['uom_svc']?></td>
                                    <td><?=qtyf($p['act_wt'])?>gr</td>                                    
                                </tr>
                                    <?php ?>
                                </table>    
                                <?php ?>
                               </td>
                              </tr>
                            </table>

                          </div>
                          
                          <div id="tabs-4">
                            <p>
</p></div>

                          <input type="hidden" name="last_status" value="<?=$row['status']?>" />
                          <input type="hidden" name="refid" value="<?=$refid?>" id="refid" />
                          <input type="hidden" name="edit" value="<?=$editable?>" id="edit" />
                        
                      </div>
                      <!--end scontent-->

                    </div>
                    
                    
                    
                    <!-- end of mainform--></td>
                  <td valign="top"></td>
                </tr>
              </table>
              <?php //} ?>
              <!--</form>-->
              
              <?php ?></td>
          </tr>
        </table></td>
    </tr>
  </table>

</body>
</html>