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

(-)a/acqui/invoice.pl (+3 lines)
Lines 236-241 foreach my $r ( @{$budgets} ) { Link Here
236
        b_txt    => $r->{budget_name},
236
        b_txt    => $r->{budget_name},
237
        b_active => $r->{budget_period_active},
237
        b_active => $r->{budget_period_active},
238
        selected => $selected,
238
        selected => $selected,
239
        b_sort1_authcat => $r->{'sort1_authcat'},
240
        b_sort2_authcat => $r->{'sort2_authcat'},
239
      };
241
      };
240
}
242
}
241
243
Lines 251-256 $template->param( Link Here
251
    suppliername                => $details->{'suppliername'},
253
    suppliername                => $details->{'suppliername'},
252
    booksellerid                => $details->{'booksellerid'},
254
    booksellerid                => $details->{'booksellerid'},
253
    shipmentdate                => $details->{'shipmentdate'},
255
    shipmentdate                => $details->{'shipmentdate'},
256
    shipment_budget_id          => $shipmentcost_budgetid,
254
    billingdate                 => $details->{'billingdate'},
257
    billingdate                 => $details->{'billingdate'},
255
    invoiceclosedate            => $details->{'closedate'},
258
    invoiceclosedate            => $details->{'closedate'},
256
    shipmentcost                => $shipmentcost,
259
    shipmentcost                => $shipmentcost,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoice.tt (-47 / +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 75-99 Link Here
75
                [% END %]
122
                [% END %]
76
            </li>
123
            </li>
77
            <li>
124
            <li>
78
                <label for="shipment_budget_id">Shipping fund: </label>
125
                [% PROCESS fund_dropdown form_id => 'shipment_budget_id' form_name => 'shipment_budget_id' selected => shipment_budget_id %]
79
                [% IF readonly %]
80
                    [% budget.budget_name | html %]
81
                [% ELSE %]
82
                    <select id="shipment_budget_id" name="shipment_budget_id">
83
                        <option value="">No fund</option>
84
                        [% FOREACH budget IN budgets %]
85
                            [% IF ( budget.selected ) %]
86
                                <option value="[% budget.b_id | html %]" selected="selected">[% budget.b_txt | html %] [% IF ( !budget.b_active ) %](inactive)[% END %]</option>
87
                            [% ELSIF ( budget.b_active ) %]
88
                                <option value="[% budget.b_id | html %]">[% budget.b_txt | html %]</option>
89
                            [% ELSE %]
90
                                <option value="[% budget.b_id | html %]" class="b_inactive">[% budget.b_txt | html %] (inactive)</option>
91
                            [% END %]
92
                        [% END %]
93
                    </select>
94
                    <label for="showallfunds" style="float:none;width:auto;">&nbsp;Show inactive:</label>
95
                    <input type="checkbox" id="showallfunds" />
96
                [% END %]
97
            </li>
126
            </li>
98
127
99
            [% IF ( invoiceclosedate ) %]
128
            [% IF ( invoiceclosedate ) %]
Lines 197-214 Link Here
197
                                      [% IF readonly %]
226
                                      [% IF readonly %]
198
                                          [% adjustement.fund.budget_name | html %]
227
                                          [% adjustement.fund.budget_name | html %]
199
                                      [% ELSE %]
228
                                      [% ELSE %]
200
                                          <select id="budget_id_[% adjustment.adjustment_id | html %]" name="budget_id">
229
                                          [% PROCESS fund_dropdown form_id => "budget_id_" _ adjustment.adjustment_id form_name => 'budget_id' selected => adjustment.budget_id %]
201
                                              <option value="">No fund</option>
202
                                              [% FOREACH budget IN budgets %]
203
                                                  [% IF ( budget.b_id == adjustment.budget_id ) %]
204
                                                      <option selected="selected" value="[% budget.b_id | html %]">
205
                                                  [% ELSE %]
206
                                                      <option value="[% budget.b_id | html %]">
207
                                                  [% END %]
208
                                                  [% budget.b_txt | html %]
209
                                                  </option>
210
                                              [% END %]
211
                                          </select>
212
                                      [% END %]
230
                                      [% END %]
213
                                  </td>
231
                                  </td>
214
                                  [% IF adjustment.encumber_open %]
232
                                  [% IF adjustment.encumber_open %]
Lines 276-290 Link Here
276
                                      <input type="text" name="note" id="note_new" value=""/>
294
                                      <input type="text" name="note" id="note_new" value=""/>
277
                                  </li>
295
                                  </li>
278
                                  <li>
296
                                  <li>
279
                                      <label for="budget_id_new">Fund: </label>
297
                                      [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]
280
                                      <select id="budget_id_new" name="budget_id">
281
                                          <option selected="selected" value="">No fund</option>
282
                                          [% FOREACH budget IN budgets %]
283
                                              <option value="[% budget.b_id | html %]">
284
                                              [% budget.b_txt | html %]
285
                                              </option>
286
                                          [% END %]
287
                                      </select>
288
                                  </li>
298
                                  </li>
289
                                  <li>
299
                                  <li>
290
                                      <label for="encumber_new">Encumber while invoice open? </label>
300
                                      <label for="encumber_new">Encumber while invoice open? </label>
Lines 359-365 Link Here
359
                  <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
369
                  <td class="number tax_included">[% order.total_tax_included | $Price %]</td>
360
                  <td class="number">[% order.tax_rate * 100 | html %]</td>
370
                  <td class="number">[% order.tax_rate * 100 | html %]</td>
361
                  <td class="number">[% order.tax_value | $Price %]</td>
371
                  <td class="number">[% order.tax_value | $Price %]</td>
362
                  <td>[% order.budget_name | html %]</td>
372
                  <td>
373
                      <span class="order_name" data-order_id="[% order.ordernumber | html %]">[% order.budget_name | html %]</span></br>
374
                      <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>
375
                  </td>
363
                </tr>
376
                </tr>
364
              [% END %]
377
              [% END %]
365
            </tbody>
378
            </tbody>
Lines 450-455 Link Here
450
463
451
[% MACRO jsinclude BLOCK %]
464
[% MACRO jsinclude BLOCK %]
452
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
465
    [% Asset.js("js/acquisitions-menu.js") | $raw %]
466
    [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
467
    [% Asset.js("js/acq.js") | $raw %]
453
    [% INCLUDE 'calendar.inc' %]
468
    [% INCLUDE 'calendar.inc' %]
454
    [% INCLUDE 'datatables.inc' %]
469
    [% INCLUDE 'datatables.inc' %]
455
    <script>
470
    <script>
Lines 504-520 Link Here
504
            });
519
            });
505
520
506
            //keep a copy of all budgets before removing the inactives
521
            //keep a copy of all budgets before removing the inactives
507
            var budgetId = $("#shipment_budget_id");
522
            var disabledBudgetsCopy = $("#all_fund_dropdown").html();
508
            var disabledBudgetsCopy = budgetId.html();
523
            $(".fund_dropdown").each(function(){
524
                $(this).html( disabledBudgetsCopy);
525
                var selected = $(this).data('selected');
526
                $(this).find('option[value="'+selected+'"]').removeClass('b_inactive');
527
                $(this).val( selected );
528
            });
529
509
            $('.b_inactive').remove();
530
            $('.b_inactive').remove();
510
531
511
            $('#showallfunds').click(function() {
532
            $('.showallfunds').click(function() {
533
                var the_dropdown = $(this).parent('span').find('.fund_dropdown');
534
                var selected = the_dropdown.val();
512
                if ($(this).is(":checked")) {
535
                if ($(this).is(":checked")) {
513
                    budgetId.html(disabledBudgetsCopy); //Puts back all the funds
536
                    the_dropdown.html(disabledBudgetsCopy).val(selected);
514
                }
537
                }
515
                else {
538
                else {
516
                    $('.b_inactive').remove();
539
                    the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive');
540
                    $(this).parent('span').find('.b_inactive').remove();
541
                }
542
            });
543
544
            $(".modify_fund").on('click',function(e){
545
                e.preventDefault();
546
                var selected = $(this).data('budget_id');
547
                var sort1 = $(this).data('sort1');
548
                var sort2 = $(this).data('sort2');
549
                $("#update_fund").data('order_id',$(this).data('order_id'));
550
                $("#modify_budget_id").html(disabledBudgetsCopy);
551
                $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive');
552
                $("#sort1").val(sort1);
553
                $("#sort2").val(sort2);
554
                $("#modify_budget_id").find('.b_inactive').remove();
555
                $("#modify_budget_id").change();
556
                $("#updateFund").modal('show');
557
            });
558
            $("#update_fund").on('click',function(){
559
                var new_fund = $("#modify_budget_id").val();
560
                var sort1 = $("#sort1").val();
561
                var sort2 = $("#sort2").val();
562
                var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text();
563
                var order_id = $(this).data('order_id');
564
                let options = {
565
                    url: "/api/v1/acquisitions/orders/" + order_id,
566
                    method: 'PUT',
567
                    contentType: 'application/json',
568
                    data: JSON.stringify({
569
                        fund_id: new_fund,
570
                        statistics_1: sort1,
571
                        statistics_2: sort2
572
                    })
573
                };
574
                $.ajax(options)
575
                    .then(function(thing,result){
576
                        $("#updateFund").modal('hide');
577
                        $('#updateFund .showallfunds').prop('checked',false);
578
                        $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund);
579
                        $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name);
580
                        humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } );
581
                    })
582
                    .fail(function(err){
583
                        humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } );
584
                    });
585
            });
586
            $("#modify_budget_id").change(function(){
587
                var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]');
588
                var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
589
                var sort1 = $(destination_sort1).val() || "";
590
                if ( destination_sort1.length < 1 ) {
591
                    destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]');
592
                }
593
                var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]');
594
                var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
595
                var sort2 = $(destination_sort2).val() || "";
596
                if ( destination_sort2.length < 1 ) {
597
                    destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]');
517
                }
598
                }
599
                getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
600
                getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
518
            });
601
            });
519
        });
602
        });
520
    </script>
603
    </script>
521
- 

Return to bug 25763