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>
76 <th class="noExport">Actions</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 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
109 [% IF budget.budget_parent_id %]
110 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
112 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
116 [% IF budget.budget_parent_id %]
117 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
119 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
123 [% IF budget.budget_parent_id %]
124 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
126 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
130 [% IF budget.budget_parent_id %]
131 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
133 <span class="total_amount">[% budget.total_spent | $Price %]</span>
138 [% BLOCK colorcellvalue %]
140 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
141 [% ELSIF (value < 0) %]
142 <span class="total_amount" style="color: red;">
144 <span class="totalamount">
150 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
153 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
155 [% IF ( budget.budget_lock ) %]
156 <td> <span></span> </td>
159 <div class="btn-group dropup">
160 <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="#">
161 Actions <b class="caret"></b>
163 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
164 <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>
165 [% IF budget.budget_has_children %]
166 <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>
168 <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>
170 <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>
184 [% END %] <!-- list -->
186 <!-- ********************************************************************************************** -->
187 <!-- create add/mod entry form -->
188 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
189 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
190 <fieldset class="rows">
191 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
192 [% IF ( budget_period_description ) %]
193 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
197 <input type="hidden" name="op" value="add_validate" />
198 <input type="hidden" name="checked" value="0" />
200 [% IF ( budget_parent_id ) %]
202 <span class="label">Fund parent: </span>
203 [% budget_parent_name | html %]
204 [% budget_parent_id | html %] - [% budget_parent_name | html %]
205 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
209 <label class="required" for="budget_code">Fund code: </label>
210 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
214 <label class="required" for="budget_name">Fund name: </label>
215 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
219 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
220 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
224 <label for="budget_encumb">Warning at (%): </label>
225 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
226 <span class="hint">0 to disable</span>
230 <label for="budget_expend">Warning at (amount): </label>
231 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
232 <span class="hint">0 to disable</span>
236 <span class="label">Owner: </span>
237 [% IF budget_owner %]
238 <span id="budget_owner_name">
239 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
240 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
244 <span id="budget_owner_name"></span>
246 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
247 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
248 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
249 value="[% budget_owner.borrowernumber | html %]" />
253 [% IF budget_has_children %]
256 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
257 Update all sub funds with this owner
259 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
264 <span class="label">Users:</span>
265 <ul style="float:left;" id="budget_users">
266 [% FOREACH user IN budget_users %]
267 <li id="user_[% user.borrowernumber | html %]">
268 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
269 [% user.firstname | html %] [% user.surname | html %]
271 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
274 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
276 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
279 <label for="budget_branchcode">Library: </label>
280 <select name="budget_branchcode" id="budget_branchcode">
281 <option value=""></option>
282 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
287 <label for="budget_permission">Restrict access to: </label>
288 <select name="budget_permission" id="budget_permission">
289 [% IF ( budget_perm_0 ) %]
290 <option value="0" selected="selected">
297 [% IF ( budget_perm_1 ) %]
298 <option value="1" selected="selected">
305 [% IF ( budget_perm_3) %]
306 <option value="3" selected="selected">
313 [% IF ( budget_perm_2 ) %]
314 <option value="2" selected="selected">
318 Owner, users and library
324 <label for="budget_notes">Notes: </label>
325 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
329 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
330 <select name="sort1_authcat" id="authorised_value_category1">
331 <option value=""></option>
332 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
336 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
337 <select name="sort2_authcat" id="authorised_value_category2">
338 <option value=""></option>
339 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
344 [% IF ( budget_id ) %]
345 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
349 <fieldset class="action">
350 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
351 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
355 [% END %] <!-- add_form -->
357 [% IF op == 'delete_confirm' %]
358 <div class="dialog alert">
359 <h3>Delete fund [% budget_name | html %]?</h3>
360 If you delete this fund, all orders linked to this fund will be deleted!
363 <th scope="row">Fund amount:</th>
364 <td>[% budget_amount | $Price %]</td>
368 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
369 <input type="hidden" name="op" value="delete_confirmed" />
370 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
371 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
372 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
374 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
375 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
381 </div> <!-- /.col-sm-10.col-sm-push-2 -->
383 <div class="col-sm-2 col-sm-pull-10">
386 [% IF op == 'list' %]
387 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
388 <a href="#" id="filterbutton">Filters</a>
389 <fieldset class="brief" id="fundfilters">
390 <h4>Fund filters</h4>
393 <label for="filter_budgetbranch2">Library: </label>
394 <select name="filter_budgetbranch" id="filter_budgetbranch2">
395 <option value=""></option>
396 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
401 <label for="show_mine">Show my funds only:</label>
402 [% IF ( show_mine ) %]
403 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
405 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
411 <label for="periods">Budget:</label>
412 <select id="periods" name="budget_period_id">
413 <option value="">All budgets</option>
414 [% FOR period IN periods %]
415 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
416 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
418 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
426 <input type="hidden" name="op" value="list" />
427 <input type="submit" class="submit" name="filter" value="Go" />
431 [% INCLUDE 'acquisitions-menu.inc' %]
433 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
434 </div> <!-- /.row -->
436 [% MACRO jsinclude BLOCK %]
437 [% Asset.js("js/acq.js") | $raw %]
438 [% IF op == 'add_form' %]
442 function userPopup() {
443 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
445 'width=740,height=450,location=yes,toolbar=no,'
446 + 'scrollbars=yes,resize=yes'
450 function ownerPopup() {
451 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
453 'width=740,height=450,location=yes,toolbar=no,'
454 + 'scrollbars=yes,resize=yes'
458 function select_user(borrowernumber, borrower) {
460 var borrowername = borrower.firstname + ' ' + borrower.surname;
461 if (borrowernumber) {
462 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
463 + '?borrowernumber=' + borrowernumber + '">'
464 + borrowername + '</a>';
465 $('#budget_owner_name').html(ownerlink);
466 $('#budget_owner_id').val(borrowernumber);
470 function ownerRemove() {
471 $('#budget_owner_name').empty();
472 $('#budget_owner_id').val('');
475 function add_user(borrowernumber, borrowername) {
476 var ids = $("#budget_users_id").val().split(':');
477 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
478 var li = '<li id="user_' + borrowernumber + '">'
479 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
480 + borrowernumber + '">' + borrowername + '</a> '
481 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
483 $("#budget_users").prepend(li);
484 ids.push(borrowernumber);
485 $("#budget_users_id").val(ids.join(':'));
492 function del_user(borrowernumber) {
493 var ids = $("#budget_users_id").val().split(':');
494 if (borrowernumber) {
495 var idx = ids.indexOf(borrowernumber+'');
498 $("#budget_users_id").val(ids.join(':'));
499 $("li#user_" + borrowernumber).remove();
509 if (!(isNotNull(f.budget_code,1))) {
510 _alertString += _("- Budget code cannot be blank") + "\n";
513 if (!(isNotNull(f.budget_name,1))) {
514 _alertString += _("- Budget name cannot be blank") + "\n";
517 if (!(isNotNull(f.budget_amount,1))) {
518 _alertString += _("- Budget amount cannot be blank") + "\n";
522 if (typeof(f.budget_id ) != "undefined") {
523 budgetId = f.budget_id.value
528 // hack to test if selected parent_id in scrolling-list...
529 // if value == 'undef' its got a selected_parent :/
530 if(f.budget_parent_id){
531 var chkAdd = f.budget_parent_id.value ;
532 if ( typeof(chkAdd ) != "undefined") {
533 newBudgetParent = f.budget_parent_id.value
535 newBudgetParent = f.budget_parent_id.item(0).value
538 if (budgetId > 0) { ; //its a mod ...
539 // if parent == curent-budget, fail...
540 if ( newBudgetParent == budgetId ) {
541 _alertString += _("- Budget parent is current budget") + "\n";
544 else if (newBudgetParent) {
545 var result = checkBudgetParent( budgetId , newBudgetParent );
547 _alertString += result;
554 var budgetTotal = Math.abs(f.budget_amount.value);
555 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
557 _alertString += result;
560 if (_alertString.length==0) {
561 document.Aform.submit();
563 alertString2 = _("Form not submitted because of the following problem(s)");
564 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
565 alertString2 += _alertString;
569 $(document).ready(function(){
570 $("#remove_owner").on("click",function(e){
574 $("#edit_owner").on("click",function(e){
578 $("body").on("click",".del_user",function(e){
580 var borrowernumber = $(this).data("borrowernumber");
581 del_user(borrowernumber);
583 $("#add_user_button").on("click",function(e){
587 $("#edit_fund").on("submit",function(e){
594 [% ELSIF op == 'list' %]
595 [% INCLUDE 'datatables.inc' %]
596 [% INCLUDE 'columns_settings.inc' %]
597 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
602 $(document).ready(function() {
604 var oTable = KohaTable("budgeth", {
605 "fnDrawCallback": function ( oSettings ) {
606 if ( oSettings.aiDisplay.length == 0 )
611 var nTrs = $('#budgeth tbody tr');
612 var iColspan = nTrs[0].getElementsByTagName('td').length;
614 for ( var i=0 ; i<nTrs.length ; i++ )
616 var iDisplayIndex = oSettings._iDisplayStart + i;
617 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
618 if ( sGroup != sLastGroup )
620 var nGroup = document.createElement( 'tr' );
621 var nCell = document.createElement( 'td' );
622 nCell.colSpan = iColspan;
623 nCell.className = "group";
624 nCell.innerHTML = sGroup;
625 nGroup.appendChild( nCell );
626 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
631 "footerCallback": function ( row, data, start, end, display ) {
632 var api = this.api(), data;
633 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
636 { "bVisible": false, "aTargets": [ 0, 1 ] },
637 { "bSortable": false, "aTargets": ["_all"] }
640 'aaSortingFixed': [[ 1, 'asc' ]],
645 $(oTable).treetable({
648 $(oTable).treetable('expandAll');
649 $("#expand_all").click(function(e){
651 $(oTable).treetable('expandAll');
653 $("#collapse_all").click(function(e){
655 $(oTable).treetable('collapseAll');
658 [% UNLESS budget_period_id %]
659 $("#hide_inactive").click(function(e){
661 oTable.fnFilter( 1, 0 ); // Show only active=1
663 $("#show_inactive").click(function(e){
665 oTable.fnFilter( '', 0 );
667 $("#hide_inactive").click();
669 oTable.fnAddFilters("filter", 750);
672 $("#filterbutton").click(function() {
673 $("#fundfilters").slideToggle(0);
676 $(".deletefund-disabled").tooltip().on("click", function(e){
678 alert(_("This fund has sub funds. It cannot be deleted."));
685 [% INCLUDE 'intranet-bottom.inc' %]