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

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

if( 
$refid && $row=getDB("cn_rm_main"$refid) ){


} else {
    
myerror("Invalid Request");
    exit;
}

?>
<!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 src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<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'])?>"
    });
            
    $(".submitform").on("click", function(e) {
         $( "#tabs" ).tabs('select', 0);  //goto first tab
    });        
    
    $("input.invoice_checkall").on('change', function(){
        //console.log('checkall');
        var c = this.checked;
        $("input.invoice_check").each(function(){
            $(this).prop("checked", c); //apply to all child
            $(this).change();
            
            $(this).closest(".itemrow").find(".cost").change();
            //console.log($(this).closest(".itemrow").find(".cost").change());
        });
        CalculateGrandtotal();
    });    
    

});    



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

function CalcSubtotal()
{
    var row = $(this).closest(".itemrow");//tr>td>input
    //console.log(row);
    
    var qty = parseFloat( row.find(".qty").val());
    var wt = parseFloat( row.find(".wt").val());
    var price = parseFloat( row.find(".cost").val());
    
    var uom_qty = row.find(".uom_qty").val();
    var uom_wt = row.find(".uom_wt").val();
    var uom_price = row.find(".uom_price").val();
    
    //console.log(qty, uom_qty, wt, uom_wt, price, uom_price);
    var amount = calcPriceByUOM(qty, uom_qty, wt, uom_wt, price, uom_price);

    row.find(".amount").val(amount.toFixed(2));

    CalculateGrandtotal();
}

function CalculateGrandtotal(){
    
    var gt=new Number(0);
 
    //$( ".amount" ).each( function() {
    $( ".itemrow" ).each( function() {    
        var row = $(this);
        //var checked = 
        //console.log(row.find(".amount_cnt"));
        //console.log(row.find(".amount_cnt").attr("checked"));
        if(row.find(".amount_cnt").attr("checked"))        {    
            var num = new Number(row.find(".amount").val());
            gt = gt + parseFloat(num);
        }
    } );
    $("#totalamount").val(gt.toFixed(2));




function updateEntry(){}



function localbind(){
    //calculate prices
    $('.cost').unbind("change, blur");
    $('.cost').bind("change, blur", CalcSubtotal);
    
    $('.amount_cnt').unbind("click");
    $('.amount_cnt').bind("click", 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>
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="cn_rm_modify.php" name="myform" id="myform" method="post" enctype="multipart/form-data">
  <input type="hidden" name="action" value="cn_rm_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="100%" 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>

                        <td width="20" class="separator"><input type="image" src="image/icon_save.jpg" width="20" height="20" class="submitform 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>

                        <!--<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="pdf_cn_rm_print.php?refid=<?=$refid?>" id="print_trig" target="new"><span class="ui-icon0 ui-icon-print" ><?=PRINT_?></span></a></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"><?=MATERIAL.WS.CREDIT_NOTE?>
                          - <span>
                          <?=MODIFY?>
                          </span></td>
                        <td class="separator etext1"><?=resolveCode_masterCustomer($row['cn_customer'])?>
                          - <span>
                          <?=empty($row['cn_nbr'])?generateRawMatCNTMP($row['refid']) : $row['cn_nbr']?>
                          </span></td>
                        <td width="200" align="right" class="separator etext2"><?=LAST_MODIFY?>:
                          <?=lastUpdate($row)?></td>
                        <td width="80" align="right" class="separator etext2"><a href="cn_rm_index.php?act=resume"  onclick="return ConfirmSave('myform')" class="closebtn"><?=CLOSE?></a>
  <input type="hidden" name="godest" id="godest" />
  <input type="hidden" name="formdest" value="cn_rm_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 ><span id="spryselect1">
                                <select name="cn_supplier_refid" id="supplier" disabled="disabled">
                                  <option value=""></option>
                                  <?php $supplier getSupplierByCode($row['cn_supplier'])?>
                                  <?=supplier_option($supplier['refid'])?>
                                </select>
                              </span></td>
                            </tr>
                            <tr>
                              <td ><?=CUSTOMER?></td>
                              <td ><span id="spryselect2">
                                <select name="cn_customer" id="buyer" disabled="disabled">
                                  <option value=""></option>
                                  <?=master_company_option($_SESSION['defaultcompany'], true)?>
                                </select></span></td>
                            </tr>
                            <tr>
                              <td ><?=BOMCATEGY?></td><td><select name="bomcategy" id="dialog_bomcategy" disabled="disabled"><option value=""></option><?=master_option("BOMCATEGY"$row['bomcategy'], true)?></select></td>
                            </tr>                          
                            <tr>
                              <td ><?=CREDIT_NOTE.WS.REQUEST.WS.NUMBER?></td>
                              <td ><?=$row['cnrq_nbr']?><!--<a href="pdf_cnr_rm_print.php?refid=<?=$refid?>" id="print_trig" class="downbtn" target="new"><?=$row['cnrq_nbr']?></a>--></td>
                            </tr>

                            <tr>
                              <td colspan="2">&nbsp;</td>
                            </tr>
                            
                            <?php 
                            
if($row['cn_supplier']==$system_var['COMPANY_FACTORY'] || $row['cn_supplier']==$system_var['COMPANY_OVERSEA']){
                                if( empty(
$row['cn_nbr']) ) {?>
                            <tr>
                              <td ><?=ISSUE.WS.CREDIT_NOTE.WS.NUMBER?></td>
                              <td ><input type="checkbox" name="issue_cnnbr"/></td>
                            </tr>                            
                            <?php } else{?>
                            <tr>
                              <td ><?=CREDIT_NOTE.WS.NUMBER?></td>
                              <td ><input name="cn_nbr" value="<?=$row['cn_nbr']?>" readonly="readonly" /></td>
                            </tr>
                            <?php 
                            } else { 
?> 
                            <tr>
                              <td ><?=CREDIT_NOTE.WS.NUMBER?></td>
                              <td ><input name="ext_cn_nbr" value="<?=$row['cn_nbr']?>" /></td>
                            </tr>
                            <?php ?> 
                            <tr>
                              <td ><?=STATUS?></td>
                              <td><select name="supplier_status" id="status">
                                  <?=master_option("CN_RM_SUP_STATUS"$row['supplier_status'], true)?>
                                </select></td>
                            </tr>
                            <tr>
                              <td ><?=APPROVAL.WS.DATE?></td>
                              <td ><input name="cn_approveddate" value="<?=datef($row['cn_approveddate'])?>" readonly="readonly" /></td>
                            </tr>   
                            <tr>
                              <td ><?=REMARKS?></td>
                              <td ><textarea name="supplier_remarks" cols="40" rows="5"><?=$row['supplier_remarks']?></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><?=INVOICE?>#</th>
                              <th><?=ITEMNO?></th>
                              <th><?=NAME?></th>
                              <!--<th width="150px"><?=DESC?></th>-->
                              <th><?=QTY?></th>
                              <th><?=WEIGHT?></th>

<?php if(havePermission("DCr")){ //DP-------------------------------?>
                              <th><?=PRICE?></th>
                              <th><?=AMOUNT?></th>
<?php //end of DP-------------------------------------------------?>

                             <th><?=CUSTOMER.WS.REMARKS?></th>
                            <!-- <th><?=STATUS?></th>-->
                             <th><?=APPROVAL?><input type="checkbox" name="invoice_check_all" class="invoice_checkall"/></th>
                            </tr>
  
                            
                            <?php
    $i
="0";
    
$sql "SELECT
            dbo.ivc_rawmat_main.ivc_nbr,
            dbo.cn_rm_dtl.*
            FROM
            dbo.cn_rm_dtl
            LEFT JOIN dbo.ivc_rawmat_dtl ON dbo.cn_rm_dtl.ivcrawmatdtl_refid = dbo.ivc_rawmat_dtl.refid
            LEFT JOIN dbo.ivc_rawmat_main ON dbo.ivc_rawmat_dtl.ivcrawmatmain_refid = dbo.ivc_rawmat_main.refid
            WHERE
            dbo.cn_rm_dtl.cnrmmain_refid = :refid
            ORDER BY
            dbo.cn_rm_dtl.refid ASC"
;    

    
$sth $dbh->prepare($sql);
    
$q $sth->execute( array(':refid'=>$refid) );
//echo $sth->getSQL( array(':refid'=>$refid) ) . HTML_EOL;
    
pdo_showerror($sth$q);
                        
    while(
$row1 $sth->fetch()) {
        
$material getDB_inv($row1['bomcategy'], $row1['itemnoid']);    
        
$i++; ?>
                        <tr class="itemrow">
                            <td><?=$row1['ivc_nbr']?></td>
                            <td><a href="inv_<?=$row1['bomcategy']?>_modifyform.php?refid=<?=$row1['itemnoid']?>" class="fbox" name="material[<?=$i?>][href]" ><?=$material['itemno']?></a>
                            <span style="display:none">
                                <input name="material[<?=$i?>][bomcategy]" value="<?=$row1['bomcategy']?>" type="hidden0" />
                                <input name="material[<?=$i?>][itemnoid]" value="<?=$row1['itemnoid']?>" type="hidden0" />
                                <input name="material[<?=$i?>][refid]" value="<?=$row1['refid']?>" type="hidden0" class="refid" />
                                <input name="material[<?=$i?>][uom_cy]" value="<?=$row1['uom_cy']?>" type="hidden0" />
                                <input name="material[<?=$i?>][uom_qty]" value="<?=$row1['uom_qty']?>" class="uom_qty" type="hidden0" />
                                <input name="material[<?=$i?>][uom_wt]" value="<?=$row1['uom_wt']?>" class="uom_wt" type="hidden0" />
                                <input name="material[<?=$i?>][uom_price]" value="<?=$row1['uom_unitprice']?>" class="uom_price" type="hidden0" />
                                <input name="material[<?=$i?>][ivcrawmatdtl_refid]" value="<?=$row1['ivcrawmatdtl_refid']?>" type="hidden0" /></span></td>
                              <!--<td><a name="material[<?=$i?>][itemname]" id="material[<?=$i?>][itemname]" ><?=$material['itemno']?></a></td>-->
                              <td><a name="material[<?=$i?>][desc]" id="material[<?=$i?>][desc]" ><?=$material['name_'.SYS_LANG]?></a></td>
                              <td><input type="text" name="material[<?=$i?>][qty]" value="<?=numf($row1['qty'], 3)?>" class="minifield positive qty" readonly="readonly" /><span name="material[<?=$i?>][uom_qty]"><?=$row1['uom_qty']?></span></td>
                              
                              <td><input type="text" name="material[<?=$i?>][wt]" value="<?=numf($row1['wt'], 3)?>" class="minifield positive wt" readonly="readonly" /><span name="material[<?=$i?>][uom_wt]"><?=$row1['uom_wt']?></span></td>
                              
 <?php if(havePermission("DCr")){ //DC-------------------------------?>
                              <td><input type="text" name="material[<?=$i?>][unit_price]" value="<?=numf(evl($row1['cn_unitprice'], $row1['unitprice']))?>" class="minifield positive cost" /><span name="material[<?=$i?>][uom_cy]"><?=$row1['uom_cy']?></span>/<span name="material[<?=$i?>][uom_price]"><?=$row1['uom_unitprice']?></span></td>
                              <td><input type="text" name="material[<?=$i?>][amount]" value="<?=numf(calcPriceByUOM($row1['qty'], $row1['uom_qty'], $row1['wt'], $row1['uom_wt'], evl($row1['cn_unitprice'], $row1['unitprice']), $row1['uom_unitprice']))?>" class="minifield positive amount"  readonly="readonly" /><span name="material[<?=$i?>][uom_cy]">&nbsp;</span></td>
<?php //end of DC------------------------------------------------------?>

                              <td><?=$row1['customer_remarks']?></td>
                              <td class="tdalignmid"><?php if($row1['cn_approvedby']){ ?>
                                  <?=resolveCode_master_type_code("CN_RM_SUP_STATUS"$row1['supplier_status'])?>
                                <span style="display:none"><input type="checkbox" class="amount_cnt" checked="checked" /></span>
                              <?php } else { ?>                                  
                                <input type="checkbox" name="material[<?=$i?>][approve]" class="invoice_check amount_cnt" />
                              <?php ?></td>    
                            </tr>
                            <?php ?>
                          </table>
                          
                         <?=TOTAL?>: <input type="number" id="totalamount" readonly="readonly" />
                          <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;
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {validateOn:["blur", "change"]});
var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2");
</script>
</body>
</html>