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 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
23 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
26 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
29 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
33 [% IF budget_period_id %]
35 <a href="#" aria-current="page">
36 Funds for '[% budget_period_description | html %]'
41 <a href="#" aria-current="page">
48 [% IF op == 'add_form' %]
50 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a>
52 [% IF ( budget_id ) %]
54 <a href="#" aria-current="page">
56 [% IF ( budget_name ) %] '[% budget_name | html %]'[% END %]
61 <a href="#" aria-current="page">
68 [% IF op == 'delete_confirm' %]
70 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a>
73 <a href="#" aria-current="page">
82 <div class="main container-fluid">
84 <div class="col-sm-10 col-sm-push-2">
87 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
89 [% IF (error_not_authorised_to_modify) %]
90 <div class="dialog alert">
91 <p>You are not authorized to modify this fund</p>
98 [% IF budget_period_id %]
99 Funds for '[% budget_period_description | html %]'
105 [% INCLUDE 'budgets-active-currency.inc' %]
109 [% UNLESS budget_period_id %]
110 <div class="toolbar btn-toolbar">
111 <span class="actions">
112 <a href="#" id="expand_all">Expand all</a> |
113 <a href="#" id="collapse_all">Collapse all</a> |
114 <a href="#" id="hide_inactive">Hide inactive budgets</a> |
115 <a href="#" id="show_inactive">Show inactive budgets</a>
120 <table id="budgeth" class="group">
124 <th>Budget period description</th>
127 <th>Base-level allocated</th>
128 <th>Base-level ordered</th>
129 <th>Total ordered</th>
130 <th>Base-level spent</th>
132 <th>Base-level available</th>
133 <th>Total available</th>
134 <th class="noExport">Actions</th>
141 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
142 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
144 <th class="data">[% ordered_total | $Price %]</th>
146 <th class="data">[% spent_total | $Price %]</th>
148 <th class="data">[% available_total | $Price %]</th>
153 [% FOREACH budget IN budgets %]
154 [% IF budget.budget_parent_id %]
155 <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
157 <tr data-tt-id="[% budget.budget_id | html %]">
159 <td>[% budget.budget_period_active | html %]</td>
160 <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
161 <td>[% budget.budget_code | html %]</td>
162 <td>[% budget.budget_name | html %]</td>
164 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]">[% budget.budget_amount | $Price %]</span>
167 [% IF budget.budget_parent_id %]
168 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
170 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
174 [% IF budget.budget_parent_id %]
175 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
177 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
181 [% IF budget.budget_parent_id %]
182 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
184 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
188 [% IF budget.budget_parent_id %]
189 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
191 <span class="total_amount">[% budget.total_spent | $Price %]</span>
196 [% BLOCK colorcellvalue %]
198 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: green;">
199 [% ELSIF (value < 0) %]
200 <span class="total_amount" data-parent_id="[% budget.budget_parent_id | html %]" data-self_id="[% budget.budget_id | html %]" style="color: red;">
202 <span class="totalamount">
208 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
211 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
213 [% IF ( budget.budget_lock ) %]
214 <td> <span></span> </td>
217 <div class="btn-group dropup">
218 <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="#">
219 Actions <b class="caret"></b>
221 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
222 <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>
223 [% IF budget.budget_has_children %]
224 <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>
226 <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>
228 <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>
242 [% END %] <!-- list -->
244 <!-- ********************************************************************************************** -->
245 <!-- create add/mod entry form -->
246 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
247 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
248 <fieldset class="rows">
249 <legend><h1>[% IF ( budget_id ) %]<span>Modify fund</span>[% ELSE %]<span>Add fund</span>[% END %]
250 [% IF ( budget_period_description ) %]
251 [% budget_name | html %] <span>for budget</span> '[% budget_period_description | html %]'
256 <input type="hidden" name="op" value="add_validate" />
257 <input type="hidden" name="checked" value="0" />
259 [% IF ( budget_parent_id ) %]
261 <span class="label">Fund parent: </span>
262 [% budget_parent_name | html %]
263 [% budget_parent_id | html %] - [% budget_parent_name | html %]
264 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
268 <label class="required" for="budget_code">Fund code: </label>
269 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
273 <label class="required" for="budget_name">Fund name: </label>
274 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
278 <label for="budget_amount" class="required">Amount: </label>
279 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
283 <label for="budget_encumb">Warning at (%): </label>
284 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
285 <span class="hint">0 to disable</span>
289 <label for="budget_expend">Warning at (amount): </label>
290 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
291 <span class="hint">0 to disable</span>
295 <span class="label">Owner: </span>
296 [% IF budget_owner %]
297 <span id="budget_owner_name">
298 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
299 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
303 <span id="budget_owner_name"></span>
305 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
306 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
307 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
308 value="[% budget_owner.borrowernumber | html %]" />
312 [% IF budget_has_children %]
315 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
316 Update all sub funds with this owner
318 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
323 <span class="label">Users:</span>
324 <ul style="float:left;" id="budget_users">
325 [% FOREACH user IN budget_users %]
326 <li id="user_[% user.borrowernumber | html %]">
327 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
328 [% user.firstname | html %] [% user.surname | html %]
330 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
333 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
335 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
338 <label for="budget_branchcode">Library: </label>
339 <select name="budget_branchcode" id="budget_branchcode">
340 <option value=""></option>
341 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
346 <label for="budget_permission">Restrict access to: </label>
347 <select name="budget_permission" id="budget_permission">
348 [% IF ( budget_perm_0 ) %]
349 <option value="0" selected="selected">
356 [% IF ( budget_perm_1 ) %]
357 <option value="1" selected="selected">
364 [% IF ( budget_perm_3) %]
365 <option value="3" selected="selected">
372 [% IF ( budget_perm_2 ) %]
373 <option value="2" selected="selected">
377 Owner, users and library
383 <label for="budget_notes">Notes: </label>
384 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
388 <label for="authorised_value_category1">Statistic 1 done on: </label>
389 <select name="sort1_authcat" id="authorised_value_category1">
390 <option value=""></option>
391 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
395 <label for="authorised_value_category2">Statistic 2 done on: </label>
396 <select name="sort2_authcat" id="authorised_value_category2">
397 <option value=""></option>
398 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
403 [% IF ( budget_id ) %]
404 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
408 <fieldset class="action">
409 <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
410 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
414 [% END %] <!-- add_form -->
416 [% IF op == 'delete_confirm' %]
417 <div class="dialog alert">
418 <h1>Delete fund [% budget_name | html %]?</h1>
419 If you delete this fund, all orders linked to this fund will be deleted!
422 <th scope="row">Fund amount:</th>
423 <td>[% budget_amount | $Price %]</td>
427 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
428 <input type="hidden" name="op" value="delete_confirmed" />
429 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
430 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
431 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
433 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
434 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
440 </div> <!-- /.col-sm-10.col-sm-push-2 -->
442 <div class="col-sm-2 col-sm-pull-10">
445 [% IF op == 'list' %]
446 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
447 <a href="#" id="filterbutton">Filters</a>
448 <fieldset class="brief" id="fundfilters">
449 <h4>Fund filters</h4>
452 <label for="filter_budgetbranch2">Library: </label>
453 <select name="filter_budgetbranch" id="filter_budgetbranch2">
454 <option value=""></option>
455 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
460 <label for="show_mine">Show my funds only:</label>
461 [% IF ( show_mine ) %]
462 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
464 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
470 <label for="periods">Budget:</label>
471 <select id="periods" name="budget_period_id">
472 <option value="">All budgets</option>
473 [% FOR period IN periods %]
474 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
475 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
477 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
485 <input type="hidden" name="op" value="list" />
486 <input type="submit" class="submit" name="filter" value="Go" />
490 [% INCLUDE 'acquisitions-menu.inc' %]
492 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
493 </div> <!-- /.row -->
495 [% MACRO jsinclude BLOCK %]
496 [% Asset.js("js/acq.js") | $raw %]
497 [% IF op == 'add_form' %]
501 function userPopup() {
502 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users",
504 'width=1024,height=768,location=yes,toolbar=no,'
505 + 'scrollbars=yes,resize=yes'
509 function ownerPopup() {
510 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners",
512 'width=1024,height=768,location=yes,toolbar=no,'
513 + 'scrollbars=yes,resize=yes'
517 function select_user(borrowernumber, borrower) {
519 var borrowername = borrower.firstname + ' ' + borrower.surname;
520 if (borrowernumber) {
521 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
522 + '?borrowernumber=' + borrowernumber + '">'
523 + borrowername + '</a>';
524 $('#budget_owner_name').html(ownerlink);
525 $('#budget_owner_id').val(borrowernumber);
529 function ownerRemove() {
530 $('#budget_owner_name').empty();
531 $('#budget_owner_id').val('');
534 function add_user(borrowernumber, borrowername) {
535 var ids = $("#budget_users_id").val().split(':');
536 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
537 var li = '<li id="user_' + borrowernumber + '">'
538 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
539 + borrowernumber + '">' + borrowername + '</a> '
540 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
542 $("#budget_users").prepend(li);
543 ids.push(borrowernumber);
544 $("#budget_users_id").val(ids.join(':'));
551 function del_user(borrowernumber) {
552 var ids = $("#budget_users_id").val().split(':');
553 if (borrowernumber) {
554 var idx = ids.indexOf(borrowernumber+'');
557 $("#budget_users_id").val(ids.join(':'));
558 $("li#user_" + borrowernumber).remove();
568 if (!(isNotNull(f.budget_code,1))) {
569 _alertString += _("- Budget code cannot be blank") + "\n";
572 if (!(isNotNull(f.budget_name,1))) {
573 _alertString += _("- Budget name cannot be blank") + "\n";
576 if (!(isNotNull(f.budget_amount,1))) {
577 _alertString += _("- Budget amount cannot be blank") + "\n";
581 if (typeof(f.budget_id ) != "undefined") {
582 budgetId = f.budget_id.value
587 // hack to test if selected parent_id in scrolling-list...
588 // if value == 'undef' its got a selected_parent :/
589 if(f.budget_parent_id){
590 var chkAdd = f.budget_parent_id.value ;
591 if ( typeof(chkAdd ) != "undefined") {
592 newBudgetParent = f.budget_parent_id.value
594 newBudgetParent = f.budget_parent_id.item(0).value
597 if (budgetId > 0) { ; //its a mod ...
598 // if parent == curent-budget, fail...
599 if ( newBudgetParent == budgetId ) {
600 _alertString += _("- Budget parent is current budget") + "\n";
603 else if (newBudgetParent) {
604 var result = checkBudgetParent( budgetId , newBudgetParent );
606 _alertString += result;
613 var budgetTotal = Math.abs(f.budget_amount.value);
614 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
616 _alertString += result;
619 if (_alertString.length==0) {
620 document.Aform.submit();
622 alertString2 = _("Form not submitted because of the following problem(s)");
623 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
624 alertString2 += _alertString;
628 $(document).ready(function(){
629 $("#remove_owner").on("click",function(e){
633 $("#edit_owner").on("click",function(e){
637 $("body").on("click",".del_user",function(e){
639 var borrowernumber = $(this).data("borrowernumber");
640 del_user(borrowernumber);
642 $("#add_user_button").on("click",function(e){
646 $("#edit_fund").on("submit",function(e){
653 [% ELSIF op == 'list' %]
654 [% INCLUDE 'datatables.inc' %]
655 [% INCLUDE 'columns_settings.inc' %]
656 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
661 $(document).ready(function() {
663 var oTable = KohaTable("budgeth", {
664 "fnDrawCallback": function ( oSettings ) {
665 if ( oSettings.aiDisplay.length == 0 )
670 var nTrs = $('#budgeth tbody tr');
671 var iColspan = nTrs[0].getElementsByTagName('td').length;
673 for ( var i=0 ; i<nTrs.length ; i++ )
675 var iDisplayIndex = oSettings._iDisplayStart + i;
676 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
677 if ( sGroup != sLastGroup )
679 var nGroup = document.createElement( 'tr' );
680 var nCell = document.createElement( 'td' );
681 nCell.colSpan = iColspan;
682 nCell.className = "group";
683 nCell.innerHTML = sGroup;
684 nGroup.appendChild( nCell );
685 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
690 "footerCallback": function ( row, data, start, end, display ) {
691 var api = this.api(), data;
692 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
695 { "bVisible": false, "aTargets": [ 0, 1 ] },
696 { "bSortable": false, "aTargets": ["_all"] }
699 'aaSortingFixed': [[ 1, 'asc' ]],
704 $(oTable).treetable({
707 $(oTable).treetable('expandAll');
708 $("#expand_all").click(function(e){
710 $(oTable).treetable('expandAll');
712 $("#collapse_all").click(function(e){
714 $(oTable).treetable('collapseAll');
717 [% UNLESS budget_period_id %]
718 $("#hide_inactive").click(function(e){
720 oTable.fnFilter( 1, 0 ); // Show only active=1
722 $("#show_inactive").click(function(e){
724 oTable.fnFilter( '', 0 );
726 $("#hide_inactive").click();
728 oTable.fnAddFilters("filter", 750);
731 $("#filterbutton").click(function() {
732 $("#fundfilters").slideToggle(0);
735 $(".deletefund-disabled").tooltip().on("click", function(e){
737 alert(_("This fund has sub funds. It cannot be deleted."));
744 [% INCLUDE 'intranet-bottom.inc' %]