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