/var/www/enzatesting.onesolution.hk/ord_so_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
<?php 
$formid 
"Order";
require_once 
"inc/configure.php";

$refid = (int)setDefaultReqVar("refid"'');
if(
$refid){
    
$sql "SELECT
dbo.ord_pomain.*,
dbo.master_supplier.companyname_en,
dbo.master_supplier.companyname_sc,
dbo.master_supplier.code

FROM
dbo.ord_pomain
INNER JOIN dbo.master_supplier ON dbo.ord_pomain.supplier_refid = dbo.master_supplier.refid
WHERE dbo.ord_pomain.refid=:refid"
;
    
$sth $dbh->prepare($sql);
    
$sth->execute(  array(':refid' => $refid) );
    
//echo $sth->getSQL(  array(':refid' => $refid) );    
            
} else {
    
myerror(INVALID.WS.REQUEST); 
    exit;
}
$row $sth->fetch();
//vdump($row);
$sth=null;

/*if($row['status']=="APPROVED"){
    $ui_width = "100%";    
}
else{*/
    //$ui_width = "1600px";    
    
$ui_width "100%";    
//}

?>
<!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() {
    
    $( "#launch_date" ).datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "<?=datef(date("Y-m-d"))?>"
    });
                
    $( "#del_date" ).datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "<?=datef($row['del_date'])?>"
    });
    
    $( "#confirm_date" ).datepicker({
        dateFormat: "yy-mm-dd",
        defaultDate: "<?=datef($row['confirm_date'])?>"
    });
    
    $( ".marksofinish" ).on("click", function(e) {
        //alert(1);
        e.preventDefault();
        
        //console.log($(this).attr("data-refid"));
        //alert($(this).attr("data-refid"));
        //console.log($(this).parent());
        var buttoncell = $(this).parent();
        
        $.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     }); 
        
        $.post("ajax_ord_podtl_markfinished.php",{  
                  formid: "<?=$formid?>",
                  action: "ajax_ord_podtl_markfinished",
                  podtl_refid: $(this).attr("data-refid")
              },
              function(data){
                 //alert(data);
                 buttoncell.html(data);
                 $.unblockUI();
              });
    });    

    $("#createPO").on("click", function(e){
        //console.log($('.newpoitem_refid:checked'));
        var checked_refid = '';
        $('.newpoitem_refid:checked').each(function(index, element) {
            checked_refid += $(this).val()+',';            
        });
        var url = 'ord_po_addform.php' 
                    + '?so_refid=' + $('#refid').val()
                    + '&layout=min'
                    + '&supplier_refid=' + $('#posupplier').val()
                    + '&remark=<?=$row['pono']?>'
                    + '&items=' + checked_refid.substr(0, checked_refid.length-1);
        $.fancybox({            
            hideOnOverlayClick: false,
            width            : '90%',
            height            : '90%',
            autoScale          : false,
            transitionIn    : 'none',
            transitionOut    : 'none',            
            type            : 'iframe',
               href            : url            
        });        
        
    });
    
    $("#cb_group_all").on('change', function(){
        //console.log('checkall');
        var c = this.checked;
        $(".cb_group").each(function(){
            $(this).prop("checked", c); //apply to all child
        });
    });    
            
});
//update po supplier selection
function setposupplier(refid){
    //alert(refid);
    $('#posupplier option[value="'+refid+'"]').prop('selected', true);
}


function updatePrices(){}

function approxQty(input, std){
    return;
    if(std>0){
        return input/std;
    }
    else{
        return '';    
    }
}



function localbind(){
    //calculate prices
    $('.qty, .cost').unbind("change, blur");
    $('.qty, .cost').bind("change, blur", CalcSubtotal);

}

</script>
<style>
    .ui-autocomplete {
        max-height: 200px;
        overflow-y: auto;
        /* prevent horizontal scrollbar */
        overflow-x: hidden;
        /* add padding to account for vertical scrollbar */
        padding-right: 20px;
    }
    /* IE 6 doesn't support max-height
     * we use height instead, but this forces the menu to always be this tall
     */
    * html .ui-autocomplete {
        height: 200px;
    }
    </style>
</head>
<body>
<form action="ord_so_modify.php" name="myform" id="myform" method="post" >
  <input type="hidden" name="action" value="so_modifyform" />
  <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="<?=$ui_width?>" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td valign="top" class="menu_bg"><?php require"mod_menu.php"?></td>
            <td valign="top" class="padding1"><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>
                        <?php if(($row['sostatus']!="CANCEL" && $row['sostatus']!="FINISHED") || $isadmin==true){
                            
$onCloseForm 'onclick="return ConfirmSave(\'myform\')"';?>
                        <td width="20" class="separator"><input type="image" src="image/icon_save.jpg" width="20" height="20" class="pressnhide2" /></td>
                        <td width="20" class="separator"><a href="<?=basename($_SERVER['REQUEST_URI'])?>"><img src="image/icon_undo.jpg" width="20" height="20" /></a></td>
                        <?php ?>
                        <!--<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="pdf_ord_po_print.php?refid=<?=$refid?>" target="_blank" id="print_trig"><span class="ui-icon0 ui-icon-print" ><?=PRINT_?></span></a></td>
                        <!--<td width="20" class="separator"><a href="xls_ord_po.php?refid=<?=$row['refid']?>" target="_new"><?=PRINT_?></a></td>-->
                        <td class="separator stext1"><?=SALES.WS.ORDER    ?>
                          <!--- <span>
                          <?=MODIFY?>-->
                          </span></td>
                        <td class="separator etext1"><table border="0" width="600px">
                        <tr><td colspan="2" align="center"><?=$row['companyname_'.SYS_LANG]?> - <span> <?=$row['pono']?> </span></td></tr>
                        <tr><td align="center"><?=LAUNCH_DATE?><?=datef($row['launch_date'])?></td>
                            <td align="center"><?=DELIVERY?><?=WS?><?=DATE?><?=datef($row['del_date'])?></td>
                            <!--<td align="center"><?=CONFIRM?><?=WS?><?=DATE?><?=datef($row['confirm_date'])?></td>--></tr>
                        </table></td>
                        <!--<td width="200" align="right" class="separator etext2"><?=LAST_MODIFY?>:
                          <?=lastUpdate($row)?></td>-->
                        <td width="80" align="right" class="separator etext2"><a href="ord_so_index.php?act=resume" <?=$onCloseForm?> class="closebtn"><?=CLOSE?></a>
  <input type="hidden" name="godest" id="godest" />
  <input type="hidden" name="formdest" value="ord_so_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 ><?=SUPPLIER?></td>
                              <td ><?=$row['companyname_'.SYS_LANG]?></td>
                            </tr>
                            <tr>
                              <td ><?=PO?><?=WS?><?=NUMBER?></td>
                              <td ><?=$row['pono']?></td>
                            </tr>
                            <tr>
                              <td ><?=BUYER?></td>
                              <td ><?=resolveCode_masterCustomer($row['buyer'])?></td>
                            </tr>
                            <tr>
                              <td ><?=CUSTOMER?><?=WS?><?=ORDER?><?=WS?><?=REFERENCE?></td>
                              <td ><?=$row['poreference']?></td>
                            </tr>                            
                            <tr>
                              <td ><?=LAUNCH_DATE?></td>
                              <td ><?=datef($row['launch_date'])?></td>
                            </tr>
                         

                            <tr>
                              <td ><?=PAYMETHOD?></td>
                              <td ><?=resolveCode_master_type_code("PAYMETHOD"$row['paymethod'])?></td>
                            </tr>
                            
                            <tr>
                              <td colspan="2">&nbsp;</td>
                            </tr>
                            <tr>
                              <td ><?=SO.WS.STATUS?></td>
                              <td><select name="sostatus" id="status"><option value=""></option><?=master_option("SO_STATUS"$row['sostatus'], true)?></select></td>
                            </tr>
                            <tr>
                              <td ><?=DELIVERY?><?=WS?><?=DATE?></td>
                              <td ><?=datef($row['del_date'])?></td>
                            </tr>
                            <!--<tr>
                              <td ><?=CONFIRM?><?=WS?><?=DATE?></td>
                              <td ><input name="confirm_date" id="confirm_date" value="<?=datef($row['confirm_date'])?>" /></td>
                            </tr> -->  
                            <tr>
                              <td ><?=REMARKS?></td>
                              <td ><textarea name="remark" cols="40" rows="5" readonly="readonly"><?=$row['remark']?></textarea></td>
                            </tr>
                            
                          </table>
                          </p>
                        </div>
             
                        <div id="tabs-4">
                          <p> 

                          <table width="100%" id="material_table" border="0" cellpadding="0" cellspacing="0" class="tablelist">
                            <tr>
                              <th><?=ITEMNO?></th>
                              <th><?=NAME?></th>
                              <!--<th width="150px"><?=DESC?></th>-->
                              <th><?=QTY?></th>
                              <th><?=INVOICED?></th>
                              <th><?=INVOICE.WS.REMAINING?></th>
                              <!--<th><?=WEIGHT?></th>-->

<?php if(havePermission("DPr")){ //DP-------------------------------?>
                              <th><?=UNITPRICE?></th>
                              <th><?=AMOUNT?></th>
<?php //end of DP-------------------------------------------------?>
                              <th><?=$row['code'].WS.SUPPLIER?></th>
                              <!--<th><?=$row['code'].WS.SUPPLIER.WS.REFERENCE?></th>-->
   
                              <th><?=ACTION?></th>
                              <th><?=NEW_.WS.PO?> <input name="cb_group_all" type="checkbox" class="cb_group_all" id="cb_group_all" /></th>
                            </tr>
                            
                            <!-- material row template-->
                            <?php $i="0";
    
$sql_clause='';
    

    
$sql "SELECT 
dbo.ord_podtl.*
FROM
dbo.ord_podtl
INNER JOIN dbo.ord_pomain ON dbo.ord_podtl.pomain_refid = dbo.ord_pomain.refid
WHERE pomain_refid=:refid"
;    

    
$sth $dbh->prepare($sql);
    
$q $sth->execute( array(':refid'=>$refid) );
//echo $sth->getSQL( $sql_param ) . HTML_EOL;
    
pdo_showerror($sth$q);
    
$ttl_amount=0;                    
    while(
$row1 $sth->fetch()) {
        
$material getDB_inv($row1['bomcategy'], $row1['itemnoid']);
        
$ttl_amount += $row1['unit_price'] * $row1['qty'];
        
$default_supplier getDB('master_supplier'po_getdefaultsupplier($row['code'], $row1['bomcategy'], $row1['itemnoid']));
        if(
$default_supplier && empty($default_po_supplier_refid)){ 
            
$default_po_supplier_refid $default_supplier['refid'];
        }
        
$i++; ?>
                            <tr class="itemrow">
                              <td><a href="inv_<?=$row1['bomcategy']?>_modifyform.php?refid=<?=$row1['itemnoid']?>" class="fbox code" ><?=$material['itemno']?></a></td>
                              <td><a name="material[<?=$i?>][desc]" id="material[<?=$i?>][desc]" ><?=$material['name_'.SYS_LANG]?></a></td>
                              <td class="tdalignright"><?=numf($row1['qty'], 3)?> <span name="material[<?=$i?>][uom_qty]"><?=$row1['uom_qty']?></span></td>
                              <td class="tdalignright"><?=$invoiced=numf(ord_soinvoiced($row1['refid']), 3)?> <span name="material[<?=$i?>][uom_qty]"><?=$row1['uom_qty']?></span></td>
                              <td class="tdalignright"><?=numf($row1['qty']-$invoiced ,3)?> <span name="material[<?=$i?>][uom_qty]"><?=$row1['uom_qty']?></span></td>
                              
 <?php if(havePermission("DCr")){ //DC-------------------------------?>
                              <td class="tdalignright"><?=numfs($row1['unit_price'])?> <?=$row1['uom_cy']?>/<span name="material[<?=$i?>][uom_qty]"><?=$row1['uom_qty']?></span></td>
                              <td class="tdalignright"><?=numfs($row1['unit_price'] * $row1['qty'])?> <?=$row1['uom_cy']?></td>
<?php //end of DC------------------------------------------------------?>
                              <td class="tdalignmid"><a href="javascript:setposupplier(<?=$default_supplier['refid']?>);" onclick0="setposupplier(<?=$default_supplier['refid']?>)"><?=simpleTip2($default_supplier['code'], $default_supplier['companyname_'.SYS_LANG])?></a></td>
                              <!--<td><?=$row1['supplier_ref']?></td>-->
                              <td><?php if($row1['sostatus']){
                                          print 
$row1['sostatus'];
                                   }else{ 
?><button class="marksofinish pressnhide" data-refid="<?=$row1['refid']?>"><?=MARK_AS.WS.FINISHED?></button><?php ?></td>
                            <td class="tdalignmid"><input type="checkbox" name="newpodtl[<?=$row1['refid']?>]" value="<?=$row1['refid']?>" class="newpoitem_refid cb_group" /></td>
                            </tr>
                            <?php ?>
                            
                            <tfoot>
                            <tr class="xfont">
                            <td><?=TOTAL?></td>
                            <td colspan="4">&nbsp;</td>
                            <td colspan="2" class="tdalignright"><?=numfs($ttl_amount ,2)?></td>
                            <td>&nbsp;</td>
                            <!--<td>&nbsp;</td>-->
                            <td>&nbsp;</td>
                            <td class="tdalignmid"></td>
                            </tr>
                            </tfoot>
                          </table>
                          
                          <table>
                              <tr>
                              <td><select name="posupplier" id="posupplier">
                                  <option value=""></option>
                                  <?=supplier_option($default_po_supplier_refid)?>
                                </select></td>
                              <td><button type="button" id="createPO"><?=CREATE.WS.PO?></button></td>
                              </tr>
                          </table>
                          <div align="left">
                          </div>
                          </p>
                        </div>
                      
                        
                      </div>
                      <!--end scontent-->
                      <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 of readonly--> 
                    
                    <!-- end of mainform--></td>
                  <td valign="top"></td>
                </tr>
              </table></td>
          </tr>
        </table></td>
    </tr>
  </table>
</form>
<script>var ent = Number(<?=$i?>)+1;</script>
</body>
</html>