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