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