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 | html %]">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 id="doc3" class="yui-t2">
31 <div class="yui-b" id="content">
34 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
36 [% IF (error_not_authorised_to_modify) %]
38 <p>You are not authorized to modify this fund</p>
45 [% IF budget_period_id %]
46 Funds for '[% budget_period_description | html %]'
52 [% INCLUDE 'budgets-active-currency.inc' %]
56 <table id="budgeth" class="group">
57 [% UNLESS budget_period_id %]
59 <span class="actions"><a href="#" id="expand_all">Expand all</a>
60 | <a href="#" id="collapse_all">Collapse all</a>
61 | <a href="#" id="hide_inactive">Hide inactive budgets</a>
62 | <a href="#" id="show_inactive">Show inactive budgets</a></span>
68 <th>Budget period description</th>
71 <th>Base-level allocated</th>
72 <th>Base-level ordered</th>
73 <th>Total ordered</th>
74 <th>Base-level spent</th>
76 <th>Base-level available</th>
77 <th>Total available</th>
85 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price | html %][% END %] </th>
86 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price | html %]</th>
88 <th class="data">[% ordered_total | $Price | html %]</th>
90 <th class="data">[% spent_total | $Price | html %]</th>
92 <th class="data">[% available_total | $Price | html %]</th>
97 [% FOREACH budget IN budgets %]
98 [% IF budget.budget_parent_id %]
99 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
101 <tr data-tt-id="[% budget.budget_id | html %]">
103 <td>[% budget.budget_period_active | html %]</td>
104 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
105 <td>[% budget.budget_code | html %]</td>
106 <td>[% budget.budget_name | html %]</td>
108 [% IF budget.budget_parent_id %]
109 <span class="child_fund_amount">[% budget.budget_amount | $Price | html %]</span>
111 <span class="total_amount">[% budget.budget_amount | $Price | html %]</span>
115 [% IF budget.budget_parent_id %]
116 <span class="child_fund_amount">[% budget.budget_ordered | $Price | html %]</span>
118 <span class="total_amount">[% budget.budget_ordered | $Price | html %]</span>
122 [% IF budget.budget_parent_id %]
123 <span class="child_fund_amount">[% budget.total_ordered | $Price | html %]</span>
125 <span class="total_amount">[% budget.total_ordered | $Price | html %]</span>
129 [% IF budget.budget_parent_id %]
130 <span class="child_fund_amount">[% budget.budget_spent | $Price | html %]</span>
132 <span class="total_amount">[% budget.budget_spent | $Price | html %]</span>
136 [% IF budget.budget_parent_id %]
137 <span class="child_fund_amount">[% budget.total_spent | $Price | html %]</span>
139 <span class="total_amount">[% budget.total_spent | $Price | html %]</span>
144 [% BLOCK colorcellvalue %]
147 <span class="child_fund_amount" style="color: green;">
148 [% ELSIF (value < 0) %]
149 <span class="child_fund_amount" style="color: red;">
151 <span class="child_fund_amount">
155 <span class="total_amount" style="color: green;">
156 [% ELSIF (value < 0) %]
157 <span class="total_amount" style="color: red;">
159 <span class="totalamount">
162 [% value | $Price | html %]
166 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
169 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
171 [% IF ( budget.budget_lock ) %]
172 <td> <span></span> </td>
175 <div class="dropdown dropup">
176 <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="#">
177 Actions <b class="caret"></b>
179 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
180 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=[% budget.budget_id | html %]&budget_period_id=[% budget.budget_period_id | html %]"><i class="fa fa-pencil"></i> Edit</a></li>
181 [% IF budget.budget_has_children %]
182 <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>
184 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=[% budget.budget_id | html %]&budget_period_id=[% budget.budget_period_id | html %]"><i class="fa fa-trash"></i> Delete</a></li>
186 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_parent_id=[% budget.budget_id | html %]&budget_period_id=[% budget.budget_period_id | html %]"><i class="fa fa-plus"></i> Add child fund</a></li>
200 [% END %] <!-- list -->
202 <!-- ********************************************************************************************** -->
203 <!-- create add/mod entry form -->
204 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
205 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
206 <fieldset class="rows">
207 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
208 [% IF ( budget_period_description ) %]
209 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
213 <input type="hidden" name="op" value="add_validate" />
214 <input type="hidden" name="checked" value="0" />
216 [% IF ( budget_parent_id ) %]
218 <span class="label">Fund parent: </span>
219 [% budget_parent_name | html %]
220 [% budget_parent_id | html %] - [% budget_parent_name | html %]
221 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
225 <label class="required" for="budget_code">Fund code: </label>
226 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
230 <label class="required" for="budget_name">Fund name: </label>
231 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
235 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
236 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 | html %]" size="8" />
240 <label for="budget_encumb">Warning at (%): </label>
241 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
242 <span class="hint">0 to disable</span>
246 <label for="budget_expend">Warning at (amount): </label>
247 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 | html %]" size="10" />
248 <span class="hint">0 to disable</span>
252 <span class="label">Owner: </span>
253 [% IF budget_owner %]
254 <span id="budget_owner_name">
255 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | html %]">
256 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
260 <span id="budget_owner_name"></span>
262 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
263 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
264 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
265 value="[% budget_owner.borrowernumber | html %]" />
269 [% IF budget_has_children %]
272 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
273 Update all child funds with this owner
275 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
280 <span class="label">Users:</span>
281 <ul style="float:left;" id="budget_users">
282 [% FOREACH user IN budget_users %]
283 <li id="user_[% user.borrowernumber | html %]">
284 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | html %]">
285 [% user.firstname | html %] [% user.surname | html %]
287 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
290 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
292 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
295 <label for="budget_branchcode">Library: </label>
296 <select name="budget_branchcode" id="budget_branchcode">
297 <option value=""></option>
298 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
303 <label for="budget_permission">Restrict access to: </label>
304 <select name="budget_permission" id="budget_permission">
305 [% IF ( budget_perm_0 ) %]
306 <option value="0" selected="selected">
313 [% IF ( budget_perm_1 ) %]
314 <option value="1" selected="selected">
321 [% IF ( budget_perm_3) %]
322 <option value="3" selected="selected">
329 [% IF ( budget_perm_2 ) %]
330 <option value="2" selected="selected">
334 Owner, users and library
340 <label for="budget_notes">Notes: </label>
341 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
345 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
346 <select name="sort1_authcat" id="authorised_value_category1">
347 <option value=""></option>
348 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
352 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
353 <select name="sort2_authcat" id="authorised_value_category2">
354 <option value=""></option>
355 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
360 [% IF ( budget_id ) %]
361 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
365 <fieldset class="action">
366 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
367 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
371 [% END %] <!-- add_form -->
373 [% IF op == 'delete_confirm' %]
374 <div class="dialog alert">
375 <h3>Delete fund [% budget_name | html %]?</h3>
376 If you delete this fund, all orders linked to this fund will be deleted!
379 <th scope="row">Fund amount:</th>
380 <td>[% budget_amount | $Price | html %]</td>
384 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
385 <input type="hidden" name="op" value="delete_confirmed" />
386 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
387 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
388 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
390 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
391 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
399 [% IF op == 'list' %]
400 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
401 <a href="#" id="filterbutton">Filters</a>
402 <fieldset class="brief" id="fundfilters">
403 <h4>Fund filters</h4>
406 <label for="filter_budgetbranch2">Library: </label>
407 <select name="filter_budgetbranch" id="filter_budgetbranch2">
408 <option value=""></option>
409 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
414 <label for="show_mine">Show my funds only:</label>
415 [% IF ( show_mine ) %]
416 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
418 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
424 <label for="periods">Budget:</label>
425 <select id="periods" name="budget_period_id">
426 <option value="">All budgets</option>
427 [% FOR period IN periods %]
428 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
429 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
431 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
439 <input type="hidden" name="op" value="list" />
440 <input type="submit" class="submit" name="filter" value="Go" />
443 [% INCLUDE 'acquisitions-menu.inc' %]
446 [% MACRO jsinclude BLOCK %]
447 [% Asset.js("js/acq.js") | $raw %]
448 <script type="text/javascript">
449 var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
450 var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
451 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
454 [% Asset.js("js/acq.js") | $raw %]
455 [% IF op == 'add_form' %]
456 <script type="text/javascript">
459 function userPopup() {
460 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
462 'width=740,height=450,location=yes,toolbar=no,'
463 + 'scrollbars=yes,resize=yes'
467 function ownerPopup() {
468 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
470 'width=740,height=450,location=yes,toolbar=no,'
471 + 'scrollbars=yes,resize=yes'
475 function select_user(borrowernumber, borrower) {
477 var borrowername = borrower.firstname + ' ' + borrower.surname;
478 if (borrowernumber) {
479 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
480 + '?borrowernumber=' + borrowernumber + '">'
481 + borrowername + '</a>';
482 $('#budget_owner_name').html(ownerlink);
483 $('#budget_owner_id').val(borrowernumber);
487 function ownerRemove() {
488 $('#budget_owner_name').empty();
489 $('#budget_owner_id').val('');
492 function add_user(borrowernumber, borrowername) {
493 var ids = $("#budget_users_id").val().split(':');
494 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
495 var li = '<li id="user_' + borrowernumber + '">'
496 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
497 + borrowernumber + '">' + borrowername + '</a> '
498 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
500 $("#budget_users").prepend(li);
501 ids.push(borrowernumber);
502 $("#budget_users_id").val(ids.join(':'));
509 function del_user(borrowernumber) {
510 var ids = $("#budget_users_id").val().split(':');
511 if (borrowernumber) {
512 var idx = ids.indexOf(borrowernumber+'');
515 $("#budget_users_id").val(ids.join(':'));
516 $("li#user_" + borrowernumber).remove();
526 if (!(isNotNull(f.budget_code,1))) {
527 _alertString += _("- Budget code cannot be blank") + "\n";
530 if (!(isNotNull(f.budget_name,1))) {
531 _alertString += _("- Budget name cannot be blank") + "\n";
534 if (!(isNotNull(f.budget_amount,1))) {
535 _alertString += _("- Budget amount cannot be blank") + "\n";
539 if (typeof(f.budget_id ) != "undefined") {
540 budgetId = f.budget_id.value
545 // hack to test if selected parent_id in scrolling-list...
546 // if value == 'undef' its got a selected_parent :/
547 if(f.budget_parent_id){
548 var chkAdd = f.budget_parent_id.value ;
549 if ( typeof(chkAdd ) != "undefined") {
550 newBudgetParent = f.budget_parent_id.value
552 newBudgetParent = f.budget_parent_id.item(0).value
555 if (budgetId > 0) { ; //its a mod ...
556 // if parent == curent-budget, fail...
557 if ( newBudgetParent == budgetId ) {
558 _alertString += _("- Budget parent is current budget") + "\n";
561 else if (newBudgetParent) {
562 var result = checkBudgetParent( budgetId , newBudgetParent );
564 _alertString += result;
571 var budgetTotal = Math.abs(f.budget_amount.value);
572 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
574 _alertString += result;
577 if (_alertString.length==0) {
578 document.Aform.submit();
580 alertString2 = _("Form not submitted because of the following problem(s)");
581 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
582 alertString2 += _alertString;
586 $(document).ready(function(){
587 $("#remove_owner").on("click",function(e){
591 $("#edit_owner").on("click",function(e){
595 $("body").on("click",".del_user",function(e){
597 var borrowernumber = $(this).data("borrowernumber");
598 del_user(borrowernumber);
600 $("#add_user_button").on("click",function(e){
604 $("#edit_fund").on("submit",function(e){
611 [% ELSIF op == 'list' %]
612 [% INCLUDE 'datatables.inc' %]
613 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
615 <script type="text/javascript">
618 $(document).ready(function() {
619 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
620 "fnDrawCallback": function ( oSettings ) {
621 if ( oSettings.aiDisplay.length == 0 )
626 var nTrs = $('#budgeth tbody tr');
627 var iColspan = nTrs[0].getElementsByTagName('td').length;
629 for ( var i=0 ; i<nTrs.length ; i++ )
631 var iDisplayIndex = oSettings._iDisplayStart + i;
632 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
633 if ( sGroup != sLastGroup )
635 var nGroup = document.createElement( 'tr' );
636 var nCell = document.createElement( 'td' );
637 nCell.colSpan = iColspan;
638 nCell.className = "group";
639 nCell.innerHTML = sGroup;
640 nGroup.appendChild( nCell );
641 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
646 "footerCallback": function ( row, data, start, end, display ) {
647 var api = this.api(), data;
648 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
651 { "bVisible": false, "aTargets": [ 0, 1 ] },
652 { "bSortable": false, "aTargets": ["_all"] }
654 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
656 'aaSortingFixed': [[ 1, 'asc' ]],
661 $(oTable).treetable({
664 $(oTable).treetable('expandAll');
665 $("#expand_all").click(function(e){
667 $(oTable).treetable('expandAll');
669 $("#collapse_all").click(function(e){
671 $(oTable).treetable('collapseAll');
674 [% UNLESS budget_period_id %]
675 $("#hide_inactive").click(function(e){
677 oTable.fnFilter( 1, 0 ); // Show only active=1
679 $("#show_inactive").click(function(e){
681 oTable.fnFilter( '', 0 );
683 $("#hide_inactive").click();
685 oTable.fnAddFilters("filter", 750);
687 $("#filterbutton").click(function() {
688 $("#fundfilters").slideToggle(0);
691 $(".deletefund-disabled").tooltip().on("click", function(e){
693 alert(_("This fund has children. It cannot be deleted."));
700 [% INCLUDE 'intranet-bottom.inc' %]