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