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