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("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
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 | html %]'[% 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 | uri %]">Funds</a> › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% 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 class="main container-fluid">
29 <div class="col-sm-10 col-sm-push-2">
32 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
34 [% IF (error_not_authorised_to_modify) %]
35 <div class="dialog alert">
36 <p>You are not authorized to modify this fund</p>
43 [% IF budget_period_id %]
44 Funds for '[% budget_period_description | html %]'
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 | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
99 <tr data-tt-id="[% budget.budget_id | html %]">
101 <td>[% budget.budget_period_active | html %]</td>
102 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
103 <td>[% budget.budget_code | html %]</td>
104 <td>[% budget.budget_name | html %]</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="btn-group dropup">
174 <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="#">
175 Actions <b class="caret"></b>
177 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
178 <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>
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 sub funds."><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 | uri %]&budget_period_id=[% budget.budget_period_id | uri %]"><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 | uri %]&budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-plus"></i> Add sub 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 | html %] for Budget '[% budget_period_description | html %]'
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 | html %]
218 [% budget_parent_id | html %] - [% budget_parent_name | html %]
219 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
223 <label class="required" for="budget_code">Fund code: </label>
224 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" 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 | html %]" 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 | html %]" 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 %]
252 <span id="budget_owner_name">
253 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
254 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
258 <span id="budget_owner_name"></span>
260 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
261 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
262 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
263 value="[% budget_owner.borrowernumber | html %]" />
267 [% IF budget_has_children %]
270 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
271 Update all sub funds with this owner
273 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
278 <span class="label">Users:</span>
279 <ul style="float:left;" id="budget_users">
280 [% FOREACH user IN budget_users %]
281 <li id="user_[% user.borrowernumber | html %]">
282 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
283 [% user.firstname | html %] [% user.surname | html %]
285 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
288 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
290 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
293 <label for="budget_branchcode">Library: </label>
294 <select name="budget_branchcode" id="budget_branchcode">
295 <option value=""></option>
296 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
301 <label for="budget_permission">Restrict access to: </label>
302 <select name="budget_permission" id="budget_permission">
303 [% IF ( budget_perm_0 ) %]
304 <option value="0" selected="selected">
311 [% IF ( budget_perm_1 ) %]
312 <option value="1" selected="selected">
319 [% IF ( budget_perm_3) %]
320 <option value="3" selected="selected">
327 [% IF ( budget_perm_2 ) %]
328 <option value="2" selected="selected">
332 Owner, users and library
338 <label for="budget_notes">Notes: </label>
339 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
343 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
344 <select name="sort1_authcat" id="authorised_value_category1">
345 <option value=""></option>
346 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
350 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
351 <select name="sort2_authcat" id="authorised_value_category2">
352 <option value=""></option>
353 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
358 [% IF ( budget_id ) %]
359 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
363 <fieldset class="action">
364 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
365 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
369 [% END %] <!-- add_form -->
371 [% IF op == 'delete_confirm' %]
372 <div class="dialog alert">
373 <h3>Delete fund [% budget_name | html %]?</h3>
374 If you delete this fund, all orders linked to this fund will be deleted!
377 <th scope="row">Fund amount:</th>
378 <td>[% budget_amount | $Price %]</td>
382 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
383 <input type="hidden" name="op" value="delete_confirmed" />
384 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
385 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
386 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
388 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
389 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
395 </div> <!-- /.col-sm-10.col-sm-push-2 -->
397 <div class="col-sm-2 col-sm-pull-10">
400 [% IF op == 'list' %]
401 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
402 <a href="#" id="filterbutton">Filters</a>
403 <fieldset class="brief" id="fundfilters">
404 <h4>Fund filters</h4>
407 <label for="filter_budgetbranch2">Library: </label>
408 <select name="filter_budgetbranch" id="filter_budgetbranch2">
409 <option value=""></option>
410 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
415 <label for="show_mine">Show my funds only:</label>
416 [% IF ( show_mine ) %]
417 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
419 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
425 <label for="periods">Budget:</label>
426 <select id="periods" name="budget_period_id">
427 <option value="">All budgets</option>
428 [% FOR period IN periods %]
429 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
430 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
432 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
440 <input type="hidden" name="op" value="list" />
441 <input type="submit" class="submit" name="filter" value="Go" />
445 [% INCLUDE 'acquisitions-menu.inc' %]
447 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
448 </div> <!-- /.row -->
450 [% MACRO jsinclude BLOCK %]
451 [% Asset.js("js/acq.js") | $raw %]
452 [% IF op == 'add_form' %]
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") | $raw %]
615 $(document).ready(function() {
617 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
618 "fnDrawCallback": function ( oSettings ) {
619 if ( oSettings.aiDisplay.length == 0 )
624 var nTrs = $('#budgeth tbody tr');
625 var iColspan = nTrs[0].getElementsByTagName('td').length;
627 for ( var i=0 ; i<nTrs.length ; i++ )
629 var iDisplayIndex = oSettings._iDisplayStart + i;
630 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
631 if ( sGroup != sLastGroup )
633 var nGroup = document.createElement( 'tr' );
634 var nCell = document.createElement( 'td' );
635 nCell.colSpan = iColspan;
636 nCell.className = "group";
637 nCell.innerHTML = sGroup;
638 nGroup.appendChild( nCell );
639 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
644 "footerCallback": function ( row, data, start, end, display ) {
645 var api = this.api(), data;
646 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
649 { "bVisible": false, "aTargets": [ 0, 1 ] },
650 { "bSortable": false, "aTargets": ["_all"] }
652 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
654 'aaSortingFixed': [[ 1, 'asc' ]],
659 $(oTable).treetable({
662 $(oTable).treetable('expandAll');
663 $("#expand_all").click(function(e){
665 $(oTable).treetable('expandAll');
667 $("#collapse_all").click(function(e){
669 $(oTable).treetable('collapseAll');
672 [% UNLESS budget_period_id %]
673 $("#hide_inactive").click(function(e){
675 oTable.fnFilter( 1, 0 ); // Show only active=1
677 $("#show_inactive").click(function(e){
679 oTable.fnFilter( '', 0 );
681 $("#hide_inactive").click();
683 oTable.fnAddFilters("filter", 750);
686 $("#filterbutton").click(function() {
687 $("#fundfilters").slideToggle(0);
690 $(".deletefund-disabled").tooltip().on("click", function(e){
692 alert(_("This fund has sub funds. It cannot be deleted."));
699 [% INCLUDE 'intranet-bottom.inc' %]