| 
      
            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;"> 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>Invoice › Acquisitions › Koha</title>  | 
          57 | 
          <title>Invoice › Acquisitions › Koha</title>  | 
        
  
    | 
      
            Lines 93-117
          
      
      
        Link Here
      
     | 
  
        
          | 93 | 
                          [% END %]  | 
          140 | 
                          [% END %]  | 
        
        
          | 94 | 
                      </li>  | 
          141 | 
                      </li>  | 
        
        
          | 95 | 
                      <li>  | 
          142 | 
                      <li>  | 
        
          
            
              | 96 | 
                              <label for="shipment_budget_id">Shipping fund: </label>  | 
              143 | 
                              [% PROCESS fund_dropdown form_id => 'shipment_budget_id' form_name => 'shipment_budget_id' selected => shipment_budget_id %]  | 
            
            
              | 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;"> Show inactive:</label>  | 
            
            
              | 113 | 
                                  <input type="checkbox" id="showallfunds" />  | 
            
            
              | 114 | 
                              [% END %]  | 
            
        
          | 115 | 
                      </li>  | 
          144 | 
                      </li>  | 
        
        
          | 116 | 
           | 
          145 | 
           | 
        
        
          | 117 | 
                      [% IF ( invoiceclosedate ) %]  | 
          146 | 
                      [% IF ( invoiceclosedate ) %]  | 
        
  
    | 
      
            Lines 212-237
          
      
      
        Link Here
      
     | 
  
        
          | 212 | 
                                                [% END %]  | 
          241 | 
                                                [% END %]  | 
        
        
          | 213 | 
                                            </td>  | 
          242 | 
                                            </td>  | 
        
        
          | 214 | 
                                            <td>  | 
          243 | 
                                            <td>  | 
        
          
            
              | 215 | 
                                                    [% IF readonly %]  | 
              244 | 
                                                    [% PROCESS fund_dropdown form_id => "budget_id_" _ adjustment.adjustment_id form_name => 'budget_id' selected => adjustment.budget_id %]  | 
            
            
              | 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>  | 
          245 | 
                                            </td>  | 
        
        
          | 236 | 
                                            [% IF adjustment.encumber_open %]  | 
          246 | 
                                            [% IF adjustment.encumber_open %]  | 
        
        
          | 237 | 
                                                <td>  | 
          247 | 
                                                <td>  | 
        
  
    | 
      
            Lines 298-318
          
      
      
        Link Here
      
     | 
  
        
          | 298 | 
                                                <input type="text" name="note" id="note_new" value=""/>  | 
          308 | 
                                                <input type="text" name="note" id="note_new" value=""/>  | 
        
        
          | 299 | 
                                            </li>  | 
          309 | 
                                            </li>  | 
        
        
          | 300 | 
                                            <li>  | 
          310 | 
                                            <li>  | 
        
          
            
              | 301 | 
                                                    <label for="budget_id_new">Fund: </label>  | 
              311 | 
                                                    [% PROCESS fund_dropdown form_id => "budget_id_new" form_name => 'budget_id' selected => "" %]  | 
            
            
              | 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;"> Show inactive:</label>  | 
            
            
              | 315 | 
                                                    <input type="checkbox" id="showallfunds_adj" />  | 
            
        
          | 316 | 
                                            </li>  | 
          312 | 
                                            </li>  | 
        
        
          | 317 | 
                                            <li>  | 
          313 | 
                                            <li>  | 
        
        
          | 318 | 
                                                <label for="encumber_new">Encumber while invoice open? </label>  | 
          314 | 
                                                <label for="encumber_new">Encumber while invoice open? </label>  | 
        
  
    | 
      
            Lines 387-393
          
      
      
        Link Here
      
     | 
  
        
          | 387 | 
                            <td class="number tax_included">[% order.total_tax_included | $Price %]</td>  | 
          383 | 
                            <td class="number tax_included">[% order.total_tax_included | $Price %]</td>  | 
        
        
          | 388 | 
                            <td class="number">[% order.tax_rate * 100 | html %]</td>  | 
          384 | 
                            <td class="number">[% order.tax_rate * 100 | html %]</td>  | 
        
        
          | 389 | 
                            <td class="number">[% order.tax_value | $Price %]</td>  | 
          385 | 
                            <td class="number">[% order.tax_value | $Price %]</td>  | 
        
          
            
              | 390 | 
                                <td>[% order.budget_name | html %]</td>  | 
              386 | 
                                <td>  | 
            
            
               | 
               | 
              387 | 
                                    <span class="order_name" data-order_id="[% order.ordernumber | html %]">[% order.budget_name | html %]</span></br>  | 
            
            
              | 388 | 
                                    <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>  | 
            
            
              | 389 | 
                                </td>  | 
            
        
          | 391 | 
                          </tr>  | 
          390 | 
                          </tr>  | 
        
        
          | 392 | 
                        [% END %]  | 
          391 | 
                        [% END %]  | 
        
        
          | 393 | 
                      </tbody>  | 
          392 | 
                      </tbody>  | 
        
  
    | 
      
            Lines 478-483
          
      
      
        Link Here
      
     | 
  
        
          | 478 | 
           | 
          477 | 
           | 
        
        
          | 479 | 
          [% MACRO jsinclude BLOCK %]  | 
          478 | 
          [% MACRO jsinclude BLOCK %]  | 
        
        
          | 480 | 
              [% Asset.js("js/acquisitions-menu.js") | $raw %] | 
          479 | 
              [% Asset.js("js/acquisitions-menu.js") | $raw %] | 
        
            
               | 
               | 
              480 | 
                  [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] | 
            
            
              | 481 | 
                  [% Asset.js("js/acq.js") | $raw %] | 
            
        
          | 481 | 
              [% INCLUDE 'calendar.inc' %]  | 
          482 | 
              [% INCLUDE 'calendar.inc' %]  | 
        
        
          | 482 | 
              [% INCLUDE 'datatables.inc' %]  | 
          483 | 
              [% INCLUDE 'datatables.inc' %]  | 
        
        
          | 483 | 
              <script>  | 
          484 | 
              <script>  | 
        
  
    | 
      
            Lines 529-545
          
      
      
        Link Here
      
     | 
  
        
          | 529 | 
                      });  | 
          530 | 
                      });  | 
        
        
          | 530 | 
           | 
          531 | 
           | 
        
        
          | 531 | 
                      //keep a copy of all budgets before removing the inactives  | 
          532 | 
                      //keep a copy of all budgets before removing the inactives  | 
        
          
            
              | 532 | 
                          var budgetId = $("#shipment_budget_id"); | 
              533 | 
                          var disabledBudgetsCopy = $("#all_fund_dropdown").html(); | 
            
            
              | 533 | 
                          var disabledBudgetsCopy = budgetId.html();  | 
              534 | 
                          $(".fund_dropdown").each(function(){ | 
            
            
               | 
               | 
              535 | 
                              $(this).html( disabledBudgetsCopy);  | 
            
            
              | 536 | 
                              var selected = $(this).data('selected'); | 
            
            
              | 537 | 
                              $(this).find('option[value="'+selected+'"]').removeClass('b_inactive'); | 
            
            
              | 538 | 
                              $(this).val( selected );  | 
            
            
              | 539 | 
                          });  | 
            
            
              | 540 | 
               | 
            
        
          | 534 | 
                      $('.b_inactive').remove(); | 
          541 | 
                      $('.b_inactive').remove(); | 
        
        
          | 535 | 
           | 
          542 | 
           | 
        
          
            
              | 536 | 
                          $('#showallfunds').click(function() { | 
              543 | 
                          $('.showallfunds').click(function() { | 
            
            
               | 
               | 
              544 | 
                              var the_dropdown = $(this).parent('span').find('.fund_dropdown'); | 
            
            
              | 545 | 
                              var selected = the_dropdown.val();  | 
            
        
          | 537 | 
                          if ($(this).is(":checked")) { | 
          546 | 
                          if ($(this).is(":checked")) { | 
        
          
            
              | 538 | 
                                  budgetId.html(disabledBudgetsCopy); //Puts back all the funds  | 
              547 | 
                                  the_dropdown.html(disabledBudgetsCopy).val(selected);  | 
            
        
          | 539 | 
                          }  | 
          548 | 
                          }  | 
        
        
          | 540 | 
                          else { | 
          549 | 
                          else { | 
        
          
            
              | 541 | 
                                  $('.b_inactive').remove(); | 
              550 | 
                                  the_dropdown.find('option[value="'+selected+'"]').removeClass('b_inactive'); | 
            
            
               | 
               | 
              551 | 
                                  $(this).parent('span').find('.b_inactive').remove(); | 
            
            
              | 552 | 
                              }  | 
            
            
              | 553 | 
                          });  | 
            
            
              | 554 | 
               | 
            
            
              | 555 | 
                          $(".modify_fund").on('click',function(e){ | 
            
            
              | 556 | 
                              e.preventDefault();  | 
            
            
              | 557 | 
                              var selected = $(this).data('budget_id'); | 
            
            
              | 558 | 
                              var sort1 = $(this).data('sort1'); | 
            
            
              | 559 | 
                              var sort2 = $(this).data('sort2'); | 
            
            
              | 560 | 
                              $("#update_fund").data('order_id',$(this).data('order_id')); | 
            
            
              | 561 | 
                              $("#modify_budget_id").html(disabledBudgetsCopy); | 
            
            
              | 562 | 
                              $("#modify_budget_id").val(selected).find('option[value="'+selected+'"]').removeClass('b_inactive'); | 
            
            
              | 563 | 
                              $("#sort1").val(sort1); | 
            
            
              | 564 | 
                              $("#sort2").val(sort2); | 
            
            
              | 565 | 
                              $("#modify_budget_id").find('.b_inactive').remove(); | 
            
            
              | 566 | 
                              $("#modify_budget_id").change(); | 
            
            
              | 567 | 
                              $("#updateFund").modal('show'); | 
            
            
              | 568 | 
                          });  | 
            
            
              | 569 | 
                          $("#update_fund").on('click',function(){ | 
            
            
              | 570 | 
                              var new_fund = $("#modify_budget_id").val(); | 
            
            
              | 571 | 
                              var sort1 = $("#sort1").val(); | 
            
            
              | 572 | 
                              var sort2 = $("#sort2").val(); | 
            
            
              | 573 | 
                              var new_fund_name = $('#modify_budget_id option[value="'+new_fund+'"]').text(); | 
            
            
              | 574 | 
                              var order_id = $(this).data('order_id'); | 
            
            
              | 575 | 
                              let options = { | 
            
            
              | 576 | 
                                  url: "/api/v1/acquisitions/orders/" + order_id,  | 
            
            
              | 577 | 
                                  method: 'PUT',  | 
            
            
              | 578 | 
                                  contentType: 'application/json',  | 
            
            
              | 579 | 
                                  data: JSON.stringify({ | 
            
            
              | 580 | 
                                      fund_id: new_fund,  | 
            
            
              | 581 | 
                                      statistics_1: sort1,  | 
            
            
              | 582 | 
                                      statistics_2: sort2  | 
            
            
              | 583 | 
                                  })  | 
            
            
              | 584 | 
                              };  | 
            
            
              | 585 | 
                              $.ajax(options)  | 
            
            
              | 586 | 
                                  .then(function(thing,result){ | 
            
            
              | 587 | 
                                      $("#updateFund").modal('hide'); | 
            
            
              | 588 | 
                                      $('#updateFund .showallfunds').prop('checked',false); | 
            
            
              | 589 | 
                                      $('.modify_fund[data-order_id="'+order_id+'"]').data('budget_id',new_fund); | 
            
            
              | 590 | 
                                      $('.order_name[data-order_id="'+order_id+'"]').text(new_fund_name); | 
            
            
              | 591 | 
                                      humanMsg.displayAlert( _("Order updated"), { className: 'humanError' } ); | 
            
            
              | 592 | 
                                  })  | 
            
            
              | 593 | 
                                  .fail(function(err){ | 
            
            
              | 594 | 
                                      humanMsg.displayAlert( _("Failed to update order:") + err.responseText, { className: 'humanError' } ); | 
            
            
              | 595 | 
                                  });  | 
            
            
              | 596 | 
                          });  | 
            
            
              | 597 | 
                          $("#modify_budget_id").change(function(){ | 
            
            
              | 598 | 
                              var destination_sort1 = $(this).parents('.modal-body').find('input[name="sort1"]'); | 
            
            
              | 599 | 
                              var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat'); | 
            
            
              | 600 | 
                              var sort1 = $(destination_sort1).val() || "";  | 
            
            
              | 601 | 
                              if ( destination_sort1.length < 1 ) { | 
            
            
              | 602 | 
                                  destination_sort1 = $(this).parents('.modal-body').find('select[name="sort1"]'); | 
            
            
              | 603 | 
                              }  | 
            
            
              | 604 | 
                              var destination_sort2 = $(this).parents('.modal-body').find('input[name="sort2"]'); | 
            
            
              | 605 | 
                              var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat'); | 
            
            
              | 606 | 
                              var sort2 = $(destination_sort2).val() || "";  | 
            
            
              | 607 | 
                              if ( destination_sort2.length < 1 ) { | 
            
            
              | 608 | 
                                  destination_sort2 = $(this).parents('.modal-body').find('select[name="sort2"]'); | 
            
        
          | 542 | 
                          }  | 
          609 | 
                          }  | 
        
            
               | 
               | 
              610 | 
                              getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );  | 
            
            
              | 611 | 
                              getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );  | 
            
        
          | 543 | 
                      });  | 
          612 | 
                      });  | 
        
        
          | 544 | 
                      // same effort for the adjustments  | 
          613 | 
                      // same effort for the adjustments  | 
        
        
          | 545 | 
                      var adjBudgetId = $("#budget_id_new"); | 
          614 | 
                      var adjBudgetId = $("#budget_id_new"); | 
        
            
              | 546 | 
              -   | 
               | 
               |