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