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