Revision 81ca8fc2
Von Hans Peter Schlaepfer vor fast 5 Jahren hinzugefügt
templates/webpages/generic/calculate_qty.html | ||
---|---|---|
1 |
[%- USE T8 %] |
|
2 |
[%- USE HTML %] |
|
3 |
<form name="CalcQtyForm" id="calc_qty_form_id"> |
|
1 |
[% USE T8 %] |
|
2 |
[% USE HTML %] |
|
4 | 3 |
|
5 |
<input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]"> |
|
6 |
<input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]"> |
|
4 |
<form name="CalcQtyForm" id="calc_qty_form_id"> |
|
7 | 5 |
|
8 |
<table width="100%"> |
|
9 |
<tr><td>[% 'Please insert object dimensions below.' | $T8 %]</td></tr> |
|
6 |
<!-- <h1>[% #title %]</h1> --><!-- PENDENT: wieso wurde das entfernt? Braucht es hier keinen Titel? --> |
|
10 | 7 |
|
11 |
<tr>
|
|
12 |
<td>
|
|
8 |
<input type="hidden" name="input_name" value="[% HTML.escape(input_name) %]">
|
|
9 |
<input type="hidden" name="input_id" value="[% HTML.escape(input_id) %]">
|
|
13 | 10 |
|
14 |
<table> |
|
15 |
<tr class="listheading"> |
|
11 |
<table class="tbl-list"> |
|
12 |
<caption>[% 'Please insert object dimensions below.' | $T8 %]</caption> |
|
13 |
<thead> |
|
14 |
<tr> |
|
16 | 15 |
[% FOREACH col = HEADER %] |
17 |
<th nowrap class="listheading">[% col.column_title %]</a></th>
|
|
16 |
<th>[% col.column_title %]</a></th>
|
|
18 | 17 |
[% END %] |
18 |
</tr> |
|
19 |
</thead> |
|
20 |
<tbody> |
|
21 |
[% FOREACH row = VARIABLES %] |
|
22 |
<tr class="listrow[% loop.count % 2 %]"> |
|
23 |
<td>[% HTML.escape(row.description) %]:</td><td><input type="text" id="[% row.name %]" name="[% row.name %]" value=""></td> |
|
24 |
<td>[% HTML.escape(row.unit) %]</td> |
|
19 | 25 |
</tr> |
26 |
[% END %] |
|
27 |
</tbody> |
|
28 |
</table> |
|
20 | 29 |
|
21 |
[% FOREACH row = VARIABLES %]
|
|
22 |
<tr class="listrow[% loop.count % 2 %]">
|
|
23 |
<td>[% HTML.escape(row.description) %]:</td><td><input id="[% row.name %]" name="[% row.name %]" value=""></td>
|
|
24 |
<td>[% HTML.escape(row.unit) %]</td> |
|
25 |
</tr>
|
|
26 |
[% END %] |
|
27 |
</table>
|
|
30 |
<div class="buttons">
|
|
31 |
<button type="button" onclick="calculate_qty()">[% 'Calculate' | $T8 %]</button>
|
|
32 |
</div>
|
|
33 |
|
|
34 |
</form>
|
|
35 |
|
|
36 |
<script type="text/javascript">
|
|
28 | 37 |
|
29 |
</td> |
|
30 |
</tr> |
|
31 |
</table> |
|
32 |
<button type="button" onclick="calculate_qty()">[% 'Calculate' | $T8 %]</button> |
|
33 |
</form> |
|
38 |
function calculate_qty() { |
|
34 | 39 |
|
35 |
<script type="text/javascript"> |
|
36 |
function calculate_qty() { |
|
37 |
[%- FOREACH row = VARIABLES %] |
|
38 |
var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', $('#calc_qty_form_id #[% row.name %]').val()); |
|
39 |
[%- END %] |
|
40 |
[% FOREACH row = VARIABLES %] |
|
41 |
var [% row.name %] = parse_amount('[% MYCONFIG.numberformat %]', $('#calc_qty_form_id #[% row.name %]').val()); |
|
42 |
[% END %] |
|
40 | 43 |
var result = [% formel %]; |
41 | 44 |
result = number_format(result, 2, '[% MYCONFIG.numberformat %]'); |
45 |
/* Every Element should be assigned by ID and not with NAME, modern Browsers handle that since 2006 or a bit later */ |
|
42 | 46 |
if (document.CalcQtyForm.input_id.value) { |
43 | 47 |
document.getElementById(document.CalcQtyForm.input_id.value).value = result; |
44 | 48 |
} else { |
45 | 49 |
document.getElementsByName(document.CalcQtyForm.input_name.value)[0].value = result; |
46 | 50 |
} |
47 | 51 |
$('#calc_qty_dialog').dialog('close'); |
48 |
} |
|
49 | 52 |
|
50 |
function parse_amount(numberformat, amount) { |
|
51 |
if (numberformat == '1.000,00' || numberformat == '1000,00') |
|
52 |
amount = amount.replace(/\./g, "").replace(/,/, "."); |
|
53 |
if (numberformat == "1'000.00") |
|
54 |
amount = amount.replace(/\'/g, ''); |
|
55 |
return amount.replace(/,/g, ''); |
|
56 |
} |
|
53 |
} |
|
57 | 54 |
|
58 |
function number_format(number, precision, numberformat) { |
|
59 |
number = Math.round( number * Math.pow(10, precision) ) / Math.pow(10, precision); |
|
60 |
var nf = numberformat.replace(/\d/g, '').split('').reverse(); |
|
61 |
var sep = nf[0]; |
|
62 |
var th_sep = nf[1]; |
|
55 |
function parse_amount(numberformat, amount) { |
|
56 |
|
|
57 |
if (numberformat == '1.000,00' || numberformat == '1000,00') |
|
58 |
amount = amount.replace(/\./g, "").replace(/,/, "."); |
|
59 |
if (numberformat == "1'000.00") |
|
60 |
amount = amount.replace(/\'/g, ''); |
|
61 |
return amount.replace(/,/g, ''); |
|
63 | 62 |
|
64 |
str_number = number+""; |
|
65 |
arr_int = str_number.split("."); |
|
66 |
if(!arr_int[0]) arr_int[0] = "0"; |
|
67 |
if(!arr_int[1]) arr_int[1] = ""; |
|
68 |
if(arr_int[1].length < precision) { |
|
69 |
nachkomma = arr_int[1]; |
|
70 |
for(i=arr_int[1].length+1; i <= precision; i++) { |
|
71 |
nachkomma += "0"; |
|
72 |
} |
|
73 |
arr_int[1] = nachkomma; |
|
74 |
} |
|
75 |
if(th_sep != "" && arr_int[0].length > 3) { |
|
76 |
raw_arr_int = arr_int[0]; |
|
77 |
arr_int[0] = ""; |
|
78 |
for(j = 3; j < raw_arr_int.length ; j+=3) { |
|
79 |
arr_int[0] = th_sep + raw_arr_int.slice(raw_arr_int.length - j, raw_arr_int.length - j + 3) + arr_int[0] + ""; |
|
80 |
} |
|
81 |
str_first = raw_arr_int.substr(0, (raw_arr_int.length % 3 == 0) ? 3 : (raw_arr_int.length % 3)); |
|
82 |
arr_int[0] = str_first + arr_int[0]; |
|
83 |
} |
|
84 |
return arr_int[0] + sep + arr_int[1]; |
|
85 |
} |
|
86 |
</script> |
|
63 |
} |
|
64 |
|
|
65 |
function number_format(number, precision, numberformat) { |
|
66 |
|
|
67 |
number = Math.round( number * Math.pow(10, precision) ) / Math.pow(10, precision); |
|
68 |
var nf = numberformat.replace(/\d/g, '').split('').reverse(); |
|
69 |
var sep = nf[0]; |
|
70 |
var th_sep = nf[1]; |
|
71 |
|
|
72 |
str_number = number+""; |
|
73 |
arr_int = str_number.split("."); |
|
74 |
if(!arr_int[0]) arr_int[0] = "0"; |
|
75 |
if(!arr_int[1]) arr_int[1] = ""; |
|
76 |
if(arr_int[1].length < precision) { |
|
77 |
nachkomma = arr_int[1]; |
|
78 |
for(i=arr_int[1].length+1; i <= precision; i++) { |
|
79 |
nachkomma += "0"; |
|
80 |
} |
|
81 |
arr_int[1] = nachkomma; |
|
82 |
} |
|
83 |
if(th_sep != "" && arr_int[0].length > 3) { |
|
84 |
raw_arr_int = arr_int[0]; |
|
85 |
arr_int[0] = ""; |
|
86 |
for(j = 3; j < raw_arr_int.length ; j+=3) { |
|
87 |
arr_int[0] = th_sep + raw_arr_int.slice(raw_arr_int.length - j, raw_arr_int.length - j + 3) + arr_int[0] + ""; |
|
88 |
} |
|
89 |
str_first = raw_arr_int.substr(0, (raw_arr_int.length % 3 == 0) ? 3 : (raw_arr_int.length % 3)); |
|
90 |
arr_int[0] = str_first + arr_int[0]; |
|
91 |
} |
|
92 |
return arr_int[0] + sep + arr_int[1]; |
|
93 |
|
|
94 |
} |
|
95 |
</script> |
Auch abrufbar als: Unified diff
Neues kivitendo Design Aenderungen in templates/webpages/generic*
Dateien in generic/* und generictranslations/*