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