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