Bug 20329: Text input fields are wider than the fieldset class they are inside of
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgets.tt
1 [% USE Asset %]
2 [% USE AuthorisedValues %]
3 [% USE Branches %]
4 [% USE Price %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Administration &rsaquo; Funds[% IF op == 'add_form' %] &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
8 [% Asset.css("css/datatables.css") %]
9 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") %]
10 [% INCLUDE 'doc-head-close.inc' %]
11 </head>
12
13 <body id="admin_aqbudgets" class="admin">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'budgets-admin-search.inc' %]
16
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
18     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo; [% IF op == 'list' %][% IF budget_period_id %]Funds for '[% budget_period_description %]'[% ELSE %]All funds[% END %][% END %]
19     [% IF op == 'add_form' %]
20       <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Funds</a> &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund[% END %]
21     [% END %]
22     [% IF op == 'delete_confirm' %]
23       <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> &rsaquo; Delete fund?
24     [% END %]
25 </div>
26
27 <div id="doc3" class="yui-t2">
28 <div id="bd">
29 <div id="yui-main">
30 <div class="yui-b" id="content">
31
32
33 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
34
35 [% IF (error_not_authorised_to_modify) %]
36     <div class="error">
37         <p>You are not authorized to modify this fund</p>
38     </div>
39 [% END %]
40
41 [% IF op == 'list' %]
42
43 <h1>
44   [% IF budget_period_id %]
45     Funds for '[% budget_period_description %]'
46   [% ELSE %]
47     All funds
48   [% END %]
49 </h1>
50
51 [% INCLUDE 'budgets-active-currency.inc' %]
52
53 [% IF budgets %]
54
55 <table id="budgeth" class="group">
56     [% UNLESS budget_period_id %]
57       <caption>
58         <span class="actions"><a href="#" id="expand_all">Expand all</a>
59         | <a href="#" id="collapse_all">Collapse all</a>
60         | <a href="#" id="hide_inactive">Hide inactive budgets</a>
61         | <a href="#" id="show_inactive">Show inactive budgets</a></span>
62       </caption>
63     [% END %]
64     <thead>
65         <tr>
66             <th>Active</th>
67             <th>Budget period description</th>
68             <th>Fund code</th>
69             <th>Fund name</th>
70             <th>Base-level allocated</th>
71             <th>Base-level ordered</th>
72             <th>Total ordered</th>
73             <th>Base-level spent</th>
74             <th>Total spent</th>
75             <th>Base-level available</th>
76             <th>Total available</th>
77             <th>Actions</th>
78         </tr>
79     </thead>
80     <tfoot>
81     <tr>
82     <th></th>
83     <th></th>
84     <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %]  </th>
85     <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
86     <th></th>
87     <th class="data">[% ordered_total | $Price %]</th>
88     <th></th>
89     <th class="data">[% spent_total | $Price %]</th>
90     <th></th>
91     <th class="data">[% available_total | $Price %]</th>
92     <th></th>
93     </tr>
94     </tfoot>
95     <tbody>
96     [% FOREACH budget IN budgets %]
97     [% IF budget.budget_parent_id %]
98       <tr data-tt-id="[% budget.budget_id %]" data-tt-parent-id="[% budget.budget_parent_id %]">
99     [% ELSE %]
100       <tr data-tt-id="[% budget.budget_id %]">
101     [% END %]
102     <td>[% budget.budget_period_active %]</td>
103     <td>Budget [% budget.budget_period_description %] [id=[% budget.budget_period_id %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
104     <td>[% budget.budget_code %]</td>
105     <td>[% budget.budget_name %]</td>
106     <td class="data">
107       [% IF budget.budget_parent_id %]
108         <span class="child_fund_amount">[% budget.budget_amount | $Price %]</span>
109       [% ELSE %]
110         <span class="total_amount">[% budget.budget_amount | $Price %]</span>
111       [% END %]
112     </td>
113     <td class="data">
114       [% IF budget.budget_parent_id %]
115         <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
116       [% ELSE %]
117         <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
118       [% END %]
119     </td>
120     <td class="data">
121       [% IF budget.budget_parent_id %]
122         <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
123       [% ELSE %]
124         <span class="total_amount">[% budget.total_ordered | $Price %]</span>
125       [% END %]
126     </td>
127     <td class="data">
128       [% IF budget.budget_parent_id %]
129         <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
130       [% ELSE %]
131         <span class="total_amount">[% budget.budget_spent | $Price %]</span>
132       [% END %]
133     </td>
134     <td class="data">
135       [% IF budget.budget_parent_id %]
136         <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
137       [% ELSE %]
138         <span class="total_amount">[% budget.total_spent | $Price %]</span>
139       [% END %]
140     </td>
141
142
143     [% BLOCK colorcellvalue %]
144         [% IF parent %]
145             [% IF (value > 0) %]
146                 <span class="child_fund_amount" style="color: green;">
147             [% ELSIF (value < 0) %]
148                 <span class="child_fund_amount" style="color: red;">
149             [% ELSE %]
150                 <span class="child_fund_amount">
151             [% END %]
152          [% ELSE %]
153             [% IF (value > 0) %]
154                 <span class="total_amount" style="color: green;">
155             [% ELSIF (value < 0) %]
156                 <span class="total_amount" style="color: red;">
157             [% ELSE %]
158                 <span class="totalamount">
159             [% END %]
160         [% END %]
161             [% value | $Price %]
162         </span>
163     [% END %]
164     <td class="data">
165         [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
166     </td>
167     <td class="data">
168         [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
169     </td>
170     [% IF ( budget.budget_lock ) %]
171         <td> <span></span> </td>
172     [% ELSE %]
173         <td>
174             <div class="dropdown dropup">
175                 <a class="btn btn-default btn-xs dropdown-toggle" id="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]" role="button" data-toggle="dropdown" href="#">
176                    Actions <b class="caret"></b>
177                 </a>
178                 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]">
179                     <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-pencil"></i> Edit</a></li>
180                     [% IF budget.budget_has_children %]
181                         <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>
182                     [% ELSE %]
183                         <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&amp;budget_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-trash"></i> Delete</a></li>
184                     [% END %]
185                     <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_parent_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-plus"></i> Add child fund</a></li>
186                 </ul>
187             </div>
188         </td>
189     [% END %]
190     </tr>
191     [% END %]
192     </tbody>
193 </table>
194
195 [% ELSE %]
196     <p>No fund found</p>
197 [% END %]
198
199 [% END %] <!-- list -->
200
201 <!-- ********************************************************************************************** -->
202 <!-- create add/mod entry form -->
203 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
204 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
205     <fieldset class="rows">
206     <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
207     [% IF ( budget_period_description ) %]
208         [% budget_name %] for Budget '[% budget_period_description %]'
209     [% END %]
210     </legend>
211
212     <input type="hidden" name="op" value="add_validate" />
213     <input type="hidden" name="checked" value="0" />
214     <ol>
215     [% IF ( budget_parent_id ) %]
216     <li>
217         <span class="label">Fund parent: </span>
218         [% budget_parent_name %]
219         [% budget_parent_id %] - [% budget_parent_name %]
220         <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
221     </li>
222     [% END %]
223     <li>
224     <label class="required"  for="budget_code">Fund code: </label>
225     <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" size="30" />
226     </li>
227
228     <li>
229     <label class="required" for="budget_name">Fund name: </label>
230     <input type="text" name="budget_name" id="budget_name" value="[% budget_name %]" size="60" />
231     </li>
232
233     <li>
234     <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
235     <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
236     </li>
237
238     <li>
239       <label for="budget_encumb">Warning at (%): </label>
240       <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="10" />
241       <span class="hint">0 to disable</span>
242     </li>
243
244     <li>
245       <label for="budget_expend">Warning at (amount): </label>
246       <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
247       <span class="hint">0 to disable</span>
248     </li>
249
250     <li>
251         <span class="label">Owner: </span>
252         [% IF  budget_owner %]
253             <span  id="budget_owner_name">
254                 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber %]">
255                     [% budget_owner.firstname %] [% budget_owner.surname %]
256                 </a> |
257             </span>
258         [% END %]
259         <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
260         <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
261         <input type="hidden" name="budget_owner_id" id="budget_owner_id"
262             value="[% budget_owner.borrowernumber %]" />
263     </li>
264
265
266     [% IF budget_has_children %]
267         <li class="radio">
268             <label>
269                 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
270                 Update all child funds with this owner
271             </label>
272             <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
273         </li>
274     [% END %]
275
276     <li>
277         <span class="label">Users:</span>
278         <ul style="float:left;" id="budget_users">
279             [% FOREACH user IN budget_users %]
280                 <li id="user_[% user.borrowernumber %]">
281                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber %]">
282                         [% user.firstname %] [% user.surname %]
283                     </a>
284                     &bull; <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber %]"><i class="fa fa-trash"></i> Remove</a>
285                 </li>
286             [% END %]
287             <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
288         </ul>
289         <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids %]" />
290     </li>
291     <li>
292     <label for="budget_branchcode">Library: </label>
293     <select name="budget_branchcode" id="budget_branchcode">
294         <option value=""></option>
295         [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
296     </select>
297     </li>
298
299     <li>
300     <label for="budget_permission">Restrict access to: </label>
301     <select name="budget_permission" id="budget_permission">
302         [% IF ( budget_perm_0 ) %]
303             <option value="0" selected="selected">
304         [% ELSE %]
305             <option value="0">
306         [% END %]
307             None
308         </option>
309
310         [% IF ( budget_perm_1 ) %]
311             <option value="1" selected="selected">
312         [% ELSE %]
313             <option value="1">
314         [% END %]
315             Owner
316         </option>
317
318         [% IF ( budget_perm_3) %]
319             <option value="3" selected="selected">
320         [% ELSE %]
321             <option value="3">
322         [% END %]
323             Owner and users
324         </option>
325
326         [% IF ( budget_perm_2 ) %]
327             <option value="2" selected="selected">
328         [% ELSE %]
329             <option value="2">
330         [% END %]
331             Owner, users and library
332         </option>
333     </select>
334     </li>
335
336     <li>
337     <label for="budget_notes">Notes: </label>
338     <textarea name="budget_notes" id="budget_notes"  cols="80" rows="6">[% budget_notes %]</textarea>
339     </li>
340
341     <li>
342     <label  style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
343         <select name="sort1_authcat" id="authorised_value_category1">
344             <option value=""></option>
345             [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
346         </select>
347     </li>
348     <li>
349     <label  style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
350         <select name="sort2_authcat" id="authorised_value_category2">
351             <option value=""></option>
352             [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
353         </select>
354     </li>
355     </ol>
356
357     [% IF ( budget_id ) %]
358         <input type="hidden" name="budget_id" value="[% budget_id %]" />
359     [% END %]
360     </fieldset>
361
362     <fieldset class="action">
363         <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
364         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
365     </fieldset>
366 </form>
367
368 [% END %] <!-- add_form -->
369
370 [% IF op == 'delete_confirm' %]
371     <div class="dialog alert">
372         <h3>Delete fund [% budget_name %]?</h3>
373         If you delete this fund, all orders linked to this fund will be deleted!
374         <table>
375             <tr>
376             <th scope="row">Fund amount:</th>
377             <td>[% budget_amount | $Price %]</td>
378             </tr>
379         </table>
380
381         <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
382             <input type="hidden" name="op" value="delete_confirmed" />
383             <input type="hidden" name="budget_id" value="[% budget_id %]" />
384             <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
385             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
386         </form>
387         <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
388             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
389         </form>
390     </div>
391 [% END %]
392
393 </div>
394 </div>
395 <div class="yui-b">
396 [% IF op == 'list' %]
397   <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
398     <a href="#" id="filterbutton">Filters</a>
399     <fieldset class="brief" id="fundfilters">
400     <h4>Fund filters</h4>
401         <ol>
402         <li>
403             <label for="filter_budgetbranch2">Library: </label>
404             <select name="filter_budgetbranch" id="filter_budgetbranch2">
405                 <option value=""></option>
406                 [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
407             </select>
408         </li>
409         <li class="radio">
410
411         <label for="show_mine">Show my funds only:</label>
412             [% IF ( show_mine ) %]
413                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
414             [% ELSE %]
415                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" />
416         [% END %]
417         </li>
418
419         [% IF periods %]
420           <li>
421             <label for="periods">Budget:</label>
422             <select id="periods" name="budget_period_id">
423               <option value="">All budgets</option>
424               [% FOR period IN periods %]
425                 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
426                   <option value="[% period.budget_period_id %]" selected="selected">[% period.budget_period_description %]</option>
427                 [% ELSE %]
428                   <option value="[% period.budget_period_id %]">[% period.budget_period_description %]</option>
429                 [% END %]
430               [% END %]
431             </select>
432           </li>
433         [% END %]
434         </ol>
435
436         <input type="hidden" name="op" value="list" />
437         <input type="submit" class="submit" name="filter" value="Go" />
438     </fieldset>
439 </form>[% END %]
440 [% INCLUDE 'acquisitions-menu.inc' %]
441 </div>
442 </div>
443 [% MACRO jsinclude BLOCK %]
444     [% Asset.js("js/acq.js") %]
445     <script type="text/javascript">
446         var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
447         var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
448         var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
449     </script>
450
451     [% Asset.js("js/acq.js") %]
452     [% IF op == 'add_form' %]
453         <script type="text/javascript">
454         //<![CDATA[
455
456             function userPopup() {
457                 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
458                     'PatronPopup',
459                     'width=740,height=450,location=yes,toolbar=no,'
460                     + 'scrollbars=yes,resize=yes'
461                 );
462             }
463
464             function ownerPopup() {
465                 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
466                     'PatronPopup',
467                     'width=740,height=450,location=yes,toolbar=no,'
468                     + 'scrollbars=yes,resize=yes'
469                 );
470             }
471
472             function select_user(borrowernumber, borrower) {
473                 ownerRemove();
474                 var borrowername = borrower.firstname + ' ' + borrower.surname
475                 if (borrowernumber) {
476                     var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
477                         + '?borrowernumber=' + borrowernumber + '">'
478                         + borrowername + '</a>';
479                     $('#budget_owner_name').html(ownerlink);
480                     $('#budget_owner_id').val(borrowernumber);
481                 }
482             }
483
484             function ownerRemove() {
485                 $('#budget_owner_name').empty();
486                 $('#budget_owner_id').val('');
487             }
488
489             function add_user(borrowernumber, borrowername) {
490                 var ids = $("#budget_users_id").val().split(':');
491                 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
492                     var li = '<li id="user_' + borrowernumber + '">'
493                         + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
494                         + borrowernumber + '">' + borrowername + '</a> '
495                         + ' &bull; <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
496                         + '</li>';
497                     $("#budget_users").prepend(li);
498                     ids.push(borrowernumber);
499                     $("#budget_users_id").val(ids.join(':'));
500                 } else {
501                     return -1;
502                 }
503                 return 0;
504             }
505
506             function del_user(borrowernumber) {
507                 var ids = $("#budget_users_id").val().split(':');
508                 if (borrowernumber) {
509                     var idx = ids.indexOf(borrowernumber+'');
510                     if (idx != -1) {
511                         ids.splice(idx, 1);
512                         $("#budget_users_id").val(ids.join(':'));
513                         $("li#user_" + borrowernumber).remove();
514                     }
515                 }
516             }
517
518             function Check(f) {
519                 var ok=1;
520                 var _alertString="";
521                 var alertString2;
522
523                 if (!(isNotNull(f.budget_code,1))) {
524                     _alertString += _("- Budget code cannot be blank") + "\n";
525                 }
526
527                 if (!(isNotNull(f.budget_name,1))) {
528                     _alertString += _("- Budget name cannot be blank") + "\n";
529                 }
530
531                 if (!(isNotNull(f.budget_amount,1))) {
532                     _alertString += _("- Budget amount cannot be blank") + "\n";
533                 }
534
535                 var budgetId;
536                 if   (typeof(f.budget_id ) != "undefined")  {
537                     budgetId = f.budget_id.value
538                 }
539
540                 var newBudgetParent;
541
542         //  hack to test if selected parent_id in scrolling-list...
543         //  if value == 'undef' its got a selected_parent :/
544                 if(f.budget_parent_id){
545                     var chkAdd   =  f.budget_parent_id.value ;
546                     if  (     typeof(chkAdd ) != "undefined") {
547                         newBudgetParent  =  f.budget_parent_id.value
548                     } else {
549                         newBudgetParent  =  f.budget_parent_id.item(0).value
550                     }
551
552                     if   (budgetId  > 0)  {  ; //its a mod ...
553                         // if parent == curent-budget, fail...
554                         if ( newBudgetParent  ==  budgetId     ) {
555                                 _alertString += _("- Budget parent is current budget") + "\n";
556                         }
557
558                         else if (newBudgetParent) {
559                             var result = checkBudgetParent(  budgetId , newBudgetParent   );
560                             if (result) {
561                                 _alertString += result;
562                             }
563                         }
564                     }
565                 }
566
567                  // else do lookup
568                 var budgetTotal = Math.abs(f.budget_amount.value);
569                 var result =   budgetExceedsParent  (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
570                 if (result) {
571                     _alertString += result;
572                 }
573
574                 if (_alertString.length==0) {
575                     document.Aform.submit();
576                 } else {
577                     alertString2 = _("Form not submitted because of the following problem(s)");
578                     alertString2 += "\n------------------------------------------------------------------------------------\n\n";
579                     alertString2 += _alertString;
580                     alert(alertString2);
581                 }
582             }
583             $(document).ready(function(){
584                 $("#remove_owner").on("click",function(e){
585                     e.preventDefault();
586                     ownerRemove();
587                 });
588                 $("#edit_owner").on("click",function(e){
589                     e.preventDefault();
590                     ownerPopup();
591                 });
592                 $("body").on("click",".del_user",function(e){
593                     e.preventDefault();
594                     var borrowernumber = $(this).data("borrowernumber");
595                     del_user(borrowernumber);
596                 });
597                 $("#add_user_button").on("click",function(e){
598                     e.preventDefault();
599                     userPopup();
600                 });
601                 $("#edit_fund").on("submit",function(e){
602                     e.preventDefault();
603                     Check(this);
604                 });
605             });
606         //]]>
607         </script>
608     [% ELSIF op == 'list' %]
609         [% INCLUDE 'datatables.inc' %]
610         [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") %]
611
612         <script type="text/javascript">
613         //<![CDATA[
614             //
615             $(document).ready(function() {
616                 var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
617                     "fnDrawCallback": function ( oSettings ) {
618                         if ( oSettings.aiDisplay.length == 0 )
619                         {
620                             return;
621                         }
622
623                         var nTrs = $('#budgeth tbody tr');
624                         var iColspan = nTrs[0].getElementsByTagName('td').length;
625                         var sLastGroup = "";
626                         for ( var i=0 ; i<nTrs.length ; i++ )
627                         {
628                             var iDisplayIndex = oSettings._iDisplayStart + i;
629                             var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
630                             if ( sGroup != sLastGroup )
631                             {
632                                 var nGroup = document.createElement( 'tr' );
633                                 var nCell = document.createElement( 'td' );
634                                 nCell.colSpan = iColspan;
635                                 nCell.className = "group";
636                                 nCell.innerHTML = sGroup;
637                                 nGroup.appendChild( nCell );
638                                 nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
639                                 sLastGroup = sGroup;
640                             }
641                         }
642                     },
643                     "footerCallback": function ( row, data, start, end, display ) {
644                         var api = this.api(), data;
645                         footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
646                     },
647                     "aoColumnDefs": [
648                         { "bVisible": false, "aTargets": [ 0, 1 ] },
649                         { "bSortable": false, "aTargets": ["_all"] }
650                     ],
651                     'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
652                     'bSort': true,
653                     'aaSortingFixed': [[ 1, 'asc' ]],
654                     'bPaginate': false,
655                     "bAutoWidth": false
656                 }));
657
658                 $(oTable).treetable({
659                     expandable: true
660                 });
661                 $(oTable).treetable('expandAll');
662                 $("#expand_all").click(function(e){
663                     e.preventDefault();
664                     $(oTable).treetable('expandAll');
665                 });
666                 $("#collapse_all").click(function(e){
667                     e.preventDefault();
668                     $(oTable).treetable('collapseAll');
669                 });
670
671                 [% UNLESS budget_period_id %]
672                   $("#hide_inactive").click(function(e){
673                     e.preventDefault();
674                     oTable.fnFilter( 1, 0 ); // Show only active=1
675                   });
676                   $("#show_inactive").click(function(e){
677                     e.preventDefault();
678                     oTable.fnFilter( '', 0 );
679                   });
680                   $("#hide_inactive").click();
681                 [% END %]
682                 oTable.fnAddFilters("filter", 750);
683
684                 $("#filterbutton").click(function() {
685                     $("#fundfilters").slideToggle(0);
686                 });
687
688                 $(".deletefund-disabled").tooltip().on("click", function(e){
689                     e.preventDefault();
690                     alert(_("This fund has children. It cannot be deleted."));
691                 });
692             });
693         //]]>
694         </script>
695     [% END %]
696 [% END %]
697 [% INCLUDE 'intranet-bottom.inc' %]