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