Bug 27636: (QA follow-up) Fix tests and validate
[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 [% SET footerjs = 1 %]
7
8 [% PROCESS 'accounts.inc' %]
9
10 [% INCLUDE 'doc-head-open.inc' %]
11 <title>Create manual invoice &rsaquo; Patrons &rsaquo; Koha</title>
12 [% INCLUDE 'doc-head-close.inc' %]
13 </head>
14
15 <body id="pat_maninvoice" class="pat">
16 [% INCLUDE 'header.inc' %]
17 [% INCLUDE 'patron-search.inc' %]
18
19 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
20     <ol>
21         <li>
22             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23         </li>
24         <li>
25             <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a>
26         </li>
27         <li>
28             <a href="#" aria-current="page">
29                 Manual invoice
30             </a>
31         </li>
32     </ol>
33 </nav>
34
35 <div class="main container-fluid">
36     <div class="row">
37         <div class="col-sm-10 col-sm-push-2">
38             <main>
39
40             [% INCLUDE 'members-toolbar.inc' %]
41
42             <!-- The manual invoice and credit buttons -->
43             <div class="statictabs">
44                 <ul>
45                     <li><a href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | uri %]">Transactions</a></li>
46                     <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Make a payment</a></li>
47                     <li class="active"><a href="/cgi-bin/koha/members/maninvoice.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual invoice</a></li>
48                     <li><a href="/cgi-bin/koha/members/mancredit.pl?borrowernumber=[% patron.borrowernumber | uri %]" >Create manual credit</a></li>
49                 </ul>
50                 <div class="tabs-container">
51
52                 [% IF error == 'itemnumber' %]
53                     <div id="error_message" class="dialog alert">
54                         Error: Invalid barcode entered, please try again
55                     </div>
56                 [% ELSIF error %]
57                     <div id="error_message" class="dialog alert">
58                         An error occurred, please try again: [% error | html %]
59                     </div>
60                 [% END %]
61                 <form action="/cgi-bin/koha/members/maninvoice.pl" method="post" id="maninvoice">
62                     <input type="hidden" name="borrowernumber" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
63                     <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
64                     <fieldset class="rows">
65                         <legend>Manual invoice</legend>
66                         <ol>
67                             <li>
68                                 <label for="type">Type: </label>
69                                 <select name="type" id="type">
70                                     [% FOREACH debit_type IN debit_types %]
71                                     [% IF debit_type.code == type %]
72                                     <option value="[% debit_type.code | html %]" selected="selected">[%- PROCESS debit_type_description debit_type=debit_type -%]</option>
73                                     [% ELSE %]
74                                     <option value="[% debit_type.code | html %]">[%- PROCESS debit_type_description debit_type=debit_type -%]</option>
75                                     [% END %]
76                                     [% END %]
77                                 </select>
78                             </li>
79                             <li><label for="barcode">Barcode: </label><input type="text" name="barcode" id="barcode" value="[% barcode | html %]" /></li>
80                             <li><label for="desc">Description: </label><input type="text" name="desc" id="desc" size="50" value="[% desc | html %]" /></li>
81                             <li><label for="note">Note: </label><input type="text" name="note" size="50" id="note" value="[% note | html %]" /></li>
82                             <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>
83                         </ol>
84                     </fieldset>
85                     <fieldset class="action">
86                         <button type="submit" name="add" value="save">Save</button>
87                         <button type="submit" name="add" value="save and pay">Save and pay</button>
88                         <a class="cancel" href="/cgi-bin/koha/members/boraccount.pl?borrowernumber=[% patron.borrowernumber | html %]">Cancel</a>
89                     </fieldset>
90                 </form>
91
92                 </div>
93             </div>
94
95             </main>
96         </div> <!-- /.col-sm-10.col-sm-push-2 -->
97
98         <div class="col-sm-2 col-sm-pull-10">
99             <aside>
100                 [% INCLUDE 'circ-menu.inc' %]
101             </aside>
102         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
103      </div> <!-- /.row -->
104
105 [% MACRO jsinclude BLOCK %]
106     [% INCLUDE 'str/members-menu.inc' %]
107     [% Asset.js("js/members-menu.js") | $raw %]
108     <script>
109         var type_fees = {};
110         [% FOREACH debit_type IN debit_types %]
111             type_fees['[% debit_type.code | html %]'] = "[% IF debit_type.default_amount %][% debit_type.default_amount | $Price %][% END %]";
112         [% END %]
113         $(document).ready(function(){
114             $('#maninvoice').preventDoubleFormSubmit();
115             $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
116             $("#invoice_type").on("change",function(){
117                 this.form.desc.value = this.options[this.selectedIndex].value;
118                 this.form.amount.value = type_fees[this.options[this.selectedIndex].value];
119             });
120             [% UNLESS amount.defined %]
121             $("#maninvoice #desc").val($("#maninvoice #type option:selected").text());
122             $("#maninvoice #amount").val(type_fees[$("#maninvoice #type option:selected").val()]);
123             [% END %]
124             $("#maninvoice #type").change(function(){
125                 $("#maninvoice #desc").val($(this).find("option:selected").text());
126                 $("#maninvoice #amount").val(type_fees[$(this).val()]);
127             });
128         });
129     </script>
130 [% END %]
131
132 [% INCLUDE 'intranet-bottom.inc' %]