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