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