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