ded63da61785959ac83f3fce6390eb06bc41b300
[infodrom.org/service.infodrom.org] / src / InfoCon / buch / reimbursement.wml
1 #include <infocon.style>
2
3 <future>
4 <page func=InfoCon title="Buchhaltung">
5
6 <style type="text/css">
7 span.in { color: green; }
8 span.out { color: red; }
9 span.in:hover, span.out:hover { background: yellow; border: 1px solid #ccc; }
10 </style>
11
12 <h3>Erstattungen / Offene Buchungen</h3>
13
14 <form id="open_items">
15 Titel <input type="text" id="title" name="title" value="" size="20" title="Optionaler Titel der Liste"><br>
16 <?php
17     $sales = new Sales();
18     foreach ($sales->getOpenItems() as $row) {
19         $date = substr ($row->date,6,2) . "." . substr ($row->date,4,2) . "." . substr ($row->date,0,4);
20         printf('<input name="nr[]" type="checkbox" value="%d" price="%d">&nbsp;', $row->nr, $row->price);
21         printf('<span class="%s">%d&nbsp;&nbsp;%s %s (%.2f&nbsp;&euro;)</span><br>',
22                $row->price < 0 ? 'out' : 'in',
23                $row->nr, $date, $row->description, $row->price / 100);
24     }
25 ?>
26 Zwischensumme <input type="text" id="subtotal" value="" size="5" style="background: #ececec;text-align:right;" readonly> &euro;
27 &nbsp;&nbsp;&nbsp;<input type="text" id="subtotal_tr" value="" size="5" style="background: #ececec;text-align:right;" readonly> &euro;
28 <p><input type="submit" class="button" value="Bezahlen" onclick="return send_request()"> <input type="reset" class="button" value="Reset"><p>
29 </form>
30
31 </page>
32 <protect>
33 <script type="text/javascript">
34 function cb_change()
35 {
36     var subtotal = $('input#subtotal').val();
37     if (typeof subtotal == 'string' && !subtotal.length) subtotal = 0;
38     else subtotal = parseInt((parseFloat(subtotal) * 100).toString());
39
40     if ($(this).prop('checked'))
41         subtotal += parseInt($(this).attr('price'));
42     else
43         subtotal -= parseInt($(this).attr('price'));
44
45     if (subtotal == 0) {
46         $('input#subtotal').val('');
47         $('input#subtotal_tr').val('');
48     } else {
49         $('input#subtotal').val(subtotal / 100);
50         $('input#subtotal_tr').val((subtotal * -1 / 100).toString().replace('.', ','));
51     }
52 }
53
54 function send_request()
55 {
56     $.invoke('Sales/Subtotal', $('form#open_items').serialize(), function(data){
57         show_message('Mail sent');
58         $('form#open_items')[0].reset();
59     });
60
61     return false;
62 }
63
64 $(function(){
65         $('form#open_items input[type="checkbox"]').click(cb_change);
66         setTimeout(function(){$('form#open_items')[0].reset();}, 500);
67 });
68 </script>
69 </protect>