Bug 25545: (follow-up) Fix capitalization
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / invoice.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% SET footerjs = 1 %]
7 [% USE AuthorisedValues %]
8
9 [% INCLUDE 'doc-head-open.inc' %]
10 <title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
11 [% INCLUDE 'doc-head-close.inc' %]
12 </head>
13
14 <body id="acq_invoice" class="acq">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'acquisitions-search.inc' %]
17
18 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoices.pl">Invoices</a> &rsaquo; <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% invoiceid | html %]">[% invoicenumber | html %]</a></div>
19
20 <div class="main container-fluid">
21     <div class="row">
22         <div class="col-sm-10 col-sm-push-2">
23             <main>
24
25       [% IF ( modified ) %]
26         <div class="dialog message">
27           <p>Invoice has been modified</p>
28         </div>
29       [% END %]
30       <h1>Invoice: [% invoicenumber | html %]</h1>
31
32       <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</a></p>
33         <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
34         <fieldset class="rows">
35             <ol>
36             <li>
37                 <label for="shipmentdate" class="required">Invoice number:</label>
38                 <input type="text" id="invoicenumber" name="invoicenumber" value="[% invoicenumber | html %]" class="required" required="required"/>
39                 <span class="required">Required</span>
40             </li>
41
42             <li><label for="shipmentdate">Shipment date:</label>
43                     <input type="text" size="10" id="shipmentdate" name="shipmentdate" value="[% shipmentdate | $KohaDates %]" class="datepicker" /></li>
44
45             <li><label for="billingdate">Billing date:</label>
46                     <input type="text" size="10" id="billingdate" name="billingdate" value="[% billingdate | $KohaDates %]" class="datepicker" /></li>
47
48             <li><label for="shipmentcost">Shipping cost:</label>
49                     <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
50
51         <li>
52             <label for="shipment_budget_id">Shipping fund: </label>
53             <select id="shipment_budget_id" name="shipment_budget_id">
54                 <option value="">No fund</option>
55                 [% FOREACH budget IN budgets %]
56                     [% IF ( budget.selected ) %]
57                         <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
58                     [% ELSIF ( budget.b_active ) %]
59                         <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
60                     [% ELSE %]
61                         <option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
62                     [% END %]
63                 [% END %]
64             </select>
65             <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
66             <input type="checkbox" id="showallfunds" />
67
68         </li>
69
70             [% IF ( invoiceclosedate ) %]
71             <li><span class="label">Status:</span>
72                 Closed on [% invoiceclosedate | $KohaDates %]</li>
73
74             <li><label for="reopen">Reopen: </label> <input type="checkbox" name="reopen" id="reopen" /></li>
75             [% ELSE %]
76             <li><span class="label">Status:</span>
77                 Open</li>
78
79             <li><label for="close">Close: </label> <input type="checkbox" name="close" id="close" />
80                 </li>
81             [% END %]
82             </ol>
83           <input type="hidden" name="op" value="mod" />
84           <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
85             <fieldset class="action">
86                 <input type="submit" value="Save" />
87                 [% UNLESS orders_loop.size %]
88                 <a href="invoice.pl?op=delete&invoiceid=[% invoiceid | uri %]" id="delete">Delete</a>
89                 [% END %]
90             </fieldset>
91         </fieldset>
92       </form>
93
94       <hr />
95
96         <h3>Adjustments</h3>
97
98           <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
99               <fieldset class="rows">
100                   <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
101                   [% IF (adjustments && adjustments.count > 0) %]
102                       <table id="invoice_adj_table">
103                           <tr>
104                              <th>Id</th>
105                              <th>Amount</th>
106                              <th>Reason</th>
107                              <th>Note</th>
108                              <th>Fund</th>
109                              <th>Encumber while invoice open</th>
110                              <th>&nbsp</th>
111                           </tr>
112                           [% total_adj = 0 %]
113                           [% FOREACH adjustment IN adjustments %]
114                               [% total_adj = total_adj + adjustment.adjustment %]
115                               <tr>
116                                   <td><input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id | html %]" />[% adjustment.adjustment_id | html %]</td>
117                                   <td><input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" /></td>
118                                   <td>
119                                       [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
120                                       [% IF reasons.0 %]
121                                           <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
122                                               <option value="">No reason</option>
123                                               [% FOREACH reason IN reasons %]
124                                                   [% IF ( adjustment.reason == reason.authorised_value ) %]
125                                                       <option selected="selected" value="[% reason.authorised_value | html %]">
126                                                   [% ELSE %]
127                                                       <option value="[% reason.authorised_value | html %]">
128                                                   [% END %]
129                                                   [% reason.lib | html %]
130                                                   </option>
131                                               [% END %]
132                                           </select>
133                                       [% ELSE %]
134                                           <p title="Define values in authorised value category ADJ_REASON to enable">None</p>
135                                           <input type="hidden" name="reason" id="reason_[% adjustment.adjustment_id | html %]" value="" />
136                                   [% END %]
137                                   </td>
138                                   <td><input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/></td>
139                                   <td>
140                                       <select id="budget_id_[% adjustment.adjustment_id | html %]" name="budget_id">
141                                               <option value="">No fund</option>
142                                           [% FOREACH budget IN budgets %]
143                                               [% IF ( budget.b_id == adjustment.budget_id ) %]
144                                                   <option selected="selected" value="[% budget.b_id | html %]">
145                                               [% ELSE %]
146                                                   <option value="[% budget.b_id | html %]">
147                                               [% END %]
148                                               [% budget.b_txt | html %]
149                                               </option>
150                                           [% END %]
151                                       </select>
152                                   </td>
153                                   [% IF adjustment.encumber_open %]
154                                       <td>
155                                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" checked/>
156                                       </td>
157                                   [% ELSE %]
158                                       <td>
159                                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" />
160                                       </td>
161                                   [% END %]
162                                   <td>
163                                      <a class="btn btn-default btn-xs delete_adjustment" href="/cgi-bin/koha/acqui/invoice.pl?op=del_adj&adjustment_id=[% adjustment.adjustment_id | html %]&invoiceid=[% invoiceid | html %]"><i class="fa fa-trash"></i> Delete</a>
164                                   </td>
165                               </tr>
166                           [% END %]
167                       </table>
168                   [% END %]
169
170                   <p>
171                       <a href="#" id="show_invoice_adjustment" class="toggle_invoice_adjustment"><i class="fa fa-plus"></i> Add an adjustment</a>
172                   </p>
173
174                   <fieldset id="add_invoice_adjustment" style="display:none">
175                       <h4>Add an adjustment</h4>
176                       <input type="hidden" name="adjustment_id" value="new" />
177                           <ol>
178                               <li>
179                                   <label for="adjustment_new">Amount: </label>
180                                   <input type="text" name="adjustment" id="adjustment_new" />
181                               </li>
182                               [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
183                               [% IF reasons.0 %]
184                                   <li>
185                                       <label for="reason_[% adjustment.adjustment_id | html %]">Reason: </label>
186                                       <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
187                                           <option value="">No reason</option>
188                                           [% FOREACH reason IN reasons %]
189                                               <option value="[% reason.authorised_value | html %]">
190                                                   [% reason.lib | html %]
191                                               </option>
192                                           [% END %]
193                                       </select>
194                                   </li>
195                               [% ELSE %]
196                                   <li>
197                                       <span class="label">Reason: </span>
198                                       <span>None</span>
199                                       <div class="hint">Define values in authorised value category ADJ_REASON to enable</div>
200                                   </li>
201                               [% END %]
202                               <li>
203                                   <label for="note_new">Note: </label>
204                                   <input type="text" name="note" id="note_new" value=""/>
205                               </li>
206                               <li>
207                                   <label for="budget_id_new">Fund: </label>
208                                   <select id="budget_id_new" name="budget_id">
209                                       <option selected="selected" value="">No fund</option>
210                                       [% FOREACH budget IN budgets %]
211                                           <option value="[% budget.b_id | html %]">
212                                           [% budget.b_txt | html %]
213                                           </option>
214                                       [% END %]
215                                   </select>
216                               </li>
217                               <li>
218                                   <label for="encumber_new">Encumber while invoice open? </label>
219                                   <input type="checkbox" name="encumber_open" id="encumber_new" value="new" />
220                                   <input type="hidden" name="delete" value="">
221                               </li>
222                               <li>
223                                   <span class="label">&nbsp;</span>
224                                   <a href="#" id="cancel_invoice_adjustment" class="toggle_invoice_adjustment" style="display:none"><i class="fa fa-remove"></i> Cancel</a>
225                               </li>
226                           </ol>
227                       </fieldset>
228                       <fieldset class="action">
229                           <input type="hidden" name="op" value="mod_adj" />
230                           <input type="submit" value="Update adjustments" />
231                       </fieldset>
232                   </fieldset>
233               </form>
234       <p>
235           <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Go to receipt page</a>
236           [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">Manage invoice files</a>[% END %]
237       </p>
238       <h2>Invoice details</h2>
239       <fieldset>
240       [% IF orders_loop.size %]
241           <label for="show_all_details">
242             <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
243             Show all details
244           </label>
245           <table id="orderst">
246             <thead>
247               <tr>
248                 <th class="anti-the">Summary</th>
249                 <th>Library</th>
250                 <th class="tax_excluded">Actual cost tax exc.</th>
251                 <th class="tax_included">Actual cost tax inc.</th>
252                 <th class="replacementprice">Replacement price</th>
253                 <th>Qty.</th>
254                 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
255                 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
256                 <th>GST %</th>
257                 <th>GST</th>
258                 <th>Fund</th>
259               </tr>
260             </thead>
261             <tbody>
262               [% FOREACH order IN orders_loop %]
263                 <tr>
264                   <td>
265                     [% IF order.biblionumber %]
266                       <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber | uri %]">[% order.title | html %]</a>
267                       [% IF ( order.author ) %]
268                         <br /><em>by</em> [% order.author | html %]
269                       [% END %]
270                     [% ELSE %]
271                       <em>Deleted bibliographic record, can't find title</em>
272                     [% END %]
273                     [% IF ( order.isbn ) %] &ndash; [% order.isbn | html %][% END %]
274                     [% IF ( order.publishercode ) %]
275                       <br/>[% order.publishercode | html %]
276                         [% IF order.publicationyear %], [% order.publicationyear | html %]
277                         [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate | html %][% END %]
278                     [% END %]
279                   </td>
280                   <td><p>[% order.branchcode | html %]</p></td>
281                   <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price %]</td>
282                   <td class="number tax_included">[% order.unitprice_tax_included | $Price %]</td>
283                   <td class="number replacementprice">[% order.replacementprice | $Price %] [% IF ( order.uncertainprice ) %] (Uncertain) [% END %]</td>
284                   <td class="number">[% order.quantity | html %]</td>
285                   <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
286                   <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
287                   <td class="number">[% order.tax_rate * 100 | html %]</td>
288                   <td class="number">[% order.tax_value | $Price %]</td>
289                   <td>[% order.budget_name | html %]</td>
290                 </tr>
291               [% END %]
292             </tbody>
293             <tfoot>
294               [% FOR tf IN foot_loop %]
295                 <tr>
296                     <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
297                     <th class="tax_excluded"></th>
298                     <th class="tax_included"></th>
299                     <th class="replacementprice"/>
300                     <th>[% tf.quantity | html %]</th>
301                     <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
302                     <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
303                     <th>&nbsp;</th>
304                     <th>[% tf.tax_value | $Price %]</th>
305                     <th>&nbsp;</th>
306                 </tr>
307               [% END %]
308               <tr>
309                 <th colspan="2">Total ([% currency.symbol | html %])</th>
310                 <th class="tax_excluded"></th>
311                 <th class="tax_included"></th>
312                 <th class="replacementprice"/>
313                 <th>[% total_quantity | html %]</th>
314                 <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
315                 <th class="tax_included">[% total_tax_included | $Price %]</th>
316                 <th>&nbsp;</th>
317                 <th>[% total_tax_value | $Price %]</th>
318                 <th>&nbsp;</th>
319               </tr>
320               <tr>
321                 <th colspan="2">Total + adjustments + shipment cost ([% currency.symbol | html %])</th>
322                 <th class="tax_excluded"></th>
323                 <th class="tax_included"></th>
324                 <th class="replacementprice"/>
325                 <th>[% total_quantity | html %]</th>
326                 <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
327                 <th class="tax_included">[% total_tax_included_shipment + total_adj | $Price %]</th>
328                 <th>&nbsp;</th>
329                 <th>[% total_tax_value | $Price %]</th>
330                 <th>&nbsp;</th>
331               </tr>
332             </tfoot>
333           </table>
334         [% ELSE %]
335             <div class="dialog message"><p>No orders yet</p>
336             [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
337             <p>Adjustments plus shipping: [% total_adj + shipmentcost | $Price %]</p>
338             [% END %]
339             </div>
340         [% END %]
341         [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
342             <br />
343             <h2>Files attached to invoice</h2>
344             <table id="invoice_files_table">
345                 <thead>
346                     <tr>
347                         <th>Name</th>
348                         <th>Type</th>
349                         <th>Description</th>
350                         <th>Uploaded</th>
351                     </tr>
352                 </thead>
353                 <tbody>
354                 [% FOREACH f IN files %]
355                     <tr>
356                          <td><a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]&amp;op=download&amp;view=1&amp;file_id=[% f.file_id | uri %]">[% f.file_name | html %]</a></td>
357                          <td>[% f.file_type | html %]</td>
358                          <td>[% f.file_description | html %]</td>
359                          <td class="title-string">
360                            <span title="[% f.date_uploaded | html %]">[% f.date_uploaded | $KohaDates %]</span>
361                          </td>
362                     </tr>
363                 [% END %]
364                 </tbody>
365             </table>
366         [% END %]
367         </fieldset>
368     </main>
369   </div> <!-- /.col-sm-10.col-sm-push-2 -->
370
371     <aside>
372         <div class="col-sm-2 col-sm-pull-10">
373             [% INCLUDE 'acquisitions-menu.inc' %]
374         </div>
375     </aside>
376 </div> <!-- /.row -->
377
378 [% MACRO jsinclude BLOCK %]
379     [% Asset.js("js/acquisitions-menu.js") | $raw %]
380     [% INCLUDE 'calendar.inc' %]
381     [% INCLUDE 'datatables.inc' %]
382     <script>
383         function updateColumnsVisibility(visible) {
384             if ( visible ) {
385                 $("table .tax_excluded, .tax_included").show();
386             } else {
387                 [% IF ( invoiceincgst ) %]
388                     $("table .tax_excluded").hide();
389                 [% ELSE %]
390                     $("table .tax_included").hide();
391                 [% END %]
392             }
393         }
394
395         $(document).ready(function() {
396             $("#delete").click(function(){
397                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
398             });
399             $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
400                 bInfo: false,
401                 bPaginate: false,
402                 bFilter: false,
403                 sDom: "t",
404                 "aoColumnDefs": [
405                     { "sType": "anti-the", "aTargets": [ "anti-the" ] }
406                 ]
407             }));
408             [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
409                 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
410                     "aoColumnDefs": [
411                         { "aTargets": [ "title-string" ], "sType": "title-string" }
412                     ],
413                     bInfo: false,
414                     bPaginate: false,
415                     bFilter: false,
416                     sDom: "t"
417                 }));
418             [% END %]
419             $("#show_all_details").click(function(){
420                 updateColumnsVisibility( $(this).is(":checked") );
421             });
422
423             $("#show_all_details").prop('checked', false);
424             updateColumnsVisibility(false);
425             $(".toggle_invoice_adjustment").on("click", function(e){
426                 e.preventDefault();
427                 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
428             });
429             $("a.delete_adjustment").click(function(){
430                 return ( confirm( _("Are you sure you want to delete this file ?") ) );
431             });
432
433             //keep a copy of all budgets before removing the inactives
434             var budgetId = $("#shipment_budget_id");
435             var disabledBudgetsCopy = budgetId.html();
436             $('.b_inactive').remove();
437
438             $('#showallfunds').click(function() {
439                 if ($(this).is(":checked")) {
440                     budgetId.html(disabledBudgetsCopy); //Puts back all the funds
441                 }
442                 else {
443                     $('.b_inactive').remove();
444                 }
445             });
446         });
447     </script>
448 [% END %]
449
450 [% INCLUDE 'intranet-bottom.inc' %]