Bug 35356: Show SMS labels only when data exists
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / members / maninvoice.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE Price %]
5 [% USE Branches %]
6 [% PROCESS 'i18n.inc' %]
7 [% SET footerjs = 1 %]
8 [% PROCESS 'accounts.inc' %]
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>[% FILTER collapse %]
11     [% t("Create manual invoice") | html %] &rsaquo;
12     [% t("Patrons") | html %] &rsaquo;
13     [% t("Koha") | html %]
14 [% END %]</title>
15 [% INCLUDE 'doc-head-close.inc' %]
16 </head>
17
18 <body id="pat_maninvoice" class="pat">
19 [% WRAPPER 'header.inc' %]
20     [% INCLUDE 'patron-search-header.inc' %]
21 [% END %]
22
23 [% WRAPPER 'sub-header.inc' %]
24     [% WRAPPER breadcrumbs %]
25         [% WRAPPER breadcrumb_item %]
26             <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
27         [% END %]
28         [% WRAPPER breadcrumb_item %]
29             <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% INCLUDE 'patron-title.inc' %]</a>
30         [% END %]
31         [% WRAPPER breadcrumb_item bc_active= 1 %]
32             <span>Manual invoice</span>
33         [% END %]
34     [% END #/ WRAPPER breadcrumbs %]
35 [% END #/ WRAPPER sub-header.inc %]
36
37 <div class="main container-fluid">
38     <div class="row">
39         <div class="col-sm-10 col-sm-push-2">
40             <main>
41
42
43             [% INCLUDE 'members-toolbar.inc' %]
44
45             <h1>Manual invoice</h1>
46
47             <!-- The manual invoice and credit buttons -->
48             <div class="toptabs">
49                 <ul class="nav nav-tabs" role="tablist">
50                     <li role="presentation" class="transactions">
51                         <a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Transactions</a>
52                     </li>
53                     <li role="presentation" class="makepayment">
54                         <a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Make a payment</a>
55                     </li>
56                     <li role="presentation" class="manualinvoice active">
57                         <a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Create manual invoice</a>
58                     </li>
59                     [% IF CAN_user_updatecharges_manual_credit %]
60                         <li role="presentation" class="manualcredit">
61                             <a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" role="tab">Create manual credit</a>
62                         </li>
63                     [% END %]
64                 </ul> <!-- /.nav.nav-tabs -->
65                 <div class="tab-content">
66                     <div role="tabpanel" class="tab-pane active">
67                 [% IF error == 'itemnumber' %]
68                     <div id="error_message" class="dialog alert">
69                         Error: Invalid barcode entered, please try again
70                     </div>
71                 [% ELSIF error %]
72                     <div id="error_message" class="dialog alert">
73                         An error occurred, please try again: [% error | html %]
74                     </div>
75                 [% END %]
76                 <form action="/cgi-bin/koha/members/maninvoice.pl" method="post" id="maninvoice">
77                     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
78                     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
79                     <fieldset class="rows">
80                         <legend>Manual invoice</legend>
81                         <ol>
82                             <li>
83                                 <label for="type">Type: </label>
84                                 <select name="type" id="type">
85                                     [% FOREACH debit_type IN debit_types %]
86                                     [% IF debit_type.code == type %]
87                                     <option value="[% debit_type.code | html %]" selected="selected">[%- PROCESS debit_type_description debit_type=debit_type -%]</option>
88                                     [% ELSE %]
89                                     <option value="[% debit_type.code | html %]">[%- PROCESS debit_type_description debit_type=debit_type -%]</option>
90                                     [% END %]
91                                     [% END %]
92                                 </select>
93                             </li>
94                             <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" value="[% barcode | html %]" /></li>
95                             <li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" value="[% desc | html %]" /></li>
96                             <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" value="[% note | html %]" /></li>
97                             <li class="additional_field"><label for="cost">Cost: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="cost" id="cost" min="0" value="[% amount | $Price on_editing => 1 %]" /></li>
98                             <li class="additional_field"><label for="quantity">Quantity: </label><input type="text" name="quantity" id="quantity" value="1" /></li>
99                             <li><label for="amount">Amount: </label><input type="text" inputmode="decimal" pattern="^\d+(\.\d{2})?$" name="amount" id="amount" required="required" min="0" value="[% amount | $Price on_editing => 1 %]" /> Example: 5.00</li>
100                         </ol>
101                     </fieldset>
102
103                     [% IF available_additional_fields %]
104                         [% INCLUDE 'additional-fields-entry.inc' available=available_additional_fields values=additional_field_values %]
105                     [% END %]
106
107                     <fieldset class="action">
108                         <button type="submit" name="add" class="btn btn-primary" value="save">Save</button>
109                         <button type="submit" name="add" class="btn btn-primary" value="save and pay">Save and pay</button>
110                         <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
111                     </fieldset>
112                 </form>
113
114                     </div> <!-- /.tab-pane -->
115                 </div> <!-- /.tab-content -->
116             </div> <!-- /.toptabs -->
117
118             </main>
119         </div> <!-- /.col-sm-10.col-sm-push-2 -->
120
121         <div class="col-sm-2 col-sm-pull-10">
122             <aside>
123                 [% INCLUDE 'circ-menu.inc' %]
124             </aside>
125         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
126      </div> <!-- /.row -->
127
128 [% MACRO jsinclude BLOCK %]
129     [% INCLUDE 'str/members-menu.inc' %]
130     [% Asset.js("js/members-menu.js") | $raw %]
131     <script>
132         var type_fees = {};
133         [% FOREACH debit_type IN debit_types %]
134             type_fees['[% debit_type.code | html %]'] = "[% IF debit_type.default_amount %][% debit_type.default_amount | $Price on_editing => 1 %][% END %]";
135         [% END %]
136         $(document).ready(function(){
137             $('#maninvoice').preventDoubleFormSubmit();
138             $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
139             $("#invoice_type").on("change",function(){
140                 this.form.desc.value = this.options[this.selectedIndex].value;
141                 this.form.amount.value = type_fees[this.options[this.selectedIndex].value];
142             });
143             [% UNLESS amount.defined %]
144             $("#maninvoice #desc").val($("#maninvoice #type option:selected").text());
145             $("#maninvoice #amount").val(type_fees[$("#maninvoice #type option:selected").val()]);
146             $("#maninvoice #cost").val(type_fees[$("#maninvoice #type option:selected").val()]);
147             if(!type_fees[$("#maninvoice #type option:selected").val()]){
148                 $("#maninvoice li.additional_field").hide();
149             }
150             [% END %]
151             $("#maninvoice #type").change(function(){
152                 $("#maninvoice #desc").val($(this).find("option:selected").text());
153                 $("#maninvoice #amount").val(type_fees[$(this).val()]);
154                 $("#maninvoice #cost").val(type_fees[$(this).val()]);
155                 $("#maninvoice #quantity").val('1');
156                 if(type_fees[$(this).val()]){
157                     $("#maninvoice li.additional_field").show();
158                 }
159                 else{
160                     $("#maninvoice li.additional_field").hide();
161                 }
162             });
163             $("#maninvoice #quantity").blur(function(){
164                 $("#maninvoice #amount").val(($("#maninvoice #cost").val() * $(this).val()).toFixed(2));
165             })
166             $("#maninvoice #cost").blur(function(){
167                 $("#maninvoice #amount").val(($("#maninvoice #quantity").val() * $(this).val()).toFixed(2));
168             })
169         });
170     </script>
171 [% END %]
172
173 [% INCLUDE 'intranet-bottom.inc' %]