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