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 [% WRAPPER 'header.inc' %]
16 [% INCLUDE 'budgets-admin-search.inc' %]
19 [% WRAPPER 'sub-header.inc' %]
20 [% WRAPPER breadcrumbs %]
21 [% WRAPPER breadcrumb_item %]
22 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24 [% WRAPPER breadcrumb_item %]
25 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
27 [% WRAPPER breadcrumb_item %]
28 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
32 [% IF budget_period_id %]
33 [% WRAPPER breadcrumb_item bc_active= 1 %]
34 <span>Funds for '[% budget_period_description | html %]'</span>
37 [% WRAPPER breadcrumb_item bc_active= 1 %]
38 <span>All funds</span>
43 [% IF op == 'add_form' %]
44 [% WRAPPER breadcrumb_item %]
45 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a>
47 [% IF ( budget_id ) %]
48 [% WRAPPER breadcrumb_item bc_active= 1 %]
49 [% IF ( budget_name ) %]
50 <span>Modify fund '[% budget_name | html %]'</span>
52 <span>Modify fund</span>
56 [% WRAPPER breadcrumb_item bc_active= 1 %]
62 [% IF op == 'delete_confirm' %]
63 [% WRAPPER breadcrumb_item %]
64 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a>
66 [% WRAPPER breadcrumb_item bc_active= 1 %]
67 <span>Delete fund?</span>
70 [% END #/ WRAPPER breadcrumbs %]
71 [% END #/ WRAPPER sub-header.inc %]
73 <div class="main container-fluid">
75 <div class="col-sm-10 col-sm-push-2">
78 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
80 [% IF (error_not_authorised_to_modify) %]
81 <div class="dialog alert">
82 <p>You are not authorized to modify this fund</p>
89 [% IF budget_period_id %]
90 Funds for '[% budget_period_description | html %]'
96 [% INCLUDE 'budgets-active-currency.inc' %]
100 [% UNLESS budget_period_id %]
101 <div class="toolbar btn-toolbar">
102 <span class="actions">
103 <a href="#" id="expand_all">Expand all</a> |
104 <a href="#" id="collapse_all">Collapse all</a> |
105 <a href="#" id="hide_inactive">Hide inactive budgets</a> |
106 <a href="#" id="show_inactive">Show inactive budgets</a>
110 <div class="page-section">
111 <table id="budgeth" class="group">
115 <th>Budget period description</th>
118 <th>Base-level allocated</th>
119 <th>Base-level ordered</th>
120 <th>Total ordered</th>
121 <th>Base-level spent</th>
123 <th>Base-level available</th>
124 <th>Total available</th>
125 <th class="noExport">Actions</th>
132 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
133 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
135 <th class="data">[% ordered_total | $Price %]</th>
137 <th class="data">[% spent_total | $Price %]</th>
139 <th class="data">[% available_total | $Price %]</th>
144 [% FOREACH budget IN budgets %]
145 [% IF budget.budget_parent_id %]
146 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
148 <tr data-tt-id="[% budget.budget_id | html %]">
150 <td>[% budget.budget_period_active | html %]</td>
151 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
152 <td>[% budget.budget_code | html %]</td>
153 <td>[% budget.budget_name | html %]</td>
155 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
158 [% IF budget.budget_parent_id %]
159 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
161 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
165 [% IF budget.budget_parent_id %]
166 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
168 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
172 [% IF budget.budget_parent_id %]
173 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
175 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
179 [% IF budget.budget_parent_id %]
180 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
182 <span class="total_amount">[% budget.total_spent | $Price %]</span>
187 [% BLOCK colorcellvalue %]
189 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
190 [% ELSIF (value < 0) %]
191 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: red;">
193 <span class="totalamount">
199 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
202 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
204 [% IF ( budget.budget_lock ) %]
205 <td> <span></span> </td>
208 <div class="btn-group dropup">
209 <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="#">
210 Actions <b class="caret"></b>
212 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
213 <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>
214 [% IF budget.budget_has_children %]
215 <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>
217 <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>
219 <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>
228 </div> <!-- /.page-section -->
234 [% END %] <!-- list -->
236 <!-- ********************************************************************************************** -->
237 <!-- create add/mod entry form -->
238 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
239 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
240 <fieldset class="rows">
241 <legend><h1>[% IF ( budget_id ) %]<span>Modify fund</span>[% ELSE %]<span>Add fund</span>[% END %]
242 [% IF ( budget_period_description ) %]
243 [% budget_name | html %] <span>for budget</span> '[% budget_period_description | html %]'
248 <input type="hidden" name="op" value="add_validate" />
249 <input type="hidden" name="checked" value="0" />
251 [% IF ( budget_parent_id ) %]
253 <span class="label">Fund parent: </span>
254 [% budget_parent_name | html %]
255 [% budget_parent_id | html %] - [% budget_parent_name | html %]
256 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
260 <label class="required" for="budget_code">Fund code: </label>
261 <input type="text" name="budget_code" id="budget_code" class="focus" value="[% budget_code | html %]" size="30" />
265 <label class="required" for="budget_name">Fund name: </label>
266 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
270 <label for="budget_amount" class="required">Amount: </label>
271 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
275 <label for="budget_encumb">Warning at (%): </label>
276 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
277 <span class="hint">0 to disable</span>
281 <label for="budget_expend">Warning at (amount): </label>
282 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
283 <span class="hint">0 to disable</span>
287 <span class="label">Owner: </span>
288 [% IF budget_owner %]
289 <span id="budget_owner_name">
290 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
291 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
295 <span id="budget_owner_name"></span>
297 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
298 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
299 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
300 value="[% budget_owner.borrowernumber | html %]" />
304 [% IF budget_has_children %]
307 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
308 Update all sub funds with this owner
310 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
315 <span class="label">Users:</span>
316 <ul style="float:left;" id="budget_users">
317 [% FOREACH user IN budget_users %]
318 <li id="user_[% user.borrowernumber | html %]">
319 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
320 [% user.firstname | html %] [% user.surname | html %]
322 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
325 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
327 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
330 <label for="budget_branchcode">Library: </label>
331 <select name="budget_branchcode" id="budget_branchcode">
332 <option value=""></option>
333 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
338 <label for="budget_permission">Restrict access to: </label>
339 <select name="budget_permission" id="budget_permission">
340 [% IF ( budget_perm_0 ) %]
341 <option value="0" selected="selected">
348 [% IF ( budget_perm_1 ) %]
349 <option value="1" selected="selected">
356 [% IF ( budget_perm_3) %]
357 <option value="3" selected="selected">
364 [% IF ( budget_perm_2 ) %]
365 <option value="2" selected="selected">
369 Owner, users and library
375 <label for="budget_notes">Notes: </label>
376 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
380 <label for="authorised_value_category1">Statistic 1 done on: </label>
381 <select name="sort1_authcat" id="authorised_value_category1">
382 <option value=""></option>
383 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
387 <label for="authorised_value_category2">Statistic 2 done on: </label>
388 <select name="sort2_authcat" id="authorised_value_category2">
389 <option value=""></option>
390 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
395 [% IF ( budget_id ) %]
396 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
400 <fieldset class="action">
401 <input type="submit" class="btn btn-primary" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
402 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
406 [% END %] <!-- add_form -->
408 [% IF op == 'delete_confirm' %]
409 <div class="dialog alert">
410 <h1>Delete fund [% budget_name | html %]?</h1>
411 If you delete this fund, all orders linked to this fund will be deleted!
414 <th scope="row">Fund amount:</th>
415 <td>[% budget_amount | $Price %]</td>
419 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
420 <input type="hidden" name="op" value="delete_confirmed" />
421 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
422 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
423 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
425 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
426 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
432 </div> <!-- /.col-sm-10.col-sm-push-2 -->
434 <div class="col-sm-2 col-sm-pull-10">
437 [% IF op == 'list' %]
438 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
439 <a href="#" id="filterbutton">Filters</a>
440 <fieldset class="brief" id="fundfilters">
441 <h4>Fund filters</h4>
444 <label for="filter_budgetbranch2">Library: </label>
445 <select name="filter_budgetbranch" id="filter_budgetbranch2">
446 <option value=""></option>
447 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
452 <label for="show_mine">Show my funds only:</label>
453 [% IF ( show_mine ) %]
454 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
456 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
462 <label for="periods">Budget:</label>
463 <select id="periods" name="budget_period_id">
464 <option value="">All budgets</option>
465 [% FOR period IN periods %]
466 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
467 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
469 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
477 <input type="hidden" name="op" value="list" />
478 <input type="submit" class="submit" name="filter" value="Go" />
482 [% INCLUDE 'acquisitions-menu.inc' %]
484 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
485 </div> <!-- /.row -->
487 [% MACRO jsinclude BLOCK %]
488 [% Asset.js("js/acq.js") | $raw %]
489 [% IF op == 'add_form' %]
493 function userPopup() {
494 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users",
496 'width=1024,height=768,location=yes,toolbar=no,'
497 + 'scrollbars=yes,resize=yes'
501 function ownerPopup() {
502 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners",
504 'width=1024,height=768,location=yes,toolbar=no,'
505 + 'scrollbars=yes,resize=yes'
509 function select_user(borrowernumber, borrower) {
511 var borrowername = borrower.firstname + ' ' + borrower.surname;
512 if (borrowernumber) {
513 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
514 + '?borrowernumber=' + borrowernumber + '">'
515 + borrowername + '</a>';
516 $('#budget_owner_name').html(ownerlink);
517 $('#budget_owner_id').val(borrowernumber);
521 function ownerRemove() {
522 $('#budget_owner_name').empty();
523 $('#budget_owner_id').val('');
526 function add_user(borrowernumber, borrowername) {
527 var ids = $("#budget_users_id").val().split(':');
528 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
529 var li = '<li id="user_' + borrowernumber + '">'
530 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
531 + borrowernumber + '">' + borrowername + '</a> '
532 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
534 $("#budget_users").prepend(li);
535 ids.push(borrowernumber);
536 $("#budget_users_id").val(ids.join(':'));
543 function del_user(borrowernumber) {
544 var ids = $("#budget_users_id").val().split(':');
545 if (borrowernumber) {
546 var idx = ids.indexOf(borrowernumber+'');
549 $("#budget_users_id").val(ids.join(':'));
550 $("li#user_" + borrowernumber).remove();
560 if (!(isNotNull(f.budget_code,1))) {
561 _alertString += _("- Budget code cannot be blank") + "\n";
564 if (!(isNotNull(f.budget_name,1))) {
565 _alertString += _("- Budget name cannot be blank") + "\n";
568 if (!(isNotNull(f.budget_amount,1))) {
569 _alertString += _("- Budget amount cannot be blank") + "\n";
573 if (typeof(f.budget_id ) != "undefined") {
574 budgetId = f.budget_id.value
579 // hack to test if selected parent_id in scrolling-list...
580 // if value == 'undef' its got a selected_parent :/
581 if(f.budget_parent_id){
582 var chkAdd = f.budget_parent_id.value ;
583 if ( typeof(chkAdd ) != "undefined") {
584 newBudgetParent = f.budget_parent_id.value
586 newBudgetParent = f.budget_parent_id.item(0).value
589 if (budgetId > 0) { ; //its a mod ...
590 // if parent == curent-budget, fail...
591 if ( newBudgetParent == budgetId ) {
592 _alertString += _("- Budget parent is current budget") + "\n";
595 else if (newBudgetParent) {
596 var result = checkBudgetParent( budgetId , newBudgetParent );
598 _alertString += result;
605 var budgetTotal = Math.abs(f.budget_amount.value);
606 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
608 _alertString += result;
611 if (_alertString.length==0) {
612 document.Aform.submit();
614 alertString2 = _("Form not submitted because of the following problem(s)");
615 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
616 alertString2 += _alertString;
620 $(document).ready(function(){
621 $("#remove_owner").on("click",function(e){
625 $("#edit_owner").on("click",function(e){
629 $("body").on("click",".del_user",function(e){
631 var borrowernumber = $(this).data("borrowernumber");
632 del_user(borrowernumber);
634 $("#add_user_button").on("click",function(e){
638 $("#edit_fund").on("submit",function(e){
645 [% ELSIF op == 'list' %]
646 [% INCLUDE 'datatables.inc' %]
647 [% INCLUDE 'columns_settings.inc' %]
648 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
653 $(document).ready(function() {
655 var oTable = KohaTable("budgeth", {
656 "fnDrawCallback": function ( oSettings ) {
657 if ( oSettings.aiDisplay.length == 0 )
662 var nTrs = $('#budgeth tbody tr');
663 var iColspan = nTrs[0].getElementsByTagName('td').length;
665 for ( var i=0 ; i<nTrs.length ; i++ )
667 var iDisplayIndex = oSettings._iDisplayStart + i;
668 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
669 if ( sGroup != sLastGroup )
671 var nGroup = document.createElement( 'tr' );
672 var nCell = document.createElement( 'td' );
673 nCell.colSpan = iColspan;
674 nCell.className = "group";
675 nCell.innerHTML = sGroup;
676 nGroup.appendChild( nCell );
677 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
682 "footerCallback": function ( row, data, start, end, display ) {
683 var api = this.api(), data;
684 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
687 { "bVisible": false, "aTargets": [ 0, 1 ] },
688 { "bSortable": false, "aTargets": ["_all"] }
691 'aaSortingFixed': [[ 1, 'asc' ]],
696 $(oTable).treetable({
699 $(oTable).treetable('expandAll');
700 $("#expand_all").click(function(e){
702 $(oTable).treetable('expandAll');
704 $("#collapse_all").click(function(e){
706 $(oTable).treetable('collapseAll');
709 [% UNLESS budget_period_id %]
710 $("#hide_inactive").click(function(e){
712 oTable.fnFilter( 1, 0 ); // Show only active=1
714 $("#show_inactive").click(function(e){
716 oTable.fnFilter( '', 0 );
718 $("#hide_inactive").click();
720 oTable.fnAddFilters("filter", 750);
723 $("#filterbutton").click(function() {
724 $("#fundfilters").slideToggle(0);
727 $(".deletefund-disabled").tooltip().on("click", function(e){
729 alert(_("This fund has sub funds. It cannot be deleted."));
736 [% INCLUDE 'intranet-bottom.inc' %]