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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
<?php $formid = $_REQUEST['formid']; require_once "inc/configure.php"; //vdump($permissionstr); //$refid = setDefaultReqVar("refid", ''); $drawing_no = setDefaultReqVar("drawing_no", 0); if($drawing_no){ $drawing_master = trimVersion($drawing_no); } $extbom = getDB_where('dgn_master_mold', 'drawing_no LIKE :drawing_no ', array(':drawing_no'=>$drawing_master.'%'), 'ORDER BY refid DESC'); // vdump($extbom, $cust); $pdt_moldno = setDefaultReqVar("pdt_moldno", 0); $refid = setDefaultReqVar("refid", 0); $edit = setDefaultReqVar("edit", 0); $editable = setDefaultReqVar("edit", 0); $action = setDefaultReqVar("action", "Drawing"); //echo "act =$action"; ?> <!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() { $('#myform').submit( function(){ return valid_form(); }); refreshtab6(); //refreshROUTE();
//dialog for printing selection $( "#dialog-print" ).dialog({ autoOpen: false, modal: true }); $( "#print_trig" ).click(function() { $( "#dialog-print" ).dialog( "open" ); return false; }); var dialog_cat = $( "#dialog_cat" ), dialog_itemno = $( "#dialog_itemno" ), dialog_qty = $( "#dialog_qty" ), dialog_uom_qty = $( "#dialog_uom_qty" ), 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_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>'; htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][qty]" value="'+dialog_qty.val()+'" class="positive bomqty" style="width:40px;" />'+dialog_uom_qty.html()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][uom_qty]" value="'+dialog_uom_qty.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" style="width:40px;" readonly />/'+dialog_uom_price.html()+'<input type="hidden" name="bom_detail['+$('#entry').val()+'][uom_price]" value="'+dialog_uom_price.html()+'" /></td>'; htmlcontent += '<td><input type="text" name="bom_detail['+$('#entry').val()+'][subtotal]" value="'+round2d(parseFloat(dialog_qty.val())*parseFloat(dialog_price.val()))+'" class="'+ ((dialog_cat.val()=='material')?'isMaterial ':'') +'positive bomsubtotal" style="width:40px;" 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); //alert('222'); //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(''); } }); $( "#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?>", custcode: $("#custcode").val(), 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_uom_price").children().each(function(){ if ($(this).val()==data.uom_price){ //jQuery $(this).attr("selected","true"); //javascript //this.selected = true; } });*/ $("#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+''+data.uom_wt) } else{ $("#dialog_weight").val('-') } //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 var qty = parseFloat( row.find(".bomqty").val()); var unitprice = parseFloat( row.find(".bomunitprice").val()); 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); fixlabor_matCost = new Number(0); fixlabor_bomCost = new Number(0); $( ".bomsubtotal" ).each( function() { var num = new Number($(this).val()); gt = gt + num; if($(this).hasClass('isMaterial')){ fixlabor_matCost += num; }else{ fixlabor_bomCost += num; } } ); $("#grandtotal").val(gt.toFixed(2)); $("#matcost").val(fixlabor_matCost.toFixed(2)); $("#bomcost").val(fixlabor_bomCost.toFixed(2)); //alert(gt.toFixed(2)); updatePrices(); }
function updatePrices(){ //main prices: var main_ttl_labor_cost = parent.jQuery("#ttl_labor_cost").val(); var main_ttl_mat_cost = parent.jQuery("#ttl_mat_cost").val(); var main_est_price = parent.jQuery("#est_price").val(); var main_qtn_price = parent.jQuery("#qtn_price").val(); //alert('matcost: '+main_ttl_mat_cost); //alert('cost: '+main_ttl_labor_cost+', '+main_est_price+', '+main_qtn_price); var mat_cost_obj = $("#eb_ttl_mat_cost").val($("#grandtotal").val()); var labor_cost_obj = $("#eb_ttl_labor_cost"); $("#eb_ttl_labor_cost").val(main_ttl_labor_cost); var fmu = parseFloat($("#eb_fmu").val()); var ttl_cost = parseFloat(mat_cost_obj.val())+ parseFloat(labor_cost_obj.val()); //alert(ttl_cost); var factory_cost = ttl_cost*fmu; var est_price = parseFloat($("#eb_est_price").val()); var qtn_price = parseFloat($("#eb_qtn_price").val()); var est_margin = (est_price-ttl_cost)*100/est_price; var qtn_margin = (qtn_price-ttl_cost)*100/qtn_price; //alert('margin='+pricemargin); $("#eb_ttl_factory_cost").val(round2d(factory_cost)); $("#eb_est_margin").val(round2d(est_margin)); $("#eb_qtn_margin").val(round2d(qtn_margin)); //var selling_price = parseFloat(selling_price.val());
}
function calculate_est_price(){ var main_margin = parseFloat(parent.jQuery("#pricemargin").val()); //var eb_ttl_factory_cost = $("#eb_ttl_factory_cost").val(); var eb_ttl_cost = parseFloat($("#eb_ttl_mat_cost").val()) + parseFloat($("#eb_ttl_labor_cost").val()); var new_est_price = eb_ttl_cost*100/(100-main_margin); //console.log(main_margin, eb_ttl_cost); $("#eb_est_price").val(round2d(new_est_price)); updatePrices(); }
function calculate_qtn_price(){ var main_margin = parseFloat(parent.jQuery("#pricemargin").val()); //var eb_ttl_factory_cost = $("#eb_ttl_factory_cost").val(); var eb_ttl_cost = parseFloat($("#eb_ttl_mat_cost").val()) + parseFloat($("#eb_ttl_labor_cost").val()); var new_qtn_price = eb_ttl_cost*100/(100-main_margin); $("#eb_qtn_price").val(round2d(new_qtn_price)); updatePrices(); }
function updateEntry(){ var ent = Number($('#entry').val())+1; $('#entry').val(ent); //alert(rowCount); }
/*function copyBOMfromMaster(){ $.get("ajax_dgn_master_bom.php",{ drawing_no: $("#drawing_no").val(), edit: <?=$editable?> }, function(data){ //alert('changed'); $('#bom').html(data); reblind(); updatePrices(); }); }*/
function refreshtab6(){ $.get("ajax_dgn_extrabom.php",{ formid: "<?=$formid?>", action: "<?=$action?>", custcode: $("#custcode").val(), drawing_no: $("#drawing_no").val(), pdt_moldno: $("#pdt_moldno").val(), showprice: 1, refid: $("#refid").val(), edit: <?=$editable?> }, function(data){ //alert('changed'); $('#bom').html(data); reblind(); updatePrices(); }); }
function newROUTE(){ $('#newROUTE').hide(); $('#editROUTE').show(); }
function localbind(){ $('.price').unbind("change, blur"); $('.price').bind("change, blur", updatePrices); }
function valid_form(){ if($('#refid').val()<=0){ if($("#myform").attr("action")=="dgn_extrabom_modify.php" ){ alert('Please Save as a new BOM'); return false; } } //alert('sent'); return true; }
function save_bom_as(){ //alert('save as');
$("#myform").attr("action", "dgn_extrabom_add.php"); $("#myform").submit(); //document.forms["myform"].action = "dgn_extrabom_add.php"; //alert('saving'); //document.forms["myform"].submit();
}
function confirmDel() { //alert('confirm'); return confirm("<?=ARE_YOU_SURE_YOU_WANT_TO_DELETE?>?"); }
</script> </head> <body>
<table border="0" width="100%"> <tr> <td><form action="dgn_extrabom_modify.php" name="myform" id="myform" method="post" enctype="multipart/form-data"> <input type="hidden" name="action" value="dgn_extrabom_modify" /> <input type="hidden" name="custcode" id="custcode" value="<?=$extbom['custcode']?>" /> <input type="hidden" name="drawing_no" id="drawing_no" value="<?=$drawing_master?>" /> <input type="hidden" name="pdt_moldno" id="pdt_moldno" value="<?=$pdt_moldno?>" /> <input type="hidden" name="formid" id="formid" value="<?=$formid?>" /> <input type="hidden" name="refid" id="refid" value="<?=$refid?>" /> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <td class="c3_bg"><table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <?php if($editable){ ?> <?php if(havePermission("BMu")){ //BM-------------------------------?> <td width="20" class="separator"><input type="image" src="image/icon_save.jpg" width="20" height="20" /></td> <?php } //BM----------------------------------------------------------?> <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 class="separator stext1"><?=EXTRA?> <?=WS?> <?=BOM?> - <span> <?=MODIFY?> </span></td> <td class="separator etext1"><?=DRAWING?> <?=WS?> <?=NUMBER?> - <span> <?=$drawing_master?> </span></td> <td width="200" align="right" class="separator etext2"></td> </tr> </table></td> </tr> <tr> <td valign="top" class="c2_bg"><!--main form--> <div id="bom"> Loading</div> <!-- end of mainform--></td> <td valign="top"></td> </tr> </table> </form> </td>
<td valign="top" width="350px"> <!-- extraBOM listing --> <?php //$edit=1; $showview=1; if($drawing_no){ $sql = "SELECT * FROM dgn_extra_bom WHERE drawing_no = :drawing_no ORDER BY refid ASC "; $sth = $dbh->prepare($sql); $sth->execute( array(':drawing_no'=> $drawing_master) ); //echo $sth->getSQL( array(':drawing_no'=> $drawing_master) ); } //echo $sth->getSQL( array(':pdt_moldno'=> $pdt_moldno) ); print '<table class="tablelist" width="100%"><tr><th>'.BOM.WS.NAME.'</th><th>'.CREATE.WS.DATE.'</th>'; if($showview){ print '<th>'.VIEW.'</th>'; } if(havePermission("BMu")){ print'<th>'.DELETE.'</th>'; } print '</tr>'; $tr=0; while($row = $sth->fetch()) { $tr++; //$editable = ($tr==1)? 'edit=1&' : ''; //$editable = 'edit=1&'; $selected = ($row['refid']==$refid)? 'class="current"' : ''; print "<tr $selected ><td>".$row['bomname'].'</td><td>'.lastUpdate($row).'</td>'; if($showview){ print '<td><a href="iframe_dgn_extrabom_modifyform.php?edit='.$edit.'&action='.$action.'&drawing_no='.$row['drawing_no'].'&formid='.$formid.'&refid='.$row['refid'].'" class="uibutton">'.VIEW.'</a>'; print'</td>'; } if(havePermission("BMu")){ print '<td> <form action="dgn_extrabom_delete.php" method="post" name="delform" onsubmit="return confirmDel()"> <input type="hidden" name="action" value="dgn_extrabom_delete" /> <input type="hidden" name="edit" value="'.$edit.'" /> <input type="hidden" name="act" value="'.$action.'" /> <input type="hidden" name="drawing_no" value="'.$row['drawing_no'].'" /> <input type="hidden" name="formid" value="'.$formid.'" /> <input type="hidden" name="refid" value="'.$row['refid'].'" /> <input type="submit" name="'.X.'" value="'.X.'" class="uibutton" /> </form> </td>'; } print '</tr>'; } print '</table>'; ?>
<!-- end of listing --> </td>
</tr> </table> <div id="dialog-form" title="<?=ADD.WS.ITEM?>"> <form> <table> <tr> <td><?=BOMCATEGY?></td> <td id="dialog_cat_td"><select name="dialog_cat" id="dialog_cat" class="ui-widget-content ui-corner-all" /> <option></option> <?=master_option("BOMCATEGY", "", true)?> </select></td> </tr> <tr> <td><?=ITEMNO?></td> <td id="dialog_itemno_td"><select name="dialog_itemno" id="dialog_itemno" class="ui-widget-content ui-corner-all" /> </select></td> </tr> <tr> <td>Qty</td> <td id="dialog_qty_td"><input type="text" name="dialog_qty" id="dialog_qty" class="text ui-widget-content ui-corner-all positive" style="width:60px" /> <span name="dialog_uom_qty" id="dialog_uom_qty">-</span> </select></td> </tr> <?php if(havePermission("BPr")){ //BP-------------------------------?> <tr> <td><?=UNITPRICE?></td> <td id="dialog_price_td"><input type="text" name="dialog_price" id="dialog_price" class="text ui-widget-content ui-corner-all positive" style="width:60px" readonly="readonly" /> /<span name="dialog_uom_price" id="dialog_uom_price" >-</span></td> </tr> <?php } //end of BR------------------------------------------------------?> <tr> <td><?=NAME?></td> <td id="dialog_name_td"><input type="text" name="dialog_name" id="dialog_name" class="text ui-widget-content ui-corner-all" readonly="readonly" /></td> </tr> <tr> <td><?=WEIGHT?></td> <td id="dialog_weight_td"><input type="text" name="dialog_weight" id="dialog_weight" class="text ui-widget-content ui-corner-all" readonly="readonly" /></td> </tr> <tr> <td><?=VERIFIED?></td> <td id="dialog_verified_td"><input type="text" name="dialog_verified" id="dialog_verified" class="text ui-widget-content ui-corner-all" readonly="readonly" /></td> </tr> </table> </form> </div> </body> </html>
|