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