... | ... |
@@ -91,7 +91,17 @@ |
91 | 91 |
var u = units.find(function(x){return x.id == id;}); |
92 | 92 |
if(!u){ amtSel.innerHTML=''; return; } |
93 | 93 |
var html = '<option value="">-</option>'; |
94 |
- for(var i=1;i<=u.max_amount;i++){ html += '<option value="'+i+'"'+(selectedAmount==i?' selected':'')+'>'+i+'</option>'; } |
|
94 |
+ var base = {{ slot.behaelter|default(0) }}; |
|
95 |
+ var booked = {{ slot.behaelterBooked|default(0) }}; |
|
96 |
+ var currentBase = {{ buchung.behaelter|default(0) }}; |
|
97 |
+ var remainingOcBase = Math.max(0, Math.floor(base * 1.5) - Math.max(0, booked - currentBase)); |
|
98 |
+ var overByUnit = Math.floor(remainingOcBase / Math.max(1, parseInt(u.multiplier||1,10))); |
|
99 |
+ var maxByUnit = Math.max(u.max_amount, overByUnit); |
|
100 |
+ for(var i=1;i<=maxByUnit;i++){ |
|
101 |
+ var label = ''+i; |
|
102 |
+ if(i > u.max_amount){ label = '({{ 'MSC.wa_approval_needed'|trans([], 'contao_default') }}) ' + label; } |
|
103 |
+ html += '<option value="'+i+'"'+(selectedAmount==i?' selected':'')+'>'+label+'</option>'; |
|
104 |
+ } |
|
95 | 105 |
amtSel.innerHTML = html; |
96 | 106 |
} |
97 | 107 |
if(unitSel){ |
... | ... |
@@ -159,7 +169,17 @@ |
159 | 169 |
var u = units.find(function(x){return x.id == id;}); |
160 | 170 |
if(!u){ amtSel.innerHTML=''; return; } |
161 | 171 |
var html = '<option value="">-</option>'; |
162 |
- for(var i=1;i<=u.max_amount;i++){ html += '<option value="'+i+'"'+(selectedAmount==i?' selected':'')+'>'+i+'</option>'; } |
|
172 |
+ var base = {{ slot.behaelter|default(0) }}; |
|
173 |
+ var booked = {{ slot.behaelterBooked|default(0) }}; |
|
174 |
+ var currentBase = {{ buchung.behaelter|default(0) }}; |
|
175 |
+ var remainingOcBase = Math.max(0, Math.floor(base * 1.5) - Math.max(0, booked - currentBase)); |
|
176 |
+ var overByUnit = Math.floor(remainingOcBase / Math.max(1, parseInt(u.multiplier||1,10))); |
|
177 |
+ var maxByUnit = Math.max(u.max_amount, overByUnit); |
|
178 |
+ for(var i=1;i<=maxByUnit;i++){ |
|
179 |
+ var label = ''+i; |
|
180 |
+ if(i > u.max_amount){ label = '({{ 'MSC.wa_approval_needed'|trans([], 'contao_default') }}) ' + label; } |
|
181 |
+ html += '<option value="'+i+'"'+(selectedAmount==i?' selected':'')+'>'+label+'</option>'; |
|
182 |
+ } |
|
163 | 183 |
amtSel.innerHTML = html; |
164 | 184 |
} |
165 | 185 |
if(unitSel){ |
... | ... |
@@ -168,7 +168,16 @@ |
168 | 168 |
var u = units.find(function(x){return x.id == id;}); |
169 | 169 |
if(!u){ amtSel.innerHTML=''; return; } |
170 | 170 |
var html = '<option value="">-</option>'; |
171 |
- for(var i=1;i<=u.max_amount;i++){ html += '<option value="'+i+'">'+i+'</option>'; } |
|
171 |
+ var base = {{ slot.behaelter|default(0) }}; |
|
172 |
+ var booked = {{ slot.behaelterBooked|default(0) }}; |
|
173 |
+ var remainingOcBase = Math.max(0, Math.floor(base * 1.5) - booked); |
|
174 |
+ var overByUnit = Math.floor(remainingOcBase / Math.max(1, parseInt(u.multiplier||1,10))); |
|
175 |
+ var maxByUnit = Math.max(u.max_amount, overByUnit); |
|
176 |
+ for(var i=1;i<=maxByUnit;i++){ |
|
177 |
+ var label = ''+i; |
|
178 |
+ if(i > u.max_amount){ label = '({{ 'MSC.wa_approval_needed'|trans([], 'contao_default') }}) ' + label; } |
|
179 |
+ html += '<option value="'+i+'">'+label+'</option>'; |
|
180 |
+ } |
|
172 | 181 |
amtSel.innerHTML = html; |
173 | 182 |
} |
174 | 183 |
if(unitSel){ |
... | ... |
@@ -234,7 +243,16 @@ |
234 | 243 |
var u = units.find(function(x){return x.id == id;}); |
235 | 244 |
if(!u){ amtSel.innerHTML=''; return; } |
236 | 245 |
var html = '<option value="">-</option>'; |
237 |
- for(var i=1;i<=u.max_amount;i++){ html += '<option value="'+i+'">'+i+'</option>'; } |
|
246 |
+ var base = {{ slot.behaelter|default(0) }}; |
|
247 |
+ var booked = {{ slot.behaelterBooked|default(0) }}; |
|
248 |
+ var remainingOcBase = Math.max(0, Math.floor(base * 1.5) - booked); |
|
249 |
+ var overByUnit = Math.floor(remainingOcBase / Math.max(1, parseInt(u.multiplier||1,10))); |
|
250 |
+ var maxByUnit = Math.max(u.max_amount, overByUnit); |
|
251 |
+ for(var i=1;i<=maxByUnit;i++){ |
|
252 |
+ var label = ''+i; |
|
253 |
+ if(i > u.max_amount){ label = '({{ 'MSC.wa_approval_needed'|trans([], 'contao_default') }}) ' + label; } |
|
254 |
+ html += '<option value="'+i+'">'+label+'</option>'; |
|
255 |
+ } |
|
238 | 256 |
amtSel.innerHTML = html; |
239 | 257 |
} |
240 | 258 |
if(unitSel){ |