Bug 19592: Move admin templates JavaScript to the footer: Acquisitions
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqplan.tt
1 [% USE Price %]
2 [% SET footerjs = 1 %]
3 [% INCLUDE 'doc-head-open.inc' %]
4 <title>Koha &rsaquo; Administration &rsaquo; Budgets &rsaquo; Funds &rsaquo; Planning for [% budget_period_description %] by [% authcat %]</title>
5 [% INCLUDE 'doc-head-close.inc' %]
6 <style type="text/css">td.locked { background-image: url('[% interface %]/[% theme %]/img/locked.png'); padding-left : 20px; background-repeat: no-repeat; background-position: 5px 5px; } a.control { font-size:85%;text-decoration:none; }</style>
7 </head>
8
9 <body id="admin_aqplan" class="admin">
10 [% INCLUDE 'header.inc' %]
11 [% INCLUDE 'budgets-admin-search.inc' %]
12
13 <div id="breadcrumbs">
14     <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
15     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo;
16     <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo; 
17     <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Funds</a> &rsaquo;
18     <a href="/cgi-bin/koha/admin/aqplan.pl?budget_period_id=[% budget_period_id %]">Planning</a> &rsaquo;
19 </div>
20
21 <div id="doc3" class="yui-t2">
22 <div id="bd">
23 <div id="yui-main">
24 <div class="yui-b">
25
26 [% INCLUDE 'budgets-admin-toolbar.inc' %]
27
28 <form method="post" id="Aform" name="Aform"  action="/cgi-bin/koha/admin/aqplan.pl">
29 <h3>Planning for [% budget_period_description %] by [% authcat %]</h3>
30 <input type="hidden" name="authcat" value="[% authcat %]" />
31 <!-- Budget Lines -->
32
33     [% IF ( budget_lines ) %]
34
35         [% INCLUDE 'budgets-active-currency.inc' %]
36         [% IF ( show_actual ) %]
37             <p><b>Each cell contain both actual and estimated values.</b></p>
38         [% ELSE %]
39             <p><b>Cells contain estimated values only.</b></p>
40         [% END %]
41
42     <p id="selections">
43         <strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span>
44         [% FOREACH authvals_ro IN authvals_row %]
45             <span class="selected"><label><input type="checkbox" checked="checked" id="col[% authvals_ro.colnum %]">[% authvals_ro.code %]</label></span>
46         [% END %]
47     </p>
48     <table id="plan">
49     <thead>
50     <tr>
51     <th>Fund name</th>
52     <th>Fund total</th>
53
54     [% FOREACH authvals_ro IN authvals_row %]
55          [% IF ( authvals_ro.display ) %]
56             <th id="col[% authvals_ro.code %]" class="[% authvals_ro.colnum %]">
57         [% ELSE %]
58             <th id="col[% authvals_ro.code %]" style="display:none;" class="[% authvals_ro.colnum %]">
59         [% END %]
60
61     [% authvals_ro.code %]</th>
62     [% END %]
63
64     <th class="remaining">Fund remaining</th><th>&nbsp;</th>
65     </tr>
66     </thead>
67
68     <tbody>
69     [% FOREACH budget_line IN budget_lines %]
70     <tr>
71         [% IF ( budget_line.budget_lock ) %]
72             <td class="locked" title="Fund locked">
73         [% ELSE %]
74             <td>
75         [% END %]
76         <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=[% budget_line.budget_id %]&amp;budget_period_id=[% budget_period_id %]">[% budget_line.budget_name %]</a></td>
77         <td><span id="[% budget_line.budget_amount %]">[% budget_line.budget_amount | $Price %]&nbsp;</span>
78
79
80         <!-- NEXT DIV ELEMENT IS USED BY JS FOR CALC-ING AUTO-FILL AND ESTIMATED AMOUNTS -->
81         <div style="display:none;" id="budget_tot_[% budget_line.budget_id %]">[% budget_line.budget_amount %]</div></td>
82
83         [% FOREACH line IN budget_line.lines %]
84             [% IF ( line.display ) %]
85                 <td class="[% line.colnum %]">
86             [% ELSE %]
87                 <td style="display:none;" class="[% line.colnum %]">
88             [% END %]
89             <table class="invis">
90                 <tr>
91                     [% IF show_actual %]
92                         <td    >[% line.actual_amount %]</td>
93                     [% END %]
94                 <td>
95
96                 [% IF ( line.budget_lock ) %]
97                     [% line.estimated_amount %]&nbsp;
98                     <input type="hidden" style="text-align: right;"  name="[% line.cell_name %]" value="[% line.estimated_amount %]"   />
99                 [% ELSE %]
100                     <input type="text" style="text-align: right;  width:90%; " size="6" name="[% line.cell_name %]"  value="[% line.estimated_amount %]"  id="budget_[% line.budget_id %][% line.colnum %]" class="plan_entry_[% line.budget_id %]" onchange="calcTotalRow(this);" />
101                 [% END %]
102
103                 </td></tr>
104             </table>
105             </td>
106         [% END %]
107
108         <td>
109         <table class="invis">
110             <tr>
111        [% IF show_actual %]
112             [% IF ( budget_line.act_negative ) %]
113                 <td style="color: red;">
114             [% ELSIF ( budget_line.act_positive ) %]
115                 <td style="color: green;">
116             [% ELSE %]
117                 <td>
118             [% END %]
119                     [% budget_line.budget_act_remain %]
120             </td>
121         [% END %]
122
123         [% IF ( budget_line.est_negative ) %]
124             <td style="color: red;" id="budget_est_[% budget_line.budget_id %]">
125         [% ELSIF ( budget_line.est_positive ) %]
126             <td style="color: green;" id="budget_est_[% budget_line.budget_id %]">
127         [% ELSE %]
128             <td id="budget_est_[% budget_line.budget_id %]">
129         [% END %] 
130                 [% budget_line.budget_est_remain | $Price %]&nbsp;
131             </td>
132             </tr>
133         </table>
134         </td>
135
136         <td>
137              [% UNLESS ( budget_line.budget_lock ) %]
138                     <input type="button"  onclick="autoFillRow('[% budget_line.budget_id %]')" value="Auto-fill row"/>
139             [% ELSE %]
140              <div style="color:red;">not owned</div>
141             [% END %]
142         </td>
143         </tr>
144     [% END %]
145     </tbody>
146     </table>
147
148     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
149     [% IF ( budget_period_locked ) %]
150         <!-- <input STYLE="background: gray;"   type="submit" value="Save" disabled="disabled"/> -->
151     [% ELSE %]
152         <fieldset class="action"><input type="button"  onclick="Check(this.form)" value="Save"/></fieldset>
153     [% END %]
154
155
156 <div id="hide_div">
157     [% FOREACH authvals_ro IN authvals_row %]
158
159      [% UNLESS ( authvals_ro.display ) %]
160         <input type="hidden" value="[% authvals_ro.code %]"  name="hide_cols"/>
161      [% END %]
162     [% END %]
163
164  </div>
165
166
167 </form>
168
169         [% ELSIF not budget_period_id %]
170 <div class="dialog alert">That budget does not exist! Please select a budget to continue.</div>
171         [% ELSE %]
172 <div class="dialog message">No funds to display for this search criteria</div>
173         [% END %]
174
175
176 </div>
177 </div>
178 <div class="yui-b">
179
180 <form method="post" action="/cgi-bin/koha/admin/aqplan.pl">
181     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
182 <fieldset class="brief">
183 <h4>Filter</h4>
184 [% BLOCK planning_types %]
185 [%   SWITCH type %]
186 [%     CASE 'MONTHS'    %]<span>by months</span>
187 [%     CASE 'ITEMTYPES' %]<span>by item types</span>
188 [%     CASE 'BRANCHES'  %]<span>by libraries</span>
189 [%     CASE             %]<span>by [% type %]</span>
190 [%   END %]
191 [% END %]
192 <ol>
193     <li>
194         <label for="authcat"> Select planning type:</label>
195         <select name="authcat" id="authcat" size="1">
196         [% FOREACH value IN authcat_dropbox.values %]
197             [% IF ( value == authcat_dropbox.default ) %]
198             <option value="[% value %]" selected="selected">[% PROCESS planning_types type=value %]</option>
199             [% ELSE %]
200             <option value="[% value %]">[% PROCESS planning_types type=value %]</option>
201             [% END %]
202         [% END %]
203         </select>
204     </li>
205     <li class="radio">
206     [% IF ( show_mine ) %]
207         <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
208     [% ELSE %]
209         <input type="checkbox" id="show_mine"  name="show_mine" value="1"  />
210     [% END %]
211     <label for="show_mine">Show my funds only</label>
212     </li>
213
214     <li class="radio">
215     [% IF ( show_active ) %]
216         <input type="checkbox" id="show_active" name="show_active" value="1" checked="checked" />
217     [% ELSE %]
218         <input type="checkbox" id="show_active" name="show_active" value="1" />
219         [% END %]
220     <label for="show_active">Show active funds only</label>
221     </li>
222
223
224     <li class="radio">
225         [% IF ( show_actual ) %]
226             <input type="checkbox" id="show_actual" name="show_actual" value="1" checked="checked" />
227         [% ELSE %]
228             <input type="checkbox" id="show_actual" name="show_actual" value="1"  />
229         [% END %]
230         <label for="show_actual">Show actual/estimated values</label>
231     </li>
232     </ol>
233     <fieldset class="action">
234         <input type="submit" name="option_submit" value="Submit" />
235         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
236     </fieldset>
237 </fieldset>
238 </form>
239 [% IF ( budget_lines ) %]
240 <form method="post" action="/cgi-bin/koha/admin/aqplan.pl">
241 <fieldset class="brief">
242 <h4>Export</h4>
243     <ol>
244         <li><label for="basename">Output to a file named: </label><input type="text" name="basename" id="basename" value="Export" /></li>
245         <li><label class="inline" for="MIME">Into an application</label>
246             <select name="MIME" id="MIME" size="1">
247             [% FOREACH value IN CGIextChoice %]
248                 <option value="[% value %]">[% value %]</option>
249             [% END %]
250             </select>
251             <select name="sep" id="sep" size="1">
252             [% FOREACH value IN CGIsepChoice %]
253                 <option value="[% value %]">[% value %]</option>
254             [% END %]
255             </select>
256         </li>
257     </ol>
258     <fieldset class="action">    <input type="submit" value="Submit"/>
259     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
260     <input type="hidden" name="report_name" value="[% report_name %]" />
261     <input type="hidden" name="output" value="file" /></fieldset>
262     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
263     <input type="hidden" name="authcat" value="[% authcat %]" />
264     </fieldset>
265 </form>
266 [% END %]
267
268 [% INCLUDE 'acquisitions-menu.inc' %]
269 </div>
270 </div>
271 [% MACRO jsinclude BLOCK %]
272     <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
273     <script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script>
274     <script type="text/javascript">
275     //<![CDATA[
276         function Check(f) {
277                 var ok=1;
278                 var _alertString="";
279                 var alertString2;
280                 var arr = document.getElementsByName('est_total')
281
282                 for ( var i=0, len=arr.length; i<len; ++i ){
283                         var tot = arr[i].innerHTML;
284
285                         if (tot == 'NaN') {
286                             _alertString += "\n- " + _("One or more cell values is non-numeric");
287                         }
288                 }
289
290                 if (_alertString.length==0) {
291
292                     var op  = document.createElement('input');
293                     op.setAttribute("type","hidden");
294                     op.setAttribute("name","op");
295                     op.setAttribute("value","save");   //ohh the pain...
296
297                     document.Aform.appendChild(op);
298                     document.Aform.submit()
299
300                 } else {
301                         alertString2  = _("Form not submitted because of the following problem(s)");
302                         alertString2 += "\n------------------------------------------------------------------------------------\n";
303                         alertString2 += _alertString;
304                         alert(alertString2);
305                 }
306         }
307         $(document).ready(function() {
308             $("#selections input").on("change",function(e){
309                 var num = $(this).attr("id");
310                 if(num == 'showall'){
311                     showAllColumns();
312                     e.stopPropagation();
313                 } else if(num == 'hideall'){
314                     hideAllColumns();
315                     e.stopPropagation();
316                 } else {
317                     if($(this).prop("checked")){
318                         showColumn(num);
319                     } else {
320                         hideColumn(num);
321                     }
322                 }
323             });
324         });
325     //]]>
326     </script>
327 [% END %]
328 [% INCLUDE 'intranet-bottom.inc' %]