Bug 8117: Divide budget periods into two tabs
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgetperiods.tt
1 [% USE KohaDates %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
4 [% INCLUDE 'doc-head-close.inc' %]
5 [% INCLUDE 'calendar.inc' %]
6 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
7 [% INCLUDE 'datatables-strings.inc' %]
8 <script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
9 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
10 <script type="text/javascript">
11 // #################################################################################
12 // Javascript
13 // #################################################################################
14     function CheckDuplicateForm(f){
15             var ok=1;
16             var _alertString="";
17             var alertString="";
18             if(!(isNotNull(f.budget_period_startdate,1))){
19               _alertString += "\n- " + _("Start date missing");
20             }
21             if (!(isNotNull(f.budget_period_enddate,1))){
22               _alertString += "\n- " + _("End date missing");
23             }
24             if( f.budget_period_startdate > f.budget_period_enddate ) {
25               _alertString += "\n- " + _("Start date must be before end date");
26             }
27
28             if(_alertString.length==0){
29               f.submit();
30             } else {
31               alertString += _("Form not submitted because of the following problem(s)");
32               alertString += "\n-----------------------------------------\n";
33               alertString += _alertString;
34               alert(alertString);
35             }
36     }
37     function Check(f) {
38             var ok=1;
39             var _alertString="";
40             var alertString2;
41
42             if (!(isNotNull(f.budget_period_startdate,1))) {
43                     _alertString += "\n- " + _("Start date missing");
44             }
45
46             if (!(isNotNull(f.budget_period_enddate,1))) {
47                     _alertString += "\n- " + _("End date missing");
48             }
49
50             if ( f.budget_period_startdate >   f.budget_period_enddate )  {
51                     _alertString += "\n- " + _("Start date must be before end date");
52             }
53
54             if (!(isNotNull(f.budget_period_description,1))) {
55                     _alertString += "\n- " + _("Description missing");
56             }
57
58             if (!(isNum(f.budget_period_total))) {
59                     _alertString += "\n- " + _("Amount must be a valid number, or empty");
60             }
61
62 /*
63                         checkBudgetTotal(f) {
64                         }
65 */
66
67             if (_alertString.length==0) {
68                     f.submit();
69             } else {
70                     alertString2  = _("Form not submitted because of the following problem(s)");
71                     alertString2 += "\n------------------------------------------------------------------------------------\n";
72                     alertString2 += _alertString;
73                     alert(alertString2);
74             }
75     }
76
77
78
79     [% IF ( dateformat == 'metric' ) %]
80         dt_add_type_uk_date();
81     [% END %]
82     $(document).ready(function() {
83         var tabs = $('#budgetsTabs').tabs();
84         [% IF ( tab ) %]
85             tabs.tabs('select', [% tab %]);
86         [% END %]
87         $("table").dataTable($.extend(true, {}, dataTablesDefaults, {
88             "aoColumnDefs": [
89                 {
90                     [% IF ( dateformat == 'metric' ) %]
91                         "aTargets": [ 1, 2 ], "sType": "uk_date",
92                     [% END %]
93                     "bSortable": false, 'aTargets':['_all'],
94                 },
95             ],
96             "sPaginationType": "four_button",
97             "bAutoWidth": false,
98             "bPaginate": false,
99             "bInfo": false,
100             "bFilter": false,
101         } ) );
102     });
103 </script>
104
105 <title>
106     Koha &rsaquo; Administration &rsaquo; Budgets
107
108     [% IF ( add_form ) %]&rsaquo;
109         [% IF ( budget_period_id ) %]
110             Modify budget'[% budget_period_id %]'
111         [% ELSE %]
112             Add budget
113         [% END %]
114     [% END %]
115     [% IF ( duplicate_form ) %]&rsaquo; Duplicate budget[% END %]
116     [% IF ( delete_confirm ) %]&rsaquo;
117             Delete budget '[% budget_period_description %]'?
118     [% END %]
119     [% IF ( delete_confirmed ) %]&rsaquo;
120         Data deleted
121     [% END %]
122 </title>
123
124
125 </head>
126
127 <body id="admin_aqbudgetperiods" class="admin">
128
129 [% INCLUDE 'header.inc' %]
130 [% INCLUDE 'budgets-admin-search.inc' %]
131
132 <!-- ################################################################################# -->
133 <!-- BREADCRUMBS -->
134 <!-- ################################################################################# -->
135
136 <div id="breadcrumbs">
137     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
138     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
139
140     <!-- add or modify a budget period -->
141     <!-- ####################################### -->
142     [% IF ( add_form ) %]
143         <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budget</a> &rsaquo;
144         [% IF ( budget_period_id ) %]
145             Modify budget [% budget_period_description %]
146
147         [% ELSE %]
148             Add budget
149         [% END %]
150     [% END %]
151
152     <!-- delete a budget period -->
153     <!-- ################################ -->
154     [% IF ( delete_confirm ) %]
155         <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo;
156         [% IF ( total ) %]
157             Cannot delete budget '[% budget_period_description %]'
158         [% ELSE %]
159             Delete budget '[% budget_period_description %]'?
160         [% END %]
161     [% END %]
162     <!-- duplicate a budget -->
163     [% IF ( duplicate_form ) %]
164         <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo; Duplicate budget
165     [% END %]
166     <!-- display budget periods list -->
167     <!-- ########################################## -->
168     [% IF ( else ) %]
169         Budgets administration
170     [% END %]
171 </div>
172
173 <div id="doc3" class="yui-t2">
174 <div id="bd">
175 <div id="yui-main">
176 <div class="yui-b">
177
178 [% INCLUDE 'budgets-admin-toolbar.inc' %]
179
180 [% IF ( duplicate_form ) %]
181 <h3>Duplicate budget</h3>
182 <form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" 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 %]" />
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 | $KohaDates %]" class="datepickerfrom" />
192                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
193     </li>
194     <li>
195
196     <label class="required" for="to">End date</label>
197     <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | $KohaDates %]" class="datepickerto" />
198                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
199     </li>
200
201     </ol>
202     </fieldset>
203
204     <fieldset class="action">
205         <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 %]">Cancel</a>
206     </fieldset>
207
208 </form>
209
210 [% END %]
211
212 [% IF ( add_form ) %]
213     <!--  add or modify a budget period   -->
214
215     [% IF ( budget_period_id ) %]
216         <h3>Modify budget</h3>
217     [% ELSE %]
218         <h3>Add budget</h3>
219         [% END %]
220 <form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post">
221     <fieldset class="rows">
222     <!-- ################################################################################# -->
223     <!-- display information about the budget period that must be added or modified -->
224     <!-- ################################################################################# -->
225     <input type="hidden" name="op" value="add_validate" />
226     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
227     <ol>
228     <li>
229     <label class="required" for="from">Start date</label>
230     <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | $KohaDates %]" class="datepickerfrom" />
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 | $KohaDates %]" class="datepickerto" />
237                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
238     </li>
239
240     <li>
241         <!-- DESCRIPTION -->
242         <!-- ############################## -->
243         <label class="required" for="budget_period_description">Description</label>
244         <input type="text" id="budget_period_description" name="budget_period_description"
245         size="48" maxlength="80" value="[% budget_period_description %]" />
246     </li>
247
248     <li>
249         <!-- TOTAL -->
250         <!-- ############################## -->
251         <label for="budget_period_total">Total amount</label>
252         <input type="text" id="budget_period_total" name="budget_period_total"
253         size="10" maxlength="80" value="[% budget_period_total %]" />
254     </li>
255
256     <li>
257         <!-- ACTIVE -->
258         <!-- ############################## -->
259         <label for="budget_period_active">Make budget active</label>
260         [% 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 %]
261     </li>
262
263     <li>
264         <!-- LOCK  -->
265         <!-- ############################## -->
266         <label for="budget_period_locked">Lock budget</label>
267         [% 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 %]
268     </li>
269     </ol>
270     </fieldset>
271
272     <fieldset class="action">
273         <!-- "save changes" button -->
274         <!-- ###################################### -->
275         <input type="button" value="Save changes"  onclick="Check(this.form)"    />
276         <!--             <input type="submit" value="Save Changes"  />  -->
277         [% IF ( budget_period_id ) %]<a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]" class="cancel">Cancel</a>[% END %]
278     </fieldset>
279
280 </form>
281
282 [% END %]
283
284 <!-- ####################################################################### -->
285 <!-- delete a budget period -->
286 <!-- ####################################################################### -->
287
288 [% IF ( delete_confirm ) %]
289     [% IF ( total ) %]
290         <div class="dialog message">
291         <h3>Cannot delete budget</h3>
292         <p><strong>This record is used [% total %] times</strong>
293         . Deletion is not possible.</p>
294     [% ELSE %]
295         <div class="dialog alert">
296         <h3>Delete budget '[% budget_period_description %]'?</h3>
297     [% END %]
298
299     <!-- ############################################################# -->
300     <!-- "delete" and "cancel" buttons    -->
301     <!-- ############################################################# -->
302
303     <form action="[% script_name %]" method="post">
304         <input type="hidden" name="op" value="delete_confirmed" />
305         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
306         <input type="submit" class="approve" value="Delete" />
307     </form>
308
309     <form action="[% script_name %]" method="post">
310         <input type="submit" class="deny" value="Cancel" />
311     </form>
312
313     </div>
314 [% END %]
315 <!--  DEFAULT  display budget periods list -->
316 [% IF ( else ) %]
317   <h2>Budgets administration</h2>
318
319   [% INCLUDE 'budgets-active-currency.inc' %]
320
321   <div id="budgetsTabs" class="toptabs">
322     <ul>
323         <li><a href="#active">Active Budgets</a></li>
324         <li><a href="#inactive">Inactive Budgets</a></li>
325     </ul>
326
327     <div id="active">
328       <h3>Active Budgets</h3>
329       [% IF ( period_active_loop ) %]
330         <table id="activeperiodst">
331           <thead>
332             <tr>
333               <th>Budget name</th>
334               <th>Start date</th>
335               <th>End date</th>
336               <th>Locked</th>
337               <th>Total</th>
338               <th>Actions</th>
339             </tr>
340           </thead>
341           <tbody>
342               [% FOREACH period_active IN period_active_loop %]
343                 <tr>
344                 <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_active.budget_period_id %]" title="View funds for [% period_active.budget_period_description %]">[% period_active.budget_period_description %]</a></td>
345                 <td>[% period_active.budget_period_startdate | $KohaDates %]</td>
346                 <td>[% period_active.budget_period_enddate | $KohaDates %]</td>
347                 <td>
348                   [% IF ( period_active.budget_period_locked ) %]
349                     <span style="color:green;">Locked</span>&nbsp;
350                   [% END %]
351                 </td>
352                 <td align='right'>[% period_active.budget_period_total %]</td>
353                 <td>
354                   <a href="[% script_name %]?op=add_form&amp;budget_period_id=[% period_active.budget_period_id |html %]">Edit</a>
355                   <a href="[% script_name %]?op=delete_confirm&amp;budget_period_id=[% period_active.budget_period_id %]">Delete</a>
356                   <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% period_active.budget_period_id %]">Add Fund</a>
357                 </td>
358                 </tr>
359               [% END %]
360           </tbody>
361         </table>
362       [% ELSE %]
363         No active budgets
364       [% END %]
365       <div class="paginationBar">[% active_pagination_bar %]</div>
366     </div>
367     <div id="inactive">
368       <h3>Inactive Budgets</h3>
369       [% IF ( period_inactive_loop ) %]
370         <table id="inactiveperiodst">
371           <thead>
372               <tr>
373                   <th>Budget name</th>
374                   <th>Start date</th>
375                   <th>End date</th>
376                   <th>Locked</th>
377                   <th>Total</th>
378                   <th>Actions</th>
379               </tr>
380           </thead>
381           <tbody>
382               [% FOREACH period_loo IN period_inactive_loop %]
383                   [% IF ( loop.odd ) %]
384                       <tr>
385                   [% ELSE %]
386                       <tr class="highlight">
387                   [% END %]
388                   <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% period_loo.budget_period_id %]" title="View funds for [% period_loo.budget_period_description %]">[% period_loo.budget_period_description %]</a></td>
389                   <td>[% period_loo.budget_period_startdate | $KohaDates %]</td>
390                   <td>[% period_loo.budget_period_enddate | $KohaDates %]</td>
391                   <td> [% IF ( period_loo.budget_period_locked ) %]<span style="color:green;">Locked</span>&nbsp;[% ELSE %][% END %] </td>
392                   <td align='right'>[% period_loo.budget_period_total %]</td>
393                   <td>
394                       <a href="[% period_loo.script_name %]?op=add_form&amp;budget_period_id=[% period_loo.budget_period_id |html %]">Edit</a>
395                       <a href="[% period_loo.script_name %]?op=delete_confirm&amp;budget_period_id=[% period_loo.budget_period_id %]">Delete</a>
396                   <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% period_loo.budget_period_id %]">Add fund</a>
397                   </td>
398                   </tr>
399               [% END %]
400           </tbody>
401         </table>
402       [% ELSE %]
403         No inactive budgets
404       [% END %]
405       <div class="pages">[% inactive_pagination_bar %]</div>
406     </div>
407   </div>
408 [% END %]
409
410
411 </div>
412 </div>
413 <div class="yui-b">
414 [% INCLUDE 'acquisitions-menu.inc' %]
415 </div>
416 </div>
417
418 [% INCLUDE 'intranet-bottom.inc' %]