/var/www/enzatesting.onesolution.hk/ord_castcheckout_modifyform.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'] = "CASO";
$delnote_nbr setDefaultReqVar("delnote_nbr"'');
$barcode setDefaultReqVar("barcode"'');
//$delnote_nbr = (int)parseCDNBarcode($_REQUEST['delnote_nbr']);
if($barcode){
    
$delnote_nbr $barcode;
}

if(
$delnote_nbr){
    
$sql "SELECT
            dbo.ord_txcasd.delnote_nbr,
            dbo.ord_txcasd.castingcompany,
            Max(dbo.ord_txcasd.exp_returndate) as exp_returndate,
            Max(dbo.ord_txcasd.act_returndate) as act_returndate,
            Min(dbo.ord_txcasd.createdate) as launch_date
            FROM
            dbo.ord_txcasd
            WHERE delnote_nbr = :delnote_nbr
            GROUP BY
            dbo.ord_txcasd.delnote_nbr,
            dbo.ord_txcasd.castingcompany"
;
    
$sth $dbh->prepare($sql);
    
$sth->execute(  array(':delnote_nbr' => $delnote_nbr) );
    
//echo $sth->getSQL(  array(':delnote_nbr' => $delnote_nbr) );    
            


if(
$row $sth->fetch()){
    
}
else{
    
//vdump($_REQUEST);
    
myerror("Invalid Request"); 
    
//exit;    
}
//vdump($row);
$sth=null;

?>
<!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>
var formdata;

$(document).ready(function() {
    
    //refreshtab6();
    //refreshROUTE();
    $( "#launch_date" ).datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "<?=date("Y-m-d")?>"
    });
                
    $( "#del_date" ).datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "<?=datef($row['del_date'])?>"
    });
    
    $(".focus").focus();
            
    $( "#dialog-jcform" ).dialog({
        autoOpen: false,
        height: 340,
        modal: true,
        buttons: {
            "<?=OK?>": function() {
                var bvalid = $('#new_enable').val();
                
                if(bvalid==1){
                    //alert('ok');
                    //add jc to listing
                    //console.log(formdata);
                    addProduct();
                    
                    $( this ).dialog( "close" );
                }
                else{
                }

            },
            "<?=CLOSE?>": function() {
                $( this ).dialog( "close" );
            }
        },
        close: function() {
            //empty form 
            $('#barcode').val('');
             $('#new_order_nbr').val('');
            $('#new_name').val('');
            $('#new_itemno').val('');
            $('#new_jc').val('');
            $('#new_part').val('');
             $('#new_qty').val('');
             $('#new_enable').val('');

        }
    });
    
    
    $( "#add_jc_button" ).click(function() {
        $( "#dialog-jcform" ).dialog( "open" );
    });
    
    $( "#barcode" ).change(function() {
        getJobCardData();
    });
});    





function getJobCardData(){
      $.blockUI({  theme:     true,
              title:    'ENZA', 
              message:  '<p><?=LOADING?>...<br/><br/><span style="float:right;" ><input type="button" name="<?=CLOSE?>" value="<?=CLOSE?>" onclick="$.unblockUI();" /></span></p>', 
              baseZ: 2000     }); 
      
      $.get("ajax_json_castdeal_jobcard_detail.php",{  
                formid: "<?=$formid?>",
                jc: $('#barcode').val(),
                format: "json"
            },
            function(data){

               formdata = jQuery.extend({}, data); //clone object
               //console.log(data);
               if(typeof(data.order_nbr) !== 'undefined' && data.order_nbr != null) {
                    $('#new_order_nbr').val(data.order_nbr);
                    //alert(data.order_nbr);
               }else{
                     $('#new_order_nbr').val('');
                    //alert(data);
               }
               
               if(typeof(data.name_<?=SYS_LANG?>) !== 'undefined' && data.name_<?=SYS_LANG?> != null) {
                       $('#new_name').val(data.name_<?=SYS_LANG?>);
               }else{
                    $('#new_name').val('');
               }
               
               if(typeof(data.itemno) !== 'undefined' && data.itemno != null) {
                       $('#new_itemno').val(data.itemno);
               }else{
                    $('#new_itemno').val('');
               }
               
               if(typeof(data.barcode) !== 'undefined' && data.barcode != null) {
                       $('#new_jc').val(data.barcode);
               }else{
                    $('#new_jc').val('');
               }
               
               if(typeof(data.part) !== 'undefined' && data.part != null) {
                       $('#new_part').val(data.part);
               }else{
                    $('#new_part').val('');
               }
               
               if(typeof(data.qty) !== 'undefined' && data.qty != null) {
                       $('#new_qty').val(data.qty);
               }else{
                     $('#new_qty').val('');
               }
               
               if(typeof(data.json_status) !== 'undefined' && data.json_status != null) {
                       $('#new_enable').val(data.json_status);
               }else{
                     $('#new_enable').val('0');
               }
               
               if(typeof(data.readyForCASO) !== 'undefined' && data.readyForCASO != null) {
                       $('#new_ready').val(data.readyForCASO);
               }else{
                     $('#new_ready').val('0');
               }               
                
                //validate job card is not added in this casting deal 
                $(".orddtl_refid").each(function() {
                    if(this.value == data.refid){
                        $('#new_enable').val('0'); //disable add function

                        setTimeout( //wait unblockui
                          function() 
                          {
                            alert('Duplicated Job Card');
                          }, 500);
                    }
                    //console.log(this.value);
                });
                
                if(data.readyForCASO != 1){
                        $('#new_enable').val('0'); //disable add function

                        setTimeout( //wait unblockui
                          function() 
                          {
                            alert('Invalid Job Card');
                          }, 500);
                }
             }, 
            "json"
      );  
      $.unblockUI();        
}






function localbind(){

}


</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_castcheckout_modifyform.php" method="post" enctype="multipart/form-data">
                <span class="stext1"><br/><?=DELIVERY_NOTE?><?=WS?><?=NUMBER?>:</span><br/>
                <input type="text" name="barcode" class="focus shortfield"  />
                <input type="submit" name="S" value="<?=SUBMIT?>" />
                </form></td>
            <td valign="top" class="padding1">
            <form action0="ord_castdeal_modify.php" name="myform" id="myform" method="post" enctype="multipart/form-data">
  <input type="hidden" name="action" value="ord_castdeal_modifyform" />
            <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'])?>"><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="download_trig"><span class="ui-icon0 ui-icon-circle-triangle-s" ></span>
                          <?=FILES?>
                          </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"><?=CASTING?>
                          - <span>
                          <?=CHECKOUT?>
                          </span></td>
                        <td class="separator etext1"><?=$row['castingcompany']?>
                          - <span>
                          <?=$delnote_nbr?>
                          </span></td>
                        <td width="200" align="right" class="separator etext2"><?=LAUNCH_DATE?>:
                          <?=datef($row['launch_date'])?></td>
                        <td width="80" align="right" class="separator etext2"><a href="ord_castcheckout_index.php?act=resume" class="closebtn"><?=CLOSE?></a>
  <input type="hidden" name="godest" id="godest" />
  <input type="hidden" name="formdest" value="ord_castcheckout_index.php?act=resume" /></td>
                      </tr>
                    </table></td>
                </tr>
                <tr>
                  <td valign="top" class="c2_bg"><!--main form--> 
                    
                    <!--editable-->
                    
                    <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">
                          <p>
                          <table>
                            <tr>
                              <td ><?=DELIVERY_NOTE?><?=WS?><?=NUMBER?></td>
                              <td ><?=$row['delnote_nbr']?></td>
                            </tr>
                            <tr>
                              <td ><?=CASTING?><?=WS?><?=COMPANY?></td>
                              <td ><?=resolveCode_masterSupplier($row['castingcompany'])?></td>
                            </tr>
                            <tr>
                              <td ><?=LAUNCH_DATE?></td>
                              <td ><?=substr(datef($row['launch_date']) ,0,10)?></td>
                            </tr>
                            <tr>
                              <td ><?=EXPECTED?><?=WS?><?=RETURN_?><?=WS?><?=DATE?></td>
                              <td ><?=datef($row['exp_returndate'])?></td>
                            </tr>
  
<!--                            <tr>
                              <td ><?=REMARKS?></td>
                              <td ><textarea name="remark" cols="40" rows="5"><?=$row['remark']?></textarea></td>
                            </tr>-->
                            
                          </table>
                          </p>
                        </div>


                        <div id="tabs-4">
                          <p>
                            <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><?=ITEMNO?></th>
                              <th width="400px"><?=DESC?></th>
                              <th><?=QTY?></th>
                              <th><?=PART?></th>
                              <th><?=CHECKOUT?></th>
                            </tr>
                            <?php 
    $sql 
"SELECT
            dbo.ord_txcasd.refid as casd_refid,
            dbo.ord_txcasd.delnote_nbr,
            dbo.ord_txcasd.status,            
            dbo.ord_txcasd.createdate,
            dbo.ord_txcasd.ordsubroute_refid,
            dbo.ord_txcasd.part_qty,
            dbo.ord_txcasd.exp_returndate,
            dbo.ord_txcasd.castingcompany,
            dbo.ord_txmain.orddtl_refid,
            dbo.ord_txmain.refid,
            dbo.ord_main.order_nbr,
            dbo.inv_product.refid as product_refid,
            dbo.inv_product.name_en,
            dbo.inv_product.name_sc,
            dbo.ord_dtl.qty,
            dbo.ord_dtl.itemno,
            dbo.ord_subroute.opr_nbr,
            dbo.ord_subroute.opr_code,
            dbo.ord_subroute.itemno as mat_itemno
            
            FROM
            dbo.ord_txmain
            INNER JOIN dbo.ord_txcasd ON dbo.ord_txcasd.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.inv_product ON dbo.ord_dtl.product_refid = dbo.inv_product.refid            
            LEFT JOIN dbo.ord_subroute ON dbo.ord_txcasd.ordsubroute_refid = dbo.ord_subroute.refid
            WHERE
            dbo.ord_txmain.opr_code = 'CASO' AND
            delnote_nbr = :delnote_nbr"
;    

    
$sth $dbh->prepare($sql);
    
$q $sth->execute( array(':delnote_nbr'=>$delnote_nbr) );
//echo $sth->getSQL( $sql_param ) . HTML_EOL;
    
pdo_showerror($sth$q);
    
$i=0;                            
    while(
$row1 $sth->fetch()) {    $i++; ?>
                            <tr id="casting_form_<?=$i?>">
                              <td><a href="ord_dtl_product_modifyform.php?refid=<?=$row1['orddtl_refid']?>" class="fbox ctip" name="product[<?=$i?>][itemno]" id="product[<?=$i?>][itemno]" ctip="ajax_thumb_inv_product.php?refid=<?=$row1['product_refid']?>&formid=<?=$formid?>"><span name="jc[<?=$i?>][barcode]"><?=generateJCBarcode($row1['orddtl_refid'])?></span></a>
                                  <input type="hidden" name="jc[<?=$i?>][orddtl_refid]" value="<?=$row1['orddtl_refid']?>" class="orddtl_refid" /></td>
                              <td><span name="jc[<?=$i?>][order_nbr]"><?=$row1['order_nbr']?></span>
                                  <input type="hidden" name="jc[<?=$i?>][refid]" value="<?=$row1['refid']?>" /></td>
                              <td name="jc[<?=$i?>][itemno]"><?=$row1['itemno']?></td>
                              <td name="jc[<?=$i?>]['name']"><?=$row1['name_'.SYS_LANG]?> <?=$row1['mat_itemno']? '('.$row1['mat_itemno'].')' ''?></td>
                              <td name="jc[<?=$i?>][qty]"><?=numf($row1['qty'])?></td>
                              <td><input type="text" name="jc[<?=$i?>][part_qty]" value="<?=numf($row1['part_qty'])?>" readonly="readonly" class="minifield" /></td>

                              <td align="center"><?php
                              $curr 
ord_currentOprDept($row1['orddtl_refid']); 
                              if(
$row1['status']!='finished'){

$submitform = ($row1['ordsubroute_refid'])? 'ord_castcheckout_submitform.php' 'ord_castcheckout_submitform_deprecated.php';
                                    
?><a href="<?=$submitform?>?refid=<?=$row1['orddtl_refid']?>&casd_refid=<?=$row1['casd_refid']?>" class="fbox newwinbtn" onclick="$( this ).hide();"><?=CHECKOUT?></a>
                              <?php } else { ?>
                              <?=FINISHED?>
                              <?php ?></td>
                            </tr>
                            <?php ?>
                            
                            
                            <?php
    $sql 
"SELECT
dbo.ord_txcasd.refid as casd_refid,
dbo.ord_txcasd.delnote_nbr,
dbo.ord_txcasd.createdate,
dbo.ord_txcasd.part_qty,
dbo.ord_txcasd.exp_returndate,
dbo.ord_txcasd.castingcompany,
dbo.ord_txcasd.refid,
dbo.ord_txcasd.pure_exp_qty,
dbo.ord_txcasd.pdt_moldno,
dbo.ord_txcasd.status
FROM
dbo.ord_txcasd
WHERE
dbo.ord_txcasd.pdt_moldno IS NOT NULL AND
dbo.ord_txcasd.delnote_nbr = :delnote_nbr"
;    

    
$sth $dbh->prepare($sql);
    
$q $sth->execute( array(':delnote_nbr'=>$delnote_nbr) );
//echo $sth->getSQL( $sql_param ) . HTML_EOL;
    
pdo_showerror($sth$q);
                    
    while(
$row1 $sth->fetch()) {    $i++; ?>
                            <tr class="itemrow" id="itemrow casting_form_<?=$i?>">
                              <td class="code jc"><a href="dgn_master_modifyform.php?pdt_moldno=<?=$row1['pdt_moldno']?>" class="fbox ctip" name="product[<?=$i?>][itemno]" id="product[<?=$i?>][itemno]" ctip="ajax_thumb_dgn_master.php?pdt_moldno=<?=$row1['pdt_moldno']?>&formid=<?=$formid?>"><span name="jc[<?=$i?>][barcode]"><?=generateTCBarcode($row1['pdt_moldno'])?></span></a>
                                  <input type="hidden" name="jc[<?=$i?>][ismaster]" value="1" class="ismaster" /></td>
                              <td class="code"><span name="jc[<?=$i?>][order_nbr]"><?=MASTER?></span></td>
                              <td name="jc[<?=$i?>][itemno]" class="code"><?=$row1['pdt_moldno']?></td>
                              <td name="jc[<?=$i?>]['name']"><?=MASTER?> (<?=SILVER?>)</td>
                              <td name="jc[<?=$i?>][qty]">1</td>
                              <td><input type="text" name="jc[<?=$i?>][part_qty]" value="<?=numf($row1['part_qty'])?>" readonly="readonly" class="minifield part_qty" /></td>
                              <!--<td><?=$row1['remark']?></td>-->
                              <td align="center"><?php
                              
if($row1['status']!="finished"){?><a href="ord_castcheckout_tc_submitform.php?casd_refid=<?=$row1['casd_refid']?>" class="fbox newwinbtn" onclick="$( this ).hide();"><?=CHECKOUT?></a>
                              <?php } else { ?>
                              <?=FINISHED?>
                              <?php ?></td>
                            </tr>
                            <?php ?>                             
                          </table>
                          </p>
                        </div>

                      </div>
                      <!--end scontent-->
                      <input type="hidden" name="refid" value="<?=$refid?>" id="refid" />
                    </div>
                    
                    <!--end of readonly--> 
                    
                    <!-- end of mainform--></td>
                  <td valign="top"></td>
                </tr>
              </table></form>  </td>
          </tr>
        </table></td>
    </tr>
  </table>



</body>
</html>