Bug 31115: Add additional field filtering for invoice search
[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       <hr />
162
163         <h3>Adjustments</h3>
164
165           <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
166               <fieldset class="rows">
167                   <input type="hidden" name="invoiceid" value="[% invoiceid | html %]" />
168                   [% IF (adjustments && adjustments.count > 0) %]
169                       <table id="invoice_adj_table">
170                           <tr>
171                              <th>Id</th>
172                              <th>Amount</th>
173                              <th>Reason</th>
174                              <th>Note</th>
175                              <th>Fund</th>
176                              <th>Encumber while invoice open</th>
177                              [% UNLESS readonly %]<th>&nbsp</th>[% END %]
178                           </tr>
179                           [% total_adj = 0 %]
180                           [% FOREACH adjustment IN adjustments %]
181                               [% total_adj = total_adj + adjustment.adjustment %]
182                               <tr>
183                                   <td><input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id | html %]" />[% adjustment.adjustment_id | html %]</td>
184                                   <td>
185                                     [% IF readonly %]
186                                         [% adjustment.adjustment | $Price %]
187                                     [% ELSE %]
188                                         <input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" />
189                                     [% END %]
190                                   </td>
191                                   <td>
192                                       [% IF readonly %]
193                                           [% AuthorisedValues.GetByCode('ADJ_REASON', adjustment.reason) | html %]
194                                       [% ELSE %]
195                                           [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
196                                           [% IF reasons.0 %]
197                                               <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
198                                                   <option value="">No reason</option>
199                                                   [% FOREACH reason IN reasons %]
200                                                       [% IF ( adjustment.reason == reason.authorised_value ) %]
201                                                           <option selected="selected" value="[% reason.authorised_value | html %]">
202                                                       [% ELSE %]
203                                                           <option value="[% reason.authorised_value | html %]">
204                                                       [% END %]
205                                                       [% reason.lib | html %]
206                                                       </option>
207                                                   [% END %]
208                                               </select>
209                                           [% ELSE %]
210                                               <p title="Define values in authorised value category ADJ_REASON to enable">None</p>
211                                               <input type="hidden" name="reason" id="reason_[% adjustment.adjustment_id | html %]" value="" />
212                                           [% END %]
213                                         [% END %]
214                                   </td>
215                                   <td>
216                                       [% IF readonly %]
217                                           [% adjustment.note | html %]
218                                       [% ELSE %]
219                                           <input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/>
220                                       [% END %]
221                                   </td>
222                                   <td>
223                                       [% IF readonly %]
224                                           [% adjustement.fund.budget_name | html %]
225                                       [% ELSE %]
226                                           <select id="budget_id_[% adjustment.adjustment_id | html %]" name="budget_id">
227                                               <option value="">No fund</option>
228                                               [% FOREACH budget IN budgets %]
229                                                   [% IF ( budget.b_id == adjustment.budget_id ) %]
230                                                       <option selected="selected" value="[% budget.b_id | html %]">
231                                                   [% ELSE %]
232                                                       <option value="[% budget.b_id | html %]">
233                                                   [% END %]
234                                                   [% IF budget.b_active %]
235                                                       [% budget.b_txt | html %]
236                                                   [% ELSE %]
237                                                       [% budget.b_txt | html %] <span>(inactive)</span>
238                                                   [% END %]
239                                                   </option>
240                                               [% END %]
241                                           </select>
242                                       [% END %]
243                                   </td>
244                                   [% IF adjustment.encumber_open %]
245                                       <td>
246                                         [% IF readonly %]
247                                           <input type="checkbox" checked="checked" readonly="readonly" />
248                                         [% ELSE %]
249                                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" checked/>
250                                         [% END %]
251                                       </td>
252                                   [% ELSE %]
253                                       <td>
254                                         [% IF readonly %]
255                                           <input type="checkbox" disabled="disabled" />
256                                         [% ELSE %]
257                                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" />
258                                         [% END %]
259                                       </td>
260                                   [% END %]
261                                   [% UNLESS readonly %]
262                                       <td>
263                                          <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>
264                                       </td>
265                                   [% END %]
266                               </tr>
267                           [% END %]
268                       </table>
269                   [% END %]
270
271                   [% UNLESS readonly %]
272                       <p>
273                           <a href="#" id="show_invoice_adjustment" class="toggle_invoice_adjustment"><i class="fa fa-plus"></i> Add an adjustment</a>
274                       </p>
275
276                       <fieldset id="add_invoice_adjustment" style="display:none">
277                           <h4>Add an adjustment</h4>
278                           <input type="hidden" name="adjustment_id" value="new" />
279                               <ol>
280                                   <li>
281                                       <label for="adjustment_new">Amount: </label>
282                                       <input type="text" name="adjustment" id="adjustment_new" />
283                                   </li>
284                                   [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
285                                   [% IF reasons.0 %]
286                                       <li>
287                                           <label for="reason_[% adjustment.adjustment_id | html %]">Reason: </label>
288                                           <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
289                                               <option value="">No reason</option>
290                                               [% FOREACH reason IN reasons %]
291                                                   <option value="[% reason.authorised_value | html %]">
292                                                       [% reason.lib | html %]
293                                                   </option>
294                                               [% END %]
295                                           </select>
296                                       </li>
297                                   [% ELSE %]
298                                       <li>
299                                           <span class="label">Reason: </span>
300                                           <span>None</span>
301                                           <div class="hint">Define values in authorised value category ADJ_REASON to enable</div>
302                                       </li>
303                                   [% END %]
304                                   <li>
305                                       <label for="note_new">Note: </label>
306                                       <input type="text" name="note" id="note_new" value=""/>
307                                   </li>
308                                   <li>
309                                       <label for="budget_id_new">Fund: </label>
310                                       <select id="budget_id_new" name="budget_id">
311                                           <option value="">No fund</option>
312                                           [% FOREACH budget IN budgets %]
313                                               [% IF ( budget.selected ) %]
314                                                   <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
315                                               [% ELSIF ( budget.b_active ) %]
316                                                   <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
317                                               [% ELSE %]
318                                                   <option value="[% budget.b_id | html %]" class="ab_inactive">[% budget.b_txt | html %] (inactive)</option>
319                                               [% END %]
320                                           [% END %]
321                                       </select>
322                                       <label for="showallfunds_adj" style="float:none;width:auto;">&nbsp;Show inactive:</label>
323                                       <input type="checkbox" id="showallfunds_adj" />
324                                   </li>
325                                   <li>
326                                       <label for="encumber_new">Encumber while invoice open? </label>
327                                       <input type="checkbox" name="encumber_open" id="encumber_new" value="new" />
328                                       <input type="hidden" name="delete" value="">
329                                   </li>
330                                   <li>
331                                       <span class="label">&nbsp;</span>
332                                       <a href="#" id="cancel_invoice_adjustment" class="toggle_invoice_adjustment" style="display:none"><i class="fa fa-remove"></i> Cancel</a>
333                                   </li>
334                               </ol>
335                           </fieldset>
336                           <fieldset class="action">
337                               <input type="hidden" name="op" value="mod_adj" />
338                               <input type="submit" value="Update adjustments" />
339                           </fieldset>
340                     [% END %]
341                   </fieldset>
342               </form>
343       <p>
344           <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid | uri %]">Go to receipt page</a>
345           [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">Manage invoice files</a>[% END %]
346       </p>
347       <h2>Invoice details</h2>
348       <fieldset>
349       [% IF orders_loop.size %]
350           <label for="show_all_details">
351             <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
352             Show all details
353           </label>
354           <table id="orderst">
355             <thead>
356               <tr>
357                 <th class="anti-the">Summary</th>
358                 <th>Library</th>
359                 <th class="tax_excluded">Actual cost tax exc.</th>
360                 <th class="tax_included">Actual cost tax inc.</th>
361                 <th class="replacementprice">Replacement price</th>
362                 <th>Qty.</th>
363                 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
364                 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
365                 <th>GST %</th>
366                 <th>GST</th>
367                 <th>Fund</th>
368               </tr>
369             </thead>
370             <tbody>
371               [% FOREACH order IN orders_loop %]
372                 <tr>
373                   <td>
374                     [% IF order.biblionumber %]
375                       [% INCLUDE 'biblio-title.inc' biblio=order link = 1 %]
376                       [% IF ( order.author ) %]
377                         <br /><em>by</em> [% order.author | html %]
378                       [% END %]
379                     [% ELSE %]
380                       <em>Deleted bibliographic record, can't find title</em>
381                     [% END %]
382                     [% IF ( order.isbn ) %] &ndash; [% order.isbn | html %][% END %]
383                     [% IF ( order.publishercode ) %]
384                       <br/>[% order.publishercode | html %]
385                         [% IF order.publicationyear %], [% order.publicationyear | html %]
386                         [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate | html %][% END %]
387                     [% END %]
388                   </td>
389                   <td><p>[% order.branchcode | html %]</p></td>
390                   <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price %]</td>
391                   <td class="number tax_included">[% order.unitprice_tax_included | $Price %]</td>
392                   <td class="number replacementprice">[% order.replacementprice | $Price %] [% IF ( order.uncertainprice ) %] <span>(Uncertain)</span> [% END %]</td>
393                   <td class="number">[% order.quantity | html %]</td>
394                   <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
395                   <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
396                   <td class="number">[% order.tax_rate * 100 | html %]</td>
397                   <td class="number">[% order.tax_value | $Price %]</td>
398                   <td>[% order.budget_name | html %]</td>
399                 </tr>
400               [% END %]
401             </tbody>
402             <tfoot>
403               [% FOR tf IN foot_loop %]
404                 <tr>
405                     <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
406                     <th class="tax_excluded"></th>
407                     <th class="tax_included"></th>
408                     <th class="replacementprice"/>
409                     <th>[% tf.quantity | html %]</th>
410                     <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
411                     <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
412                     <th>&nbsp;</th>
413                     <th>[% tf.tax_value | $Price %]</th>
414                     <th>&nbsp;</th>
415                 </tr>
416               [% END %]
417               <tr>
418                 <th colspan="2">Total ([% currency.symbol | html %])</th>
419                 <th class="tax_excluded"></th>
420                 <th class="tax_included"></th>
421                 <th class="replacementprice"/>
422                 <th>[% total_quantity | html %]</th>
423                 <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
424                 <th class="tax_included">[% total_tax_included | $Price %]</th>
425                 <th>&nbsp;</th>
426                 <th>[% total_tax_value | $Price %]</th>
427                 <th>&nbsp;</th>
428               </tr>
429               <tr>
430                 <th colspan="2">Total + adjustments + shipment cost ([% currency.symbol | html %])</th>
431                 <th class="tax_excluded"></th>
432                 <th class="tax_included"></th>
433                 <th class="replacementprice"/>
434                 <th>[% total_quantity | html %]</th>
435                 <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
436                 <th class="tax_included">[% total_tax_included_shipment + total_adj | $Price %]</th>
437                 <th>&nbsp;</th>
438                 <th>[% total_tax_value | $Price %]</th>
439                 <th>&nbsp;</th>
440               </tr>
441             </tfoot>
442           </table>
443         [% ELSE %]
444             <div class="dialog message"><p>No orders yet</p>
445             [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
446             <p>Adjustments plus shipping: [% total_adj + shipmentcost | $Price %]</p>
447             [% END %]
448             </div>
449         [% END %]
450         [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
451             <br />
452             <h2>Files attached to invoice</h2>
453             <table id="invoice_files_table">
454                 <thead>
455                     <tr>
456                         <th>Name</th>
457                         <th>Type</th>
458                         <th>Description</th>
459                         <th>Uploaded</th>
460                     </tr>
461                 </thead>
462                 <tbody>
463                 [% FOREACH f IN files %]
464                     <tr>
465                          <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>
466                          <td>[% f.file_type | html %]</td>
467                          <td>[% f.file_description | html %]</td>
468                          <td data-order="[% f.date_uploaded | html %]">
469                             [% f.date_uploaded | $KohaDates %]
470                          </td>
471                     </tr>
472                 [% END %]
473                 </tbody>
474             </table>
475         [% END %]
476         </fieldset>
477     </main>
478   </div> <!-- /.col-sm-10.col-sm-push-2 -->
479
480     <aside>
481         <div class="col-sm-2 col-sm-pull-10">
482             [% INCLUDE 'acquisitions-menu.inc' %]
483         </div>
484     </aside>
485 </div> <!-- /.row -->
486
487 [% MACRO jsinclude BLOCK %]
488     [% Asset.js("js/acquisitions-menu.js") | $raw %]
489     [% INCLUDE 'calendar.inc' %]
490     [% INCLUDE 'datatables.inc' %]
491     <script>
492         function updateColumnsVisibility(visible) {
493             if ( visible ) {
494                 $("table .tax_excluded, .tax_included").show();
495             } else {
496                 [% IF ( invoiceincgst ) %]
497                     $("table .tax_excluded").hide();
498                 [% ELSE %]
499                     $("table .tax_included").hide();
500                 [% END %]
501             }
502         }
503
504         $(document).ready(function() {
505             $("#delete").click(function(){
506                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
507             });
508             $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
509                 bInfo: false,
510                 bPaginate: false,
511                 bFilter: false,
512                 sDom: "t",
513                 "aoColumnDefs": [
514                     { "sType": "anti-the", "aTargets": [ "anti-the" ] }
515                 ]
516             }));
517             [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
518                 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
519                     bInfo: false,
520                     bPaginate: false,
521                     bFilter: false,
522                     sDom: "t"
523                 }));
524             [% END %]
525             $("#show_all_details").click(function(){
526                 updateColumnsVisibility( $(this).is(":checked") );
527             });
528
529             $("#show_all_details").prop('checked', false);
530             updateColumnsVisibility(false);
531             $(".toggle_invoice_adjustment").on("click", function(e){
532                 e.preventDefault();
533                 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
534             });
535             $("a.delete_adjustment").click(function(){
536                 return ( confirm( _("Are you sure you want to delete this file ?") ) );
537             });
538
539             //keep a copy of all budgets before removing the inactives
540             var budgetId = $("#shipment_budget_id");
541             var disabledBudgetsCopy = budgetId.html();
542             $('.b_inactive').remove();
543
544             $('#showallfunds').click(function() {
545                 if ($(this).is(":checked")) {
546                     budgetId.html(disabledBudgetsCopy); //Puts back all the funds
547                 }
548                 else {
549                     $('.b_inactive').remove();
550                 }
551             });
552             // same effort for the adjustments
553             var adjBudgetId = $("#budget_id_new");
554             var disabledAdjBudgetsCopy = adjBudgetId.html();
555             $('.ab_inactive').remove();
556             $('#showallfunds_adj').click(function() {
557                 if ($(this).is(":checked")) {
558                     adjBudgetId.html(disabledAdjBudgetsCopy); //Puts back all the funds
559                 }
560                 else {
561                     $('.ab_inactive').remove();
562                 }
563             });
564         });
565     </script>
566 [% END %]
567
568 [% INCLUDE 'intranet-bottom.inc' %]