Bug 19166: (follow-up) Add ADJ_REASON auhtorised value category and minor fixes
[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>
80         <fieldset class="action">
81             <input type="submit" value="Save" />
82             [% UNLESS orders_loop.size %]
83             <a href="invoice.pl?op=delete&invoiceid=[% invoiceid %]" id="delete">Delete</a>
84             [% END %]
85         </fieldset>
86       </form>
87       <form action="/cgi-bin/koha/acqui/invoice.pl" method="post" class="validated">
88           <input type="hidden" name="invoiceid" value="[% invoiceid %]" />
89               <table id="invoice_adj_table">
90                   <tr>
91                      <th>Id</th>
92                      <th>Amount</th>
93                      <th>Reason</th>
94                      <th>Note</th>
95                      <th>Fund</th>
96                      <th>Encumber while invoice open</th>
97                      <th>&nbsp</th>
98                   </tr>
99                   [% IF (adjustments.count > 0) %]
100                   <tr><td colspan="7">Current adjustments</td></tr>
101                   [% total_adj = 0 %]
102                   [% FOREACH adjustment IN adjustments %]
103                   [% total_adj = total_adj + adjustment.adjustment %]
104                   <tr>
105                       <td><input type="hidden" name="adjustment_id" value="[% adjustment.adjustment_id %]" />[% adjustment.adjustment_id %]</td>
106                       <td><input type="text" name="adjustment" id="adjustment_[% adjustment.adjustment_id %]" value="[% adjustment.adjustment | $Price %]" /></td>
107                       <td>
108                           [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
109                           [% IF reasons.0 %]
110                           <select id="reason_[% adjustment.adjustment_id %]" name="reason">
111                                   <option value="">No reason</option>
112                               [% FOREACH reason IN reasons %]
113                                 [% IF ( adjustment.reason == reason.authorised_value ) %]
114                                   <option selected="selected" value="[% reason.authorised_value %]">
115                                 [% ELSE %]
116                                   <option value="[% reason.authorised_value %]">
117                                 [% END %]
118                                   [% reason.lib %]
119                                   </option>
120                               [% END %]
121                           </select>
122                           [% ELSE %]
123                           <p title="Define values in authorised value category ADJ_REASON to enable">None</p>
124                           <input type="hidden" name="reason" id="reason_[% adjustment.adjustment_id %]" value="" />
125                           [% END %]
126                       </td>
127                       <td><input type="text" name="note" id="note_new" value="[% adjustment.note %]"/></td>
128                       <td>
129                           <select id="budget_id_[% adjustment.adjustment_id %]" name="budget_id">
130                                   <option value="">No fund</option>
131                               [% FOREACH budget IN budgets_loop %]
132                                 [% IF ( budget.budget_id == adjustment.budget_id ) %]
133                                   <option selected="selected" value="[% budget.budget_id %]">
134                                 [% ELSE %]
135                                   <option value="[% budget.budget_id %]">
136                                 [% END %]
137                                   [% budget.budget_name %]
138                                   </option>
139                               [% END %]
140                           </select>
141                       </td>
142                       [% IF adjustment.encumber_open %]
143                       <td>
144                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id %]"  value="[% adjustment.adjustment_id %]" checked/>
145                       </td>
146                       [% ELSE %]
147                       <td>
148                           <input type="checkbox" name="encumber_open" id="encumber_[% adjustment.adjustment_id %]"  value="[% adjustment.adjustment_id %]" />
149                       </td>
150                       [% END %]
151                       <td>
152                           <a class="btn btn-default btn-xs" 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>
153                       </td>
154                   </tr>
155                   [% END %]
156                   [% END %]
157                   <tr><td colspan="7">Add an adjustment</td></tr>
158                       <td><input type="hidden" name="adjustment_id" value="new" />New</td>
159                       <td><input type="text" name="adjustment" id="adjustment_new]" /></td>
160                       <td>
161                           [% reasons = AuthorisedValues.Get("ADJ_REASON") %]
162                           [% IF reasons.0 %]
163                           <select id="reason_[% adjustment.adjustment_id %]" name="reason">
164                                   <option value="">No reason</option>
165                                 [% FOREACH reason IN reasons %]
166                                   <option value="[% reason.authorised_value %]">
167                                   [% reason.lib %]
168                                   </option>
169                                 [% END %]
170                           </select>
171                           [% ELSE %]
172                           <p title="Define values in authorised value category ADJ_REASON to enable">None</p>
173                           [% END %]
174                       </td>
175                       <td><input type="text" name="note" id="note_new" value=""/></td>
176                       <td>
177                           <select id="budget_id_[% adjustment.adjustment_id %]" name="budget_id">
178                                <option selected="selected" value="">No fund</option>
179                                [% FOREACH budget IN budgets_loop %]
180                                <option value="[% budget.budget_id %]">
181                                [% budget.budget_name %]
182                                </option>
183                                [% END %]
184                           </select>
185                       </td>
186                       <td><input type="checkbox" name="encumber_open" id="encumber_new" value="new" /></td>
187                       <td><input type="hidden" name="delete" value=""></td>
188                   </tr>
189                 </table>
190           <input type="hidden" name="op" value="mod_adj" />
191           <input type="submit" value="Update adjustments" />
192       </form>
193       <p>
194           <a href="/cgi-bin/koha/acqui/parcel.pl?invoiceid=[% invoiceid %]">Go to receipt page</a>
195           [% IF Koha.Preference('AcqEnableFiles') %]| <a href="/cgi-bin/koha/acqui/invoice-files.pl?invoiceid=[% invoiceid %]">Manage invoice files</a>[% END %]
196       </p>
197       <h2>Invoice details</h2>
198       [% IF orders_loop.size %]
199           <label for="show_all_details">
200             <input type="checkbox" style="vertical-align: middle;" id="show_all_details" />
201             Show all details
202           </label>
203           <table id="orderst">
204             <thead>
205               <tr>
206                 <th class="anti-the">Summary</th>
207                 <th>Library</th>
208                 <th class="tax_excluded">Actual cost tax exc.</th>
209                 <th class="tax_included">Actual cost tax inc.</th>
210                 <th>Qty.</th>
211                 <th class="tax_excluded">Total tax exc. ([% currency.symbol %])</th>
212                 <th class="tax_included">Total tax inc. ([% currency.symbol %])</th>
213                 <th>GST %</th>
214                 <th>GST</th>
215                 <th>Fund</th>
216               </tr>
217             </thead>
218             <tbody>
219               [% FOREACH order IN orders_loop %]
220                 <tr>
221                   <td>
222                     [% IF order.biblionumber %]
223                       <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% order.biblionumber %]">[% order.title |html %]</a>
224                       [% IF ( order.author ) %]
225                         <br /><em>by</em> [% order.author %]
226                       [% END %]
227                     [% ELSE %]
228                       <em>Deleted bibliographic record, can't find title</em>
229                     [% END %]
230                     [% IF ( order.isbn ) %] &ndash; [% order.isbn %][% END %]
231                     [% IF ( order.publishercode ) %]
232                       <br/>[% order.publishercode %]
233                         [% IF order.publicationyear %], [% order.publicationyear %]
234                         [% ELSIF ( order.copyrightdate ) %][% order.copyrightdate %][% END %]
235                     [% END %]
236                   </td>
237                   <td><p>[% order.branchcode %]</p></td>
238                   <td class="number tax_excluded">[% order.unitprice_tax_excluded | $Price %]</td>
239                   <td class="number tax_included">[% order.unitprice_tax_included | $Price %]</td>
240                   <td class="number">[% order.quantity %]</td>
241                   <td class="number tax_excluded">[% order.total_tax_excluded | $Price %]</td>
242                   <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
243                   <td class="number">[% order.tax_rate * 100 %]</td>
244                   <td class="number">[% order.tax_value | $Price %]</td>
245                   <td>[% order.budget_name %]</td>
246                 </tr>
247               [% END %]
248             </tbody>
249             <tfoot>
250               [% FOR tf IN foot_loop %]
251                 <tr>
252                     <th colspan="2">Total (GST [% tf.tax_rate * 100 %] %)</th>
253                     <th class="tax_excluded"></th>
254                     <th class="tax_included"></th>
255                     <th>[% tf.quantity %]</th>
256                     <th class="tax_excluded">[% tf.total_tax_excluded | $Price %]</th>
257                     <th class="tax_included">[% tf.total_tax_included | $Price %]</th>
258                     <th>&nbsp;</th>
259                     <th>[% tf.tax_value | $Price %]</th>
260                     <th>&nbsp;</th>
261                 </tr>
262               [% END %]
263               <tr>
264                 <th colspan="2">Total ([% currency.symbol %])</th>
265                 <th class="tax_excluded"></th>
266                 <th class="tax_included"></th>
267                 <th>[% total_quantity %]</th>
268                 <th class="tax_excluded">[% total_tax_excluded | $Price %]</th>
269                 <th class="tax_included">[% total_tax_included | $Price %]</th>
270                 <th>&nbsp;</th>
271                 <th>[% total_tax_value | $Price %]</th>
272                 <th>&nbsp;</th>
273               </tr>
274               <tr>
275                 <th colspan="2">Total + Adjustments + Shipment cost ([% currency.symbol %])</th>
276                 <th class="tax_excluded"></th>
277                 <th class="tax_included"></th>
278                 <th>[% total_quantity %]</th>
279                 <th class="tax_excluded">[% total_tax_excluded_shipment + total_adj | $Price %]</th>
280                 <th class="tax_included">[% total_tax_included_shipment | $Price %]</th>
281                 <th>&nbsp;</th>
282                 <th>[% total_tax_value | $Price %]</th>
283                 <th>&nbsp;</th>
284               </tr>
285             </tfoot>
286           </table>
287         [% ELSE %]
288             <div class="dialog message"><p>No orders yet</p>
289             [% IF adjustments && adjustments.count > 0 || shipmentcost && shipmentcost > 0 %]
290             <p>Adjustments plus shipping:[% total_adj + shipmentcost | $Price %]</p>
291             [% END %]
292             </div>
293         [% END %]
294         [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
295             <br />
296             <h2>Files attached to invoice</h2>
297             <table id="invoice_files_table">
298                 <thead>
299                     <tr>
300                         <th>Name</th>
301                         <th>Type</th>
302                         <th>Description</th>
303                         <th>Uploaded</th>
304                     </tr>
305                 </thead>
306                 <tbody>
307                 [% FOREACH f IN files %]
308                     <tr>
309                          <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>
310                          <td>[% f.file_type | html %]</td>
311                          <td>[% f.file_description | html %]</td>
312                          <td class="title-string">
313                            <span title="[% f.date_uploaded %]">[% f.date_uploaded | $KohaDates %]</span>
314                          </td>
315                     </tr>
316                 [% END %]
317                 </tbody>
318             </table>
319         [% END %]
320     </main>
321   </div> <!-- /.col-sm-10.col-sm-push-2 -->
322
323     <aside>
324         <div class="col-sm-2 col-sm-pull-10">
325             [% INCLUDE 'acquisitions-menu.inc' %]
326         </div>
327     </aside>
328 </div> <!-- /.row -->
329
330 [% MACRO jsinclude BLOCK %]
331     [% Asset.js("js/acquisitions-menu.js") %]
332     [% INCLUDE 'calendar.inc' %]
333     [% INCLUDE 'datatables.inc' %]
334     <script>
335         function updateColumnsVisibility(visible) {
336             if ( visible ) {
337                 $("table .tax_excluded, .tax_included").show();
338             } else {
339                 [% IF ( invoiceincgst ) %]
340                     $("table .tax_excluded").hide();
341                 [% ELSE %]
342                     $("table .tax_included").hide();
343                 [% END %]
344             }
345         }
346
347         $(document).ready(function() {
348             $("#delete").click(function(){
349                 return confirmDelete(_("Are you sure you want to delete this invoice?"));
350             });
351             $("#orderst").dataTable($.extend(true, {}, dataTablesDefaults, {
352                 bInfo: false,
353                 bPaginate: false,
354                 bFilter: false,
355                 sDom: "t",
356                 "aoColumnDefs": [
357                     { "sType": "anti-the", "aTargets": [ "anti-the" ] }
358                 ]
359             }));
360             [% IF ( (Koha.Preference('AcqEnableFiles')) && files ) %]
361                 $("#invoice_files_table").dataTable($.extend(true, {}, dataTablesDefaults, {
362                     "aoColumnDefs": [
363                         { "aTargets": [ "title-string" ], "sType": "title-string" }
364                     ],
365                     bInfo: false,
366                     bPaginate: false,
367                     bFilter: false,
368                     sDom: "t"
369                 }));
370             [% END %]
371             $("#show_all_details").click(function(){
372                 updateColumnsVisibility( $(this).is(":checked") );
373             });
374
375             $("#show_all_details").prop('checked', false);
376             updateColumnsVisibility(false);
377         });
378     </script>
379 [% END %]
380
381 [% INCLUDE 'intranet-bottom.inc' %]