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