2 [% USE AuthorisedValues %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <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>
8 [% Asset.css("css/datatables.css") %]
9 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") %]
10 [% INCLUDE 'doc-head-close.inc' %]
13 <body id="admin_aqbudgets" class="admin">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'budgets-admin-search.inc' %]
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
18 <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 %]
19 [% IF op == 'add_form' %]
20 <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 %]
22 [% IF op == 'delete_confirm' %]
23 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> › Delete fund?
27 <div id="doc3" class="yui-t2">
30 <div class="yui-b" id="content">
33 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
35 [% IF (error_not_authorised_to_modify) %]
37 <p>You are not authorized to modify this fund</p>
44 [% IF budget_period_id %]
45 Funds for '[% budget_period_description %]'
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 %]" data-tt-parent-id="[% budget.budget_parent_id %]">
100 <tr data-tt-id="[% budget.budget_id %]">
102 <td>[% budget.budget_period_active %]</td>
103 <td>Budget [% budget.budget_period_description %] [id=[% budget.budget_period_id %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
104 <td>[% budget.budget_code %]</td>
105 <td>[% budget.budget_name %]</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 %]_[% budget.budget_period_id %]" 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 %]_[% budget.budget_period_id %]">
179 <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>
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 %]&budget_period_id=[% budget.budget_period_id %]"><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 %]&budget_period_id=[% budget.budget_period_id %]"><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 %] for Budget '[% budget_period_description %]'
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 %]
219 [% budget_parent_id %] - [% budget_parent_name %]
220 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
224 <label class="required" for="budget_code">Fund code: </label>
225 <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" 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 %]" 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 %]" size="8" />
239 <label for="budget_encumb">Warning at (%): </label>
240 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" 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 %]" 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 %]">
255 [% budget_owner.firstname %] [% budget_owner.surname %]
259 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
260 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
261 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
262 value="[% budget_owner.borrowernumber %]" />
266 [% IF budget_has_children %]
269 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
270 Update all child funds with this owner
272 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
277 <span class="label">Users:</span>
278 <ul style="float:left;" id="budget_users">
279 [% FOREACH user IN budget_users %]
280 <li id="user_[% user.borrowernumber %]">
281 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber %]">
282 [% user.firstname %] [% user.surname %]
284 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber %]"><i class="fa fa-trash"></i> Remove</a>
287 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
289 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids %]" />
292 <label for="budget_branchcode">Library: </label>
293 <select name="budget_branchcode" id="budget_branchcode">
294 <option value=""></option>
295 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
300 <label for="budget_permission">Restrict access to: </label>
301 <select name="budget_permission" id="budget_permission">
302 [% IF ( budget_perm_0 ) %]
303 <option value="0" selected="selected">
310 [% IF ( budget_perm_1 ) %]
311 <option value="1" selected="selected">
318 [% IF ( budget_perm_3) %]
319 <option value="3" selected="selected">
326 [% IF ( budget_perm_2 ) %]
327 <option value="2" selected="selected">
331 Owner, users and library
337 <label for="budget_notes">Notes: </label>
338 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes %]</textarea>
342 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
343 <select name="sort1_authcat" id="authorised_value_category1">
344 <option value=""></option>
345 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
349 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
350 <select name="sort2_authcat" id="authorised_value_category2">
351 <option value=""></option>
352 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
357 [% IF ( budget_id ) %]
358 <input type="hidden" name="budget_id" value="[% budget_id %]" />
362 <fieldset class="action">
363 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
364 <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
368 [% END %] <!-- add_form -->
370 [% IF op == 'delete_confirm' %]
371 <div class="dialog alert">
372 <h3>Delete fund [% budget_name %]?</h3>
373 If you delete this fund, all orders linked to this fund will be deleted!
376 <th scope="row">Fund amount:</th>
377 <td>[% budget_amount | $Price %]</td>
381 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
382 <input type="hidden" name="op" value="delete_confirmed" />
383 <input type="hidden" name="budget_id" value="[% budget_id %]" />
384 <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
385 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
387 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
388 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
396 [% IF op == 'list' %]
397 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
398 <a href="#" id="filterbutton">Filters</a>
399 <fieldset class="brief" id="fundfilters">
400 <h4>Fund filters</h4>
403 <label for="filter_budgetbranch2">Library: </label>
404 <select name="filter_budgetbranch" id="filter_budgetbranch2">
405 <option value=""></option>
406 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
411 <label for="show_mine">Show my funds only:</label>
412 [% IF ( show_mine ) %]
413 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
415 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
421 <label for="periods">Budget:</label>
422 <select id="periods" name="budget_period_id">
423 <option value="">All budgets</option>
424 [% FOR period IN periods %]
425 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
426 <option value="[% period.budget_period_id %]" selected="selected">[% period.budget_period_description %]</option>
428 <option value="[% period.budget_period_id %]">[% period.budget_period_description %]</option>
436 <input type="hidden" name="op" value="list" />
437 <input type="submit" class="submit" name="filter" value="Go" />
440 [% INCLUDE 'acquisitions-menu.inc' %]
443 [% MACRO jsinclude BLOCK %]
444 [% Asset.js("js/acq.js") %]
445 <script type="text/javascript">
446 var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
447 var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
448 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
451 [% Asset.js("js/acq.js") %]
452 [% IF op == 'add_form' %]
453 <script type="text/javascript">
456 function userPopup() {
457 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
459 'width=740,height=450,location=yes,toolbar=no,'
460 + 'scrollbars=yes,resize=yes'
464 function ownerPopup() {
465 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
467 'width=740,height=450,location=yes,toolbar=no,'
468 + 'scrollbars=yes,resize=yes'
472 function select_user(borrowernumber, borrower) {
474 var borrowername = borrower.firstname + ' ' + borrower.surname
475 if (borrowernumber) {
476 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
477 + '?borrowernumber=' + borrowernumber + '">'
478 + borrowername + '</a>';
479 $('#budget_owner_name').html(ownerlink);
480 $('#budget_owner_id').val(borrowernumber);
484 function ownerRemove() {
485 $('#budget_owner_name').empty();
486 $('#budget_owner_id').val('');
489 function add_user(borrowernumber, borrowername) {
490 var ids = $("#budget_users_id").val().split(':');
491 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
492 var li = '<li id="user_' + borrowernumber + '">'
493 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
494 + borrowernumber + '">' + borrowername + '</a> '
495 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
497 $("#budget_users").prepend(li);
498 ids.push(borrowernumber);
499 $("#budget_users_id").val(ids.join(':'));
506 function del_user(borrowernumber) {
507 var ids = $("#budget_users_id").val().split(':');
508 if (borrowernumber) {
509 var idx = ids.indexOf(borrowernumber+'');
512 $("#budget_users_id").val(ids.join(':'));
513 $("li#user_" + borrowernumber).remove();
523 if (!(isNotNull(f.budget_code,1))) {
524 _alertString += _("- Budget code cannot be blank") + "\n";
527 if (!(isNotNull(f.budget_name,1))) {
528 _alertString += _("- Budget name cannot be blank") + "\n";
531 if (!(isNotNull(f.budget_amount,1))) {
532 _alertString += _("- Budget amount cannot be blank") + "\n";
536 if (typeof(f.budget_id ) != "undefined") {
537 budgetId = f.budget_id.value
542 // hack to test if selected parent_id in scrolling-list...
543 // if value == 'undef' its got a selected_parent :/
544 if(f.budget_parent_id){
545 var chkAdd = f.budget_parent_id.value ;
546 if ( typeof(chkAdd ) != "undefined") {
547 newBudgetParent = f.budget_parent_id.value
549 newBudgetParent = f.budget_parent_id.item(0).value
552 if (budgetId > 0) { ; //its a mod ...
553 // if parent == curent-budget, fail...
554 if ( newBudgetParent == budgetId ) {
555 _alertString += _("- Budget parent is current budget") + "\n";
558 else if (newBudgetParent) {
559 var result = checkBudgetParent( budgetId , newBudgetParent );
561 _alertString += result;
568 var budgetTotal = Math.abs(f.budget_amount.value);
569 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
571 _alertString += result;
574 if (_alertString.length==0) {
575 document.Aform.submit();
577 alertString2 = _("Form not submitted because of the following problem(s)");
578 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
579 alertString2 += _alertString;
583 $(document).ready(function(){
584 $("#remove_owner").on("click",function(e){
588 $("#edit_owner").on("click",function(e){
592 $("body").on("click",".del_user",function(e){
594 var borrowernumber = $(this).data("borrowernumber");
595 del_user(borrowernumber);
597 $("#add_user_button").on("click",function(e){
601 $("#edit_fund").on("submit",function(e){
608 [% ELSIF op == 'list' %]
609 [% INCLUDE 'datatables.inc' %]
610 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") %]
612 <script type="text/javascript">
615 $(document).ready(function() {
616 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
617 "fnDrawCallback": function ( oSettings ) {
618 if ( oSettings.aiDisplay.length == 0 )
623 var nTrs = $('#budgeth tbody tr');
624 var iColspan = nTrs[0].getElementsByTagName('td').length;
626 for ( var i=0 ; i<nTrs.length ; i++ )
628 var iDisplayIndex = oSettings._iDisplayStart + i;
629 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
630 if ( sGroup != sLastGroup )
632 var nGroup = document.createElement( 'tr' );
633 var nCell = document.createElement( 'td' );
634 nCell.colSpan = iColspan;
635 nCell.className = "group";
636 nCell.innerHTML = sGroup;
637 nGroup.appendChild( nCell );
638 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
643 "footerCallback": function ( row, data, start, end, display ) {
644 var api = this.api(), data;
645 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
648 { "bVisible": false, "aTargets": [ 0, 1 ] },
649 { "bSortable": false, "aTargets": ["_all"] }
651 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
653 'aaSortingFixed': [[ 1, 'asc' ]],
658 $(oTable).treetable({
661 $(oTable).treetable('expandAll');
662 $("#expand_all").click(function(e){
664 $(oTable).treetable('expandAll');
666 $("#collapse_all").click(function(e){
668 $(oTable).treetable('collapseAll');
671 [% UNLESS budget_period_id %]
672 $("#hide_inactive").click(function(e){
674 oTable.fnFilter( 1, 0 ); // Show only active=1
676 $("#show_inactive").click(function(e){
678 oTable.fnFilter( '', 0 );
680 $("#hide_inactive").click();
682 oTable.fnAddFilters("filter", 750);
684 $("#filterbutton").click(function() {
685 $("#fundfilters").slideToggle(0);
688 $(".deletefund-disabled").tooltip().on("click", function(e){
690 alert(_("This fund has children. It cannot be deleted."));
697 [% INCLUDE 'intranet-bottom.inc' %]