/var/www/enzatesting.onesolution.hk/01_20240711_full_backup/ord_setd_index.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
<?php
$formid 
"Order";
require_once 
"inc/configure.php";
session_start();
//echo"BEFORE req sess cust"; vdump($_REQUEST['customer'], $_SESSION['search']['order'], $_REQUEST['customer']);
$opr_param['opr_code'] = "SETO";
search_orderField($_REQUEST['act'], $_REQUEST['customer'] );
//echo"AFTER req sess"; vdump($_REQUEST['customer'], $_SESSION['search']['order']);
$refid = (int)setDefaultReqVar("refid"'');
$barcode setDefaultReqVar("barcode"'');

$msg setDefaultReqVar("msg"'');
if(
$msg){
    
$msg_header "&msg=$msg";
}

if(
$barcode){
    
$refid = (int)parseJCBarcode($barcode);
}

if(empty(
$refid)){
    goto 
index;
}

function 
isSplitSETO($refid$txmain_refid){
    
//return false;
    
global $dbh;
    
// update route
    
$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.refid = :txmain_refid AND
            dbo.ord_txmain.opr_code = 'SETO' "
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array(    ':refid' => $refid':txmain_refid' => $txmain_refid) );
    
//echo $sth->getSQL(  array(    ':refid' => $refid, ':txmain_refid' => $txmain_refid) );
    
$row $sth->fetch();
    return 
$row['counter']>1;
}

function 
splitIsReadyForCheckout($orddtl_refid){
    return 
false//user click checkout button to checkout
    
global $dbh;
    
// update route
    
$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.checkin_time IS NULL OR
            dbo.ord_txseto.checkin_time = '')"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute(  array(    ':refid' => $orddtl_refid) );
    
$row $sth->fetch();
    return 
$row['counter']==0;
}
$opr ord_nextOprDept($refid);
/*$checkin_info = oprReadyForCheckin($refid, $opr_param, $status);
$checkout_info = oprReadyForCheckout($refid, $opr_param, $status);*/
//vdump($opr); vdump( isSplitSETO($refid, $opr['ordtxmain_refid']) ); exit;
if( $status=="INVALID" ){ //next operation is not FILO
    
echo("Location: ord_setd_modifyform.php?refid=$refid$msg_header");
    
header("Location: ord_setd_modifyform.php?refid=$refid$msg_header");
    exit;
}

if( 
isSplitSETO($refid$opr['ordtxmain_refid']) ){ //started split

    
if( splitIsReadyForCheckout($refid) ){ //checkout
        //vdump($checkout_info);
        
echo("Location: ord_setd_split_checkoutform.php?refid=$refid$msg_header");
        
header("Location: ord_setd_split_checkoutform.php?refid=$refid$msg_header");
        exit;
    }else{ 
//checkout
        
echo ("Location: ord_setd_split_resumeform.php?refid=$refid$msg_header");
        
header("Location: ord_setd_split_resumeform.php?refid=$refid$msg_header");
        exit;
    }

}elseif( 
$checkout_info oprReadyForCheckout($refid$opr_param$status)){ //single checkout

    
echo("Location: ord_setd_checkoutform.php?refid=$refid$msg_header");
    
header("Location: ord_setd_checkoutform.php?refid=$refid$msg_header");
    exit;

}
else{ 
//single checkin OR next operation is not FILO
    
echo ("Location: ord_setd_modifyform.php?refid=$refid$msg_header");
    
//vdump($checkout_info); exit;

    
header("Location: ord_setd_modifyform.php?refid=$refid$msg_header");
    exit;

}

header("Location: ord_setd_modifyform.php");
exit;


index:
?>
<!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" />
<?php require_once "inc/jsheader.php"?>
<script>
$(document).ready(function() {
    $(".focus").focus();
});
</script>
</head>

<?=wip_transferWarning($opr_param$haltfalse);?>

<?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>
            <br/><br/>
            <span class="mod_menu"><a href="ord_txpending_index.php?dept=<?=$opr_param['opr_code']?>" target="_new" class="uibutton" ><?=MATERIAL.WS.RECEIVE?></a></span>

            <form action="<?=basename($_SERVER['REQUEST_URI'])?>" 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_setd_index.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"><?=JOB_CARD?>:</span></td>
                <td valign="top">

                <table>
                <tr>
                <td class="stext2"><?=CUSTOMER?></td>
                <td class="stext2" colspan="2"><select name="customer" id="customer">
                                  <option value=""></option>
                                  <?=customer_option($_REQUEST['customer'], true)?>
                                </select></td>
                </tr>
                <tr>
                <td class="stext2"><?=WORKER?></td>
                <td class="stext2" colspan="2"><select name="worker" id="worker">
                                  <option value=""></option>
                                  <?=input_masterWorker_option($_REQUEST['worker'], ture'SETD')?>
                                </select></td>
                </tr>
                <tr>
                <td class="stext2"><?=NOT_CHECKIN?></td>
                <td class="stext2" colspan="2"><input type="checkbox" name="not_checkin" <?=checkboxChecked($_REQUEST['not_checkin'])?> /></td>
                </tr>
<!--                <tr>
                <td class="stext2"><?=STATUS?></td>
                <td class="stext2" colspan="2"><select name="status" id="status"><option value=""></option><?=master_option("ORDER_STATUS"$_REQUEST['status'], true)?></select></td>
                </tr>

                <tr>
                <td class="stext2"><?=LAUNCH_DATE?></td>
                <td class="stext2"><input type="text" name="launchdate_start" id="launchdate_start" value="<?=$_REQUEST['launchdate_start']?>" class="shortfield" /></td>
                <td class="stext2"><input type="text" name="launchdate_end" id="launchdate_end" value="<?=$_REQUEST['launchdate_end']?>" class="shortfield" /></td>
                </tr>

                <tr>
                <td class="stext2"><?=DELIVERY?><?=WS?><?=DATE?></td>
                <td class="stext2"><input type="text" name="deliverydate_start" id="deliverydate_start" value="<?=$_REQUEST['deliverydate_start']?>" class="shortfield" /></td>
                <td class="stext2"><input type="text" name="deliverydate_end" id="deliverydate_end" value="<?=$_REQUEST['deliverydate_end']?>" class="shortfield" /></td>
                </tr>

                <tr>
                <td class="stext2"><?=FINISHED?></td>
                <td class="stext2" colspan="2"><input type="checkbox" name="finished" <?=empty($_REQUEST['finished'])?'':'checked="checked"'?>  /></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><br /><br />
                  <span class="mod_menu"><a href="ord_setd_deptrpt.php" class="uibutton"><?=DEPARTMENT.WS.REPORT?></a></span></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">
                  <tr>
                          <th><?=JOB_CARD?></th>
                          <th><?=ORDER?><?=WS?><?=NUMBER?></th>
                        <th><?=STATUS?></th>
                        <th><?=CUSTOMER?><?=WS?><?=NAME?></th>
                        <th><?=DELIVERY?><?=WS?><?=DATE?></th>
                        <th><?=ITEMNO?></th>
                        <th><?=DEPARTMENT?><?=WS?><?=CHECKIN?><!--<?=WS?><?=TIME?>--></th>
                        <th><?=CHECKIN?><?=WS?><?=TIME?></th>
                        <!--<th><?=CHECKOUT?><?=WS?><?=TIME?></th>-->
                        <th><?=QTY?></th>
                        <th><?=MATTYPE?></th>
                        <th><?=WEIGHT?><?=WS?><?=IN?></th>
                        <th><?=WORKER?></th>
                        <th><?=EXPECTED?><?=WS?><?=FINISH?><?=WS?><?=DATE?></th>
                    </tr>

<?php
    $sql_param
[':opr_code'] = $opr_param['opr_code'];

    
$sql_clause='';
    if( !empty(
$_REQUEST['customer']) ){
        
$sql_clause .= ' AND dbo.ord_main.custcode = :customer ';

        
$sql_param[':customer'] = $_REQUEST['customer'];
    }
    if( !empty(
$_REQUEST['worker']) ){
        
$sql_clause .= ' AND worker = :worker ';

        
$sql_param[':worker'] = $_REQUEST['worker'];
    }
    if( !empty(
$_REQUEST['not_checkin']) ){
        
$sql_clause .= ' AND dbo.ord_route.checkin_time IS NULL ';
    }


$sql="SELECT
dbo.ord_route.orddtl_refid,
dbo.ord_main.order_nbr,
dbo.ord_main.del_date,
dbo.ord_main.launch_date,
dbo.ord_main.confirm_date,
dbo.ord_dtl.itemno,
dbo.ord_dtl.qty,
Min(dbo.ord_route.dept_checkin_time) AS dept_checkin_time,
Min(dbo.ord_route.checkin_time) AS checkin_time,
Max(dbo.ord_route.checkout_time) AS checkout_time,
Max(dbo.ord_txseto.checkin_wt) AS checkin_wt,
Avg(dbo.ord_dtl.qty),
dbo.ord_txmain.refid,
dbo.master_customer.custname_en,
dbo.master_customer.custname_sc,
Min(dbo.ord_txseto.worker) as worker
FROM
dbo.ord_route
INNER JOIN dbo.ord_dtl ON dbo.ord_dtl.refid = dbo.ord_route.orddtl_refid
INNER JOIN dbo.ord_main ON dbo.ord_dtl.main_refid = dbo.ord_main.refid
LEFT JOIN dbo.ord_txmain ON dbo.ord_route.ordtxmain_refid = dbo.ord_txmain.refid
INNER JOIN dbo.ord_txseto ON dbo.ord_txseto.txmain_refid = dbo.ord_txmain.refid
INNER JOIN dbo.master_customer ON dbo.master_customer.custcode = dbo.ord_main.custcode
WHERE
dbo.ord_route.opr_code = :opr_code AND
(dbo.ord_route.checkin_time IS NOT NULL OR
dbo.ord_route.dept_checkin_time IS NOT NULL) AND
dbo.ord_route.checkout_time IS NULL
$sql_clause
GROUP BY
dbo.ord_route.orddtl_refid,
dbo.ord_main.order_nbr,
dbo.ord_main.del_date,
dbo.ord_main.launch_date,
dbo.ord_main.confirm_date,
dbo.ord_dtl.itemno,
dbo.ord_dtl.qty,
dbo.ord_txmain.refid,
dbo.master_customer.custname_en,
dbo.master_customer.custname_sc
ORDER BY
dbo.ord_main.del_date ASC

"
;
$sql="SELECT
dbo.ord_route.orddtl_refid,
dbo.ord_main.status,
dbo.ord_main.order_nbr,
dbo.ord_main.del_date,
dbo.ord_main.launch_date,
dbo.ord_main.confirm_date,
dbo.ord_dtl.itemno,
dbo.ord_dtl.qty,
dbo.ord_dtl.chkinordroute_refid,
Min(dbo.ord_route.dept_checkin_time) AS dept_checkin_time,
Min(dbo.ord_route.checkin_time) AS checkin_time,
Max(dbo.ord_route.checkout_time) AS checkout_time,
Max(dbo.ord_txseto.checkin_wt) AS checkin_wt,
Avg(dbo.ord_dtl.qty),
dbo.ord_txmain.refid,
dbo.master_customer.custname_en,
dbo.master_customer.custname_sc,
Min(dbo.ord_txseto.worker) as worker
FROM
dbo.ord_route
INNER JOIN dbo.ord_dtl ON dbo.ord_dtl.refid = dbo.ord_route.orddtl_refid
INNER JOIN dbo.ord_main ON dbo.ord_dtl.main_refid = dbo.ord_main.refid
LEFT JOIN dbo.ord_txmain ON dbo.ord_route.ordtxmain_refid = dbo.ord_txmain.refid
LEFT JOIN dbo.ord_txseto ON dbo.ord_txseto.txmain_refid = dbo.ord_txmain.refid
INNER JOIN dbo.master_customer ON dbo.master_customer.custcode = dbo.ord_main.custcode
WHERE
dbo.ord_route.opr_code = :opr_code AND
(dbo.ord_route.checkin_time IS NOT NULL OR
dbo.ord_route.dept_checkin_time IS NOT NULL) AND
dbo.ord_route.checkout_time IS NULL
$sql_clause
GROUP BY
dbo.ord_route.orddtl_refid,
dbo.ord_main.status,
dbo.ord_main.order_nbr,
dbo.ord_main.del_date,
dbo.ord_main.launch_date,
dbo.ord_main.confirm_date,
dbo.ord_dtl.itemno,
dbo.ord_dtl.qty,
dbo.ord_dtl.chkinordroute_refid,
dbo.ord_txmain.refid,
dbo.master_customer.custname_en,
dbo.master_customer.custname_sc
ORDER BY
dbo.ord_main.del_date ASC

"
;
    
$sth $dbh->prepare($sql);
    
$q $sth->execute$sql_param );
//echo $sth->getSQL( array(':opr_code'=>$opr_param['opr_code']) ) . HTML_EOL;
    
pdo_showerror($sth$q);
    
$total_qty=0;
    while(
$row $sth->fetch()) {
        
//$tx = getTxdata($row['orddtl_refid']);
        
$total_qty += $row['qty'];
        if(empty(
$row['chkinordroute_refid'])){
            
$error LEGACY.WS.JOB_CARD;
        }
        elseif(
$row['status']=='CANCEL'){
            
$error CANCEL;
        }else{
            
$error false;
        }
?>
                  <tr>
                        <td class="code"><a href="ord_setd_index.php?refid=<?=$row['orddtl_refid']?>"  class="ctip" ctip="ajax_thumb_inv_product.php?itemno=<?=$row['itemno']?>&formid=<?=$formid?>"><?=generateJCbarcode($row['orddtl_refid'])?></a></td>
                        <td class="code"><span title="<?=$row['status']?>" class="ctip"><?=$row['order_nbr']?></span><?=!empty($error)? '<br/><span class="ui-state-error">'.$error.'</span>':''?></td>
                        <td class="code"><?=$row['status']?></td>
                        <td><?=$row['custname_'.SYS_LANG]?></td>
                        <td><?=datef($row['del_date'])?></td>
                        <td class="code"><?=$row['itemno']?></td>
                        <td><?=datef($row['dept_checkin_time'])?></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><?=numf($row['checkin_wt'],3)?></td>
                        <td><?=empty($row['checkin_time'])? WAITING $row['worker']?></td>
                        <td><?=datef($row['est_checkout_date'])?></td>
                  </tr>
            <?php ?>
                <!--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>&nbsp;</td>
                        <td>&nbsp;</td>
                        <!--<td>&nbsp;</td>-->
                        <td class="tdalignright"><?=numf($total_qty)?></td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>

                  </tr>
                </tfoot>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>


</body>
</html>