Bug 22015: Move DataTables CSS to global include
[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 <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>
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 | html %]</h1>
31
32       <p>Vendor: <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% booksellerid | uri %]">[% suppliername | html %]</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 | html %]" 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 | $Price on_editing => 1 %]" /></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 | html %]">
56                         [% ELSE %]
57                           <option value="[% budget.budget_id | html %]">
58                         [% END %]
59                           [% budget.budget_name | html %]
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 | html %]" />
79             <fieldset class="action">
80                 <input type="submit" value="Save" />
81                 [% UNLESS orders_loop.size %]
82                 <a href="invoice.pl?op=delete&invoiceid=[% invoiceid | uri %]" 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 | html %]" />
95                   [% IF (adjustments && 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 | html %]" />[% adjustment.adjustment_id | html %]</td>
111                                   <td><input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id | html %]" value="[% adjustment.adjustment | $Price on_editing => 1 %]" /></td>
112                                   <td>
113                                       [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
114                                       [% IF reasons.0 %]
115                                           <select id="reason_[% adjustment.adjustment_id | html %]" 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 | html %]">
120                                                   [% ELSE %]
121                                                       <option value="[% reason.authorised_value | html %]">
122                                                   [% END %]
123                                                   [% reason.lib | html %]
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 | html %]" value="" />
130                                   [% END %]
131                                   </td>
132                                   <td><input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/></td>
133                                   <td>
134                                       <select id="budget_id_[% adjustment.adjustment_id | html %]" 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 | html %]">
139                                               [% ELSE %]
140                                                   <option value="[% budget.budget_id | html %]">
141                                               [% END %]
142                                               [% budget.budget_name | html %]
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 | html %]"  value="[% adjustment.adjustment_id | html %]" checked/>
150                                       </td>
151                                   [% ELSE %]
152                                       <td>
153                                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id | html %]"  value="[% adjustment.adjustment_id | html %]" />
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 | html %]&invoiceid=[% invoiceid | html %]"><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 | html %]">Reason: </label>
180                                       <select id="reason_[% adjustment.adjustment_id | html %]" name="reason">
181                                           <option value="">No reason</option>
182                                           [% FOREACH reason IN reasons %]
183                                               <option value="[% reason.authorised_value | html %]">
184                                                   [% reason.lib | html %]
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 | html %]">
206                                           [% budget.budget_name | html %]
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 | uri %]">Go to receipt page</a>
230           [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid | uri %]">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 class="replacementprice">Replacement price</th>
247                 <th>Qty.</th>
248                 <th class="tax_excluded">Total tax exc. ([% currency.symbol | html %])</th>
249                 <th class="tax_included">Total tax inc. ([% currency.symbol | html %])</th>
250                 <th>GST %</th>
251                 <th>GST</th>
252                 <th>Fund</th>
253               </tr>
254             </thead>
255             <tbody>
256               [% FOREACH order IN orders_loop %]
257                 <tr>
258                   <td>
259                     [% IF order.biblionumber %]
260                       <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber | uri %]">[% order.title | html %]</a>
261                       [% IF ( order.author ) %]
262                         <br /><em>by</em> [% order.author | html %]
263                       [% END %]
264                     [% ELSE %]
265                       <em>Deleted bibliographic record, can't find title</em>
266                     [% END %]
267                     [% IF ( order.isbn ) %] &ndash; [% order.isbn | html %][% END %]
268                     [% IF ( order.publishercode ) %]
269                       <br/>[% order.publishercode | html %]
270                         [% IF order.publicationyear %], [% order.publicationyear | html %]
271                         [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate | html %][% END %]
272                     [% END %]
273                   </td>
274                   <td><p>[% order.branchcode | html %]</p></td>
275                   <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price %]</td>
276                   <td class="number tax_included">[% order.unitprice_tax_included | $Price %]</td>
277                   <td class="number replacementprice">[% order.replacementprice | $Price %]</td>
278                   <td class="number">[% order.quantity | html %]</td>
279                   <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
280                   <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
281                   <td class="number">[% order.tax_rate * 100 | html %]</td>
282                   <td class="number">[% order.tax_value | $Price %]</td>
283                   <td>[% order.budget_name | html %]</td>
284                 </tr>
285               [% END %]
286             </tbody>
287             <tfoot>
288               [% FOR tf IN foot_loop %]
289                 <tr>
290                     <th colspan="2">Total (GST [% tf.tax_rate * 100 | html %] %)</th>
291                     <th class="tax_excluded"></th>
292                     <th class="tax_included"></th>
293                     <th class="replacementprice"/>
294                     <th>[% tf.quantity | html %]</th>
295                     <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
296                     <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
297                     <th>&nbsp;</th>
298                     <th>[% tf.tax_value | $Price %]</th>
299                     <th>&nbsp;</th>
300                 </tr>
301               [% END %]
302               <tr>
303                 <th colspan="2">Total ([% currency.symbol | html %])</th>
304                 <th class="tax_excluded"></th>
305                 <th class="tax_included"></th>
306                 <th class="replacementprice"/>
307                 <th>[% total_quantity | html %]</th>
308                 <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
309                 <th class="tax_included">[% total_tax_included | $Price %]</th>
310                 <th>&nbsp;</th>
311                 <th>[% total_tax_value | $Price %]</th>
312                 <th>&nbsp;</th>
313               </tr>
314               <tr>
315                 <th colspan="2">Total + Adjustments + Shipment cost ([% currency.symbol | html %])</th>
316                 <th class="tax_excluded"></th>
317                 <th class="tax_included"></th>
318                 <th class="replacementprice"/>
319                 <th>[% total_quantity | html %]</th>
320                 <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
321                 <th class="tax_included">[% total_tax_included_shipment | $Price %]</th>
322                 <th>&nbsp;</th>
323                 <th>[% total_tax_value | $Price %]</th>
324                 <th>&nbsp;</th>
325               </tr>
326             </tfoot>
327           </table>
328         [% ELSE %]
329             <div class="dialog message"><p>No orders yet</p>
330             [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
331             <p>Adjustments plus shipping:[% total_adj + shipmentcost | $Price %]</p>
332             [% END %]
333             </div>
334         [% END %]
335         [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
336             <br />
337             <h2>Files attached to invoice</h2>
338             <table id="invoice_files_table">
339                 <thead>
340                     <tr>
341                         <th>Name</th>
342                         <th>Type</th>
343                         <th>Description</th>
344                         <th>Uploaded</th>
345                     </tr>
346                 </thead>
347                 <tbody>
348                 [% FOREACH f IN files %]
349                     <tr>
350                          <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>
351                          <td>[% f.file_type | html %]</td>
352                          <td>[% f.file_description | html %]</td>
353                          <td class="title-string">
354                            <span title="[% f.date_uploaded | html %]">[% f.date_uploaded | $KohaDates %]</span>
355                          </td>
356                     </tr>
357                 [% END %]
358                 </tbody>
359             </table>
360         [% END %]
361         </fieldset>
362     </main>
363   </div> <!-- /.col-sm-10.col-sm-push-2 -->
364
365     <aside>
366         <div class="col-sm-2 col-sm-pull-10">
367             [% INCLUDE 'acquisitions-menu.inc' %]
368         </div>
369     </aside>
370 </div> <!-- /.row -->
371
372 [% MACRO jsinclude BLOCK %]
373     [% Asset.js("js/acquisitions-menu.js") | $raw %]
374     [% INCLUDE 'calendar.inc' %]
375     [% INCLUDE 'datatables.inc' %]
376     <script>
377         function updateColumnsVisibility(visible) {
378             if ( visible ) {
379                 $("table .tax_excluded, .tax_included").show();
380             } else {
381                 [% IF ( invoiceincgst ) %]
382                     $("table .tax_excluded").hide();
383                 [% ELSE %]
384                     $("table .tax_included").hide();
385                 [% END %]
386             }
387         }
388
389         $(document).ready(function() {
390             $("#delete").click(function(){
391                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
392             });
393             $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
394                 bInfo: false,
395                 bPaginate: false,
396                 bFilter: false,
397                 sDom: "t",
398                 "aoColumnDefs": [
399                     { "sType": "anti-the", "aTargets": [ "anti-the" ] }
400                 ]
401             }));
402             [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
403                 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
404                     "aoColumnDefs": [
405                         { "aTargets": [ "title-string" ], "sType": "title-string" }
406                     ],
407                     bInfo: false,
408                     bPaginate: false,
409                     bFilter: false,
410                     sDom: "t"
411                 }));
412             [% END %]
413             $("#show_all_details").click(function(){
414                 updateColumnsVisibility( $(this).is(":checked") );
415             });
416
417             $("#show_all_details").prop('checked', false);
418             updateColumnsVisibility(false);
419             $(".toggle_invoice_adjustment").on("click", function(e){
420                 e.preventDefault();
421                 $("#show_invoice_adjustment, #cancel_invoice_adjustment, #add_invoice_adjustment").toggle();
422             });
423             $("a.delete_adjustment").click(function(){
424                 return ( confirm( _("Are you sure you want to delete this file ?") ) );
425             });
426         });
427     </script>
428 [% END %]
429
430 [% INCLUDE 'intranet-bottom.inc' %]