Bug 12164: On cloning budget period, mark original budget as inactive
[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     <li>
189       <label for="mark_as_inactive">Mark the original budget as inactive</label>
190       <input type="checkbox" id="mark_as_inactive" name="mark_original_budget_as_inactive" />
191     </li>
192
193     </ol>
194     </fieldset>
195
196     <fieldset class="action">
197         <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>
198     </fieldset>
199
200 </form>
201
202 [% END %]
203
204 [% IF ( add_form ) %]
205     <!--  add or modify a budget period   -->
206
207     [% IF ( budget_period_id ) %]
208         <h3>Modify budget</h3>
209     [% ELSE %]
210         <h3>Add budget</h3>
211         [% END %]
212 <form action="/cgi-bin/koha/admin/aqbudgetperiods.pl" name="f" method="post">
213     <fieldset class="rows">
214     <!-- ################################################################################# -->
215     <!-- display information about the budget period that must be added or modified -->
216     <!-- ################################################################################# -->
217     <input type="hidden" name="op" value="add_validate" />
218     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
219     <ol>
220     <li>
221     <label class="required" for="from">Start date: </label>
222     <input type="text" size="10" id="from" name="budget_period_startdate" value="[% budget_period_startdate | $KohaDates %]" class="datepickerfrom" />
223                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
224     </li>
225     <li>
226
227     <label class="required" for="to">End date: </label>
228     <input type="text" size="10" id="to" name="budget_period_enddate" value="[% budget_period_enddate | $KohaDates %]" class="datepickerto" />
229                                 <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
230     </li>
231
232     <li>
233         <!-- DESCRIPTION -->
234         <!-- ############################## -->
235         <label class="required" for="budget_period_description">Description: </label>
236         <input type="text" id="budget_period_description" name="budget_period_description"
237         size="48" maxlength="80" value="[% budget_period_description %]" />
238     </li>
239
240     <li>
241         <!-- TOTAL -->
242         <!-- ############################## -->
243         <label for="budget_period_total">Total amount: </label>
244         <input type="text" id="budget_period_total" name="budget_period_total"
245         size="10" maxlength="80" value="[% budget_period_total %]" />
246     </li>
247
248     <li>
249         <!-- ACTIVE -->
250         <!-- ############################## -->
251         <label for="budget_period_active">Make budget active: </label>
252         [% 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 %]
253     </li>
254
255     <li>
256         <!-- LOCK  -->
257         <!-- ############################## -->
258         <label for="budget_period_locked">Lock budget: </label>
259         [% 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 %]
260     </li>
261     </ol>
262     </fieldset>
263
264     <fieldset class="action">
265         <!-- "save changes" button -->
266         <!-- ###################################### -->
267         <input type="button" value="Save changes"  onclick="Check(this.form)"    />
268         <!--             <input type="submit" value="Save Changes"  />  -->
269         [% IF ( budget_period_id ) %]<a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]" class="cancel">Cancel</a>[% END %]
270     </fieldset>
271
272 </form>
273
274 [% END %]
275
276 <!-- ####################################################################### -->
277 <!-- delete a budget period -->
278 <!-- ####################################################################### -->
279
280 [% IF ( delete_confirm ) %]
281     [% IF ( total ) %]
282         <div class="dialog message">
283         <h3>Cannot delete budget</h3>
284         <p><strong>This record is used [% total %] times</strong>
285         . Deletion is not possible.</p>
286     [% ELSE %]
287         <div class="dialog alert">
288         <h3>Delete budget '[% budget_period_description %]'?</h3>
289     [% END %]
290
291     <!-- ############################################################# -->
292     <!-- "delete" and "cancel" buttons    -->
293     <!-- ############################################################# -->
294
295     <form action="[% script_name %]" method="post">
296         <input type="hidden" name="op" value="delete_confirmed" />
297         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
298         <input type="submit" class="approve" value="Delete" />
299     </form>
300
301     <form action="[% script_name %]" method="post">
302         <input type="submit" class="deny" value="Cancel" />
303     </form>
304
305     </div>
306 [% END %]
307 <!--  DEFAULT  display budget periods list -->
308 [% IF ( else ) %]
309   <h2>Budgets administration</h2>
310
311   [% INCLUDE 'budgets-active-currency.inc' %]
312
313   <div id="budgetsTabs" class="toptabs">
314     <ul>
315         <li><a href="#active">Active budgets</a></li>
316         <li><a href="#inactive">Inactive budgets</a></li>
317     </ul>
318
319     <div id="active">
320       [% IF ( period_active_loop ) %]
321         <table id="activeperiodst">
322           <thead>
323             <tr>
324               <th>Budget name</th>
325               <th class="title-string">Start date</th>
326               <th class="title-string">End date</th>
327               <th>Locked</th>
328               <th>Total</th>
329               <th>Actions</th>
330             </tr>
331           </thead>
332           <tbody>
333               [% FOREACH period_active IN period_active_loop %]
334                 <tr>
335                 <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>
336                 <td><span title="[% period_active.budget_period_startdate %]">[% period_active.budget_period_startdate | $KohaDates %]</span></td>
337                 <td><span title="[% period_active.budget_period_enddate %]">[% period_active.budget_period_enddate | $KohaDates %]</span></td>
338                 <td>
339                   [% IF ( period_active.budget_period_locked ) %]
340                     <span style="color:green;">Locked</span>&nbsp;
341                   [% END %]
342                 </td>
343                 <td class="data">[% period_active.budget_period_total %]</td>
344                 <td>
345                   <a href="[% script_name %]?op=add_form&amp;budget_period_id=[% period_active.budget_period_id |html %]">Edit</a>
346                   <a href="[% script_name %]?op=delete_confirm&amp;budget_period_id=[% period_active.budget_period_id %]">Delete</a>
347                   <a href="[% script_name %]?op=duplicate_form&amp;budget_period_id=[% period_active.budget_period_id %]">Duplicate</a>
348                   <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% period_active.budget_period_id %]">Add fund</a>
349                 </td>
350                 </tr>
351               [% END %]
352           </tbody>
353         </table>
354       [% ELSE %]
355         No active budgets
356       [% END %]
357       <div class="paginationBar">[% active_pagination_bar %]</div>
358     </div>
359     <div id="inactive">
360       [% IF ( period_inactive_loop ) %]
361         <table id="inactiveperiodst">
362           <thead>
363               <tr>
364                   <th>Budget name</th>
365                   <th class="title-string">Start date</th>
366                   <th class="title-string">End date</th>
367                   <th>Locked</th>
368                   <th>Total</th>
369                   <th>Actions</th>
370               </tr>
371           </thead>
372           <tbody>
373               [% FOREACH period_loo IN period_inactive_loop %]
374                   [% IF ( loop.odd ) %]
375                       <tr>
376                   [% ELSE %]
377                       <tr class="highlight">
378                   [% END %]
379                   <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>
380                   <td><span title="[% period_loo.budget_period_startdate %]">[% period_loo.budget_period_startdate | $KohaDates %]</span></td>
381                   <td><span title="[% period_loo.budget_period_enddate %]">[% period_loo.budget_period_enddate | $KohaDates %]</span></td>
382                   <td> [% IF ( period_loo.budget_period_locked ) %]<span style="color:green;">Locked</span>&nbsp;[% ELSE %][% END %] </td>
383                   <td class="data">[% period_loo.budget_period_total %]</td>
384                   <td>
385                       <a href="[% script_name %]?op=add_form&amp;budget_period_id=[% period_loo.budget_period_id |html %]">Edit</a>
386                       <a href="[% script_name %]?op=delete_confirm&amp;budget_period_id=[% period_loo.budget_period_id %]">Delete</a>
387                       <a href="[% script_name %]?op=duplicate_form&amp;budget_period_id=[% period_loo.budget_period_id %]">Duplicate</a>
388                   <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_period_id=[% period_loo.budget_period_id %]">Add fund</a>
389                   </td>
390                   </tr>
391               [% END %]
392           </tbody>
393         </table>
394       [% ELSE %]
395         No inactive budgets
396       [% END %]
397       <div class="pages">[% inactive_pagination_bar %]</div>
398     </div>
399   </div>
400 [% END %]
401
402
403 </div>
404 </div>
405 <div class="yui-b">
406 [% INCLUDE 'acquisitions-menu.inc' %]
407 </div>
408 </div>
409
410 [% INCLUDE 'intranet-bottom.inc' %]