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