Bug 33180: Use template wrapper for tabs: Budgets and Search engine configuration
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgetperiods.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% USE KohaDates %]
4 [% USE Price %]
5 [% SET footerjs = 1 %]
6 [%- BLOCK action_menu %]
7     <div class="btn-group dropup">
8         <a class="btn btn-default btn-xs dropdown-toggle" id="budgetmenu_[% block_budget.budget_period_id | html %]" role="button" data-toggle="dropdown" href="#">
9            Actions <b class="caret"></b>
10         </a>
11         <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetmenu_[% block_budget.budget_period_id | html %]">
12               <li>
13                   <a href="[% script_name | url %]?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-pencil"></i> Edit</a>
14               </li>
15               [% IF block_budget.count %]
16                   <li class="disabled">
17                       <a data-toggle="tooltip" data-placement="left" title="[% block_budget.count | html %] fund(s) are attached to this budget. You must delete all attached funds before deleting this budget." href="#"><i class="fa fa-trash"></i> Delete</a>
18                   </li>
19               [% ELSE %]
20                   <li>
21                       <a href="[% script_name | url %]?op=delete_confirm&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-trash"></i> Delete</a>
22                   </li>
23               [% END %]
24               <li>
25                   <a href="[% script_name | url %]?op=duplicate_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-copy"></i> Duplicate</a>
26               </li>
27               <li>
28                   <a href="[% script_name | url %]?op=close_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-times-circle"></i> Close</a>
29               </li>
30               <li>
31                   <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% block_budget.budget_period_id | uri %]"><i class="fa fa-plus"></i> Add fund</a>
32               </li>
33         </ul>
34     </div>
35 [% END -%]
36
37 [% INCLUDE 'doc-head-open.inc' %]
38 [% INCLUDE 'doc-head-close.inc' %]
39 [% IF close_form %]
40     [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
41 [% END %]
42
43 <title>
44     [% IF ( add_form ) %]
45         [% IF ( budget_period_id ) %]
46             Modify budget [% budget_period_description | html %]
47         [% ELSE %]
48             Add budget
49         [% END %] &rsaquo; [% END %]
50
51     [% IF ( duplicate_form ) %]
52         Duplicate budget &rsaquo; [% END %]
53
54     [% IF ( delete_confirm ) %]
55             Delete budget '[% budget_period_description | html %]'? &rsaquo; [% END %]
56
57     [% IF ( delete_confirmed ) %]
58         Data deleted &rsaquo; [% END %]
59
60     [% IF close_form %]
61       Close budget [% budget_period_description | html %] &rsaquo; [% END %]
62
63     [% IF closed %]
64       Budget [% budget_period_description | html %] closed &rsaquo; [% END %]
65
66     Budgets &rsaquo; Administration &rsaquo; Koha
67
68 </title>
69
70
71 </head>
72
73 <body id="admin_aqbudgetperiods" class="admin">
74
75 [% WRAPPER 'header.inc' %]
76     [% INCLUDE 'budgets-admin-search.inc' %]
77 [% END %]
78
79 [% WRAPPER 'sub-header.inc' %]
80     [% WRAPPER breadcrumbs %]
81         [% WRAPPER breadcrumb_item %]
82             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
83         [% END %]
84
85         [% IF ( else ) %]
86             [% WRAPPER breadcrumb_item bc_active= 1 %]
87                 <span>Budgets administration</span>
88             [% END %]
89         [% ELSE %]
90             [% WRAPPER breadcrumb_item %]
91                 <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a>
92             [% END %]
93         [% END %]
94
95         [% IF ( add_form ) %]
96             [% IF ( budget_period_id ) %]
97                 [% WRAPPER breadcrumb_item bc_active= 1 %]
98                     <span>Modify budget '[% budget_period_description | html %]'</span>
99                 [% END %]
100             [% ELSE %]
101                 [% WRAPPER breadcrumb_item bc_active= 1 %]
102                     <span>Add budget</span>
103                 [% END %]
104             [% END %]
105         [% END %]
106
107         [% IF ( delete_confirm ) %]
108             [% IF ( total || funds_exist ) %]
109                 [% WRAPPER breadcrumb_item bc_active= 1 %]
110                     <span>Cannot delete budget '[% budget_period_description | html %]'</span>
111                 [% END %]
112             [% ELSE %]
113                 [% WRAPPER breadcrumb_item bc_active= 1 %]
114                     <span>Delete budget '[% budget_period_description | html %]'?</span>
115                 [% END %]
116             [% END %]
117         [% END %]
118
119             [% IF ( duplicate_form ) %]
120                 [% WRAPPER breadcrumb_item bc_active= 1 %]
121                     <span>Duplicate budget</span>
122                 [% END %]
123             [% END %]
124
125         [% IF close_form %]
126             [% WRAPPER breadcrumb_item bc_active= 1 %]
127                 <span>Close budget [% budget_period_description | html %]</span>
128             [% END %]
129         [% END %]
130
131         [% IF closed %]
132             [% WRAPPER breadcrumb_item bc_active= 1 %]
133                 <span>Budget [% budget_period_description | html %] closed</span>
134             [% END %]
135         [% END %]
136     [% END #/ WRAPPER breadcrumbs %]
137 [% END #/ WRAPPER sub-header.inc %]
138
139 <div class="main container-fluid">
140     <div class="row">
141         <div class="col-sm-10 col-sm-push-2">
142             <main>
143
144 [% UNLESS close_form OR closed OR duplicate_form %]
145   [% INCLUDE 'budgets-admin-toolbar.inc' %]
146 [% END %]
147
148 [% IF ( duplicate_form ) %]
149 <h1>Duplicate budget</h1>
150 <form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" id="add_modify_budget" name="f" method="post">
151     <fieldset class="rows">
152     <input type="hidden" name="op" value="duplicate_budget" />
153     <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
154
155     <ol>
156
157     <li>
158     <label class="required" for="from">Start date: </label>
159     <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | html %]" class="flatpickr" data-date_to="to" />
160         <span class="required">Required</span>
161         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
162     </li>
163     <li>
164
165     <label class="required" for="to">End date: </label>
166     <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | html %]" class="flatpickr" />
167         <span class="required">Required</span>
168         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
169     </li>
170
171     <li>
172     <label class="required" for="budget_period_description">Description</label>
173     <input type="text" id="budget_period_description" name="budget_period_description" value="[% budgetperiod.budget_period_description | html %]" />
174         <span class="required">Required</span>
175     </li>
176
177     <li>
178       <label for="amount_change_percentage">Change amounts by</label>
179       <input type="text" id="amount_change_percentage" name="amount_change_percentage" /> %
180       <div class="hint">(can be positive or negative)</div>
181     </li>
182
183     <li>
184       <label for="amount_change_round_increment">If amounts changed, round to a multiple of</label>
185       <input type="text" id="amount_change_round_increment" name="amount_change_round_increment" />
186       <div class="hint">(amounts will be rounded down)</div>
187     </li>
188
189     <li>
190       <label for="mark_as_inactive">Mark the original budget as inactive</label>
191       <input type="checkbox" id="mark_as_inactive" name="mark_original_budget_as_inactive" />
192     </li>
193
194     <li>
195       <label for="reset_all_budgets">Set all funds to zero</label>
196       <input type="checkbox" id="reset_all_budgets" name="reset_all_budgets" />
197     </li>
198
199     </ol>
200     </fieldset>
201
202     <fieldset class="action">
203         <input type="submit" class="btn btn-primary" value="Save" />
204         <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | html %]">Cancel</a>
205     </fieldset>
206
207 </form>
208
209 [% END %]
210
211 [% IF ( add_form ) %]
212     <!--  add or modify a budget period   -->
213
214     [% IF ( budget_period_id ) %]
215         <h1>Modify budget <em>[% budget_period_description | html %]</em></h1>
216     [% ELSE %]
217         <h1>Add budget</h1>
218         [% END %]
219 <form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" id="add_modify_budget" name="f" method="post">
220     <fieldset class="rows">
221     <!-- ################################################################################# -->
222     <!-- display information about the budget period that must be added or modified -->
223     <!-- ################################################################################# -->
224     <input type="hidden" name="op" value="add_validate" />
225     <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
226     <ol>
227     <li>
228     <label class="required" for="from">Start date: </label>
229     <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | html %]" class="flatpickr" data-date_to="to" />
230         <span class="required">Required</span>
231         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
232     </li>
233     <li>
234
235     <label class="required" for="to">End date: </label>
236     <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | html %]" class="flatpickr" />
237         <span class="required">Required</span>
238         <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
239     </li>
240
241     <li>
242         <!-- DESCRIPTION -->
243         <!-- ############################## -->
244         <label class="required" for="budget_period_description">Description: </label>
245         <input type="text" id="budget_period_description" name="budget_period_description"
246         size="48" maxlength="80" value="[% budget_period_description | html %]" />
247             <span class="required">Required</span>
248     </li>
249
250     <li>
251         <!-- TOTAL -->
252         <!-- ############################## -->
253         <label for="budget_period_total">Total amount: </label>
254         <input type="text" id="budget_period_total" name="budget_period_total"
255         size="10" maxlength="80" value="[% budget_period_total | $Price on_editing => 1 %]" />
256     </li>
257
258     <li>
259         <!-- ACTIVE -->
260         <!-- ############################## -->
261         <label for="budget_period_active">Make budget active: </label>
262         [% IF ( budget_period_active ) %]<input type="checkbox" checked="checked" id="budget_period_active" name="budget_period_active" value="1" />[% ELSE %]  <input type="checkbox" id="budget_period_active" name="budget_period_active" value="1"/> [% END %]
263     </li>
264
265     <li>
266         <!-- LOCK  -->
267         <!-- ############################## -->
268         <label for="budget_period_locked">Lock budget: </label>
269         [% IF ( budget_period_locked ) %]<input type="checkbox" checked="checked" id="budget_period_locked" name="budget_period_locked" value="1" />[% ELSE %]  <input type="checkbox" id="budget_period_locked" name="budget_period_locked" value="1"/> [% END %]
270     </li>
271     </ol>
272     </fieldset>
273
274     <fieldset class="action">
275         <!-- "save changes" button -->
276         <!-- ###################################### -->
277         <input type="submit" class="btn btn-primary" value="Save" />
278         [% IF ( budget_period_id ) %]
279             <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]" class="cancel">Cancel</a>
280         [% ELSE %]
281             <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl" class="cancel">Cancel</a>
282         [% END %]
283     </fieldset>
284
285 </form>
286
287 [% END %]
288
289 <!-- ####################################################################### -->
290 <!-- delete a budget period -->
291 <!-- ####################################################################### -->
292
293 [% IF ( delete_confirm ) %]
294     [% IF ( total ) %]
295         <div class="dialog message">
296         <h1>Cannot delete budget</h1>
297         <p><strong>This record is used [% total | html %] times</strong>
298         . Deletion is not possible.</p>
299     [% ELSIF ( funds_exist ) %]
300         <div class="dialog message">
301         <h1>Cannot delete budget</h1>
302         <p>This budget has funds attached. You must delete all attached funds before you can delete this budget.</p>
303     [% ELSE %]
304         <div class="dialog alert">
305         <h1>Delete budget '[% budget_period_description | html %]'?</h1>
306
307     <!-- ############################################################# -->
308     <!-- "delete" and "cancel" buttons    -->
309     <!-- ############################################################# -->
310
311     <form action="[% script_name | html %]" method="post">
312         <input type="hidden" name="op" value="delete_confirmed" />
313         <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
314         <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete</button>
315     </form>
316     <form action="[% script_name | html %]" method="post">
317         <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
318     </form>
319     [% END %]
320
321     </div>
322 [% END %]
323
324 [% IF close_form %]
325 <h1>Close budget [% budget_period_description | html %]</h1>
326   [% IF budget_periods.size == 0 %]
327     <span>You cannot move funds of this budget, there is no active budget.
328     Please create a new active budget and retry.</span>
329     <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Back</a>
330   [% ELSIF number_of_unreceived_orders == 0 %]
331     <span>There are no unreceived orders for this budget.</span>
332     <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Back</a>
333   [% ELSE %]
334     <div class="page-section">
335         <h3>The unreceived orders from the following funds will be moved</h3>
336           Fund list of budget <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">[% budget_period_description | html %]</a>:
337         <table id="budgeth">
338           <thead>
339             <tr>
340                 <th>Fund ID</th>
341                 <th>Fund code</th>
342                 <th>Fund name</th>
343                 <th>Unreceived orders</th>
344             </tr>
345           </thead>
346           <tbody>
347             [% FOREACH budget IN budgets_to_move %]
348               <tr>
349                 <td>[% budget.budget_id | html %]</td>
350                 <td>[% budget.budget_code | html %]</td>
351                 <td>[% budget.budget_name | html %]</td>
352                 <td>[% budget.unreceived_orders.size | html %]</td>
353               </tr>
354             [% END %]
355           </tbody>
356         </table>
357         <form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post" id="move_form">
358           <fieldset class="rows">
359             <ol>
360               <li>
361                 <label class="required" for="to_budget_period_id">Select a budget</label>
362                 <select name="to_budget_period_id" id="to_budget_period_id" required="required">
363                   <option value=""></option>
364                   [% FOR budget_period IN budget_periods %]
365                     <option value="[% budget_period.budget_period_id | html %]">[% budget_period.budget_period_description | html %]</option>
366                   [% END %]
367                 </select>
368               </li>
369               <li>
370               <label for="move_remaining_unspent">Move remaining unspent funds</label>
371                 <input type="checkbox" name="move_remaining_unspent" id="move_remaining_unspent" />
372               </li>
373             </ol>
374           </fieldset>
375           <fieldset class="action">
376               <input type="hidden" name="op" value="close_confirmed" />
377               <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
378               <input type="submit" class="btn btn-primary" value="Move unreceived orders" />
379               <a class="cancel" href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Cancel</a>
380           </fieldset>
381         </form>
382     </div><!-- /.page-section -->
383   [% END %]
384 [% ELSIF closed %]
385     <h1>Budget [% budget_period_description | html %] closed</h1>
386
387     <div class="page-section">
388         <h3>Report after moving unreceived orders from budget [% from_budget_period.budget_period_description | html %] ([% from_budget_period.budget_period_startdate | $KohaDates %] - [% from_budget_period.budget_period_enddate | $KohaDates %]) to [% to_budget_period.budget_period_description | html %] ([% to_budget_period.budget_period_startdate | $KohaDates %] - [% to_budget_period.budget_period_enddate | $KohaDates%])</h3>
389
390         <table id="closed_report">
391         <thead>
392           <tr>
393             <td>Budget id</td>
394             <td>Basket</td>
395             <td>Ordernumber</td>
396             <td>Details</td>
397           </tr>
398         </thead>
399         <tbody>
400           [% FOR r IN report %]
401               [% IF r.moved %]
402                 [% IF r.orders_moved.size > 0 %]
403                   [% FOR order IN r.orders_moved %]
404                     <tr>
405                       <td>[% r.budget.budget_name | html %] (id=[% r.budget.budget_id | html %]) Amount=[% r.budget.budget_amount | $Price %][% IF r.unspent_moved %] ([% r.unspent_moved | $Price %] remaining has been moved)[% END %]</td>
406                       <td>[% order.basketname | html %]</td>
407                       <td>[% order.ordernumber | html %]</td>
408                       <td>Moved!</td>
409                     </tr>
410                   [% END %]
411                 [% ELSE %]
412                   <tr>
413                     <td>[% r.budget.budget_name | html %] (id=[% r.budget.budget_id | html %])</td>
414                     <td></td>
415                     <td></td>
416                     <td>There were no unreceived orders for this fund.</td>
417                   </tr>
418                 [% END %]
419               [% ELSE %]
420                 [% IF r.error == 'budget_code_not_exists' %]
421                   <tr>
422                     <td>[% r.budget.budget_id | html %] [% r.budget.budget_amount | $Price %][% IF r.unspent_moved %] ([% r.unspent_moved | $Price %] remaining has been moved)[% END %]</td>
423                     <td></td>
424                     <td></td>
425                     <td>This fund code does not exist in the destination budget.</td>
426                   </tr>
427                 [% END %]
428               [% END %]
429             </tr>
430           [% END %]
431         </tbody>
432         </table>
433         <a class="cancel" href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Back</a>
434     </div>
435 [% END %]
436
437 <!--  DEFAULT  display budget periods list -->
438 [% IF ( else ) %]
439   <h1>Budgets administration</h1>
440
441     [% IF ( failed_delete_funds_exist ) %]
442         <div class="dialog message">Failed to delete budget because funds exist.</div>
443     [% END %]
444
445     [% INCLUDE 'budgets-active-currency.inc' %]
446
447     [% WRAPPER tabs id= "budgetsTabs" %]
448
449         [% WRAPPER tabs_nav %]
450             [% WRAPPER tab_item tabname= "active" bt_active= 1 %] <span>Active budgets</span> [% END %]
451             [% WRAPPER tab_item tabname= "inactive" %] <span>Inactive budgets</span> [% END %]
452         [% END # /WRAPPER tabs_nav %]
453
454         [% WRAPPER tab_panels %]
455             [% WRAPPER tab_panel tabname="active" bt_active= 1 %]
456                 [% IF ( period_active_loop ) %]
457                     <table id="activeperiodst">
458                         <thead>
459                             <tr>
460                                 <th>Budget name</th>
461                                 <th>Start date</th>
462                                 <th>End date</th>
463                                 <th>Locked</th>
464                                 <th>Total</th>
465                                 <th class="noExport">Actions</th>
466                             </tr>
467                         </thead>
468                         <tbody>
469                             [% FOREACH period_active IN period_active_loop %]
470                                 <tr>
471                                     <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_active.budget_period_id | uri %]" title="View funds for [% period_active.budget_period_description | html %]">[% period_active.budget_period_description | html %]</a></td>
472                                     <td data-order="[% period_active.budget_period_startdate | html %]">[% period_active.budget_period_startdate | $KohaDates %]</td>
473                                     <td data-order="[% period_active.budget_period_enddate | html %]">[% period_active.budget_period_enddate | $KohaDates %]</td>
474                                     <td>
475                                         [% IF ( period_active.budget_period_locked ) %]
476                                             <i class="fa fa-lock"></i> Locked</span>
477                                         [% END %]
478                                     </td>
479                                     <td class="data">[% period_active.budget_period_total | $Price %]</td>
480                                     <td>
481                                         [% PROCESS action_menu block_budget=period_active %]
482                                     </td>
483                                 </tr>
484                             [% END # /FOREACH period_active %]
485                         </tbody>
486                     </table> <!-- /#activeperiodst -->
487                 [% ELSE %]
488                     <span>No active budgets</span>
489                 [% END # /IF period_active_loop %]
490             [% END # /WRAPPER tab_panel#active %]
491
492             [% WRAPPER tab_panel tabname="inactive" %]
493                 [% IF ( period_inactive_loop ) %]
494                     <table id="inactiveperiodst">
495                         <thead>
496                             <tr>
497                                 <th>Budget name</th>
498                                 <th>Start date</th>
499                                 <th>End date</th>
500                                 <th>Locked</th>
501                                 <th>Total</th>
502                                 <th class="noExport">Actions</th>
503                             </tr>
504                         </thead>
505                         <tbody>
506                             [% FOREACH period_loo IN period_inactive_loop %]
507                                 <tr>
508                                     <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_loo.budget_period_id | uri %]" title="View funds for [% period_loo.budget_period_description | html %]">[% period_loo.budget_period_description | html %]</a></td>
509                                     <td data-order="[% period_loo.budget_period_startdate | html %]">[% period_loo.budget_period_startdate | $KohaDates %]</td>
510                                     <td data-order="[% period_loo.budget_period_enddate | html %]">[% period_loo.budget_period_enddate | $KohaDates %]</td>
511                                     <td>[% IF ( period_loo.budget_period_locked ) %]<i class="fa fa-lock"></i> Locked[% END %]</td>
512                                     <td class="data">[% period_loo.budget_period_total | $Price %]</td>
513                                     <td>
514                                             [% PROCESS action_menu block_budget=period_loo %]
515                                     </td>
516                                 </tr>
517                             [% END # /FOREACH period_loo %]
518                         </tbody>
519                     </table> <!-- /#inactiveperiodst -->
520                 [% ELSE %]
521                     <span>No inactive budgets</span>
522                 [% END # /IF inactiveperiodst %]
523             [% END # /WRAPPER tab_panel#inactive %]
524         [% END # /WRAPPER tab_panels %]
525     [% END # /WRAPPER tabs %]
526
527 [% END # /IF else %]
528
529             </main>
530         </div> <!-- /.col-sm-10.col-sm-push-2 -->
531
532         <div class="col-sm-2 col-sm-pull-10">
533             <aside>
534                 [% INCLUDE 'acquisitions-menu.inc' %]
535             </aside>
536         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
537      </div> <!-- /.row -->
538
539 [% MACRO jsinclude BLOCK %]
540     [% INCLUDE 'calendar.inc' %]
541     [% INCLUDE 'datatables.inc' %]
542     [% IF close_form %]
543         [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
544     [% END %]
545     [% Asset.js("js/acq.js") | $raw %]
546     <script>
547         $(document).ready(function() {
548             [% IF ( tab ) %]
549                 $("#budgetsTabs li:eq([% tab | html %]) a").tab("show");
550             [% END %]
551
552             $("#activeperiodst,#inactiveperiodst").dataTable($.extend(true, {}, dataTablesDefaults, {
553                 "aoColumnDefs": [
554                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
555                 ],
556                 "sPaginationType": "full",
557                 'bAutoWidth': false
558             } ) );
559
560             [% IF close_form %]
561               $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
562                 sDom: "t"
563               }));
564               $("#move_form").submit(function(){
565                 var budget_from = "[% budget_period_description | html %]";
566                 var budget_to = $("#to_budget_period_id").find("option:selected").html();
567                 var alert_message = _("You have chosen to move all unreceived orders from '%s' to '%s'.").format(budget_from, budget_to);
568                 alert_message += "\n" + _("This action cannot be reversed. Do you wish to continue?");
569                 return confirm ( alert_message );
570               });
571             [% END %]
572             [% IF closed %]
573               var oTable = $("#closed_report").dataTable($.extend(true, {}, dataTablesDefaults, {
574                 // The following is a c/p from aqbudgets.tt and is a candidate for refactoring.
575                 "fnDrawCallback": function ( oSettings ) {
576                     if ( oSettings.aiDisplay.length == 0 )
577                     {
578                         return;
579                     }
580
581                     var nTrs = $('#closed_report tbody tr');
582                     var iColspan = nTrs[1].getElementsByTagName('td').length;
583                     var sLastGroup = "";
584                     for ( var i=0 ; i<nTrs.length ; i++ )
585                     {
586                         var iDisplayIndex = oSettings._iDisplayStart + i;
587                         var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[0];
588                         if ( sGroup != sLastGroup )
589                         {
590                             var nGroup = document.createElement( 'tr' );
591                             var nCell = document.createElement( 'td' );
592                             nCell.colSpan = iColspan;
593                             nCell.className = "group";
594                             nCell.innerHTML = sGroup;
595                             nGroup.appendChild( nCell );
596                             nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
597                             sLastGroup = sGroup;
598                         }
599                     }
600                 },
601                 "aoColumnDefs": [
602                     { "bVisible": false, "aTargets": [ 0, 1 ] },
603                     { "bSortable": false, "aTargets": ["_all"] }
604                 ],
605                 'bSort': true,
606                 'aaSortingFixed': [[ 1, 'asc' ]],
607                 "bAutoWidth": false,
608                 "sPaginationType": "full_numbers"
609               }));
610             [% END %]
611             $("#add_modify_budget").validate({
612                 rules: {
613                     budget_period_startdate: "required",
614                     budget_period_enddate: {
615                         required: true,
616                         date_on_or_after: "#from"
617                     },
618                     budget_period_description: "required",
619                     budget_period_total: {
620                         number: true
621                     }
622                 },
623                 messages: {
624                     budget_period_enddate: {
625                         date_on_or_after: _("Budget end date must be on or after budget start date")
626                     }
627                 }
628             });
629         });
630     </script>
631 [% END %]
632 [% INCLUDE 'intranet-bottom.inc' %]