Merge remote-tracking branch 'origin/new/bug_5327'
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgets.tt
1 [% INCLUDE 'doc-head-open.inc' %]
2 <title>Koha &rsaquo; Administration &rsaquo; Funds[% IF ( add_form ) %] &rsaquo; [% IF ( budget_id ) %]Modify Fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add Fund [% END %][% END %]</title>
3 [% INCLUDE 'doc-head-close.inc' %]
4 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
5
6 [% IF ( add_form ) %]
7 <script type="text/javascript">
8 //<![CDATA[
9 //
10      var actTotal ="";
11
12     function ownerRemove(f) {
13         document.getElementById('budget_owner_name').innerHTML = '';
14         document.getElementById('budget_owner_id').value = '';
15     }
16
17     function Check(f) {
18         var ok=1;
19         var _alertString="";
20         var alertString2;
21
22         // var actTotal ="";
23
24         if (!(isNotNull(f.budget_code,1))) {
25             _alertString += _("- Budget code cannot be blank") + "\n";
26         }
27
28         if (!(isNotNull(f.budget_name,1))) {
29             _alertString += _("- Budget name cannot be blank") + "\n";
30         }
31
32         if (!(isNotNull(f.budget_amount,1))) {
33             _alertString += _("- Budget amount cannot be blank") + "\n";
34         }
35
36         var budgetId;
37         if   (typeof(f.budget_id ) != "undefined")  {
38             budgetId = f.budget_id.value
39         }
40
41         var newBudgetParent;
42
43 //  hack to test if selected parent_id in scrolling-list...
44 //  if value == 'undef' its got a selected_parent :/
45         if(f.budget_parent_id){
46             var chkAdd   =  f.budget_parent_id.value ;
47             if  (     typeof(chkAdd ) != "undefined") {
48                 newBudgetParent  =  f.budget_parent_id.value
49             } else {
50                 newBudgetParent  =  f.budget_parent_id.item(0).value
51             }
52
53             if   (budgetId  > 0)  {  ; //its a mod ...
54                 // if parent == curent-budget, fail...
55                 if ( newBudgetParent  ==  budgetId     ) {
56                         _alertString += _("- Budget parent is current budget") + "\n";
57                 }
58
59                 else if (newBudgetParent) {
60                     var result = checkBudgetParent(  budgetId , newBudgetParent   );
61                     if (result) {
62                         _alertString += result;
63                     }
64                 }
65             }
66         }
67
68          // else do lookup
69         var budgetTotal = Math.abs(f.budget_amount.value);
70         var result =   budgetExceedsParent  (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
71         if (result) {
72             _alertString += result;
73         }
74
75         if (_alertString.length==0) {
76             document.Aform.submit();
77         } else {
78             alertString2 = _("Form not submitted because of the following problem(s)");
79             alertString2 += "\n------------------------------------------------------------------------------------\n\n";
80             alertString2 += _alertString;
81             alert(alertString2);
82         }
83     }
84 //]]>
85 </script>
86 [% ELSE %]
87 <link href="[% themelang %]/lib/jquery/plugins/treetable/stylesheets/jquery.treeTable.css" rel="stylesheet" type="text/css" />
88
89 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
90 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/treetable/jquery.treeTable.min.js"></script>
91 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.qtip.js"></script>
92
93 <script type="text/javascript">
94 //<![CDATA[
95     //
96     $(document).ready(function() {
97         var tooltipcontent = $(".tooltipcontent");
98         tooltipcontent.hide();
99
100         $(".tooltiped td").each(function (){
101             contentelem = $(this).parent().children().filter(".tooltipcontent");
102             if(contentelem.html() != ""){
103             $(this).qtip({
104                 content: contentelem.html(),
105                 show: "mouseover",
106                 hide: "mouseout",
107                 style: {
108                     name: "light",
109                     tip: "bottomLeft",
110                     border: {
111                         radius: 5,
112                         color: "#356CA1"
113                     }
114                 },
115                 position: {
116                     corner: {
117                         target: "topRight",
118                         tooltip: "bottomRight"
119                     }
120                 }
121             });
122             }
123         });
124         [% IF ( notree ) %]
125         $("#budgeth").tablesorter({
126             widgets : ['zebra'],
127             sortList: [[0,0]],
128             headers: { 7: { sorter: false }}
129         });
130         [% ELSE %]
131         $("#budgeth").treeTable();
132         [% END %]
133
134         $("#filterbutton").click(function() {
135             $("#fundfilters").slideToggle(0);
136             $("#content").css({ marginLeft:  $("#content").css("marginLeft") == "4em"?"15em":"4em"});
137         });
138     });
139 //]]>
140 </script>
141 [% END %]
142
143 </head>
144 <body>
145 [% INCLUDE 'header.inc' %]
146 [% INCLUDE 'budgets-admin-search.inc' %]
147
148 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
149     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo; [% IF ( else ) %]Funds for '[% budget_period_description %]'[% END %][% IF ( add_form ) %]
150     <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id %]">Funds</a> &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund[% END %][% END %]  [% IF ( delete_confirm ) %]
151     <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> &rsaquo; Delete fund?[% END %]</div>
152
153 <div id="doc3" class="yui-t2">
154 <div id="bd">
155 <div id="yui-main">
156 <div class="yui-b" id="content">
157
158 [% UNLESS ( delete_confirm ) %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
159 [% IF ( else ) %]
160
161 <h1>Funds for '[% budget_period_description %]'</h1>
162
163 [% INCLUDE 'budgets-active-currency.inc' %]
164
165 <table id="budgeth">
166     <thead>
167         <tr>
168             <th>Fund code</th>
169             <th>Fund name</th>
170             <th>Total<br />allocated</th>
171             <th>Base-level<br />allocated</th>
172             <th>Base-level<br />spent</th>
173             <th>Total sublevels<br />spent</th>
174             <th>Base-level<br />remaining</th>
175             <th class="tooltipcontent">&nbsp;</th>
176             <th>Actions</th>
177         </tr>
178     </thead>
179 <tfoot>
180     <tr>
181     <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
182     <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
183     <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
184     <th class="data">[% base_spent_total %]</th>
185     <th class="data">[% base_spent_total %]</th>
186     <th class="data">[% base_remaining_total %]</th>
187     <th class="tooltipcontent"></th>
188     <th></th>
189     </tr>
190     </tfoot>
191     <tbody>
192     [% IF ( budget ) %]
193         [% FOREACH budge IN budget %]
194     [% IF ( budge.toggle ) %]
195     <tr id="node-[% budge.budget_id %]" class="highlight[% IF ( budge.budget_parent_id ) %] child-of-node-[% budge.budget_parent_id %][% END %] tooltiped">
196     [% ELSE %]
197     <tr id="node-[% budge.budget_id %]" class="tooltiped [% IF ( budge.budget_parent_id ) %] child-of-node-[% budge.budget_parent_id %][% END %]">
198     [% END %]
199
200     <td>[% budge.budget_code_indent %]</td>
201     <td>[% budge.budget_name %]</td>
202     <td class="data">[% budge.budget_amount_total %]</td>
203     <td class="data">[% budge.budget_amount %] </td>
204     <td class="data">[% budge.budget_spent %] </td>
205     <td class="data">[% budge.total_levels_spent %]</td>
206     [% IF ( budge.remaining_pos ) %]
207         <td class="data" style="color: green;">
208     [% ELSIF ( budge.remaining_neg ) %] 
209         <td class="data" style="color: red;">
210     [% ELSE %]
211         <td class="data">
212     [% END %]
213             [% budge.budget_remaining %] </td>
214
215     <td class="tooltipcontent">[% IF ( budge.budget_owner_id ) %]<strong>Owner: </strong><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budge.budget_owner_id %]">[% budge.budget_owner_name %]</a>[% END %]
216         [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
217         [% IF ( budge.budget_notes ) %]<br /><strong>Notes: </strong>[% budge.budget_notes %][% END %]
218         [% IF ( budge.budget_hierarchy ) %]
219             <ul class="budget_hierarchy">[% FOREACH budget_hierarch IN budge.budget_hierarchy %]
220                 [% IF ( budget_hierarch.element_id ) %]
221                     <li><a href="?op=add_form&amp;budget_id=[% budget_hierarch.element_id %]&amp;budget_period_id=[% budget_hierarch.budget_period_id %]">[% budget_hierarch.element_name %]</a></li>
222                 [% ELSE %]
223                     <li><strong>[% budget_hierarch.element_name %] : </strong></li>
224                 [% END %]
225                 [% END %]
226             </ul>
227         [% END %]</td>
228     [% IF ( budge.budget_lock ) %]
229         <td> <span style="color: gray;" > Edit Delete </span> </td>
230     [% ELSE %]
231         <td>
232             <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=[% budge.budget_id %]&amp;budget_period_id=[% budge.budget_period_id %]" >Edit</a>
233             <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&amp;budget_id=[% budge.budget_id %]&amp;budget_period_id=[% budge.budget_period_id %]">Delete</a>
234             <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_parent_id=[% budge.budget_id %]&amp;budget_period_id=[% budge.budget_period_id %]">Add Child Fund</a>
235         </td>
236     [% END %]
237     </tr>
238         [% END %]
239     [% ELSE %]
240         <tr><td colspan="12">No fund found</td></tr>
241     [% END %]
242     </tbody>
243 </table>
244
245 [% IF ( pagination_bar ) %]<div class="pages">[% pagination_bar %]</div>[% END %]
246 [% END %] <!-- else -->
247
248 <!-- ********************************************************************************************** -->
249 <!-- create add/mod entry form -->
250 [% IF ( add_form ) %]
251 <form action="/cgi-bin/koha/admin/aqbudgets.pl" name="Aform" method="post">
252     <fieldset class="rows">
253     <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
254     [% IF ( budget_period_description ) %]
255         [% budget_name %] for Budget '[% budget_period_description %]'
256     [% END %]
257     </legend>
258
259     <input type="hidden" name="op" value="add_validate" />
260     <input type="hidden" name="checked" value="0" />
261     <ol>
262     [% IF ( budget_parent_id ) %]
263     <li>
264         <span class="label">Fund Parent: </span>
265         [% budget_parent_name %]
266         [% budget_parent_id %] - [% budget_parent_name %]
267         <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
268     </li>
269     [% END %]
270     <li>
271     <label class="required"  for="budget_code">Fund Code: </label>
272     <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" size="30" />
273     </li>
274
275     <li>
276     <label class="required" for="budget_name">Fund Name: </label>
277     <input type="text" name="budget_name" id="budget_name" value="[% budget_name %]" size="60" />
278     </li>
279
280     <li>
281     <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
282     <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount %]" size="8" />
283     </li>
284
285     <li>
286     <label for="budget_encumb">Encumbrance: </label>
287     <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="8" />
288     </li>
289
290     <li>
291     <label for="budget_expend">Expenditure: </label>
292     <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend %]" size="8" /><input type="hidden" name="budget_owner_id" id="budget_owner_id" value="[% budget_owner_id %]" />
293     </li>
294
295     <li>
296     <span class="label">Owner: </span>
297     <span  id="budget_owner_name">
298     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner_id %]">[% budget_owner_name %]</a>
299     </span>
300
301     <!-- FIXME: hardcoded button positions :/ -->
302     <input style="" type="button" id="edit_owner" value="Edit owner" onclick="ownerPopup(); return false;" />
303     <input style=""  type="button" id="remove_owner" value="Remove owner" onclick="ownerRemove(this.form); return false;" />
304     </li>
305
306     <li>
307     <label for="budget_branchcode">Library: </label>
308     <select name="budget_branchcode" id="budget_branchcode">
309     <option value=""></option>
310     [% FOREACH branchloop_selec IN branchloop_select %]
311         [% UNLESS ( branchloop_selec.selected ) %] <option value="[% branchloop_selec.value %]" > [% ELSE %] <option value="[% branchloop_selec.value %]" selected="selected"> [% END %] [% branchloop_selec.value %]-[% branchloop_selec.branchname %]</option>
312     [% END %]
313     </select>
314     </li>
315
316     <li>
317     <label for="budget_permission">Restrict access to: </label>
318     <select name="budget_permission" id="budget_permission">
319     [% IF ( budget_perm_0 ) %]<option value="0" selected="selected">None</option>[% ELSE %]<option value="0">None</option>[% END %]
320     [% IF ( budget_perm_1 ) %]<option value="1" selected="selected">Owner</option>[% ELSE %]<option value="1">Owner</option>[% END %]
321     [% IF ( budget_perm_2 ) %]<option value="2" selected="selected">Library</option>[% ELSE %]<option value="2">Library</option>[% END %]
322     </option>
323     </select>
324     </li>
325
326     <li>
327     <label for="budget_notes">Notes: </label>
328     <textarea name="budget_notes" id="budget_notes"  cols="80" rows="6">[% budget_notes %]</textarea>
329     </li>
330
331     <li>
332     <label  style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
333         <select name="sort1_authcat" id="authorised_value_category1">
334             <option value=""></option>
335             [% FOREACH authorised_value_categories IN authorised_value_categories1 %]
336                 [% IF ( authorised_value_categories.selected ) %]
337                     <option value="[% authorised_value_categories.category %]" selected="selected">
338                         [% authorised_value_categories.category %]
339                     </option>
340                 [% ELSE %]
341                     <option value="[% authorised_value_categories.category %]">
342                         [% authorised_value_categories.category %]
343                     </option>
344                 [% END %]
345             [% END %]
346         </select>
347     </li>
348     <li>
349     <label  style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
350         <select name="sort2_authcat" id="authorised_value_category2">
351             <option value=""></option>
352             [% FOREACH authorised_value_categories IN authorised_value_categories2 %]
353                 [% IF ( authorised_value_categories.selected ) %]
354                     <option value="[% authorised_value_categories.category %]" selected="selected">
355                         [% authorised_value_categories.category %]
356                     </option>
357                 [% ELSE %]
358                     <option value="[% authorised_value_categories.category %]">
359                         [% authorised_value_categories.category %]
360                     </option>
361                 [% END %]
362             [% END %]
363         </select>
364     </li>
365     </ol>
366
367     [% IF ( budget_id ) %]
368         <input type="hidden" name="budget_id" value="[% budget_id %]" />
369     [% END %]
370     </fieldset>
371
372     <fieldset class="action">
373         <input type="submit" value="Submit" onclick="Check(this.form); return false;" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
374         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
375     </fieldset>
376 </form>
377
378 [% END %] <!-- add_form -->
379
380 [% IF ( delete_confirm ) %]
381 <div class="dialog alert"> <h3>Delete Fund [% budget_name %]?</h3>
382 <table>
383     <tr>
384     <th scope="row">Fund Amount:</th>
385     <td>[% budget_amount %]</td>
386     </tr>
387 </table>
388
389 <form action="[% action %]" method="post">
390     <input type="hidden" name="op" value="delete_confirmed" />
391     <input type="hidden" name="budget_id" value="[% budget_id %]" />
392     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
393     <input type="submit" value="Delete this budget" class="approve" />
394 </form>
395
396 <form action="[% action %]" method="get">
397     <input type="submit" class="deny" value="No, Do Not Delete" />
398 </form>
399 </div>
400 [% END %]
401
402 </div>
403 </div>
404 <div class="yui-b">
405 [% IF ( else ) %]<form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
406     <a href="#" id="filterbutton">Filters</a>
407     <fieldset class="brief" id="fundfilters">
408     <h4>Fund filters</h4>
409         <ol>
410         <li>
411             <label for="filter_budgetbranch2">Library: </label>
412             <select name="filter_budgetbranch" id="filter_budgetbranch2" style="width:10em;">
413                 <option value=""></option>
414                 [% FOREACH branchloo IN branchloop %]
415                 [% UNLESS ( branchloo.selected ) %]<option value="[% branchloo.value %]">
416                 [% ELSE %]<option value="[% branchloo.value %]" selected="selected">[% END %]
417                 [% branchloo.branchname %]</option>
418                 [% END %]
419             </select>
420         </li>
421         <li class="radio">
422
423         <label for="show_mine">Show my funds only</label>
424             [% IF ( show_mine ) %]
425                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
426             [% ELSE %]
427                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" />
428         [% END %]
429         </li>
430         </ol>
431
432         <input type="hidden" name="show" value="1" />
433         <input type="hidden"  name="budget_period_id" value="[% budget_period_id %]" />
434         <input type="submit" class="submit" name="filter" value="Go" />
435     </fieldset>
436 </form>[% END %]
437 [% INCLUDE 'acquisitions-menu.inc' %]
438 </div>
439 </div>
440 [% INCLUDE 'intranet-bottom.inc' %]