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 [% WRAPPER 'header.inc' %]
16 [% INCLUDE 'budgets-admin-search.inc' %]
19 [% WRAPPER 'sub-header.inc' %]
20 [% WRAPPER breadcrumbs %]
21 [% WRAPPER breadcrumb_item %]
22 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
24 [% WRAPPER breadcrumb_item %]
25 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
29 [% IF budget_period_id %]
30 [% WRAPPER breadcrumb_item bc_active= 1 %]
31 <span>Funds for '[% budget_period_description | html %]'</span>
34 [% WRAPPER breadcrumb_item bc_active= 1 %]
35 <span>All funds</span>
40 [% IF op == 'add_form' %]
41 [% WRAPPER breadcrumb_item %]
42 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a>
44 [% IF ( budget_id ) %]
45 [% WRAPPER breadcrumb_item bc_active= 1 %]
46 [% IF ( budget_name ) %]
47 <span>Modify fund '[% budget_name | html %]'</span>
49 <span>Modify fund</span>
53 [% WRAPPER breadcrumb_item bc_active= 1 %]
59 [% IF op == 'delete_confirm' %]
60 [% WRAPPER breadcrumb_item %]
61 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a>
63 [% WRAPPER breadcrumb_item bc_active= 1 %]
64 <span>Delete fund?</span>
67 [% END #/ WRAPPER breadcrumbs %]
68 [% END #/ WRAPPER sub-header.inc %]
70 <div class="main container-fluid">
72 <div class="col-sm-10 col-sm-push-2">
75 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
77 [% IF (error_not_authorised_to_modify) %]
78 <div class="dialog alert">
79 <p>You are not authorized to modify this fund</p>
86 [% IF budget_period_id %]
87 Funds for '[% budget_period_description | html %]'
93 [% INCLUDE 'budgets-active-currency.inc' %]
97 [% UNLESS budget_period_id %]
98 <div class="toolbar btn-toolbar">
99 <span class="actions">
100 <a href="#" id="expand_all">Expand all</a> |
101 <a href="#" id="collapse_all">Collapse all</a> |
102 <a href="#" id="hide_inactive">Hide inactive budgets</a> |
103 <a href="#" id="show_inactive">Show inactive budgets</a>
107 <div class="page-section">
108 <table id="budgeth" class="group">
112 <th>Budget period description</th>
115 <th>Base-level allocated</th>
116 <th>Base-level ordered</th>
117 <th>Total ordered</th>
118 <th>Base-level spent</th>
120 <th>Base-level available</th>
121 <th>Total available</th>
122 <th class="noExport">Actions</th>
129 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
130 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
132 <th class="data">[% ordered_total | $Price %]</th>
134 <th class="data">[% spent_total | $Price %]</th>
136 <th class="data">[% available_total | $Price %]</th>
141 [% FOREACH budget IN budgets %]
142 [% IF budget.budget_parent_id %]
143 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
145 <tr data-tt-id="[% budget.budget_id | html %]">
147 <td>[% budget.budget_period_active | html %]</td>
148 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
149 <td>[% budget.budget_code | html %]</td>
150 <td>[% budget.budget_name | html %]</td>
152 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
155 [% IF budget.budget_parent_id %]
156 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
158 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
162 [% IF budget.budget_parent_id %]
163 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
165 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
169 [% IF budget.budget_parent_id %]
170 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
172 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
176 [% IF budget.budget_parent_id %]
177 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
179 <span class="total_amount">[% budget.total_spent | $Price %]</span>
184 [% BLOCK colorcellvalue %]
186 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
187 [% ELSIF (value < 0) %]
188 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: red;">
190 <span class="totalamount">
196 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
199 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
201 [% IF ( budget.budget_lock ) %]
202 <td> <span></span> </td>
205 <div class="btn-group dropup">
206 <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="#">
207 Actions <b class="caret"></b>
209 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
210 <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-alt"></i> Edit</a></li>
211 [% IF budget.budget_has_children %]
212 <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-can"></i> Delete</a></li>
214 <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-can"></i> Delete</a></li>
216 <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>
225 </div> <!-- /.page-section -->
231 [% END %] <!-- list -->
233 <!-- ********************************************************************************************** -->
234 <!-- create add/mod entry form -->
235 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
236 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
237 <fieldset class="rows">
238 <legend><h1>[% IF ( budget_id ) %]<span>Modify fund</span>[% ELSE %]<span>Add fund</span>[% END %]
239 [% IF ( budget_period_description ) %]
240 [% budget_name | html %] <span>for budget</span> '[% budget_period_description | html %]'
245 <input type="hidden" name="op" value="add_validate" />
246 <input type="hidden" name="checked" value="0" />
248 [% IF ( budget_parent_id ) %]
250 <span class="label">Fund parent: </span>
251 [% budget_parent_name | html %]
252 [% budget_parent_id | html %] - [% budget_parent_name | html %]
253 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
257 <label class="required" for="budget_code">Fund code: </label>
258 <input type="text" name="budget_code" id="budget_code" class="focus" value="[% budget_code | html %]" size="30" />
262 <label class="required" for="budget_name">Fund name: </label>
263 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
267 <label for="budget_amount" class="required">Amount: </label>
268 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
272 <label for="budget_encumb">Warning at (%): </label>
273 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
274 <span class="hint">0 to disable</span>
278 <label for="budget_expend">Warning at (amount): </label>
279 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
280 <span class="hint">0 to disable</span>
284 <span class="label">Owner: </span>
285 [% IF budget_owner %]
286 <span id="budget_owner_name">
287 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
288 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
292 <span id="budget_owner_name"></span>
294 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
295 <a id="remove_owner" href="#"><i class="fa fa-trash-can"></i> Remove owner</a>
296 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
297 value="[% budget_owner.borrowernumber | html %]" />
301 [% IF budget_has_children %]
304 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
305 Update all sub funds with this owner
307 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
312 <span class="label">Users:</span>
313 <ul style="float:left;" id="budget_users">
314 [% FOREACH user IN budget_users %]
315 <li id="user_[% user.borrowernumber | html %]">
316 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
317 [% user.firstname | html %] [% user.surname | html %]
319 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash-can"></i> Remove</a>
322 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
324 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
327 <label for="budget_branchcode">Library: </label>
328 <select name="budget_branchcode" id="budget_branchcode">
329 <option value=""></option>
330 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
335 <label for="budget_permission">Restrict access to: </label>
336 <select name="budget_permission" id="budget_permission">
337 [% IF ( budget_perm_0 ) %]
338 <option value="0" selected="selected">
345 [% IF ( budget_perm_1 ) %]
346 <option value="1" selected="selected">
353 [% IF ( budget_perm_3) %]
354 <option value="3" selected="selected">
361 [% IF ( budget_perm_2 ) %]
362 <option value="2" selected="selected">
366 Owner, users and library
372 <label for="budget_notes">Notes: </label>
373 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
377 <label for="authorised_value_category1">Statistic 1 done on: </label>
378 <select name="sort1_authcat" id="authorised_value_category1">
379 <option value=""></option>
380 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
384 <label for="authorised_value_category2">Statistic 2 done on: </label>
385 <select name="sort2_authcat" id="authorised_value_category2">
386 <option value=""></option>
387 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
392 [% IF ( budget_id ) %]
393 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
397 <fieldset class="action">
398 <input type="submit" class="btn btn-primary" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
399 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
403 [% END %] <!-- add_form -->
405 [% IF op == 'delete_confirm' %]
406 <div class="dialog alert">
407 <h1>Delete fund [% budget_name | html %]?</h1>
408 If you delete this fund, all orders linked to this fund will be deleted!
411 <th scope="row">Fund amount:</th>
412 <td>[% budget_amount | $Price %]</td>
416 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
417 <input type="hidden" name="op" value="delete_confirmed" />
418 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
419 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
420 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
422 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
423 <button type="submit" class="deny"><i class="fa fa-fw fa-times"></i> No, do not delete</button>
429 </div> <!-- /.col-sm-10.col-sm-push-2 -->
431 <div class="col-sm-2 col-sm-pull-10">
434 [% IF op == 'list' %]
435 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
436 <a href="#" id="filterbutton">Filters</a>
437 <fieldset class="brief" id="fundfilters">
438 <h4>Fund filters</h4>
441 <label for="filter_budgetbranch2">Library: </label>
442 <select name="filter_budgetbranch" id="filter_budgetbranch2">
443 <option value=""></option>
444 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
449 <label for="show_mine">Show my funds only:</label>
450 [% IF ( show_mine ) %]
451 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
453 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
459 <label for="periods">Budget:</label>
460 <select id="periods" name="budget_period_id">
461 <option value="">All budgets</option>
462 [% FOR period IN periods %]
463 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
464 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
466 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
474 <input type="hidden" name="op" value="list" />
475 <input type="submit" class="submit" name="filter" value="Go" />
479 [% INCLUDE 'acquisitions-menu.inc' %]
481 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
482 </div> <!-- /.row -->
484 [% MACRO jsinclude BLOCK %]
485 [% Asset.js("js/acq.js") | $raw %]
486 [% IF op == 'add_form' %]
490 function userPopup() {
491 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users",
493 'width=1024,height=768,location=yes,toolbar=no,'
494 + 'scrollbars=yes,resize=yes'
498 function ownerPopup() {
499 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners",
501 'width=1024,height=768,location=yes,toolbar=no,'
502 + 'scrollbars=yes,resize=yes'
506 function select_user(borrowernumber, borrower) {
508 var borrowername = borrower.firstname + ' ' + borrower.surname;
509 if (borrowernumber) {
510 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
511 + '?borrowernumber=' + borrowernumber + '">'
512 + borrowername + '</a>';
513 $('#budget_owner_name').html(ownerlink);
514 $('#budget_owner_id').val(borrowernumber);
518 function ownerRemove() {
519 $('#budget_owner_name').empty();
520 $('#budget_owner_id').val('');
523 function add_user(borrowernumber, borrowername) {
524 var ids = $("#budget_users_id").val().split(':');
525 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
526 var li = '<li id="user_' + borrowernumber + '">'
527 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
528 + borrowernumber + '">' + borrowername + '</a> '
529 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash-can"></i> '+_("Remove")+'</a> '
531 $("#budget_users").prepend(li);
532 ids.push(borrowernumber);
533 $("#budget_users_id").val(ids.join(':'));
540 function del_user(borrowernumber) {
541 var ids = $("#budget_users_id").val().split(':');
542 if (borrowernumber) {
543 var idx = ids.indexOf(borrowernumber+'');
546 $("#budget_users_id").val(ids.join(':'));
547 $("li#user_" + borrowernumber).remove();
557 if (!(isNotNull(f.budget_code,1))) {
558 _alertString += _("- Budget code cannot be blank") + "\n";
561 if (!(isNotNull(f.budget_name,1))) {
562 _alertString += _("- Budget name cannot be blank") + "\n";
565 if (!(isNotNull(f.budget_amount,1))) {
566 _alertString += _("- Budget amount cannot be blank") + "\n";
570 if (typeof(f.budget_id ) != "undefined") {
571 budgetId = f.budget_id.value
576 // hack to test if selected parent_id in scrolling-list...
577 // if value == 'undef' its got a selected_parent :/
578 if(f.budget_parent_id){
579 var chkAdd = f.budget_parent_id.value ;
580 if ( typeof(chkAdd ) != "undefined") {
581 newBudgetParent = f.budget_parent_id.value
583 newBudgetParent = f.budget_parent_id.item(0).value
586 if (budgetId > 0) { ; //its a mod ...
587 // if parent == curent-budget, fail...
588 if ( newBudgetParent == budgetId ) {
589 _alertString += _("- Budget parent is current budget") + "\n";
592 else if (newBudgetParent) {
593 var result = checkBudgetParent( budgetId , newBudgetParent );
595 _alertString += result;
602 var budgetTotal = Math.abs(f.budget_amount.value);
603 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
605 _alertString += result;
608 if (_alertString.length==0) {
609 document.Aform.submit();
611 alertString2 = _("Form not submitted because of the following problem(s)");
612 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
613 alertString2 += _alertString;
617 $(document).ready(function(){
618 $("#remove_owner").on("click",function(e){
622 $("#edit_owner").on("click",function(e){
626 $("body").on("click",".del_user",function(e){
628 var borrowernumber = $(this).data("borrowernumber");
629 del_user(borrowernumber);
631 $("#add_user_button").on("click",function(e){
635 $("#edit_fund").on("submit",function(e){
642 [% ELSIF op == 'list' %]
643 [% INCLUDE 'datatables.inc' %]
644 [% INCLUDE 'columns_settings.inc' %]
645 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
650 $(document).ready(function() {
652 var oTable = KohaTable("budgeth", {
653 "fnDrawCallback": function ( oSettings ) {
654 if ( oSettings.aiDisplay.length == 0 )
659 var nTrs = $('#budgeth tbody tr');
660 var iColspan = nTrs[0].getElementsByTagName('td').length;
662 for ( var i=0 ; i<nTrs.length ; i++ )
664 var iDisplayIndex = oSettings._iDisplayStart + i;
665 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
666 if ( sGroup != sLastGroup )
668 var nGroup = document.createElement( 'tr' );
669 var nCell = document.createElement( 'td' );
670 nCell.colSpan = iColspan;
671 nCell.className = "group";
672 nCell.innerHTML = sGroup;
673 nGroup.appendChild( nCell );
674 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
679 "footerCallback": function ( row, data, start, end, display ) {
680 var api = this.api(), data;
681 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
684 { "bVisible": false, "aTargets": [ 0, 1 ] },
685 { "bSortable": false, "aTargets": ["_all"] }
688 'aaSortingFixed': [[ 1, 'asc' ]],
693 $(oTable).treetable({
696 $(oTable).treetable('expandAll');
697 $("#expand_all").click(function(e){
699 $(oTable).treetable('expandAll');
701 $("#collapse_all").click(function(e){
703 $(oTable).treetable('collapseAll');
706 [% UNLESS budget_period_id %]
707 $("#hide_inactive").click(function(e){
709 oTable.fnFilter( 1, 0 ); // Show only active=1
711 $("#show_inactive").click(function(e){
713 oTable.fnFilter( '', 0 );
715 $("#hide_inactive").click();
717 oTable.fnAddFilters("filter", 750);
720 $("#filterbutton").click(function() {
721 $("#fundfilters").slideToggle(0);
724 $(".deletefund-disabled").tooltip().on("click", function(e){
726 alert(_("This fund has sub funds. It cannot be deleted."));
733 [% INCLUDE 'intranet-bottom.inc' %]