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>
119 <div class="page-section">
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>
237 </div> <!-- /.page-section -->
243 [% END %] <!-- list -->
245 <!-- ********************************************************************************************** -->
246 <!-- create add/mod entry form -->
247 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
248 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
249 <fieldset class="rows">
250 <legend><h1>[% IF ( budget_id ) %]<span>Modify fund</span>[% ELSE %]<span>Add fund</span>[% END %]
251 [% IF ( budget_period_description ) %]
252 [% budget_name | html %] <span>for budget</span> '[% budget_period_description | html %]'
257 <input type="hidden" name="op" value="add_validate" />
258 <input type="hidden" name="checked" value="0" />
260 [% IF ( budget_parent_id ) %]
262 <span class="label">Fund parent: </span>
263 [% budget_parent_name | html %]
264 [% budget_parent_id | html %] - [% budget_parent_name | html %]
265 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
269 <label class="required" for="budget_code">Fund code: </label>
270 <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
274 <label class="required" for="budget_name">Fund name: </label>
275 <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
279 <label for="budget_amount" class="required">Amount: </label>
280 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
284 <label for="budget_encumb">Warning at (%): </label>
285 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
286 <span class="hint">0 to disable</span>
290 <label for="budget_expend">Warning at (amount): </label>
291 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
292 <span class="hint">0 to disable</span>
296 <span class="label">Owner: </span>
297 [% IF budget_owner %]
298 <span id="budget_owner_name">
299 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
300 [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
304 <span id="budget_owner_name"></span>
306 <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
307 <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
308 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
309 value="[% budget_owner.borrowernumber | html %]" />
313 [% IF budget_has_children %]
316 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
317 Update all sub funds with this owner
319 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
324 <span class="label">Users:</span>
325 <ul style="float:left;" id="budget_users">
326 [% FOREACH user IN budget_users %]
327 <li id="user_[% user.borrowernumber | html %]">
328 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
329 [% user.firstname | html %] [% user.surname | html %]
331 • <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
334 <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
336 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
339 <label for="budget_branchcode">Library: </label>
340 <select name="budget_branchcode" id="budget_branchcode">
341 <option value=""></option>
342 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
347 <label for="budget_permission">Restrict access to: </label>
348 <select name="budget_permission" id="budget_permission">
349 [% IF ( budget_perm_0 ) %]
350 <option value="0" selected="selected">
357 [% IF ( budget_perm_1 ) %]
358 <option value="1" selected="selected">
365 [% IF ( budget_perm_3) %]
366 <option value="3" selected="selected">
373 [% IF ( budget_perm_2 ) %]
374 <option value="2" selected="selected">
378 Owner, users and library
384 <label for="budget_notes">Notes: </label>
385 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes | html %]</textarea>
389 <label for="authorised_value_category1">Statistic 1 done on: </label>
390 <select name="sort1_authcat" id="authorised_value_category1">
391 <option value=""></option>
392 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
396 <label for="authorised_value_category2">Statistic 2 done on: </label>
397 <select name="sort2_authcat" id="authorised_value_category2">
398 <option value=""></option>
399 [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
404 [% IF ( budget_id ) %]
405 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
409 <fieldset class="action">
410 <input type="submit" class="btn btn-primary" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
411 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
415 [% END %] <!-- add_form -->
417 [% IF op == 'delete_confirm' %]
418 <div class="dialog alert">
419 <h1>Delete fund [% budget_name | html %]?</h1>
420 If you delete this fund, all orders linked to this fund will be deleted!
423 <th scope="row">Fund amount:</th>
424 <td>[% budget_amount | $Price %]</td>
428 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
429 <input type="hidden" name="op" value="delete_confirmed" />
430 <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
431 <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
432 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
434 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
435 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
441 </div> <!-- /.col-sm-10.col-sm-push-2 -->
443 <div class="col-sm-2 col-sm-pull-10">
446 [% IF op == 'list' %]
447 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
448 <a href="#" id="filterbutton">Filters</a>
449 <fieldset class="brief" id="fundfilters">
450 <h4>Fund filters</h4>
453 <label for="filter_budgetbranch2">Library: </label>
454 <select name="filter_budgetbranch" id="filter_budgetbranch2">
455 <option value=""></option>
456 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
461 <label for="show_mine">Show my funds only:</label>
462 [% IF ( show_mine ) %]
463 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
465 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
471 <label for="periods">Budget:</label>
472 <select id="periods" name="budget_period_id">
473 <option value="">All budgets</option>
474 [% FOR period IN periods %]
475 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
476 <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
478 <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
486 <input type="hidden" name="op" value="list" />
487 <input type="submit" class="submit" name="filter" value="Go" />
491 [% INCLUDE 'acquisitions-menu.inc' %]
493 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
494 </div> <!-- /.row -->
496 [% MACRO jsinclude BLOCK %]
497 [% Asset.js("js/acq.js") | $raw %]
498 [% IF op == 'add_form' %]
502 function userPopup() {
503 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add&filter=funds_users",
505 'width=1024,height=768,location=yes,toolbar=no,'
506 + 'scrollbars=yes,resize=yes'
510 function ownerPopup() {
511 window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=select&filter=funds_owners",
513 'width=1024,height=768,location=yes,toolbar=no,'
514 + 'scrollbars=yes,resize=yes'
518 function select_user(borrowernumber, borrower) {
520 var borrowername = borrower.firstname + ' ' + borrower.surname;
521 if (borrowernumber) {
522 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
523 + '?borrowernumber=' + borrowernumber + '">'
524 + borrowername + '</a>';
525 $('#budget_owner_name').html(ownerlink);
526 $('#budget_owner_id').val(borrowernumber);
530 function ownerRemove() {
531 $('#budget_owner_name').empty();
532 $('#budget_owner_id').val('');
535 function add_user(borrowernumber, borrowername) {
536 var ids = $("#budget_users_id").val().split(':');
537 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
538 var li = '<li id="user_' + borrowernumber + '">'
539 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
540 + borrowernumber + '">' + borrowername + '</a> '
541 + ' • <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
543 $("#budget_users").prepend(li);
544 ids.push(borrowernumber);
545 $("#budget_users_id").val(ids.join(':'));
552 function del_user(borrowernumber) {
553 var ids = $("#budget_users_id").val().split(':');
554 if (borrowernumber) {
555 var idx = ids.indexOf(borrowernumber+'');
558 $("#budget_users_id").val(ids.join(':'));
559 $("li#user_" + borrowernumber).remove();
569 if (!(isNotNull(f.budget_code,1))) {
570 _alertString += _("- Budget code cannot be blank") + "\n";
573 if (!(isNotNull(f.budget_name,1))) {
574 _alertString += _("- Budget name cannot be blank") + "\n";
577 if (!(isNotNull(f.budget_amount,1))) {
578 _alertString += _("- Budget amount cannot be blank") + "\n";
582 if (typeof(f.budget_id ) != "undefined") {
583 budgetId = f.budget_id.value
588 // hack to test if selected parent_id in scrolling-list...
589 // if value == 'undef' its got a selected_parent :/
590 if(f.budget_parent_id){
591 var chkAdd = f.budget_parent_id.value ;
592 if ( typeof(chkAdd ) != "undefined") {
593 newBudgetParent = f.budget_parent_id.value
595 newBudgetParent = f.budget_parent_id.item(0).value
598 if (budgetId > 0) { ; //its a mod ...
599 // if parent == curent-budget, fail...
600 if ( newBudgetParent == budgetId ) {
601 _alertString += _("- Budget parent is current budget") + "\n";
604 else if (newBudgetParent) {
605 var result = checkBudgetParent( budgetId , newBudgetParent );
607 _alertString += result;
614 var budgetTotal = Math.abs(f.budget_amount.value);
615 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
617 _alertString += result;
620 if (_alertString.length==0) {
621 document.Aform.submit();
623 alertString2 = _("Form not submitted because of the following problem(s)");
624 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
625 alertString2 += _alertString;
629 $(document).ready(function(){
630 $("#remove_owner").on("click",function(e){
634 $("#edit_owner").on("click",function(e){
638 $("body").on("click",".del_user",function(e){
640 var borrowernumber = $(this).data("borrowernumber");
641 del_user(borrowernumber);
643 $("#add_user_button").on("click",function(e){
647 $("#edit_fund").on("submit",function(e){
654 [% ELSIF op == 'list' %]
655 [% INCLUDE 'datatables.inc' %]
656 [% INCLUDE 'columns_settings.inc' %]
657 [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
662 $(document).ready(function() {
664 var oTable = KohaTable("budgeth", {
665 "fnDrawCallback": function ( oSettings ) {
666 if ( oSettings.aiDisplay.length == 0 )
671 var nTrs = $('#budgeth tbody tr');
672 var iColspan = nTrs[0].getElementsByTagName('td').length;
674 for ( var i=0 ; i<nTrs.length ; i++ )
676 var iDisplayIndex = oSettings._iDisplayStart + i;
677 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
678 if ( sGroup != sLastGroup )
680 var nGroup = document.createElement( 'tr' );
681 var nCell = document.createElement( 'td' );
682 nCell.colSpan = iColspan;
683 nCell.className = "group";
684 nCell.innerHTML = sGroup;
685 nGroup.appendChild( nCell );
686 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
691 "footerCallback": function ( row, data, start, end, display ) {
692 var api = this.api(), data;
693 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
696 { "bVisible": false, "aTargets": [ 0, 1 ] },
697 { "bSortable": false, "aTargets": ["_all"] }
700 'aaSortingFixed': [[ 1, 'asc' ]],
705 $(oTable).treetable({
708 $(oTable).treetable('expandAll');
709 $("#expand_all").click(function(e){
711 $(oTable).treetable('expandAll');
713 $("#collapse_all").click(function(e){
715 $(oTable).treetable('collapseAll');
718 [% UNLESS budget_period_id %]
719 $("#hide_inactive").click(function(e){
721 oTable.fnFilter( 1, 0 ); // Show only active=1
723 $("#show_inactive").click(function(e){
725 oTable.fnFilter( '', 0 );
727 $("#hide_inactive").click();
729 oTable.fnAddFilters("filter", 750);
732 $("#filterbutton").click(function() {
733 $("#fundfilters").slideToggle(0);
736 $(".deletefund-disabled").tooltip().on("click", function(e){
738 alert(_("This fund has sub funds. It cannot be deleted."));
745 [% INCLUDE 'intranet-bottom.inc' %]