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