View | Details | Raw Unified | Return to bug 25763
Collapse All | Expand All

(-)a/acqui/invoice.pl (+3 lines)
Lines 207-212 foreach my $r ( @{$budgets} ) { Link Here
207
        b_txt    => $r->{budget_name},
207
        b_txt    => $r->{budget_name},
208
        b_active => $r->{budget_period_active},
208
        b_active => $r->{budget_period_active},
209
        selected => $selected,
209
        selected => $selected,
210
        b_sort1_authcat => $r->{'sort1_authcat'},
211
        b_sort2_authcat => $r->{'sort2_authcat'},
210
      };
212
      };
211
}
213
}
212
214
Lines 222-227 $template->param( Link Here
222
    suppliername                => $details->{'suppliername'},
224
    suppliername                => $details->{'suppliername'},
223
    booksellerid                => $details->{'booksellerid'},
225
    booksellerid                => $details->{'booksellerid'},
224
    shipmentdate                => $details->{'shipmentdate'},
226
    shipmentdate                => $details->{'shipmentdate'},
227
    shipment_budget_id          => $shipmentcost_budgetid,
225
    billingdate                 => $details->{'billingdate'},
228
    billingdate                 => $details->{'billingdate'},
226
    invoiceclosedate            => $details->{'closedate'},
229
    invoiceclosedate            => $details->{'closedate'},
227
    shipmentcost                => $shipmentcost,
230
    shipmentcost                => $shipmentcost,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (-44 / +129 lines)
Lines 5-10 Link Here
5
[% USE Price %]
5
[% USE Price %]
6
[% SET footerjs = 1 %]
6
[% SET footerjs = 1 %]
7
[% USE AuthorisedValues %]
7
[% USE AuthorisedValues %]
8
[% Asset.css("css/humanmsg.css") | $raw %]
9
10
<span style="display:none;" id="all_fund_dropdown">
11
    <option value="">No fund</option>
12
    [% FOREACH budget IN budgets %]
13
        [% IF ( budget.b_active ) %]
14
            <option value="[% budget.b_id | html %]" data-sort1-authcat="[% budget.b_sort1_authcat | html %]" data-sort2-authcat="[% budget.b_sort2_authcat | html %]">[% budget.b_txt | html %]</option>
15
        [% ELSE %]
16
            <option value="[% budget.b_id | html %]" class="b_inactive" data-sort1-authcat="[% budget.b_sort1_authcat | html %]" data-sort2-authcat="[% budget.b_sort2_authcat |html %]">[% budget.b_txt | html %] (inactive)</option>
17
        [% END %]
18
    [% END %]
19
</span>
20
[% BLOCK fund_dropdown %]
21
    <span>
22
    <label for="[% form_name | html %]">Fund: </label>
23
    <select id="[% form_id | html %]" name="[% form_name | html %]" class="fund_dropdown" data-selected="[% selected | html %]">
24
    </select>
25
    <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
26
    <input type="checkbox" class="showallfunds" />
27
    </span>
28
[% END %]
29
30
<div id="updateFund" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="updateReceivedFund" aria-hidden="true">
31
    <div class="modal-dialog">
32
        <div class="modal-content">
33
            <div class="modal-header">
34
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
35
                <h3 id="updateReceivedFund">Update received fund</h3>
36
            </div>
37
            <div class="modal-body">
38
                <p>Updating the fund may change available statistics for the order, please check values before submitting.</p>
39
                [% PROCESS fund_dropdown form_id => 'modify_budget_id' form_name => 'modify_budget_id' selected => "" %]
40
                </br>
41
                <label for="sort1">Statistic 1</label>
42
                <input type="text" name="sort1" />
43
                </br>
44
                <label for="sort2">Statistic 2</label>
45
                <input type="text" name="sort2" />
46
                <br><a id="update_fund" class="btn btn-default">Update fund</a>
47
            </div>
48
            <div class="modal-footer">
49
                <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
50
            </div>
51
        </div>
52
    </div>
53
</div>
54
8
55
9
[% INCLUDE 'doc-head-open.inc' %]
56
[% INCLUDE 'doc-head-open.inc' %]
10
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
57
<title>Koha &rsaquo; Acquisitions &rsaquo; Invoice</title>
Lines 49-70 Link Here
49
                    <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
96
                    <input type="text" size="10" id="shipmentcost" name="shipmentcost" value="[% shipmentcost | $Price on_editing => 1 %]" /></li>
50
97
51
        <li>
98
        <li>
52
            <label for="shipment_budget_id">Shipping fund: </label>
99
            [% PROCESS fund_dropdown form_id => 'shipment_budget_id' form_name => 'shipment_budget_id' selected => shipment_budget_id %]
53
            <select id="shipment_budget_id" name="shipment_budget_id">
54
                <option value="">No fund</option>
55
                [% FOREACH budget IN budgets %]
56
                    [% IF ( budget.selected ) %]
57
                        <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
58
                    [% ELSIF ( budget.b_active ) %]
59
                        <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
60
                    [% ELSE %]
61
                        <option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
62
                    [% END %]
63
                [% END %]
64
            </select>
65
            <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
66
            <input type="checkbox" id="showallfunds" />
67
68
        </li>
100
        </li>
69
101
70
            [% IF ( invoiceclosedate ) %]
102
            [% IF ( invoiceclosedate ) %]
Lines 137-154 Link Here
137
                                  </td>
169
                                  </td>
138
                                  <td><input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/></td>
170
                                  <td><input type="text" name="note" id="note_new" value="[% adjustment.note | html %]"/></td>
139
                                  <td>
171
                                  <td>
140
                                      <select id="budget_id_[% adjustment.adjustment_id | html %]" name="budget_id">
172
                                      [% PROCESS fund_dropdown form_id => "budget_id_" _ adjustment.adjustment_id form_name => 'budget_id' selected => adjustment.budget_id %]
141
                                              <option value="">No fund</option>
142
                                          [% FOREACH budget IN budgets %]
143
                                              [% IF ( budget.b_id == adjustment.budget_id ) %]
144
                                                  <option selected="selected" value="[% budget.b_id | html %]">
145
                                              [% ELSE %]
146
                                                  <option value="[% budget.b_id | html %]">
147
                                              [% END %]
148
                                              [% budget.b_txt | html %]
149
                                              </option>
150
                                          [% END %]
151
                                      </select>
152
                                  </td>
173
                                  </td>
153
                                  [% IF adjustment.encumber_open %]
174
                                  [% IF adjustment.encumber_open %]
154
                                      <td>
175
                                      <td>
Lines 204-218 Link Here
204
                                  <input type="text" name="note" id="note_new" value=""/>
225
                                  <input type="text" name="note" id="note_new" value=""/>
205
                              </li>
226
                              </li>
206
                              <li>
227
                              <li>
207
                                  <label for="budget_id_new">Fund: </label>
228
                                  [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]
208
                                  <select id="budget_id_new" name="budget_id">
209
                                      <option selected="selected" value="">No fund</option>
210
                                      [% FOREACH budget IN budgets %]
211
                                          <option value="[% budget.b_id | html %]">
212
                                          [% budget.b_txt | html %]
213
                                          </option>
214
                                      [% END %]
215
                                  </select>
216
                              </li>
229
                              </li>
217
                              <li>
230
                              <li>
218
                                  <label for="encumber_new">Encumber while invoice open? </label>
231
                                  <label for="encumber_new">Encumber while invoice open? </label>
Lines 286-292 Link Here
286
                  <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
299
                  <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
287
                  <td class="number">[% order.tax_rate * 100 | html %]</td>
300
                  <td class="number">[% order.tax_rate * 100 | html %]</td>
288
                  <td class="number">[% order.tax_value | $Price %]</td>
301
                  <td class="number">[% order.tax_value | $Price %]</td>
289
                  <td>[% order.budget_name | html %]</td>
302
                  <td>
303
                      <span class="order_name" data-order_id="[% order.ordernumber | html %]">[% order.budget_name | html %]</span></br>
304
                      <a href="#" class="modify_fund" data-order_id="[% order.ordernumber | html %]" data-budget_id="[% order.budget_id | html %]" data-sort_1="[% order.sort1 | html %]" data-sort_2="[% order.sort2 | html %]" data-sort1="[% order.sort1 | html %]" data-sort2="[% order.sort2 | html %]">Modify fund</a>
305
                  </td>
290
                </tr>
306
                </tr>
291
              [% END %]
307
              [% END %]
292
            </tbody>
308
            </tbody>
Lines 377-382 Link Here
377
393
378
[% MACRO jsinclude BLOCK %]
394
[% MACRO jsinclude BLOCK %]
379
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
395
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
396
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
397
    [% Asset.js("js/acq.js") | $raw %]
380
    [% INCLUDE 'calendar.inc' %]
398
    [% INCLUDE 'calendar.inc' %]
381
    [% INCLUDE 'datatables.inc' %]
399
    [% INCLUDE 'datatables.inc' %]
382
    <script>
400
    <script>
Lines 431-447 Link Here
431
            });
449
            });
432
450
433
            //keep a copy of all budgets before removing the inactives
451
            //keep a copy of all budgets before removing the inactives
434
            var budgetId = $("#shipment_budget_id");
452
            var disabledBudgetsCopy = $("#all_fund_dropdown").html();
435
            var disabledBudgetsCopy = budgetId.html();
453
            $(".fund_dropdown").each(function(){
454
                $(this).html( disabledBudgetsCopy);
455
                var selected = $(this).data('selected');
456
                $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
457
                $(this).val( selected );
458
            });
459
436
            $('.b_inactive').remove();
460
            $('.b_inactive').remove();
437
461
438
            $('#showallfunds').click(function() {
462
            $('.showallfunds').click(function() {
463
                var the_dropdown = $(this).parent('span').find('.fund_dropdown');
464
                var selected = the_dropdown.val();
439
                if ($(this).is(":checked")) {
465
                if ($(this).is(":checked")) {
440
                    budgetId.html(disabledBudgetsCopy); //Puts back all the funds
466
                    the_dropdown.html(disabledBudgetsCopy).val(selected);
441
                }
467
                }
442
                else {
468
                else {
443
                    $('.b_inactive').remove();
469
                    the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive');
470
                    $(this).parent('span').find('.b_inactive').remove();
471
                }
472
            });
473
474
            $(".modify_fund").on('click',function(e){
475
                e.preventDefault();
476
                var selected = $(this).data('budget_id');
477
                var sort1 = $(this).data('sort1');
478
                var sort2 = $(this).data('sort2');
479
                $("#update_fund").data('order_id',$(this).data('order_id'));
480
                $("#modify_budget_id").html(disabledBudgetsCopy);
481
                $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
482
                $("#sort1").val(sort1);
483
                $("#sort2").val(sort2);
484
                $("#modify_budget_id").find('.b_inactive').remove();
485
                $("#modify_budget_id").change();
486
                $("#updateFund").modal('show');
487
            });
488
            $("#update_fund").on('click',function(){
489
                var new_fund = $("#modify_budget_id").val();
490
                var sort1 = $("#sort1").val();
491
                var sort2 = $("#sort2").val();
492
                var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
493
                var order_id = $(this).data('order_id');
494
                let options = {
495
                    url: "/api/v1/acquisitions/orders/" + order_id,
496
                    method: 'PUT',
497
                    contentType: 'application/json',
498
                    data: JSON.stringify({
499
                        fund_id: new_fund,
500
                        statistics_1: sort1,
501
                        statistics_2: sort2
502
                    })
503
                };
504
                $.ajax(options)
505
                    .then(function(thing,result){
506
                        $("#updateFund").modal('hide');
507
                        $('#updateFund .showallfunds').prop('checked',false);
508
                        $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
509
                        $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
510
                        humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
511
                    })
512
                    .fail(function(err){
513
                        humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
514
                    });
515
            });
516
            $("#modify_budget_id").change(function(){
517
                var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
518
                var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
519
                var sort1 = $(destination_sort1).val() || "";
520
                if ( destination_sort1.length < 1 ) {
521
                    destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
522
                }
523
                var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
524
                var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
525
                var sort2 = $(destination_sort2).val() || "";
526
                if ( destination_sort2.length < 1 ) {
527
                    destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
444
                }
528
                }
529
                getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
530
                getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
445
            });
531
            });
446
        });
532
        });
447
    </script>
533
    </script>
448
- 

Return to bug 25763