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 = setDefaultReqVar("refid", ''); if( $refid){ $sql = "SELECT * FROM ord_dtl WHERE refid=:refid"; $sth = $dbh->prepare($sql); $sth->execute( array(':refid' => $refid) ); } else { myerror("Invalid Request"); exit; } //echo $sql; $row = $sth->fetch(); $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> $(document).ready(function() { refreshtab6(); refreshROUTE(); refreshStatus(); var dialog_cat = $( "#dialog_cat" ), dialog_itemno = $( "#dialog_itemno" ), dialog_qty = $( "#dialog_qty" ), dialog_uom_qty = $( "#dialog_uom_qty" ), dialog_uom_wt = $( "#dialog_uom_wt" ), dialog_price = $( "#dialog_price" ), dialog_uom_price = $( "#dialog_uom_price" ), dialog_name = $( "#dialog_name" ), dialog_weight = $( "#dialog_weight" ), dialog_verified = $( "#dialog_verified" ), allFields = $( [] ).add( dialog_cat ).add( dialog_itemno ).add( dialog_qty ).add( dialog_uom_qty ).add( dialog_uom_wt ).add( dialog_price ).add( dialog_uom_price ).add( dialog_name ).add( dialog_weight ).add( dialog_verified ); $( "#dialog-form" ).dialog({ autoOpen: false, height: 340, width: 300, modal: true, buttons: { "Add": function() { var bValid = true; if ( bValid ) { htmlcontent = '<tr style="background-color: #CCCCCC;">'; htmlcontent += '<td>'+dialog_cat.val()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][bomcategy]" value="'+dialog_cat.val()+'" /></td>'; htmlcontent += '<td><a href="inv_'+dialog_cat.val()+'_modifyform.php?refid='+dialog_itemno.val()+'&act=edit#tabs-2" target="_new" class="fbox">'+$('#dialog_itemno option:selected').text()+'</a><input type="hidden" name="bom_detail['+$('#entry').val()+'][itemnoid]" value="'+dialog_itemno.val()+'" /></td>'; //htmlcontent += '<td>'+dialog_itemno.val()+'</td>'; var total_qty = dialog_qty.val() * Number(<?=$row['qty']?>); var total_weight = dialog_weight.val() * total_qty; //console.log(dialog_qty.val() * Number(<?=$row['qty']?>)); htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][qty]" value="'+total_qty+'" class="positive bomqty0 minifield" />'+dialog_uom_qty.html()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][uom_qty]" value="'+dialog_uom_qty.html()+'" class="uom_qty" /></td>'; htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][weight]" value="'+total_weight+'" readonly="readonly" class="positive std_qty minifield" />'+dialog_uom_wt.html()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][uom_wt]" value="'+dialog_uom_wt.html()+'" class="uom_wt" /></td>'; htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][actual_qty]" value="0" readonly="readonly" class="positive bomqty bomactual_qty minifield" />'+dialog_uom_wt.html()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][uom_actualqty]" value="'+dialog_uom_wt.html()+'"/></td>';
<?php if(havePermission("BPr")){ //BP-------------------------------?> htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][unitprice]" value="'+dialog_price.val()+'" class="positive bomunitprice minifield" readonly />/'+dialog_uom_price.html()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][uom_price]" value="'+dialog_uom_price.html()+'" class="uom_price" /></td>'; htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][subtotal]" value="0" class="positive bomsubtotal minifield" readonly /></td>'; <?php } //BP---------------------------------------------------------?> htmlcontent += '<td>'+dialog_name.val()+'</td>'; htmlcontent += '<td>'+dialog_verified.val()+'</td>'; //htmlcontent += '<td>Edit</td>'; htmlcontent += '<td><a href="#" class="deleteRowButton uibutton"><?=X?></a></td>'; htmlcontent += '</tr>'; $('#bom_table tr:last').after(htmlcontent); var trigger = $('#bom_table tr:last').find(".bomqty0").blur(); CalcSubtotalNew(trigger); //fbox_blind(); //numeric_blind(); reblind(); /*$('.deleteRowButton').unbind('click'); $('.deleteRowButton').click(DeleteRow);*/ updateEntry(); $( this ).dialog( "close" ); } }, Cancel: function() { $( this ).dialog( "close" ); } }, close: function() { allFields.val( "" ).removeClass( "ui-state-error" ); $('#dialog_itemno').html(''); $("#dialog_uom_qty").html(''); $("#dialog_uom_price").html(''); } }); $( "#opr-dialog-form" ).dialog({ autoOpen: false, height: 340, width: 400, modal: true, buttons: { "Add": function() { $( this ).dialog( "close" ); }, Cancel: function() { $( this ).dialog( "close" ); } }, close: function() { } }); $( "#add_bom_item_button" ).click(function() { $( "#dialog-form" ).dialog( "open" ); }); $( "#dialog_cat" ).change(function() { //show item of selected cat //tm=$("#dialog_cat").val(); //alert('ajax_cat_item.php?bomcategy='+tm); //qty.val('ajax_cat_item.php?bomcategy='+tm); $.get("ajax_cat_item.php",{ formid: "<?=$formid?>", bomcategy: $("#dialog_cat").val() }, function(data){ //alert('changed'); $('#dialog_itemno').html(data); $( "#dialog_itemno" ).change(); }); });
$( "#dialog_itemno" ).change(function() { //alert('detail..'); //show item of detail $.getJSON("ajax_json_cat_item_detail.php?",{ formid: "<?=$formid?>", bomcategy: $("#dialog_cat").val(), refid: $("#dialog_itemno").val(), format: "json" }, function(data) { //alert('id='+data.refid); //alert('name='+data.name); if(typeof(data.unitprice) !== 'undefined' && data.unitprice != null) { //alert('weight='+data.weight+''+data.uom_wt); $("#dialog_price").val(data.unitprice) } else{ $("#dialog_price").val('0.00') } if(typeof(data.uom_inventory) !== 'undefined' && data.uom_inventory != null) { $("#dialog_uom_qty").html(data.uom_inventory); $("#dialog_uom_price").html(data.uom_inventory); } else{ $("#dialog_uom_qty").html(''); $("#dialog_uom_price").html(''); } $("#dialog_name").val(data.name_<?=SYS_LANG?>) if(typeof(data.weight) !== 'undefined' && data.weight != null) { //alert('weight='+data.weight+''+data.uom_wt); $("#dialog_weight").val(data.weight) } else{ $("#dialog_weight").val('0') } if(typeof(data.uom_wt) !== 'undefined' && data.uom_wt != null) { $("#dialog_uom_wt").html(data.uom_wt); } else{ $("#dialog_uom_wt").html('-'); } //alert('verified='+data.verified_en); $("#dialog_verified").val(data.verified_<?=SYS_LANG?>) }); }); });
function CalcSubtotal() { //var row = $(this).parents('tr'); var row = $(this).parent().parent(); //tr>td>input if( row.find(".uom_price").val()==row.find(".uom_wt").val() ){ var qty = parseFloat( row.find(".bomqty").val()); if(qty<=0){ //standard weight qty = parseFloat( row.find(".std_qty").val()); //alert(qty); } } else { //standard qty var qty = parseFloat( row.find(".bomqty0").val()); } //alert( row.find(".uom_price").val()+ ", "+row.find(".uom_wt").val()+ "= "+qty); var unitprice = parseFloat( row.find(".bomunitprice").val()); //alert(qty+","+unitprice); var subtotal = round2d(qty*unitprice); //set val to subtotal row.find(".bomsubtotal").val(subtotal); //$(this).parents('tr').first().remove(); // alert(qty*unitprice); CalculateGrandtotal(); }
function CalcSubtotalNew(obj) { //var row = $(this).parents('tr'); var row = obj.parent().parent(); //tr>td>input if( row.find(".uom_price").val()==row.find(".uom_wt").val() ){ var qty = parseFloat( row.find(".bomqty").val()); if(qty<=0){ //standard weight qty = parseFloat( row.find(".std_qty").val()); //alert(qty); } } else { //standard qty var qty = parseFloat( row.find(".bomqty0").val()); } //alert( row.find(".uom_price").val()+ ", "+row.find(".uom_wt").val()+ "= "+qty); var unitprice = parseFloat( row.find(".bomunitprice").val()); //alert(qty+","+unitprice); var subtotal = round2d(qty*unitprice); //set val to subtotal row.find(".bomsubtotal").val(subtotal); //$(this).parents('tr').first().remove(); // alert(qty*unitprice); CalculateGrandtotal(); }
function CalculateGrandtotal(){ var gt=new Number(0); $( ".bomsubtotal" ).each( function() { var num = new Number($(this).val()); gt = gt + num; } ); $("#grandtotal").val(gt.toFixed(2)); //alert(gt.toFixed(2)); updatePrices(); }
function updateEntry(){ //var rowCount = $('#bom_table tr').length; var ent = Number($('#entry').val())+1; $('#entry').val(ent); //alert(rowCount); }
function refreshtab6(){ rid= $("#refid").val(); //alert(rid); $.get("ajax_ord_picking.php",{ formid: "<?=$formid?>", action: "PICKING", refid: $("#refid").val(), qty: "<?=$row['qty']?>" }, function(data){ //alert('changed'); $('#tabs-6').html(data); reblind(); updatePrices(); }); }
function refreshROUTE(){}
function refreshStatus(){
$.get("ajax_ord_jobcard_status.php",{ formid: "<?=$formid?>", jc_refid: "<?=$refid?>" }, function(data){ // alert(data); $('#statusArea').html(data); rebind(); }); }
function updatePrices(){ //alert('updatePrices'); return; var mat_cost_obj = $("#ttl_mat_cost").val($("#grandtotal").val()); var labor_cost_obj = $("#ttl_labor_cost").val($("#route_total").val()); var fmu = parseFloat($("#fmu").val()); var ttl_cost = parseFloat(mat_cost_obj.val())+ parseFloat(labor_cost_obj.val()); //alert(ttl_cost); var factory_cost = ttl_cost*fmu; $("#ttl_factory_cost").val(round2d(factory_cost)); var selling_price = parseFloat($("#sellingprice").val()); var pricemargin = (selling_price-ttl_cost)*100/selling_price; //alert(pricemargin); $("#pricemargin").val(round2d(pricemargin)); //var selling_price = parseFloat(selling_price.val());
}
function localbind(){ //calculate prices $('.price').unbind("change, blur"); $('.price').bind("change, blur", updatePrices); $('.bomqty0').unbind("change, blur"); $('.bomqty0').bind("change, blur", CalcSubtotal); } </script>
</head> <body> <form action="ord_pick_submit.php" name="myform" method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="ord_pick_submit" /> <input type="hidden" name="refid" value="<?=$row['refid']?>" /> <input type="hidden" name="qty" value="<?=$row['qty']?>" /> <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" onClick="return ConfirmModify(<?=$row['verified']?>)" /></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 class="separator stext1"><?=JOB_CARD?> - <span><?=PICKING?></span></td> <td class="separator etext1"><?=$row['itemno']?> - <span><?=generateJCBarcode($row['refid'])?></span></td> <td width="200" align="right" class="separator etext2">Last Modified: <?=lastUpdate($row)?></td> <td width="50" align="right" class="separator etext2"><a href="#" onclick="parent.$.fancybox.close();"><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="scontent"> <div id="tabs-6"> Loading... </div>
</div><!--end scontent--> <input type="hidden" name="refid" value="<?=$refid?>" id="refid" /> </div><!-- End TAB -->
<!-- end of mainform--> </td> <!--<td width="150" valign="top" class="product_image"><?=""//showProductImgThumb($refid)?></td>--> </tr> </table></td> </tr> </table></td> </tr> </table> </form> <!-- BOM form -->
<!-- end of BOM form --> </body> </html>
|