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("css/datatables.css") | $raw %]
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 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
19 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> › [% IF op == 'list' %][% IF budget_period_id %]Funds for '[% budget_period_description | html %]'[% ELSE %]All funds[% END %][% END %]
20 [% IF op == 'add_form' %]
21 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a> › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% END %][% ELSE %]Add fund[% END %]
23 [% IF op == 'delete_confirm' %]
24 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> › Delete fund?
28 <div class="main container-fluid">
30 <div class="col-sm-10 col-sm-push-2">
33 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
35 [% IF (error_not_authorised_to_modify) %]
36 <div class="dialog alert">
37 <p>You are not authorized to modify this fund</p>
44 [% IF budget_period_id %]
45 Funds for '[% budget_period_description | html %]'
51 [% INCLUDE 'budgets-active-currency.inc' %]
55 <table id="budgeth" class="group">
56 [% UNLESS budget_period_id %]
58 <span class="actions"><a href="#" id="expand_all">Expand all</a>
59 | <a href="#" id="collapse_all">Collapse all</a>
60 | <a href="#" id="hide_inactive">Hide inactive budgets</a>
61 | <a href="#" id="show_inactive">Show inactive budgets</a></span>
67 <th>Budget period description</th>
70 <th>Base-level allocated</th>
71 <th>Base-level ordered</th>
72 <th>Total ordered</th>
73 <th>Base-level spent</th>
75 <th>Base-level available</th>
76 <th>Total available</th>
84 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
85 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
87 <th class="data">[% ordered_total | $Price %]</th>
89 <th class="data">[% spent_total | $Price %]</th>
91 <th class="data">[% available_total | $Price %]</th>
96 [% FOREACH budget IN budgets %]
97 [% IF budget.budget_parent_id %]
98 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
100 <tr data-tt-id="[% budget.budget_id | html %]">
102 <td>[% budget.budget_period_active | html %]</td>
103 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
104 <td>[% budget.budget_code | html %]</td>
105 <td>[% budget.budget_name | html %]</td>
107 [% IF budget.budget_parent_id %]
108 <span class="child_fund_amount">[% budget.budget_amount | $Price %]</span>
110 <span class="total_amount">[% budget.budget_amount | $Price %]</span>
114 [% IF budget.budget_parent_id %]
115 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
117 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
121 [% IF budget.budget_parent_id %]
122 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
124 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
128 [% IF budget.budget_parent_id %]
129 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
131 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
135 [% IF budget.budget_parent_id %]
136 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
138 <span class="total_amount">[% budget.total_spent | $Price %]</span>
143 [% BLOCK colorcellvalue %]
146 <span class="child_fund_amount" style="color: green;">
147 [% ELSIF (value < 0) %]
148 <span class="child_fund_amount" style="color: red;">
150 <span class="child_fund_amount">
154 <span class="total_amount" style="color: green;">
155 [% ELSIF (value < 0) %]
156 <span class="total_amount" style="color: red;">
158 <span class="totalamount">
165 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
168 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
170 [% IF ( budget.budget_lock ) %]
171 <td> <span></span> </td>
174 <div class="dropdown dropup">
175 <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="#">
176 Actions <b class="caret"></b>
178 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
179 <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>
180 [% IF budget.budget_has_children %]
181 <li class="disabled"><a href="#" class="deletefund-disabled" data-toggle="tooltip" data-placement="left" title="This fund has children"><i class="fa fa-trash"></i> Delete</a></li>
183 <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>
185 <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 child fund</a></li>
199 [% END %] <!-- list -->
201 <!-- ********************************************************************************************** -->
202 <!-- create add/mod entry form -->
203 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
204 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
205 <fieldset class="rows">
206 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
207 [% IF ( budget_period_description ) %]
208 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
212 <input type="hidden" name="op" value="add_validate" />
213 <input type="hidden" name="checked" value="0" />
215 [% IF ( budget_parent_id ) %]
217 <span class="label">Fund parent: </span>
218 [% budget_parent_name | html %]
219 [% budget_parent_id | html %] - [% budget_parent_name | html %]
220 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
224 <label class="required" for="budget_code">Fund code: </label>
225 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
229 <label class="required" for="budget_name">Fund name: </label>
230 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
234 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
235 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 | html %]" size="8" />
239 <label for="budget_encumb">Warning at (%): </label>
240 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
241 <span class="hint">0 to disable</span>
245 <label for="budget_expend">Warning at (amount): </label>
246 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 | html %]" size="10" />
247 <span class="hint">0 to disable</span>
251 <span class="label">Owner: </span>
252 [% IF budget_owner %]
253 <span id="budget_owner_name">
254 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
255 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
259 <span id="budget_owner_name"></span>
261 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
262 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
263 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
264 value="[% budget_owner.borrowernumber | html %]" />
268 [% IF budget_has_children %]
271 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
272 Update all child funds with this owner
274 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
279 <span class="label">Users:</span>
280 <ul style="float:left;" id="budget_users">
281 [% FOREACH user IN budget_users %]
282 <li id="user_[% user.borrowernumber | html %]">
283 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
284 [% user.firstname | html %] [% user.surname | html %]
286 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
289 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
291 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
294 <label for="budget_branchcode">Library: </label>
295 <select name="budget_branchcode" id="budget_branchcode">
296 <option value=""></option>
297 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
302 <label for="budget_permission">Restrict access to: </label>
303 <select name="budget_permission" id="budget_permission">
304 [% IF ( budget_perm_0 ) %]
305 <option value="0" selected="selected">
312 [% IF ( budget_perm_1 ) %]
313 <option value="1" selected="selected">
320 [% IF ( budget_perm_3) %]
321 <option value="3" selected="selected">
328 [% IF ( budget_perm_2 ) %]
329 <option value="2" selected="selected">
333 Owner, users and library
339 <label for="budget_notes">Notes: </label>
340 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
344 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
345 <select name="sort1_authcat" id="authorised_value_category1">
346 <option value=""></option>
347 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
351 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
352 <select name="sort2_authcat" id="authorised_value_category2">
353 <option value=""></option>
354 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
359 [% IF ( budget_id ) %]
360 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
364 <fieldset class="action">
365 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
366 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
370 [% END %] <!-- add_form -->
372 [% IF op == 'delete_confirm' %]
373 <div class="dialog alert">
374 <h3>Delete fund [% budget_name | html %]?</h3>
375 If you delete this fund, all orders linked to this fund will be deleted!
378 <th scope="row">Fund amount:</th>
379 <td>[% budget_amount | $Price %]</td>
383 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
384 <input type="hidden" name="op" value="delete_confirmed" />
385 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
386 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
387 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
389 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
390 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
396 </div> <!-- /.col-sm-10.col-sm-push-2 -->
398 <div class="col-sm-2 col-sm-pull-10">
401 [% IF op == 'list' %]
402 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
403 <a href="#" id="filterbutton">Filters</a>
404 <fieldset class="brief" id="fundfilters">
405 <h4>Fund filters</h4>
408 <label for="filter_budgetbranch2">Library: </label>
409 <select name="filter_budgetbranch" id="filter_budgetbranch2">
410 <option value=""></option>
411 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
416 <label for="show_mine">Show my funds only:</label>
417 [% IF ( show_mine ) %]
418 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
420 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
426 <label for="periods">Budget:</label>
427 <select id="periods" name="budget_period_id">
428 <option value="">All budgets</option>
429 [% FOR period IN periods %]
430 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
431 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
433 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
441 <input type="hidden" name="op" value="list" />
442 <input type="submit" class="submit" name="filter" value="Go" />
446 [% INCLUDE 'acquisitions-menu.inc' %]
448 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
449 </div> <!-- /.row -->
451 [% MACRO jsinclude BLOCK %]
452 [% Asset.js("js/acq.js") | $raw %]
454 var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
455 var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
456 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
459 [% Asset.js("js/acq.js") | $raw %]
460 [% IF op == 'add_form' %]
464 function userPopup() {
465 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
467 'width=740,height=450,location=yes,toolbar=no,'
468 + 'scrollbars=yes,resize=yes'
472 function ownerPopup() {
473 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
475 'width=740,height=450,location=yes,toolbar=no,'
476 + 'scrollbars=yes,resize=yes'
480 function select_user(borrowernumber, borrower) {
482 var borrowername = borrower.firstname + ' ' + borrower.surname;
483 if (borrowernumber) {
484 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
485 + '?borrowernumber=' + borrowernumber + '">'
486 + borrowername + '</a>';
487 $('#budget_owner_name').html(ownerlink);
488 $('#budget_owner_id').val(borrowernumber);
492 function ownerRemove() {
493 $('#budget_owner_name').empty();
494 $('#budget_owner_id').val('');
497 function add_user(borrowernumber, borrowername) {
498 var ids = $("#budget_users_id").val().split(':');
499 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
500 var li = '<li id="user_' + borrowernumber + '">'
501 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
502 + borrowernumber + '">' + borrowername + '</a> '
503 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
505 $("#budget_users").prepend(li);
506 ids.push(borrowernumber);
507 $("#budget_users_id").val(ids.join(':'));
514 function del_user(borrowernumber) {
515 var ids = $("#budget_users_id").val().split(':');
516 if (borrowernumber) {
517 var idx = ids.indexOf(borrowernumber+'');
520 $("#budget_users_id").val(ids.join(':'));
521 $("li#user_" + borrowernumber).remove();
531 if (!(isNotNull(f.budget_code,1))) {
532 _alertString += _("- Budget code cannot be blank") + "\n";
535 if (!(isNotNull(f.budget_name,1))) {
536 _alertString += _("- Budget name cannot be blank") + "\n";
539 if (!(isNotNull(f.budget_amount,1))) {
540 _alertString += _("- Budget amount cannot be blank") + "\n";
544 if (typeof(f.budget_id ) != "undefined") {
545 budgetId = f.budget_id.value
550 // hack to test if selected parent_id in scrolling-list...
551 // if value == 'undef' its got a selected_parent :/
552 if(f.budget_parent_id){
553 var chkAdd = f.budget_parent_id.value ;
554 if ( typeof(chkAdd ) != "undefined") {
555 newBudgetParent = f.budget_parent_id.value
557 newBudgetParent = f.budget_parent_id.item(0).value
560 if (budgetId > 0) { ; //its a mod ...
561 // if parent == curent-budget, fail...
562 if ( newBudgetParent == budgetId ) {
563 _alertString += _("- Budget parent is current budget") + "\n";
566 else if (newBudgetParent) {
567 var result = checkBudgetParent( budgetId , newBudgetParent );
569 _alertString += result;
576 var budgetTotal = Math.abs(f.budget_amount.value);
577 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
579 _alertString += result;
582 if (_alertString.length==0) {
583 document.Aform.submit();
585 alertString2 = _("Form not submitted because of the following problem(s)");
586 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
587 alertString2 += _alertString;
591 $(document).ready(function(){
592 $("#remove_owner").on("click",function(e){
596 $("#edit_owner").on("click",function(e){
600 $("body").on("click",".del_user",function(e){
602 var borrowernumber = $(this).data("borrowernumber");
603 del_user(borrowernumber);
605 $("#add_user_button").on("click",function(e){
609 $("#edit_fund").on("submit",function(e){
616 [% ELSIF op == 'list' %]
617 [% INCLUDE 'datatables.inc' %]
618 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
623 $(document).ready(function() {
624 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
625 "fnDrawCallback": function ( oSettings ) {
626 if ( oSettings.aiDisplay.length == 0 )
631 var nTrs = $('#budgeth tbody tr');
632 var iColspan = nTrs[0].getElementsByTagName('td').length;
634 for ( var i=0 ; i<nTrs.length ; i++ )
636 var iDisplayIndex = oSettings._iDisplayStart + i;
637 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
638 if ( sGroup != sLastGroup )
640 var nGroup = document.createElement( 'tr' );
641 var nCell = document.createElement( 'td' );
642 nCell.colSpan = iColspan;
643 nCell.className = "group";
644 nCell.innerHTML = sGroup;
645 nGroup.appendChild( nCell );
646 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
651 "footerCallback": function ( row, data, start, end, display ) {
652 var api = this.api(), data;
653 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
656 { "bVisible": false, "aTargets": [ 0, 1 ] },
657 { "bSortable": false, "aTargets": ["_all"] }
659 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
661 'aaSortingFixed': [[ 1, 'asc' ]],
666 $(oTable).treetable({
669 $(oTable).treetable('expandAll');
670 $("#expand_all").click(function(e){
672 $(oTable).treetable('expandAll');
674 $("#collapse_all").click(function(e){
676 $(oTable).treetable('collapseAll');
679 [% UNLESS budget_period_id %]
680 $("#hide_inactive").click(function(e){
682 oTable.fnFilter( 1, 0 ); // Show only active=1
684 $("#show_inactive").click(function(e){
686 oTable.fnFilter( '', 0 );
688 $("#hide_inactive").click();
690 oTable.fnAddFilters("filter", 750);
692 $("#filterbutton").click(function() {
693 $("#fundfilters").slideToggle(0);
696 $(".deletefund-disabled").tooltip().on("click", function(e){
698 alert(_("This fund has children. It cannot be deleted."));
705 [% INCLUDE 'intranet-bottom.inc' %]