3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha › Administration › Funds[% IF op == 'add_form' %] › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 <script type="text/javascript">
8 var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
9 var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
10 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
14 <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script>
15 [% IF op == 'add_form' %]
16 <script type="text/javascript">
19 function userPopup() {
20 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
22 'width=740,height=450,location=yes,toolbar=no,'
23 + 'scrollbars=yes,resize=yes'
27 function ownerPopup() {
28 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
30 'width=740,height=450,location=yes,toolbar=no,'
31 + 'scrollbars=yes,resize=yes'
35 function select_user(borrowernumber, borrower) {
37 var borrowername = borrower.firstname + ' ' + borrower.surname
39 var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
40 + '?borrowernumber=' + borrowernumber + '">'
41 + borrowername + '</a>';
42 $('#budget_owner_name').html(ownerlink);
43 $('#budget_owner_id').val(borrowernumber);
47 function ownerRemove() {
48 $('#budget_owner_name').empty();
49 $('#budget_owner_id').val('');
52 function add_user(borrowernumber, borrowername) {
53 var ids = $("#budget_users_id").val().split(':');
54 if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
55 var li = '<li id="user_' + borrowernumber + '">'
56 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
57 + borrowernumber + '">' + borrowername
58 + '</a> [<a style="cursor:pointer"'
59 + 'onclick="del_user(' + borrowernumber +')">Remove</a>]</li>';
60 $(li).insertBefore("li#add_user_button");
61 ids.push(borrowernumber);
62 $("#budget_users_id").val(ids.join(':'));
69 function del_user(borrowernumber) {
70 var ids = $("#budget_users_id").val().split(':');
72 var idx = ids.indexOf(borrowernumber+'');
75 $("#budget_users_id").val(ids.join(':'));
76 $("li#user_" + borrowernumber).remove();
86 if (!(isNotNull(f.budget_code,1))) {
87 _alertString += _("- Budget code cannot be blank") + "\n";
90 if (!(isNotNull(f.budget_name,1))) {
91 _alertString += _("- Budget name cannot be blank") + "\n";
94 if (!(isNotNull(f.budget_amount,1))) {
95 _alertString += _("- Budget amount cannot be blank") + "\n";
99 if (typeof(f.budget_id ) != "undefined") {
100 budgetId = f.budget_id.value
105 // hack to test if selected parent_id in scrolling-list...
106 // if value == 'undef' its got a selected_parent :/
107 if(f.budget_parent_id){
108 var chkAdd = f.budget_parent_id.value ;
109 if ( typeof(chkAdd ) != "undefined") {
110 newBudgetParent = f.budget_parent_id.value
112 newBudgetParent = f.budget_parent_id.item(0).value
115 if (budgetId > 0) { ; //its a mod ...
116 // if parent == curent-budget, fail...
117 if ( newBudgetParent == budgetId ) {
118 _alertString += _("- Budget parent is current budget") + "\n";
121 else if (newBudgetParent) {
122 var result = checkBudgetParent( budgetId , newBudgetParent );
124 _alertString += result;
131 var budgetTotal = Math.abs(f.budget_amount.value);
132 var result = budgetExceedsParent (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
134 _alertString += result;
137 if (_alertString.length==0) {
138 document.Aform.submit();
140 alertString2 = _("Form not submitted because of the following problem(s)");
141 alertString2 += "\n------------------------------------------------------------------------------------\n\n";
142 alertString2 += _alertString;
148 [% ELSIF op == 'list' %]
149 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
150 [% INCLUDE 'datatables.inc' %]
151 <link href="[% interface %]/lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css" rel="stylesheet" type="text/css" />
152 <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/treetable/jquery.treetable.js"></script>
154 <script type="text/javascript">
157 $(document).ready(function() {
160 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
161 "fnDrawCallback": function ( oSettings ) {
162 if ( oSettings.aiDisplay.length == 0 )
167 var nTrs = $('#budgeth tbody tr');
168 var iColspan = nTrs[0].getElementsByTagName('td').length;
170 for ( var i=0 ; i<nTrs.length ; i++ )
172 var iDisplayIndex = oSettings._iDisplayStart + i;
173 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
174 if ( sGroup != sLastGroup )
176 var nGroup = document.createElement( 'tr' );
177 var nCell = document.createElement( 'td' );
178 nCell.colSpan = iColspan;
179 nCell.className = "group";
180 nCell.innerHTML = sGroup;
181 nGroup.appendChild( nCell );
182 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
187 "footerCallback": function ( row, data, start, end, display ) {
188 var api = this.api(), data;
189 footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
192 { "bVisible": false, "aTargets": [ 0, 1 ] },
193 { "bSortable": false, "aTargets": ["_all"] }
195 'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
197 'aaSortingFixed': [[ 1, 'asc' ]],
202 $(oTable).treetable({
205 $(oTable).treetable('expandAll');
206 $("#expand_all").click(function(e){
208 $(oTable).treetable('expandAll');
210 $("#collapse_all").click(function(e){
212 $(oTable).treetable('collapseAll');
215 [% UNLESS budget_period_id %]
216 $("#hide_inactive").click(function(e){
218 oTable.fnFilter( 1, 0 ); // Show only active=1
220 $("#show_inactive").click(function(e){
222 oTable.fnFilter( '', 0 );
224 $("#hide_inactive").click();
226 oTable.fnAddFilters("filter", 750);
228 $("#filterbutton").click(function() {
229 $("#fundfilters").slideToggle(0);
232 $(".deletefund-disabled").tooltip().on("click", function(e){
234 alert(_("This fund has children. It cannot be deleted."));
242 <body id="admin_aqbudgets" class="admin">
243 [% INCLUDE 'header.inc' %]
244 [% INCLUDE 'budgets-admin-search.inc' %]
246 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> ›
247 <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 %]'[% ELSE %]All funds[% END %][% END %]
248 [% IF op == 'add_form' %]
249 <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Funds</a> › [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund[% END %]
251 [% IF op == 'delete_confirm' %]
252 <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> › Delete fund?
256 <div id="doc3" class="yui-t2">
259 <div class="yui-b" id="content">
262 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
264 [% IF (error_not_authorised_to_modify) %]
266 <p>You are not authorized to modify this fund</p>
270 [% IF op == 'list' %]
273 [% IF budget_period_id %]
274 Funds for '[% budget_period_description %]'
280 [% INCLUDE 'budgets-active-currency.inc' %]
284 <table id="budgeth" class="group">
285 [% UNLESS budget_period_id %]
287 <span class="actions"><a href="#" id="expand_all">Expand all</a>
288 | <a href="#" id="collapse_all">Collapse all</a>
289 | <a href="#" id="hide_inactive">Hide inactive budgets</a>
290 | <a href="#" id="show_inactive">Show inactive budgets</a></span>
296 <th>Budget period description</th>
299 <th>Base-level allocated</th>
300 <th>Base-level ordered</th>
301 <th>Total ordered</th>
302 <th>Base-level spent</th>
304 <th>Base-level available</th>
305 <th>Total available</th>
313 <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %] </th>
314 <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
316 <th class="data">[% ordered_total | $Price %]</th>
318 <th class="data">[% spent_total | $Price %]</th>
320 <th class="data">[% available_total | $Price %]</th>
325 [% FOREACH budget IN budgets %]
326 [% IF budget.budget_parent_id %]
327 <tr data-tt-id="[% budget.budget_id %]" data-tt-parent-id="[% budget.budget_parent_id %]">
329 <tr data-tt-id="[% budget.budget_id %]">
331 <td>[% budget.budget_period_active %]</td>
332 <td>Budget [% budget.budget_period_description %] [id=[% budget.budget_period_id %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
333 <td>[% budget.budget_code %]</td>
334 <td>[% budget.budget_name %]</td>
336 [% IF budget.budget_parent_id %]
337 <span class="child_fund_amount">[% budget.budget_amount | $Price %]</span>
339 <span class="total_amount">[% budget.budget_amount | $Price %]</span>
343 [% IF budget.budget_parent_id %]
344 <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
346 <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
350 [% IF budget.budget_parent_id %]
351 <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
353 <span class="total_amount">[% budget.total_ordered | $Price %]</span>
357 [% IF budget.budget_parent_id %]
358 <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
360 <span class="total_amount">[% budget.budget_spent | $Price %]</span>
364 [% IF budget.budget_parent_id %]
365 <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
367 <span class="total_amount">[% budget.total_spent | $Price %]</span>
372 [% BLOCK colorcellvalue %]
375 <span class="child_fund_amount" style="color: green;">
376 [% ELSIF (value < 0) %]
377 <span class="child_fund_amount" style="color: red;">
379 <span class="child_fund_amount">
383 <span class="total_amount" style="color: green;">
384 [% ELSIF (value < 0) %]
385 <span class="total_amount" style="color: red;">
387 <span class="totalamount">
394 [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
397 [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
399 [% IF ( budget.budget_lock ) %]
400 <td> <span></span> </td>
403 <div class="dropdown dropup">
404 <a class="btn btn-mini dropdown-toggle" id="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]" role="button" data-toggle="dropdown" href="#">
405 Actions <b class="caret"></b>
407 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]">
408 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-pencil"></i> Edit</a></li>
409 [% IF budget.budget_has_children %]
410 <li class="disabled"><a href="#" class="deletefund-disabled" data-toggle="tooltip" data-placement="left" title="This fund has children"><i class="fa fa-trash"></i> Delete</a></li>
412 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&budget_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-trash"></i> Delete</a></li>
414 <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&budget_parent_id=[% budget.budget_id %]&budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-plus"></i> Add child fund</a></li>
428 [% END %] <!-- list -->
430 <!-- ********************************************************************************************** -->
431 <!-- create add/mod entry form -->
432 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
433 <form action="/cgi-bin/koha/admin/aqbudgets.pl" name="Aform" method="post">
434 <fieldset class="rows">
435 <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
436 [% IF ( budget_period_description ) %]
437 [% budget_name %] for Budget '[% budget_period_description %]'
441 <input type="hidden" name="op" value="add_validate" />
442 <input type="hidden" name="checked" value="0" />
444 [% IF ( budget_parent_id ) %]
446 <span class="label">Fund parent: </span>
447 [% budget_parent_name %]
448 [% budget_parent_id %] - [% budget_parent_name %]
449 <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
453 <label class="required" for="budget_code">Fund code: </label>
454 <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" size="30" />
458 <label class="required" for="budget_name">Fund name: </label>
459 <input type="text" name="budget_name" id="budget_name" value="[% budget_name %]" size="60" />
463 <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
464 <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
468 <label for="budget_encumb">Warning at (%): </label>
469 <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="10" />
470 <span class="hint">0 to disable</span>
474 <label for="budget_expend">Warning at (amount): </label>
475 <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
476 <span class="hint">0 to disable</span>
480 <span class="label">Owner: </span>
481 <span id="budget_owner_name">
482 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner_id %]">
483 [% budget_owner_name %]
486 <input type="hidden" name="budget_owner_id" id="budget_owner_id"
487 value="[% budget_owner_id %]" />
489 <input type="button" id="edit_owner" value="Edit owner"
490 onclick="ownerPopup(); return false;" />
491 <input type="button" id="remove_owner" value="Remove owner"
492 onclick="ownerRemove(); return false;" />
495 [% IF budget_has_children %]
498 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
499 Update all child funds with this owner
501 <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
506 <span class="label">Users:</span>
507 <ul style="float:left;" id="budget_users">
508 [% FOREACH user IN budget_users %]
509 <li id="user_[% user.borrowernumber %]">
510 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber %]">
511 [% user.firstname %] [% user.surname %]
513 [<a style="cursor:pointer"
514 onclick="del_user([% user.borrowernumber %])">Remove</a>]
517 <li id="add_user_button">
518 <input type="button" onclick="userPopup()" value="Add users" />
521 <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids %]" />
523 <label for="budget_branchcode">Library: </label>
524 <select name="budget_branchcode" id="budget_branchcode">
525 <option value=""></option>
526 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
531 <label for="budget_permission">Restrict access to: </label>
532 <select name="budget_permission" id="budget_permission">
533 [% IF ( budget_perm_0 ) %]
534 <option value="0" selected="selected">
541 [% IF ( budget_perm_1 ) %]
542 <option value="1" selected="selected">
549 [% IF ( budget_perm_3) %]
550 <option value="3" selected="selected">
557 [% IF ( budget_perm_2 ) %]
558 <option value="2" selected="selected">
562 Owner, users and library
568 <label for="budget_notes">Notes: </label>
569 <textarea name="budget_notes" id="budget_notes" cols="80" rows="6">[% budget_notes %]</textarea>
573 <label style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
574 <select name="sort1_authcat" id="authorised_value_category1">
575 <option value=""></option>
576 [% FOREACH authorised_value_categories IN authorised_value_categories1 %]
577 [% IF ( authorised_value_categories.selected ) %]
578 <option value="[% authorised_value_categories.category %]" selected="selected">
579 [% authorised_value_categories.category %]
582 <option value="[% authorised_value_categories.category %]">
583 [% authorised_value_categories.category %]
590 <label style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
591 <select name="sort2_authcat" id="authorised_value_category2">
592 <option value=""></option>
593 [% FOREACH authorised_value_categories IN authorised_value_categories2 %]
594 [% IF ( authorised_value_categories.selected ) %]
595 <option value="[% authorised_value_categories.category %]" selected="selected">
596 [% authorised_value_categories.category %]
599 <option value="[% authorised_value_categories.category %]">
600 [% authorised_value_categories.category %]
608 [% IF ( budget_id ) %]
609 <input type="hidden" name="budget_id" value="[% budget_id %]" />
613 <fieldset class="action">
614 <input type="submit" value="Submit" onclick="Check(this.form); return false;" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
615 <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
619 [% END %] <!-- add_form -->
621 [% IF op == 'delete_confirm' %]
622 <div class="dialog alert">
623 <h3>Delete fund [% budget_name %]?</h3>
624 If you delete this fund, all orders linked to this fund will be deleted!
627 <th scope="row">Fund amount:</th>
628 <td>[% budget_amount | $Price %]</td>
632 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
633 <input type="hidden" name="op" value="delete_confirmed" />
634 <input type="hidden" name="budget_id" value="[% budget_id %]" />
635 <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
636 <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
638 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
639 <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
647 [% IF op == 'list' %]
648 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
649 <a href="#" id="filterbutton">Filters</a>
650 <fieldset class="brief" id="fundfilters">
651 <h4>Fund filters</h4>
654 <label for="filter_budgetbranch2">Library: </label>
655 <select name="filter_budgetbranch" id="filter_budgetbranch2" style="width:10em;">
656 <option value=""></option>
657 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
662 <label for="show_mine">Show my funds only:</label>
663 [% IF ( show_mine ) %]
664 <input type="checkbox" id="show_mine" name="show_mine" value="1" checked="checked" />
666 <input type="checkbox" id="show_mine" name="show_mine" value="1" />
672 <label for="periods">Budget:</label>
673 <select id="periods" name="budget_period_id">
674 <option value="">All budgets</option>
675 [% FOR period IN periods %]
676 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
677 <option value="[% period.budget_period_id %]" selected="selected">[% period.budget_period_description %]</option>
679 <option value="[% period.budget_period_id %]">[% period.budget_period_description %]</option>
687 <input type="hidden" name="op" value="list" />
688 <input type="submit" class="submit" name="filter" value="Go" />
691 [% INCLUDE 'acquisitions-menu.inc' %]
694 [% INCLUDE 'intranet-bottom.inc' %]