1 [% USE AuthorisedValues %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>Koha › Administration › Funds[% IF op == 'add_form' %] › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
7 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
8 <link href="[% interface %]/lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css" rel="stylesheet" type="text/css" />
9 [% INCLUDE 'doc-head-close.inc' %]
12 <body id="admin_aqbudgets" class="admin">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'budgets-admin-search.inc' %]
16 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
17 <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 %]'[% ELSE %]All funds[% END %][% END %]
18 [% IF op == 'add_form' %]
19 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Funds</a> › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund[% END %]
21 [% IF op == 'delete_confirm' %]
22 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> › Delete fund?
26 <div id="doc3" class="yui-t2">
29 <div class="yui-b" id="content">
32 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
34 [% IF (error_not_authorised_to_modify) %]
36 <p>You are not authorized to modify this fund</p>
43 [% IF budget_period_id %]
44 Funds for '[% budget_period_description %]'
50 [% INCLUDE 'budgets-active-currency.inc' %]
54 <table id="budgeth" class="group">
55 [% UNLESS budget_period_id %]
57 <span class="actions"><a href="#" id="expand_all">Expand all</a>
58 | <a href="#" id="collapse_all">Collapse all</a>
59 | <a href="#" id="hide_inactive">Hide inactive budgets</a>
60 | <a href="#" id="show_inactive">Show inactive budgets</a></span>
66 <th>Budget period description</th>
69 <th>Base-level allocated</th>
70 <th>Base-level ordered</th>
71 <th>Total ordered</th>
72 <th>Base-level spent</th>
74 <th>Base-level available</th>
75 <th>Total available</th>
83 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
84 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
86 <th class="data">[% ordered_total | $Price %]</th>
88 <th class="data">[% spent_total | $Price %]</th>
90 <th class="data">[% available_total | $Price %]</th>
95 [% FOREACH budget IN budgets %]
96 [% IF budget.budget_parent_id %]
97 <tr data-tt-id="[% budget.budget_id %]" data-tt-parent-id="[% budget.budget_parent_id %]">
99 <tr data-tt-id="[% budget.budget_id %]">
101 <td>[% budget.budget_period_active %]</td>
102 <td>Budget [% budget.budget_period_description %] [id=[% budget.budget_period_id %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
103 <td>[% budget.budget_code %]</td>
104 <td>[% budget.budget_name %]</td>
106 [% IF budget.budget_parent_id %]
107 <span class="child_fund_amount">[% budget.budget_amount | $Price %]</span>
109 <span class="total_amount">[% budget.budget_amount | $Price %]</span>
113 [% IF budget.budget_parent_id %]
114 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
116 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
120 [% IF budget.budget_parent_id %]
121 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
123 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
127 [% IF budget.budget_parent_id %]
128 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
130 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
134 [% IF budget.budget_parent_id %]
135 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
137 <span class="total_amount">[% budget.total_spent | $Price %]</span>
142 [% BLOCK colorcellvalue %]
145 <span class="child_fund_amount" style="color: green;">
146 [% ELSIF (value < 0) %]
147 <span class="child_fund_amount" style="color: red;">
149 <span class="child_fund_amount">
153 <span class="total_amount" style="color: green;">
154 [% ELSIF (value < 0) %]
155 <span class="total_amount" style="color: red;">
157 <span class="totalamount">
164 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
167 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
169 [% IF ( budget.budget_lock ) %]
170 <td> <span></span> </td>
173 <div class="dropdown dropup">
174 <a class="btn btn-default btn-xs dropdown-toggle" id="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]" role="button" data-toggle="dropdown" href="#">
175 Actions <b class="caret"></b>
177 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]">
178 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-pencil"></i> Edit</a></li>
179 [% IF budget.budget_has_children %]
180 <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>
182 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-trash"></i> Delete</a></li>
184 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_parent_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-plus"></i> Add child fund</a></li>
198 [% END %] <!-- list -->
200 <!-- ********************************************************************************************** -->
201 <!-- create add/mod entry form -->
202 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
203 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
204 <fieldset class="rows">
205 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
206 [% IF ( budget_period_description ) %]
207 [% budget_name %] for Budget '[% budget_period_description %]'
211 <input type="hidden" name="op" value="add_validate" />
212 <input type="hidden" name="checked" value="0" />
214 [% IF ( budget_parent_id ) %]
216 <span class="label">Fund parent: </span>
217 [% budget_parent_name %]
218 [% budget_parent_id %] - [% budget_parent_name %]
219 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
223 <label class="required" for="budget_code">Fund code: </label>
224 <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" size="30" />
228 <label class="required" for="budget_name">Fund name: </label>
229 <input type="text" name="budget_name" id="budget_name" value="[% budget_name %]" size="60" />
233 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
234 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
238 <label for="budget_encumb">Warning at (%): </label>
239 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="10" />
240 <span class="hint">0 to disable</span>
244 <label for="budget_expend">Warning at (amount): </label>
245 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
246 <span class="hint">0 to disable</span>
250 <span class="label">Owner: </span>
251 [% IF ( budget_owner_name ) %]
252 <span id="budget_owner_name">
253 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner_id %]">
254 [% budget_owner_name %]
258 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
259 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
260 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
261 value="[% budget_owner_id %]" />
265 [% IF budget_has_children %]
268 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
269 Update all child funds with this owner
271 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
276 <span class="label">Users:</span>
277 <ul style="float:left;" id="budget_users">
278 [% FOREACH user IN budget_users %]
279 <li id="user_[% user.borrowernumber %]">
280 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber %]">
281 [% user.firstname %] [% user.surname %]
283 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber %]"><i class="fa fa-trash"></i> Remove</a>
286 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
288 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids %]" />
291 <label for="budget_branchcode">Library: </label>
292 <select name="budget_branchcode" id="budget_branchcode">
293 <option value=""></option>
294 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
299 <label for="budget_permission">Restrict access to: </label>
300 <select name="budget_permission" id="budget_permission">
301 [% IF ( budget_perm_0 ) %]
302 <option value="0" selected="selected">
309 [% IF ( budget_perm_1 ) %]
310 <option value="1" selected="selected">
317 [% IF ( budget_perm_3) %]
318 <option value="3" selected="selected">
325 [% IF ( budget_perm_2 ) %]
326 <option value="2" selected="selected">
330 Owner, users and library
336 <label for="budget_notes">Notes: </label>
337 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes %]</textarea>
341 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
342 <select name="sort1_authcat" id="authorised_value_category1">
343 <option value=""></option>
344 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
348 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
349 <select name="sort2_authcat" id="authorised_value_category2">
350 <option value=""></option>
351 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
356 [% IF ( budget_id ) %]
357 <input type="hidden" name="budget_id" value="[% budget_id %]" />
361 <fieldset class="action">
362 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
363 <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
367 [% END %] <!-- add_form -->
369 [% IF op == 'delete_confirm' %]
370 <div class="dialog alert">
371 <h3>Delete fund [% budget_name %]?</h3>
372 If you delete this fund, all orders linked to this fund will be deleted!
375 <th scope="row">Fund amount:</th>
376 <td>[% budget_amount | $Price %]</td>
380 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
381 <input type="hidden" name="op" value="delete_confirmed" />
382 <input type="hidden" name="budget_id" value="[% budget_id %]" />
383 <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
384 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
386 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
387 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
395 [% IF op == 'list' %]
396 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
397 <a href="#" id="filterbutton">Filters</a>
398 <fieldset class="brief" id="fundfilters">
399 <h4>Fund filters</h4>
402 <label for="filter_budgetbranch2">Library: </label>
403 <select name="filter_budgetbranch" id="filter_budgetbranch2" style="width:10em;">
404 <option value=""></option>
405 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
410 <label for="show_mine">Show my funds only:</label>
411 [% IF ( show_mine ) %]
412 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
414 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
420 <label for="periods">Budget:</label>
421 <select id="periods" name="budget_period_id">
422 <option value="">All budgets</option>
423 [% FOR period IN periods %]
424 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
425 <option value="[% period.budget_period_id %]" selected="selected">[% period.budget_period_description %]</option>
427 <option value="[% period.budget_period_id %]">[% period.budget_period_description %]</option>
435 <input type="hidden" name="op" value="list" />
436 <input type="submit" class="submit" name="filter" value="Go" />
439 [% INCLUDE 'acquisitions-menu.inc' %]
442 [% MACRO jsinclude BLOCK %]
443 <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script>
444 <script type="text/javascript">
445 var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
446 var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
447 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
450 <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script>
451 [% IF op == 'add_form' %]
452 <script type="text/javascript">
455 function userPopup() {
456 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
458 'width=740,height=450,location=yes,toolbar=no,'
459 + 'scrollbars=yes,resize=yes'
463 function ownerPopup() {
464 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
466 'width=740,height=450,location=yes,toolbar=no,'
467 + 'scrollbars=yes,resize=yes'
471 function select_user(borrowernumber, borrower) {
473 var borrowername = borrower.firstname + ' ' + borrower.surname
474 if (borrowernumber) {
475 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
476 + '?borrowernumber=' + borrowernumber + '">'
477 + borrowername + '</a>';
478 $('#budget_owner_name').html(ownerlink);
479 $('#budget_owner_id').val(borrowernumber);
483 function ownerRemove() {
484 $('#budget_owner_name').empty();
485 $('#budget_owner_id').val('');
488 function add_user(borrowernumber, borrowername) {
489 var ids = $("#budget_users_id").val().split(':');
490 if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
491 var li = '<li id="user_' + borrowernumber + '">'
492 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
493 + borrowernumber + '">' + borrowername + '</a> '
494 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> Remove</a> '
496 $("#budget_users").prepend(li);
497 ids.push(borrowernumber);
498 $("#budget_users_id").val(ids.join(':'));
505 function del_user(borrowernumber) {
506 var ids = $("#budget_users_id").val().split(':');
507 if (borrowernumber) {
508 var idx = ids.indexOf(borrowernumber+'');
511 $("#budget_users_id").val(ids.join(':'));
512 $("li#user_" + borrowernumber).remove();
522 if (!(isNotNull(f.budget_code,1))) {
523 _alertString += _("- Budget code cannot be blank") + "\n";
526 if (!(isNotNull(f.budget_name,1))) {
527 _alertString += _("- Budget name cannot be blank") + "\n";
530 if (!(isNotNull(f.budget_amount,1))) {
531 _alertString += _("- Budget amount cannot be blank") + "\n";
535 if (typeof(f.budget_id ) != "undefined") {
536 budgetId = f.budget_id.value
541 // hack to test if selected parent_id in scrolling-list...
542 // if value == 'undef' its got a selected_parent :/
543 if(f.budget_parent_id){
544 var chkAdd = f.budget_parent_id.value ;
545 if ( typeof(chkAdd ) != "undefined") {
546 newBudgetParent = f.budget_parent_id.value
548 newBudgetParent = f.budget_parent_id.item(0).value
551 if (budgetId > 0) { ; //its a mod ...
552 // if parent == curent-budget, fail...
553 if ( newBudgetParent == budgetId ) {
554 _alertString += _("- Budget parent is current budget") + "\n";
557 else if (newBudgetParent) {
558 var result = checkBudgetParent( budgetId , newBudgetParent );
560 _alertString += result;
567 var budgetTotal = Math.abs(f.budget_amount.value);
568 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
570 _alertString += result;
573 if (_alertString.length==0) {
574 document.Aform.submit();
576 alertString2 = _("Form not submitted because of the following problem(s)");
577 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
578 alertString2 += _alertString;
582 $(document).ready(function(){
583 $("#remove_owner").on("click",function(e){
587 $("#edit_owner").on("click",function(e){
591 $("body").on("click",".del_user",function(e){
593 var borrowernumber = $(this).data("borrowernumber");
594 del_user(borrowernumber);
596 $("#add_user_button").on("click",function(e){
600 $("#edit_fund").on("submit",function(e){
607 [% ELSIF op == 'list' %]
608 [% INCLUDE 'datatables.inc' %]
609 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/treetable/jquery.treetable.js"></script>
611 <script type="text/javascript">
614 $(document).ready(function() {
615 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
616 "fnDrawCallback": function ( oSettings ) {
617 if ( oSettings.aiDisplay.length == 0 )
622 var nTrs = $('#budgeth tbody tr');
623 var iColspan = nTrs[0].getElementsByTagName('td').length;
625 for ( var i=0 ; i<nTrs.length ; i++ )
627 var iDisplayIndex = oSettings._iDisplayStart + i;
628 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
629 if ( sGroup != sLastGroup )
631 var nGroup = document.createElement( 'tr' );
632 var nCell = document.createElement( 'td' );
633 nCell.colSpan = iColspan;
634 nCell.className = "group";
635 nCell.innerHTML = sGroup;
636 nGroup.appendChild( nCell );
637 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
642 "footerCallback": function ( row, data, start, end, display ) {
643 var api = this.api(), data;
644 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
647 { "bVisible": false, "aTargets": [ 0, 1 ] },
648 { "bSortable": false, "aTargets": ["_all"] }
650 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
652 'aaSortingFixed': [[ 1, 'asc' ]],
657 $(oTable).treetable({
660 $(oTable).treetable('expandAll');
661 $("#expand_all").click(function(e){
663 $(oTable).treetable('expandAll');
665 $("#collapse_all").click(function(e){
667 $(oTable).treetable('collapseAll');
670 [% UNLESS budget_period_id %]
671 $("#hide_inactive").click(function(e){
673 oTable.fnFilter( 1, 0 ); // Show only active=1
675 $("#show_inactive").click(function(e){
677 oTable.fnFilter( '', 0 );
679 $("#hide_inactive").click();
681 oTable.fnAddFilters("filter", 750);
683 $("#filterbutton").click(function() {
684 $("#fundfilters").slideToggle(0);
687 $(".deletefund-disabled").tooltip().on("click", function(e){
689 alert(_("This fund has children. It cannot be deleted."));
696 [% INCLUDE 'intranet-bottom.inc' %]