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 [% UNLESS budget_period_id %]
55 <div class="toolbar btn-toolbar">
56 <span class="actions">
57 <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>
65 <table id="budgeth" class="group">
69 <th>Budget period description</th>
72 <th>Base-level allocated</th>
73 <th>Base-level ordered</th>
74 <th>Total ordered</th>
75 <th>Base-level spent</th>
77 <th>Base-level available</th>
78 <th>Total available</th>
79 <th class="noExport">Actions</th>
86 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
87 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
89 <th class="data">[% ordered_total | $Price %]</th>
91 <th class="data">[% spent_total | $Price %]</th>
93 <th class="data">[% available_total | $Price %]</th>
98 [% FOREACH budget IN budgets %]
99 [% IF budget.budget_parent_id %]
100 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
102 <tr data-tt-id="[% budget.budget_id | html %]">
104 <td>[% budget.budget_period_active | html %]</td>
105 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
106 <td>[% budget.budget_code | html %]</td>
107 <td>[% budget.budget_name | html %]</td>
109 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
112 [% IF budget.budget_parent_id %]
113 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
115 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
119 [% IF budget.budget_parent_id %]
120 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
122 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
126 [% IF budget.budget_parent_id %]
127 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
129 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
133 [% IF budget.budget_parent_id %]
134 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
136 <span class="total_amount">[% budget.total_spent | $Price %]</span>
141 [% BLOCK colorcellvalue %]
143 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
144 [% ELSIF (value < 0) %]
145 <span class="total_amount" style="color: red;">
147 <span class="totalamount">
153 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
156 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
158 [% IF ( budget.budget_lock ) %]
159 <td> <span></span> </td>
162 <div class="btn-group dropup">
163 <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="#">
164 Actions <b class="caret"></b>
166 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
167 <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>
168 [% IF budget.budget_has_children %]
169 <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>
171 <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>
173 <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>
187 [% END %] <!-- list -->
189 <!-- ********************************************************************************************** -->
190 <!-- create add/mod entry form -->
191 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
192 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
193 <fieldset class="rows">
194 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
195 [% IF ( budget_period_description ) %]
196 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
200 <input type="hidden" name="op" value="add_validate" />
201 <input type="hidden" name="checked" value="0" />
203 [% IF ( budget_parent_id ) %]
205 <span class="label">Fund parent: </span>
206 [% budget_parent_name | html %]
207 [% budget_parent_id | html %] - [% budget_parent_name | html %]
208 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
212 <label class="required" for="budget_code">Fund code: </label>
213 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
217 <label class="required" for="budget_name">Fund name: </label>
218 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
222 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
223 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
227 <label for="budget_encumb">Warning at (%): </label>
228 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
229 <span class="hint">0 to disable</span>
233 <label for="budget_expend">Warning at (amount): </label>
234 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
235 <span class="hint">0 to disable</span>
239 <span class="label">Owner: </span>
240 [% IF budget_owner %]
241 <span id="budget_owner_name">
242 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
243 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
247 <span id="budget_owner_name"></span>
249 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
250 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
251 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
252 value="[% budget_owner.borrowernumber | html %]" />
256 [% IF budget_has_children %]
259 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
260 Update all sub funds with this owner
262 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
267 <span class="label">Users:</span>
268 <ul style="float:left;" id="budget_users">
269 [% FOREACH user IN budget_users %]
270 <li id="user_[% user.borrowernumber | html %]">
271 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
272 [% user.firstname | html %] [% user.surname | html %]
274 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
277 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
279 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
282 <label for="budget_branchcode">Library: </label>
283 <select name="budget_branchcode" id="budget_branchcode">
284 <option value=""></option>
285 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
290 <label for="budget_permission">Restrict access to: </label>
291 <select name="budget_permission" id="budget_permission">
292 [% IF ( budget_perm_0 ) %]
293 <option value="0" selected="selected">
300 [% IF ( budget_perm_1 ) %]
301 <option value="1" selected="selected">
308 [% IF ( budget_perm_3) %]
309 <option value="3" selected="selected">
316 [% IF ( budget_perm_2 ) %]
317 <option value="2" selected="selected">
321 Owner, users and library
327 <label for="budget_notes">Notes: </label>
328 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
332 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
333 <select name="sort1_authcat" id="authorised_value_category1">
334 <option value=""></option>
335 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
339 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
340 <select name="sort2_authcat" id="authorised_value_category2">
341 <option value=""></option>
342 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
347 [% IF ( budget_id ) %]
348 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
352 <fieldset class="action">
353 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
354 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
358 [% END %] <!-- add_form -->
360 [% IF op == 'delete_confirm' %]
361 <div class="dialog alert">
362 <h3>Delete fund [% budget_name | html %]?</h3>
363 If you delete this fund, all orders linked to this fund will be deleted!
366 <th scope="row">Fund amount:</th>
367 <td>[% budget_amount | $Price %]</td>
371 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
372 <input type="hidden" name="op" value="delete_confirmed" />
373 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
374 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
375 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
377 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
378 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
384 </div> <!-- /.col-sm-10.col-sm-push-2 -->
386 <div class="col-sm-2 col-sm-pull-10">
389 [% IF op == 'list' %]
390 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
391 <a href="#" id="filterbutton">Filters</a>
392 <fieldset class="brief" id="fundfilters">
393 <h4>Fund filters</h4>
396 <label for="filter_budgetbranch2">Library: </label>
397 <select name="filter_budgetbranch" id="filter_budgetbranch2">
398 <option value=""></option>
399 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
404 <label for="show_mine">Show my funds only:</label>
405 [% IF ( show_mine ) %]
406 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
408 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
414 <label for="periods">Budget:</label>
415 <select id="periods" name="budget_period_id">
416 <option value="">All budgets</option>
417 [% FOR period IN periods %]
418 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
419 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
421 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
429 <input type="hidden" name="op" value="list" />
430 <input type="submit" class="submit" name="filter" value="Go" />
434 [% INCLUDE 'acquisitions-menu.inc' %]
436 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
437 </div> <!-- /.row -->
439 [% MACRO jsinclude BLOCK %]
440 [% Asset.js("js/acq.js") | $raw %]
441 [% IF op == 'add_form' %]
445 function userPopup() {
446 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
448 'width=740,height=450,location=yes,toolbar=no,'
449 + 'scrollbars=yes,resize=yes'
453 function ownerPopup() {
454 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
456 'width=740,height=450,location=yes,toolbar=no,'
457 + 'scrollbars=yes,resize=yes'
461 function select_user(borrowernumber, borrower) {
463 var borrowername = borrower.firstname + ' ' + borrower.surname;
464 if (borrowernumber) {
465 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
466 + '?borrowernumber=' + borrowernumber + '">'
467 + borrowername + '</a>';
468 $('#budget_owner_name').html(ownerlink);
469 $('#budget_owner_id').val(borrowernumber);
473 function ownerRemove() {
474 $('#budget_owner_name').empty();
475 $('#budget_owner_id').val('');
478 function add_user(borrowernumber, borrowername) {
479 var ids = $("#budget_users_id").val().split(':');
480 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
481 var li = '<li id="user_' + borrowernumber + '">'
482 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
483 + borrowernumber + '">' + borrowername + '</a> '
484 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
486 $("#budget_users").prepend(li);
487 ids.push(borrowernumber);
488 $("#budget_users_id").val(ids.join(':'));
495 function del_user(borrowernumber) {
496 var ids = $("#budget_users_id").val().split(':');
497 if (borrowernumber) {
498 var idx = ids.indexOf(borrowernumber+'');
501 $("#budget_users_id").val(ids.join(':'));
502 $("li#user_" + borrowernumber).remove();
512 if (!(isNotNull(f.budget_code,1))) {
513 _alertString += _("- Budget code cannot be blank") + "\n";
516 if (!(isNotNull(f.budget_name,1))) {
517 _alertString += _("- Budget name cannot be blank") + "\n";
520 if (!(isNotNull(f.budget_amount,1))) {
521 _alertString += _("- Budget amount cannot be blank") + "\n";
525 if (typeof(f.budget_id ) != "undefined") {
526 budgetId = f.budget_id.value
531 // hack to test if selected parent_id in scrolling-list...
532 // if value == 'undef' its got a selected_parent :/
533 if(f.budget_parent_id){
534 var chkAdd = f.budget_parent_id.value ;
535 if ( typeof(chkAdd ) != "undefined") {
536 newBudgetParent = f.budget_parent_id.value
538 newBudgetParent = f.budget_parent_id.item(0).value
541 if (budgetId > 0) { ; //its a mod ...
542 // if parent == curent-budget, fail...
543 if ( newBudgetParent == budgetId ) {
544 _alertString += _("- Budget parent is current budget") + "\n";
547 else if (newBudgetParent) {
548 var result = checkBudgetParent( budgetId , newBudgetParent );
550 _alertString += result;
557 var budgetTotal = Math.abs(f.budget_amount.value);
558 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
560 _alertString += result;
563 if (_alertString.length==0) {
564 document.Aform.submit();
566 alertString2 = _("Form not submitted because of the following problem(s)");
567 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
568 alertString2 += _alertString;
572 $(document).ready(function(){
573 $("#remove_owner").on("click",function(e){
577 $("#edit_owner").on("click",function(e){
581 $("body").on("click",".del_user",function(e){
583 var borrowernumber = $(this).data("borrowernumber");
584 del_user(borrowernumber);
586 $("#add_user_button").on("click",function(e){
590 $("#edit_fund").on("submit",function(e){
597 [% ELSIF op == 'list' %]
598 [% INCLUDE 'datatables.inc' %]
599 [% INCLUDE 'columns_settings.inc' %]
600 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
605 $(document).ready(function() {
607 var oTable = KohaTable("budgeth", {
608 "fnDrawCallback": function ( oSettings ) {
609 if ( oSettings.aiDisplay.length == 0 )
614 var nTrs = $('#budgeth tbody tr');
615 var iColspan = nTrs[0].getElementsByTagName('td').length;
617 for ( var i=0 ; i<nTrs.length ; i++ )
619 var iDisplayIndex = oSettings._iDisplayStart + i;
620 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
621 if ( sGroup != sLastGroup )
623 var nGroup = document.createElement( 'tr' );
624 var nCell = document.createElement( 'td' );
625 nCell.colSpan = iColspan;
626 nCell.className = "group";
627 nCell.innerHTML = sGroup;
628 nGroup.appendChild( nCell );
629 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
634 "footerCallback": function ( row, data, start, end, display ) {
635 var api = this.api(), data;
636 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
639 { "bVisible": false, "aTargets": [ 0, 1 ] },
640 { "bSortable": false, "aTargets": ["_all"] }
643 'aaSortingFixed': [[ 1, 'asc' ]],
648 $(oTable).treetable({
651 $(oTable).treetable('expandAll');
652 $("#expand_all").click(function(e){
654 $(oTable).treetable('expandAll');
656 $("#collapse_all").click(function(e){
658 $(oTable).treetable('collapseAll');
661 [% UNLESS budget_period_id %]
662 $("#hide_inactive").click(function(e){
664 oTable.fnFilter( 1, 0 ); // Show only active=1
666 $("#show_inactive").click(function(e){
668 oTable.fnFilter( '', 0 );
670 $("#hide_inactive").click();
672 oTable.fnAddFilters("filter", 750);
675 $("#filterbutton").click(function() {
676 $("#fundfilters").slideToggle(0);
679 $(".deletefund-disabled").tooltip().on("click", function(e){
681 alert(_("This fund has sub funds. It cannot be deleted."));
688 [% INCLUDE 'intranet-bottom.inc' %]