3 [% USE AuthorisedValues %]
7 [% INCLUDE 'doc-head-open.inc' %]
9 <title>[% IF op == 'add_form' %][% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% END %][% ELSE %]Add fund[% END %] ›[% END %] Funds › Administration › Koha</title>
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 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
21 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
27 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
31 [% IF budget_period_id %]
33 <a href="#" aria-current="page">
34 Funds for '[% budget_period_description | html %]'
39 <a href="#" aria-current="page">
46 [% IF op == 'add_form' %]
48 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a>
50 [% IF ( budget_id ) %]
52 <a href="#" aria-current="page">
54 [% IF ( budget_name ) %] '[% budget_name | html %]'[% END %]
59 <a href="#" aria-current="page">
66 [% IF op == 'delete_confirm' %]
68 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a>
71 <a href="#" aria-current="page">
79 <div class="main container-fluid">
81 <div class="col-sm-10 col-sm-push-2">
84 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
86 [% IF (error_not_authorised_to_modify) %]
87 <div class="dialog alert">
88 <p>You are not authorized to modify this fund</p>
95 [% IF budget_period_id %]
96 Funds for '[% budget_period_description | html %]'
102 [% INCLUDE 'budgets-active-currency.inc' %]
106 [% UNLESS budget_period_id %]
107 <div class="toolbar btn-toolbar">
108 <span class="actions">
109 <a href="#" id="expand_all">Expand all</a> |
110 <a href="#" id="collapse_all">Collapse all</a> |
111 <a href="#" id="hide_inactive">Hide inactive budgets</a> |
112 <a href="#" id="show_inactive">Show inactive budgets</a>
117 <table id="budgeth" class="group">
121 <th>Budget period description</th>
124 <th>Base-level allocated</th>
125 <th>Base-level ordered</th>
126 <th>Total ordered</th>
127 <th>Base-level spent</th>
129 <th>Base-level available</th>
130 <th>Total available</th>
131 <th class="noExport">Actions</th>
138 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
139 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
141 <th class="data">[% ordered_total | $Price %]</th>
143 <th class="data">[% spent_total | $Price %]</th>
145 <th class="data">[% available_total | $Price %]</th>
150 [% FOREACH budget IN budgets %]
151 [% IF budget.budget_parent_id %]
152 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
154 <tr data-tt-id="[% budget.budget_id | html %]">
156 <td>[% budget.budget_period_active | html %]</td>
157 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
158 <td>[% budget.budget_code | html %]</td>
159 <td>[% budget.budget_name | html %]</td>
161 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
164 [% IF budget.budget_parent_id %]
165 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
167 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
171 [% IF budget.budget_parent_id %]
172 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
174 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
178 [% IF budget.budget_parent_id %]
179 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
181 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
185 [% IF budget.budget_parent_id %]
186 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
188 <span class="total_amount">[% budget.total_spent | $Price %]</span>
193 [% BLOCK colorcellvalue %]
195 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
196 [% ELSIF (value < 0) %]
197 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: red;">
199 <span class="totalamount">
205 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
208 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
210 [% IF ( budget.budget_lock ) %]
211 <td> <span></span> </td>
214 <div class="btn-group dropup">
215 <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="#">
216 Actions <b class="caret"></b>
218 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
219 <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>
220 [% IF budget.budget_has_children %]
221 <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>
223 <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>
225 <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>
239 [% END %] <!-- list -->
241 <!-- ********************************************************************************************** -->
242 <!-- create add/mod entry form -->
243 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
244 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
245 <fieldset class="rows">
246 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
247 [% IF ( budget_period_description ) %]
248 [% budget_name | html %] for Budget '[% budget_period_description | html %]'
252 <input type="hidden" name="op" value="add_validate" />
253 <input type="hidden" name="checked" value="0" />
255 [% IF ( budget_parent_id ) %]
257 <span class="label">Fund parent: </span>
258 [% budget_parent_name | html %]
259 [% budget_parent_id | html %] - [% budget_parent_name | html %]
260 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
264 <label class="required" for="budget_code">Fund code: </label>
265 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
269 <label class="required" for="budget_name">Fund name: </label>
270 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
274 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
275 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
279 <label for="budget_encumb">Warning at (%): </label>
280 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
281 <span class="hint">0 to disable</span>
285 <label for="budget_expend">Warning at (amount): </label>
286 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
287 <span class="hint">0 to disable</span>
291 <span class="label">Owner: </span>
292 [% IF budget_owner %]
293 <span id="budget_owner_name">
294 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
295 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
299 <span id="budget_owner_name"></span>
301 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
302 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
303 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
304 value="[% budget_owner.borrowernumber | html %]" />
308 [% IF budget_has_children %]
311 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
312 Update all sub funds with this owner
314 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
319 <span class="label">Users:</span>
320 <ul style="float:left;" id="budget_users">
321 [% FOREACH user IN budget_users %]
322 <li id="user_[% user.borrowernumber | html %]">
323 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
324 [% user.firstname | html %] [% user.surname | html %]
326 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
329 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
331 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
334 <label for="budget_branchcode">Library: </label>
335 <select name="budget_branchcode" id="budget_branchcode">
336 <option value=""></option>
337 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
342 <label for="budget_permission">Restrict access to: </label>
343 <select name="budget_permission" id="budget_permission">
344 [% IF ( budget_perm_0 ) %]
345 <option value="0" selected="selected">
352 [% IF ( budget_perm_1 ) %]
353 <option value="1" selected="selected">
360 [% IF ( budget_perm_3) %]
361 <option value="3" selected="selected">
368 [% IF ( budget_perm_2 ) %]
369 <option value="2" selected="selected">
373 Owner, users and library
379 <label for="budget_notes">Notes: </label>
380 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
384 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
385 <select name="sort1_authcat" id="authorised_value_category1">
386 <option value=""></option>
387 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
391 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
392 <select name="sort2_authcat" id="authorised_value_category2">
393 <option value=""></option>
394 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
399 [% IF ( budget_id ) %]
400 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
404 <fieldset class="action">
405 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
406 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
410 [% END %] <!-- add_form -->
412 [% IF op == 'delete_confirm' %]
413 <div class="dialog alert">
414 <h3>Delete fund [% budget_name | html %]?</h3>
415 If you delete this fund, all orders linked to this fund will be deleted!
418 <th scope="row">Fund amount:</th>
419 <td>[% budget_amount | $Price %]</td>
423 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
424 <input type="hidden" name="op" value="delete_confirmed" />
425 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
426 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
427 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
429 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
430 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
436 </div> <!-- /.col-sm-10.col-sm-push-2 -->
438 <div class="col-sm-2 col-sm-pull-10">
441 [% IF op == 'list' %]
442 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
443 <a href="#" id="filterbutton">Filters</a>
444 <fieldset class="brief" id="fundfilters">
445 <h4>Fund filters</h4>
448 <label for="filter_budgetbranch2">Library: </label>
449 <select name="filter_budgetbranch" id="filter_budgetbranch2">
450 <option value=""></option>
451 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
456 <label for="show_mine">Show my funds only:</label>
457 [% IF ( show_mine ) %]
458 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
460 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
466 <label for="periods">Budget:</label>
467 <select id="periods" name="budget_period_id">
468 <option value="">All budgets</option>
469 [% FOR period IN periods %]
470 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
471 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
473 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
481 <input type="hidden" name="op" value="list" />
482 <input type="submit" class="submit" name="filter" value="Go" />
486 [% INCLUDE 'acquisitions-menu.inc' %]
488 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
489 </div> <!-- /.row -->
491 [% MACRO jsinclude BLOCK %]
492 [% Asset.js("js/acq.js") | $raw %]
493 [% IF op == 'add_form' %]
497 function userPopup() {
498 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
500 'width=740,height=450,location=yes,toolbar=no,'
501 + 'scrollbars=yes,resize=yes'
505 function ownerPopup() {
506 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
508 'width=740,height=450,location=yes,toolbar=no,'
509 + 'scrollbars=yes,resize=yes'
513 function select_user(borrowernumber, borrower) {
515 var borrowername = borrower.firstname + ' ' + borrower.surname;
516 if (borrowernumber) {
517 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
518 + '?borrowernumber=' + borrowernumber + '">'
519 + borrowername + '</a>';
520 $('#budget_owner_name').html(ownerlink);
521 $('#budget_owner_id').val(borrowernumber);
525 function ownerRemove() {
526 $('#budget_owner_name').empty();
527 $('#budget_owner_id').val('');
530 function add_user(borrowernumber, borrowername) {
531 var ids = $("#budget_users_id").val().split(':');
532 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
533 var li = '<li id="user_' + borrowernumber + '">'
534 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
535 + borrowernumber + '">' + borrowername + '</a> '
536 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
538 $("#budget_users").prepend(li);
539 ids.push(borrowernumber);
540 $("#budget_users_id").val(ids.join(':'));
547 function del_user(borrowernumber) {
548 var ids = $("#budget_users_id").val().split(':');
549 if (borrowernumber) {
550 var idx = ids.indexOf(borrowernumber+'');
553 $("#budget_users_id").val(ids.join(':'));
554 $("li#user_" + borrowernumber).remove();
564 if (!(isNotNull(f.budget_code,1))) {
565 _alertString += _("- Budget code cannot be blank") + "\n";
568 if (!(isNotNull(f.budget_name,1))) {
569 _alertString += _("- Budget name cannot be blank") + "\n";
572 if (!(isNotNull(f.budget_amount,1))) {
573 _alertString += _("- Budget amount cannot be blank") + "\n";
577 if (typeof(f.budget_id ) != "undefined") {
578 budgetId = f.budget_id.value
583 // hack to test if selected parent_id in scrolling-list...
584 // if value == 'undef' its got a selected_parent :/
585 if(f.budget_parent_id){
586 var chkAdd = f.budget_parent_id.value ;
587 if ( typeof(chkAdd ) != "undefined") {
588 newBudgetParent = f.budget_parent_id.value
590 newBudgetParent = f.budget_parent_id.item(0).value
593 if (budgetId > 0) { ; //its a mod ...
594 // if parent == curent-budget, fail...
595 if ( newBudgetParent == budgetId ) {
596 _alertString += _("- Budget parent is current budget") + "\n";
599 else if (newBudgetParent) {
600 var result = checkBudgetParent( budgetId , newBudgetParent );
602 _alertString += result;
609 var budgetTotal = Math.abs(f.budget_amount.value);
610 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
612 _alertString += result;
615 if (_alertString.length==0) {
616 document.Aform.submit();
618 alertString2 = _("Form not submitted because of the following problem(s)");
619 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
620 alertString2 += _alertString;
624 $(document).ready(function(){
625 $("#remove_owner").on("click",function(e){
629 $("#edit_owner").on("click",function(e){
633 $("body").on("click",".del_user",function(e){
635 var borrowernumber = $(this).data("borrowernumber");
636 del_user(borrowernumber);
638 $("#add_user_button").on("click",function(e){
642 $("#edit_fund").on("submit",function(e){
649 [% ELSIF op == 'list' %]
650 [% INCLUDE 'datatables.inc' %]
651 [% INCLUDE 'columns_settings.inc' %]
652 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
657 $(document).ready(function() {
659 var oTable = KohaTable("budgeth", {
660 "fnDrawCallback": function ( oSettings ) {
661 if ( oSettings.aiDisplay.length == 0 )
666 var nTrs = $('#budgeth tbody tr');
667 var iColspan = nTrs[0].getElementsByTagName('td').length;
669 for ( var i=0 ; i<nTrs.length ; i++ )
671 var iDisplayIndex = oSettings._iDisplayStart + i;
672 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
673 if ( sGroup != sLastGroup )
675 var nGroup = document.createElement( 'tr' );
676 var nCell = document.createElement( 'td' );
677 nCell.colSpan = iColspan;
678 nCell.className = "group";
679 nCell.innerHTML = sGroup;
680 nGroup.appendChild( nCell );
681 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
686 "footerCallback": function ( row, data, start, end, display ) {
687 var api = this.api(), data;
688 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
691 { "bVisible": false, "aTargets": [ 0, 1 ] },
692 { "bSortable": false, "aTargets": ["_all"] }
695 'aaSortingFixed': [[ 1, 'asc' ]],
700 $(oTable).treetable({
703 $(oTable).treetable('expandAll');
704 $("#expand_all").click(function(e){
706 $(oTable).treetable('expandAll');
708 $("#collapse_all").click(function(e){
710 $(oTable).treetable('collapseAll');
713 [% UNLESS budget_period_id %]
714 $("#hide_inactive").click(function(e){
716 oTable.fnFilter( 1, 0 ); // Show only active=1
718 $("#show_inactive").click(function(e){
720 oTable.fnFilter( '', 0 );
722 $("#hide_inactive").click();
724 oTable.fnAddFilters("filter", 750);
727 $("#filterbutton").click(function() {
728 $("#fundfilters").slideToggle(0);
731 $(".deletefund-disabled").tooltip().on("click", function(e){
733 alert(_("This fund has sub funds. It cannot be deleted."));
740 [% INCLUDE 'intranet-bottom.inc' %]