3 [% USE AuthorisedValues %]
7 [% INCLUDE 'doc-head-open.inc' %]
9 <title>[% IF op == 'add_form' %][% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% END %][% ELSE %]Add fund[% END %] ›[% END %] Funds › Administration › Koha</title>
10 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
11 [% INCLUDE 'doc-head-close.inc' %]
14 <body id="admin_aqbudgets" class="admin">
15 [% INCLUDE 'header.inc' %]
16 [% INCLUDE 'budgets-admin-search.inc' %]
18 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
21 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
27 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
31 [% IF budget_period_id %]
33 <a href="#" aria-current="page">
34 Funds for '[% budget_period_description | html %]'
39 <a href="#" aria-current="page">
46 [% IF op == 'add_form' %]
48 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a>
50 [% IF ( budget_id ) %]
52 <a href="#" aria-current="page">
54 [% IF ( budget_name ) %] '[% budget_name | html %]'[% END %]
59 <a href="#" aria-current="page">
66 [% IF op == 'delete_confirm' %]
68 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a>
71 <a href="#" aria-current="page">
79 <div class="main container-fluid">
81 <div class="col-sm-10 col-sm-push-2">
84 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
86 [% IF (error_not_authorised_to_modify) %]
87 <div class="dialog alert">
88 <p>You are not authorized to modify this fund</p>
95 [% IF budget_period_id %]
96 Funds for '[% budget_period_description | html %]'
102 [% INCLUDE 'budgets-active-currency.inc' %]
106 [% UNLESS budget_period_id %]
107 <div class="toolbar btn-toolbar">
108 <span class="actions">
109 <a href="#" id="expand_all">Expand all</a> |
110 <a href="#" id="collapse_all">Collapse all</a> |
111 <a href="#" id="hide_inactive">Hide inactive budgets</a> |
112 <a href="#" id="show_inactive">Show inactive budgets</a>
117 <table id="budgeth" class="group">
121 <th>Budget period description</th>
124 <th>Base-level allocated</th>
125 <th>Base-level ordered</th>
126 <th>Total ordered</th>
127 <th>Base-level spent</th>
129 <th>Base-level available</th>
130 <th>Total available</th>
131 <th class="noExport">Actions</th>
138 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
139 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
141 <th class="data">[% ordered_total | $Price %]</th>
143 <th class="data">[% spent_total | $Price %]</th>
145 <th class="data">[% available_total | $Price %]</th>
150 [% FOREACH budget IN budgets %]
151 [% IF budget.budget_parent_id %]
152 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
154 <tr data-tt-id="[% budget.budget_id | html %]">
156 <td>[% budget.budget_period_active | html %]</td>
157 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
158 <td>[% budget.budget_code | html %]</td>
159 <td>[% budget.budget_name | html %]</td>
161 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
164 [% IF budget.budget_parent_id %]
165 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
167 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
171 [% IF budget.budget_parent_id %]
172 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
174 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
178 [% IF budget.budget_parent_id %]
179 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
181 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
185 [% IF budget.budget_parent_id %]
186 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
188 <span class="total_amount">[% budget.total_spent | $Price %]</span>
193 [% BLOCK colorcellvalue %]
195 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
196 [% ELSIF (value < 0) %]
197 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: red;">
199 <span class="totalamount">
205 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
208 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
210 [% IF ( budget.budget_lock ) %]
211 <td> <span></span> </td>
214 <div class="btn-group dropup">
215 <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="#">
216 Actions <b class="caret"></b>
218 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
219 <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>
220 [% IF budget.budget_has_children %]
221 <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>
223 <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>
225 <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>
239 [% END %] <!-- list -->
241 <!-- ********************************************************************************************** -->
242 <!-- create add/mod entry form -->
243 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
244 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
245 <fieldset class="rows">
246 <legend><h1>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
247 [% IF ( budget_period_description ) %]
248 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
253 <input type="hidden" name="op" value="add_validate" />
254 <input type="hidden" name="checked" value="0" />
256 [% IF ( budget_parent_id ) %]
258 <span class="label">Fund parent: </span>
259 [% budget_parent_name | html %]
260 [% budget_parent_id | html %] - [% budget_parent_name | html %]
261 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
265 <label class="required" for="budget_code">Fund code: </label>
266 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
270 <label class="required" for="budget_name">Fund name: </label>
271 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
275 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
276 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
280 <label for="budget_encumb">Warning at (%): </label>
281 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
282 <span class="hint">0 to disable</span>
286 <label for="budget_expend">Warning at (amount): </label>
287 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
288 <span class="hint">0 to disable</span>
292 <span class="label">Owner: </span>
293 [% IF budget_owner %]
294 <span id="budget_owner_name">
295 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
296 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
300 <span id="budget_owner_name"></span>
302 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
303 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
304 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
305 value="[% budget_owner.borrowernumber | html %]" />
309 [% IF budget_has_children %]
312 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
313 Update all sub funds with this owner
315 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
320 <span class="label">Users:</span>
321 <ul style="float:left;" id="budget_users">
322 [% FOREACH user IN budget_users %]
323 <li id="user_[% user.borrowernumber | html %]">
324 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
325 [% user.firstname | html %] [% user.surname | html %]
327 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
330 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
332 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
335 <label for="budget_branchcode">Library: </label>
336 <select name="budget_branchcode" id="budget_branchcode">
337 <option value=""></option>
338 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
343 <label for="budget_permission">Restrict access to: </label>
344 <select name="budget_permission" id="budget_permission">
345 [% IF ( budget_perm_0 ) %]
346 <option value="0" selected="selected">
353 [% IF ( budget_perm_1 ) %]
354 <option value="1" selected="selected">
361 [% IF ( budget_perm_3) %]
362 <option value="3" selected="selected">
369 [% IF ( budget_perm_2 ) %]
370 <option value="2" selected="selected">
374 Owner, users and library
380 <label for="budget_notes">Notes: </label>
381 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
385 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
386 <select name="sort1_authcat" id="authorised_value_category1">
387 <option value=""></option>
388 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
392 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
393 <select name="sort2_authcat" id="authorised_value_category2">
394 <option value=""></option>
395 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
400 [% IF ( budget_id ) %]
401 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
405 <fieldset class="action">
406 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
407 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
411 [% END %] <!-- add_form -->
413 [% IF op == 'delete_confirm' %]
414 <div class="dialog alert">
415 <h1>Delete fund [% budget_name | html %]?</h1>
416 If you delete this fund, all orders linked to this fund will be deleted!
419 <th scope="row">Fund amount:</th>
420 <td>[% budget_amount | $Price %]</td>
424 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
425 <input type="hidden" name="op" value="delete_confirmed" />
426 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
427 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
428 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
430 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
431 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
437 </div> <!-- /.col-sm-10.col-sm-push-2 -->
439 <div class="col-sm-2 col-sm-pull-10">
442 [% IF op == 'list' %]
443 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
444 <a href="#" id="filterbutton">Filters</a>
445 <fieldset class="brief" id="fundfilters">
446 <h4>Fund filters</h4>
449 <label for="filter_budgetbranch2">Library: </label>
450 <select name="filter_budgetbranch" id="filter_budgetbranch2">
451 <option value=""></option>
452 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
457 <label for="show_mine">Show my funds only:</label>
458 [% IF ( show_mine ) %]
459 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
461 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
467 <label for="periods">Budget:</label>
468 <select id="periods" name="budget_period_id">
469 <option value="">All budgets</option>
470 [% FOR period IN periods %]
471 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
472 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
474 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
482 <input type="hidden" name="op" value="list" />
483 <input type="submit" class="submit" name="filter" value="Go" />
487 [% INCLUDE 'acquisitions-menu.inc' %]
489 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
490 </div> <!-- /.row -->
492 [% MACRO jsinclude BLOCK %]
493 [% Asset.js("js/acq.js") | $raw %]
494 [% IF op == 'add_form' %]
498 function userPopup() {
499 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users",
501 'width=1024,height=768,location=yes,toolbar=no,'
502 + 'scrollbars=yes,resize=yes'
506 function ownerPopup() {
507 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners",
509 'width=1024,height=768,location=yes,toolbar=no,'
510 + 'scrollbars=yes,resize=yes'
514 function select_user(borrowernumber, borrower) {
516 var borrowername = borrower.firstname + ' ' + borrower.surname;
517 if (borrowernumber) {
518 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
519 + '?borrowernumber=' + borrowernumber + '">'
520 + borrowername + '</a>';
521 $('#budget_owner_name').html(ownerlink);
522 $('#budget_owner_id').val(borrowernumber);
526 function ownerRemove() {
527 $('#budget_owner_name').empty();
528 $('#budget_owner_id').val('');
531 function add_user(borrowernumber, borrowername) {
532 var ids = $("#budget_users_id").val().split(':');
533 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
534 var li = '<li id="user_' + borrowernumber + '">'
535 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
536 + borrowernumber + '">' + borrowername + '</a> '
537 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
539 $("#budget_users").prepend(li);
540 ids.push(borrowernumber);
541 $("#budget_users_id").val(ids.join(':'));
548 function del_user(borrowernumber) {
549 var ids = $("#budget_users_id").val().split(':');
550 if (borrowernumber) {
551 var idx = ids.indexOf(borrowernumber+'');
554 $("#budget_users_id").val(ids.join(':'));
555 $("li#user_" + borrowernumber).remove();
565 if (!(isNotNull(f.budget_code,1))) {
566 _alertString += _("- Budget code cannot be blank") + "\n";
569 if (!(isNotNull(f.budget_name,1))) {
570 _alertString += _("- Budget name cannot be blank") + "\n";
573 if (!(isNotNull(f.budget_amount,1))) {
574 _alertString += _("- Budget amount cannot be blank") + "\n";
578 if (typeof(f.budget_id ) != "undefined") {
579 budgetId = f.budget_id.value
584 // hack to test if selected parent_id in scrolling-list...
585 // if value == 'undef' its got a selected_parent :/
586 if(f.budget_parent_id){
587 var chkAdd = f.budget_parent_id.value ;
588 if ( typeof(chkAdd ) != "undefined") {
589 newBudgetParent = f.budget_parent_id.value
591 newBudgetParent = f.budget_parent_id.item(0).value
594 if (budgetId > 0) { ; //its a mod ...
595 // if parent == curent-budget, fail...
596 if ( newBudgetParent == budgetId ) {
597 _alertString += _("- Budget parent is current budget") + "\n";
600 else if (newBudgetParent) {
601 var result = checkBudgetParent( budgetId , newBudgetParent );
603 _alertString += result;
610 var budgetTotal = Math.abs(f.budget_amount.value);
611 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
613 _alertString += result;
616 if (_alertString.length==0) {
617 document.Aform.submit();
619 alertString2 = _("Form not submitted because of the following problem(s)");
620 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
621 alertString2 += _alertString;
625 $(document).ready(function(){
626 $("#remove_owner").on("click",function(e){
630 $("#edit_owner").on("click",function(e){
634 $("body").on("click",".del_user",function(e){
636 var borrowernumber = $(this).data("borrowernumber");
637 del_user(borrowernumber);
639 $("#add_user_button").on("click",function(e){
643 $("#edit_fund").on("submit",function(e){
650 [% ELSIF op == 'list' %]
651 [% INCLUDE 'datatables.inc' %]
652 [% INCLUDE 'columns_settings.inc' %]
653 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
658 $(document).ready(function() {
660 var oTable = KohaTable("budgeth", {
661 "fnDrawCallback": function ( oSettings ) {
662 if ( oSettings.aiDisplay.length == 0 )
667 var nTrs = $('#budgeth tbody tr');
668 var iColspan = nTrs[0].getElementsByTagName('td').length;
670 for ( var i=0 ; i<nTrs.length ; i++ )
672 var iDisplayIndex = oSettings._iDisplayStart + i;
673 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
674 if ( sGroup != sLastGroup )
676 var nGroup = document.createElement( 'tr' );
677 var nCell = document.createElement( 'td' );
678 nCell.colSpan = iColspan;
679 nCell.className = "group";
680 nCell.innerHTML = sGroup;
681 nGroup.appendChild( nCell );
682 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
687 "footerCallback": function ( row, data, start, end, display ) {
688 var api = this.api(), data;
689 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
692 { "bVisible": false, "aTargets": [ 0, 1 ] },
693 { "bSortable": false, "aTargets": ["_all"] }
696 'aaSortingFixed': [[ 1, 'asc' ]],
701 $(oTable).treetable({
704 $(oTable).treetable('expandAll');
705 $("#expand_all").click(function(e){
707 $(oTable).treetable('expandAll');
709 $("#collapse_all").click(function(e){
711 $(oTable).treetable('collapseAll');
714 [% UNLESS budget_period_id %]
715 $("#hide_inactive").click(function(e){
717 oTable.fnFilter( 1, 0 ); // Show only active=1
719 $("#show_inactive").click(function(e){
721 oTable.fnFilter( '', 0 );
723 $("#hide_inactive").click();
725 oTable.fnAddFilters("filter", 750);
728 $("#filterbutton").click(function() {
729 $("#fundfilters").slideToggle(0);
732 $(".deletefund-disabled").tooltip().on("click", function(e){
734 alert(_("This fund has sub funds. It cannot be deleted."));
741 [% INCLUDE 'intranet-bottom.inc' %]