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