3 [% USE AuthorisedValues %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › Administration › Funds[% IF op == 'add_form' %] › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
9 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
10 [% INCLUDE 'doc-head-close.inc' %]
13 <body id="admin_aqbudgets" class="admin">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'budgets-admin-search.inc' %]
17 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
20 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
23 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
26 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
30 [% IF budget_period_id %]
32 <a href="#" aria-current="page">
33 Funds for '[% budget_period_description | html %]'
38 <a href="#" aria-current="page">
45 [% IF op == 'add_form' %]
47 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a>
49 [% IF ( budget_id ) %]
51 <a href="#" aria-current="page">
53 [% IF ( budget_name ) %] '[% budget_name | html %]'[% END %]
58 <a href="#" aria-current="page">
65 [% IF op == 'delete_confirm' %]
67 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a>
70 <a href="#" aria-current="page">
78 <div class="main container-fluid">
80 <div class="col-sm-10 col-sm-push-2">
83 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
85 [% IF (error_not_authorised_to_modify) %]
86 <div class="dialog alert">
87 <p>You are not authorized to modify this fund</p>
94 [% IF budget_period_id %]
95 Funds for '[% budget_period_description | html %]'
101 [% INCLUDE 'budgets-active-currency.inc' %]
105 [% UNLESS budget_period_id %]
106 <div class="toolbar btn-toolbar">
107 <span class="actions">
108 <a href="#" id="expand_all">Expand all</a> |
109 <a href="#" id="collapse_all">Collapse all</a> |
110 <a href="#" id="hide_inactive">Hide inactive budgets</a> |
111 <a href="#" id="show_inactive">Show inactive budgets</a>
116 <table id="budgeth" class="group">
120 <th>Budget period description</th>
123 <th>Base-level allocated</th>
124 <th>Base-level ordered</th>
125 <th>Total ordered</th>
126 <th>Base-level spent</th>
128 <th>Base-level available</th>
129 <th>Total available</th>
130 <th class="noExport">Actions</th>
137 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
138 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
140 <th class="data">[% ordered_total | $Price %]</th>
142 <th class="data">[% spent_total | $Price %]</th>
144 <th class="data">[% available_total | $Price %]</th>
149 [% FOREACH budget IN budgets %]
150 [% IF budget.budget_parent_id %]
151 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
153 <tr data-tt-id="[% budget.budget_id | html %]">
155 <td>[% budget.budget_period_active | html %]</td>
156 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
157 <td>[% budget.budget_code | html %]</td>
158 <td>[% budget.budget_name | html %]</td>
160 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
163 [% IF budget.budget_parent_id %]
164 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
166 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
170 [% IF budget.budget_parent_id %]
171 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
173 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
177 [% IF budget.budget_parent_id %]
178 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
180 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
184 [% IF budget.budget_parent_id %]
185 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
187 <span class="total_amount">[% budget.total_spent | $Price %]</span>
192 [% BLOCK colorcellvalue %]
194 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
195 [% ELSIF (value < 0) %]
196 <span class="total_amount" style="color: red;">
198 <span class="totalamount">
204 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
207 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
209 [% IF ( budget.budget_lock ) %]
210 <td> <span></span> </td>
213 <div class="btn-group dropup">
214 <a class="btn btn-default btn-xs dropdown-toggle" id="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]" role="button" data-toggle="dropdown" href="#">
215 Actions <b class="caret"></b>
217 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
218 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=[% budget.budget_id | uri %]&budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
219 [% IF budget.budget_has_children %]
220 <li class="disabled"><a href="#" class="deletefund-disabled" data-toggle="tooltip" data-placement="left" title="This fund has sub funds."><i class="fa fa-trash"></i> Delete</a></li>
222 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=[% budget.budget_id | uri %]&budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-trash"></i> Delete</a></li>
224 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_parent_id=[% budget.budget_id | uri %]&budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-plus"></i> Add sub fund</a></li>
238 [% END %] <!-- list -->
240 <!-- ********************************************************************************************** -->
241 <!-- create add/mod entry form -->
242 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
243 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
244 <fieldset class="rows">
245 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
246 [% IF ( budget_period_description ) %]
247 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
251 <input type="hidden" name="op" value="add_validate" />
252 <input type="hidden" name="checked" value="0" />
254 [% IF ( budget_parent_id ) %]
256 <span class="label">Fund parent: </span>
257 [% budget_parent_name | html %]
258 [% budget_parent_id | html %] - [% budget_parent_name | html %]
259 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
263 <label class="required" for="budget_code">Fund code: </label>
264 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
268 <label class="required" for="budget_name">Fund name: </label>
269 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
273 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
274 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
278 <label for="budget_encumb">Warning at (%): </label>
279 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
280 <span class="hint">0 to disable</span>
284 <label for="budget_expend">Warning at (amount): </label>
285 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
286 <span class="hint">0 to disable</span>
290 <span class="label">Owner: </span>
291 [% IF budget_owner %]
292 <span id="budget_owner_name">
293 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
294 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
298 <span id="budget_owner_name"></span>
300 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
301 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
302 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
303 value="[% budget_owner.borrowernumber | html %]" />
307 [% IF budget_has_children %]
310 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
311 Update all sub funds with this owner
313 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
318 <span class="label">Users:</span>
319 <ul style="float:left;" id="budget_users">
320 [% FOREACH user IN budget_users %]
321 <li id="user_[% user.borrowernumber | html %]">
322 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
323 [% user.firstname | html %] [% user.surname | html %]
325 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
328 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
330 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
333 <label for="budget_branchcode">Library: </label>
334 <select name="budget_branchcode" id="budget_branchcode">
335 <option value=""></option>
336 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
341 <label for="budget_permission">Restrict access to: </label>
342 <select name="budget_permission" id="budget_permission">
343 [% IF ( budget_perm_0 ) %]
344 <option value="0" selected="selected">
351 [% IF ( budget_perm_1 ) %]
352 <option value="1" selected="selected">
359 [% IF ( budget_perm_3) %]
360 <option value="3" selected="selected">
367 [% IF ( budget_perm_2 ) %]
368 <option value="2" selected="selected">
372 Owner, users and library
378 <label for="budget_notes">Notes: </label>
379 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
383 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
384 <select name="sort1_authcat" id="authorised_value_category1">
385 <option value=""></option>
386 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
390 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
391 <select name="sort2_authcat" id="authorised_value_category2">
392 <option value=""></option>
393 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
398 [% IF ( budget_id ) %]
399 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
403 <fieldset class="action">
404 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
405 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
409 [% END %] <!-- add_form -->
411 [% IF op == 'delete_confirm' %]
412 <div class="dialog alert">
413 <h3>Delete fund [% budget_name | html %]?</h3>
414 If you delete this fund, all orders linked to this fund will be deleted!
417 <th scope="row">Fund amount:</th>
418 <td>[% budget_amount | $Price %]</td>
422 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
423 <input type="hidden" name="op" value="delete_confirmed" />
424 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
425 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
426 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
428 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
429 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
435 </div> <!-- /.col-sm-10.col-sm-push-2 -->
437 <div class="col-sm-2 col-sm-pull-10">
440 [% IF op == 'list' %]
441 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
442 <a href="#" id="filterbutton">Filters</a>
443 <fieldset class="brief" id="fundfilters">
444 <h4>Fund filters</h4>
447 <label for="filter_budgetbranch2">Library: </label>
448 <select name="filter_budgetbranch" id="filter_budgetbranch2">
449 <option value=""></option>
450 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
455 <label for="show_mine">Show my funds only:</label>
456 [% IF ( show_mine ) %]
457 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
459 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
465 <label for="periods">Budget:</label>
466 <select id="periods" name="budget_period_id">
467 <option value="">All budgets</option>
468 [% FOR period IN periods %]
469 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
470 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
472 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
480 <input type="hidden" name="op" value="list" />
481 <input type="submit" class="submit" name="filter" value="Go" />
485 [% INCLUDE 'acquisitions-menu.inc' %]
487 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
488 </div> <!-- /.row -->
490 [% MACRO jsinclude BLOCK %]
491 [% Asset.js("js/acq.js") | $raw %]
492 [% IF op == 'add_form' %]
496 function userPopup() {
497 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
499 'width=740,height=450,location=yes,toolbar=no,'
500 + 'scrollbars=yes,resize=yes'
504 function ownerPopup() {
505 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
507 'width=740,height=450,location=yes,toolbar=no,'
508 + 'scrollbars=yes,resize=yes'
512 function select_user(borrowernumber, borrower) {
514 var borrowername = borrower.firstname + ' ' + borrower.surname;
515 if (borrowernumber) {
516 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
517 + '?borrowernumber=' + borrowernumber + '">'
518 + borrowername + '</a>';
519 $('#budget_owner_name').html(ownerlink);
520 $('#budget_owner_id').val(borrowernumber);
524 function ownerRemove() {
525 $('#budget_owner_name').empty();
526 $('#budget_owner_id').val('');
529 function add_user(borrowernumber, borrowername) {
530 var ids = $("#budget_users_id").val().split(':');
531 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
532 var li = '<li id="user_' + borrowernumber + '">'
533 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
534 + borrowernumber + '">' + borrowername + '</a> '
535 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
537 $("#budget_users").prepend(li);
538 ids.push(borrowernumber);
539 $("#budget_users_id").val(ids.join(':'));
546 function del_user(borrowernumber) {
547 var ids = $("#budget_users_id").val().split(':');
548 if (borrowernumber) {
549 var idx = ids.indexOf(borrowernumber+'');
552 $("#budget_users_id").val(ids.join(':'));
553 $("li#user_" + borrowernumber).remove();
563 if (!(isNotNull(f.budget_code,1))) {
564 _alertString += _("- Budget code cannot be blank") + "\n";
567 if (!(isNotNull(f.budget_name,1))) {
568 _alertString += _("- Budget name cannot be blank") + "\n";
571 if (!(isNotNull(f.budget_amount,1))) {
572 _alertString += _("- Budget amount cannot be blank") + "\n";
576 if (typeof(f.budget_id ) != "undefined") {
577 budgetId = f.budget_id.value
582 // hack to test if selected parent_id in scrolling-list...
583 // if value == 'undef' its got a selected_parent :/
584 if(f.budget_parent_id){
585 var chkAdd = f.budget_parent_id.value ;
586 if ( typeof(chkAdd ) != "undefined") {
587 newBudgetParent = f.budget_parent_id.value
589 newBudgetParent = f.budget_parent_id.item(0).value
592 if (budgetId > 0) { ; //its a mod ...
593 // if parent == curent-budget, fail...
594 if ( newBudgetParent == budgetId ) {
595 _alertString += _("- Budget parent is current budget") + "\n";
598 else if (newBudgetParent) {
599 var result = checkBudgetParent( budgetId , newBudgetParent );
601 _alertString += result;
608 var budgetTotal = Math.abs(f.budget_amount.value);
609 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
611 _alertString += result;
614 if (_alertString.length==0) {
615 document.Aform.submit();
617 alertString2 = _("Form not submitted because of the following problem(s)");
618 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
619 alertString2 += _alertString;
623 $(document).ready(function(){
624 $("#remove_owner").on("click",function(e){
628 $("#edit_owner").on("click",function(e){
632 $("body").on("click",".del_user",function(e){
634 var borrowernumber = $(this).data("borrowernumber");
635 del_user(borrowernumber);
637 $("#add_user_button").on("click",function(e){
641 $("#edit_fund").on("submit",function(e){
648 [% ELSIF op == 'list' %]
649 [% INCLUDE 'datatables.inc' %]
650 [% INCLUDE 'columns_settings.inc' %]
651 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
656 $(document).ready(function() {
658 var oTable = KohaTable("budgeth", {
659 "fnDrawCallback": function ( oSettings ) {
660 if ( oSettings.aiDisplay.length == 0 )
665 var nTrs = $('#budgeth tbody tr');
666 var iColspan = nTrs[0].getElementsByTagName('td').length;
668 for ( var i=0 ; i<nTrs.length ; i++ )
670 var iDisplayIndex = oSettings._iDisplayStart + i;
671 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
672 if ( sGroup != sLastGroup )
674 var nGroup = document.createElement( 'tr' );
675 var nCell = document.createElement( 'td' );
676 nCell.colSpan = iColspan;
677 nCell.className = "group";
678 nCell.innerHTML = sGroup;
679 nGroup.appendChild( nCell );
680 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
685 "footerCallback": function ( row, data, start, end, display ) {
686 var api = this.api(), data;
687 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
690 { "bVisible": false, "aTargets": [ 0, 1 ] },
691 { "bSortable": false, "aTargets": ["_all"] }
694 'aaSortingFixed': [[ 1, 'asc' ]],
699 $(oTable).treetable({
702 $(oTable).treetable('expandAll');
703 $("#expand_all").click(function(e){
705 $(oTable).treetable('expandAll');
707 $("#collapse_all").click(function(e){
709 $(oTable).treetable('collapseAll');
712 [% UNLESS budget_period_id %]
713 $("#hide_inactive").click(function(e){
715 oTable.fnFilter( 1, 0 ); // Show only active=1
717 $("#show_inactive").click(function(e){
719 oTable.fnFilter( '', 0 );
721 $("#hide_inactive").click();
723 oTable.fnAddFilters("filter", 750);
726 $("#filterbutton").click(function() {
727 $("#fundfilters").slideToggle(0);
730 $(".deletefund-disabled").tooltip().on("click", function(e){
732 alert(_("This fund has sub funds. It cannot be deleted."));
739 [% INCLUDE 'intranet-bottom.inc' %]