Smaller fixes
[fa-stable.git] / js / allocate.js
1 function allocate_all(doc) {
2         var amount = get_amount('amount'+doc);
3         var unallocated = get_amount('un_allocated'+doc);
4         var total = get_amount('total_allocated', 1);
5         var left = get_amount('left_to_allocate', 1);
6
7         if(unallocated<amount) amount = unallocated;
8         if((unallocated-amount)<=left){
9             left-=unallocated-amount;
10             total+=unallocated-amount;
11             amount=unallocated;
12         }else{
13           total+=left;
14           amount+=left;
15           left=0;
16         }
17         price_format('amount'+doc, amount, user.pdec);
18         price_format('left_to_allocate', left, user.pdec, 1);
19         price_format('total_allocated', total, user.pdec, 1);
20 }
21 function allocate_none(doc) {
22         amount = get_amount('amount'+doc);
23         left = get_amount('left_to_allocate', 1);
24         total = get_amount('total_allocated', 1);
25         price_format('left_to_allocate',amount+left, user.pdec, 1);
26         price_format('amount'+doc, 0, user.pdec);
27         price_format('total_allocated', total-amount, user.pdec, 1);
28 }