Bug 7308: Show ordered amount in aqbudgets.pl
[srvgit] / 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">
5 //<![CDATA[
6 var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
7 var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
8 var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
9 //]]>
10 </script>
11
12 <script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
13
14 [% IF ( add_form ) %]
15 <script type="text/javascript">
16 //<![CDATA[
17
18     function userPopup() {
19         window.open("/cgi-bin/koha/admin/aqbudget_user_search.pl?type=user",
20             'PatronPopup',
21             'width=740,height=450,location=yes,toolbar=no,'
22             + 'scrollbars=yes,resize=yes'
23         );
24     }
25
26     function ownerPopup() {
27         window.open("/cgi-bin/koha/admin/aqbudget_user_search.pl?type=owner",
28             'PatronPopup',
29             'width=740,height=450,location=yes,toolbar=no,'
30             + 'scrollbars=yes,resize=yes'
31         );
32     }
33
34     function edit_owner(borrowernumber, surname, firstname) {
35         $('#budget_owner_name').empty();
36         $('#budget_owner_id').val('');
37         if (borrowernumber) {
38             var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
39                 + '?borrowernumber=' + borrowernumber + '">'
40                 + firstname + ' ' + surname + '</a>';
41             $('#budget_owner_name').html(ownerlink);
42             $('#budget_owner_id').val(borrowernumber);
43         }
44     }
45
46     function ownerRemove() {
47         edit_owner(0);
48     }
49
50     function add_user(borrowernumber, surname, firstname) {
51         var ids = $("#budget_users_id").val().split(':');
52         if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
53             var li = '<li id="user_' + borrowernumber + '">'
54                 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
55                 + borrowernumber + '">' + firstname + ' ' + surname
56                 + '</a> [<a style="cursor:pointer"'
57                 + 'onclick="del_user(' + borrowernumber +')">Remove</a>]</li>';
58             $(li).insertBefore("li#add_user_button");
59             ids.push(borrowernumber);
60             $("#budget_users_id").val(ids.join(':'));
61         } else {
62             return -1;
63         }
64         return 0;
65     }
66
67     function del_user(borrowernumber) {
68         var ids = $("#budget_users_id").val().split(':');
69         if (borrowernumber) {
70             var idx = ids.indexOf(borrowernumber+'');
71             if (idx != -1) {
72                 ids.splice(idx, 1);
73                 $("#budget_users_id").val(ids.join(':'));
74                 $("li#user_" + borrowernumber).remove();
75             }
76         }
77     }
78
79     function Check(f) {
80         var ok=1;
81         var _alertString="";
82         var alertString2;
83
84         if (!(isNotNull(f.budget_code,1))) {
85             _alertString += _("- Budget code cannot be blank") + "\n";
86         }
87
88         if (!(isNotNull(f.budget_name,1))) {
89             _alertString += _("- Budget name cannot be blank") + "\n";
90         }
91
92         if (!(isNotNull(f.budget_amount,1))) {
93             _alertString += _("- Budget amount cannot be blank") + "\n";
94         }
95
96         var budgetId;
97         if   (typeof(f.budget_id ) != "undefined")  {
98             budgetId = f.budget_id.value
99         }
100
101         var newBudgetParent;
102
103 //  hack to test if selected parent_id in scrolling-list...
104 //  if value == 'undef' its got a selected_parent :/
105         if(f.budget_parent_id){
106             var chkAdd   =  f.budget_parent_id.value ;
107             if  (     typeof(chkAdd ) != "undefined") {
108                 newBudgetParent  =  f.budget_parent_id.value
109             } else {
110                 newBudgetParent  =  f.budget_parent_id.item(0).value
111             }
112
113             if   (budgetId  > 0)  {  ; //its a mod ...
114                 // if parent == curent-budget, fail...
115                 if ( newBudgetParent  ==  budgetId     ) {
116                         _alertString += _("- Budget parent is current budget") + "\n";
117                 }
118
119                 else if (newBudgetParent) {
120                     var result = checkBudgetParent(  budgetId , newBudgetParent   );
121                     if (result) {
122                         _alertString += result;
123                     }
124                 }
125             }
126         }
127
128          // else do lookup
129         var budgetTotal = Math.abs(f.budget_amount.value);
130         var result =   budgetExceedsParent  (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
131         if (result) {
132             _alertString += result;
133         }
134
135         if (_alertString.length==0) {
136             document.Aform.submit();
137         } else {
138             alertString2 = _("Form not submitted because of the following problem(s)");
139             alertString2 += "\n------------------------------------------------------------------------------------\n\n";
140             alertString2 += _alertString;
141             alert(alertString2);
142         }
143     }
144 //]]>
145 </script>
146 [% ELSE %]
147     [% IF ( notree ) %]
148         <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
149         [% INCLUDE 'datatables.inc' %]
150     [% ELSE %]
151         <link href="[% themelang %]/lib/jquery/plugins/treetable/stylesheets/jquery.treeTable.css" rel="stylesheet" type="text/css" />
152         <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/treetable/jquery.treeTable.min.js"></script>
153     [% END %]
154
155 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.qtip.js"></script>
156
157 <script type="text/javascript">
158 //<![CDATA[
159     //
160     $(document).ready(function() {
161         var tooltipcontent = $(".tooltipcontent");
162         tooltipcontent.hide();
163
164         $(".tooltiped td").each(function (){
165             contentelem = $(this).parent().children().filter(".tooltipcontent");
166             if(contentelem.html() != ""){
167             $(this).qtip({
168                 content: contentelem.html(),
169                 show: "mouseover",
170                 hide: "mouseout",
171                 style: {
172                     name: "light",
173                     tip: "bottomLeft",
174                     border: {
175                         radius: 5,
176                         color: "#356CA1"
177                     }
178                 },
179                 position: {
180                     corner: {
181                         target: "topRight",
182                         tooltip: "bottomRight"
183                     }
184                 }
185             });
186             }
187         });
188         [% IF ( notree ) %]
189             $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
190                 "aoColumnDefs": [
191                     { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
192                 ],
193                 "sPaginationType": "four_button"
194             }));
195         [% ELSE %]
196         $("#budgeth").treeTable();
197         [% END %]
198
199         $("#filterbutton").click(function() {
200             $("#fundfilters").slideToggle(0);
201         });
202     });
203 //]]>
204 </script>
205 [% END %]
206
207 </head>
208 <body id="admin_aqbudgets" class="admin">
209 [% INCLUDE 'header.inc' %]
210 [% INCLUDE 'budgets-admin-search.inc' %]
211
212 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
213     <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 ) %]
214     <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 ) %]
215     <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> &rsaquo; Delete fund?[% END %]</div>
216
217 <div id="doc3" class="yui-t2">
218 <div id="bd">
219 <div id="yui-main">
220 <div class="yui-b" id="content">
221
222
223 [% UNLESS ( delete_confirm ) %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
224
225 [% IF (error_not_authorised_to_modify) %]
226     <div class="error">
227         <p>You are not authorized to modify this fund</p>
228     </div>
229 [% END %]
230
231 [% IF ( else ) %]
232
233 <h1>Funds for '[% budget_period_description %]'</h1>
234
235 [% INCLUDE 'budgets-active-currency.inc' %]
236
237 [% IF ( budget ) %]
238
239 <table id="budgeth">
240     <thead>
241         <tr>
242             <th>Fund code</th>
243             <th>Fund name</th>
244             <th>Total<br />allocated</th>
245             <th>Base-level<br />allocated</th>
246             <th>Base-level<br />ordered</th>
247             <th>Base-level<br />spent</th>
248             <th>Total sublevels<br />spent</th>
249             <th>Base-level<br />remaining</th>
250             <th class="tooltipcontent">&nbsp;</th>
251             <th>Actions</th>
252         </tr>
253     </thead>
254 <tfoot>
255     <tr>
256     <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
257     <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
258     <th nowrap="nowrap"  class="data"> [% base_alloc_total %]</th>
259     <th class="data">[% base_ordered_total %]</th>
260     <th class="data">[% base_spent_total %]</th>
261     <th class="data">[% base_spent_total %]</th>
262     <th class="data">[% base_remaining_total %]</th>
263     <th class="tooltipcontent"></th>
264     <th></th>
265     </tr>
266     </tfoot>
267     <tbody>
268         [% FOREACH budge IN budget %]
269     [% IF ( budge.toggle ) %]
270     <tr id="node-[% budge.budget_id %]" class="highlight[% IF ( budge.budget_parent_id ) %] child-of-node-[% budge.budget_parent_id %][% END %] tooltiped">
271     [% ELSE %]
272     <tr id="node-[% budge.budget_id %]" class="tooltiped [% IF ( budge.budget_parent_id ) %] child-of-node-[% budge.budget_parent_id %][% END %]">
273     [% END %]
274
275     <td>[% budge.budget_code_indent %]</td>
276     <td>[% budge.budget_name %]</td>
277     <td class="data">[% budge.budget_amount_total %]</td>
278     <td class="data">[% budge.budget_amount %] </td>
279     <td class="data">[% budge.budget_ordered %]</td>
280     <td class="data">[% budge.budget_spent %] </td>
281     <td class="data">[% budge.total_levels_spent %]</td>
282     [% IF ( budge.remaining_pos ) %]
283         <td class="data" style="color: green;">
284     [% ELSIF ( budge.remaining_neg ) %] 
285         <td class="data" style="color: red;">
286     [% ELSE %]
287         <td class="data">
288     [% END %]
289             [% budge.budget_remaining %] </td>
290
291     <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 %]
292         [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
293         [% IF ( budge.budget_notes ) %]<br /><strong>Notes: </strong>[% budge.budget_notes %][% END %]
294         [% IF ( budge.budget_hierarchy ) %]
295             <ul class="budget_hierarchy">[% FOREACH budget_hierarch IN budge.budget_hierarchy %]
296                 [% IF ( budget_hierarch.element_id ) %]
297                     <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>
298                 [% ELSE %]
299                     <li><strong>[% budget_hierarch.element_name %] : </strong></li>
300                 [% END %]
301                 [% END %]
302             </ul>
303         [% END %]</td>
304     [% IF ( budge.budget_lock ) %]
305         <td> <span style="color: gray;"> Edit Delete </span> </td>
306     [% ELSE %]
307         <td>
308             <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>
309             <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>
310             <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>
311         </td>
312     [% END %]
313     </tr>
314     [% END %]
315     </tbody>
316 </table>
317
318 [% ELSE %]
319     No fund found
320 [% END %]
321
322 [% IF ( pagination_bar ) %]<div class="pages">[% pagination_bar %]</div>[% END %]
323 [% END %] <!-- else -->
324
325 <!-- ********************************************************************************************** -->
326 <!-- create add/mod entry form -->
327 [% IF ( add_form && !error_not_authorised_to_modify ) %]
328 <form action="/cgi-bin/koha/admin/aqbudgets.pl" name="Aform" method="post">
329     <fieldset class="rows">
330     <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
331     [% IF ( budget_period_description ) %]
332         [% budget_name %] for Budget '[% budget_period_description %]'
333     [% END %]
334     </legend>
335
336     <input type="hidden" name="op" value="add_validate" />
337     <input type="hidden" name="checked" value="0" />
338     <ol>
339     [% IF ( budget_parent_id ) %]
340     <li>
341         <span class="label">Fund parent: </span>
342         [% budget_parent_name %]
343         [% budget_parent_id %] - [% budget_parent_name %]
344         <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
345     </li>
346     [% END %]
347     <li>
348     <label class="required"  for="budget_code">Fund code: </label>
349     <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" size="30" />
350     </li>
351
352     <li>
353     <label class="required" for="budget_name">Fund name: </label>
354     <input type="text" name="budget_name" id="budget_name" value="[% budget_name %]" size="60" />
355     </li>
356
357     <li>
358     <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
359     <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount %]" size="8" />
360     </li>
361
362     <li>
363       <label for="budget_encumb">Warning at (%): </label>
364       <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="10" />
365       <span style="color:grey">0 to disable</span>
366     </li>
367
368     <li>
369       <label for="budget_expend">Warning at (amount): </label>
370       <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend %]" size="10" /><input type="hidden" name="budget_owner_id" id="budget_owner_id" value="[% budget_owner_id %]" />
371       <span style="color:grey">0 to disable</span>
372     </li>
373
374     <li>
375         <span class="label">Owner: </span>
376         <span  id="budget_owner_name">
377         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner_id %]">
378             [% budget_owner_name %]
379         </a>
380         </span>
381         <input type="hidden" name="budget_owner_id" id="budget_owner_id"
382             value="[% budget_owner_id %]" />
383
384         <!-- FIXME: hardcoded button positions :/ -->
385         <input type="button" id="edit_owner" value="Edit owner"
386             onclick="ownerPopup(); return false;" />
387         <input type="button" id="remove_owner" value="Remove owner"
388             onclick="ownerRemove(); return false;" />
389     </li>
390
391     <li>
392         <span class="label">Users:</span>
393         <ul style="float:left;" id="budget_users">
394             [% FOREACH user IN budget_users %]
395                 <li id="user_[% user.borrowernumber %]">
396                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber %]">
397                         [% user.firstname %] [% user.surname %]
398                     </a>
399                     [<a style="cursor:pointer"
400                     onclick="del_user([% user.borrowernumber %])">Remove</a>]
401                 </li>
402             [% END %]
403             <li id="add_user_button">
404                 <input type="button" onclick="userPopup()" value="Add users" />
405             </li>
406         </ul>
407         <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids %]" />
408     <li>
409     <label for="budget_branchcode">Library: </label>
410     <select name="budget_branchcode" id="budget_branchcode">
411     <option value=""></option>
412     [% FOREACH branchloop_selec IN branchloop_select %]
413         [% 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>
414     [% END %]
415     </select>
416     </li>
417
418     <li>
419     <label for="budget_permission">Restrict access to: </label>
420     <select name="budget_permission" id="budget_permission">
421         [% IF ( budget_perm_0 ) %]
422             <option value="0" selected="selected">
423         [% ELSE %]
424             <option value="0">
425         [% END %]
426             None
427         </option>
428
429         [% IF ( budget_perm_1 ) %]
430             <option value="1" selected="selected">
431         [% ELSE %]
432             <option value="1">
433         [% END %]
434             Owner
435         </option>
436
437         [% IF ( budget_perm_3) %]
438             <option value="3" selected="selected">
439         [% ELSE %]
440             <option value="3">
441         [% END %]
442             Owner and users
443         </option>
444
445         [% IF ( budget_perm_2 ) %]
446             <option value="2" selected="selected">
447         [% ELSE %]
448             <option value="2">
449         [% END %]
450             Owner, users and library
451         </option>
452     </select>
453     </li>
454
455     <li>
456     <label for="budget_notes">Notes: </label>
457     <textarea name="budget_notes" id="budget_notes"  cols="80" rows="6">[% budget_notes %]</textarea>
458     </li>
459
460     <li>
461     <label  style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
462         <select name="sort1_authcat" id="authorised_value_category1">
463             <option value=""></option>
464             [% FOREACH authorised_value_categories IN authorised_value_categories1 %]
465                 [% IF ( authorised_value_categories.selected ) %]
466                     <option value="[% authorised_value_categories.category %]" selected="selected">
467                         [% authorised_value_categories.category %]
468                     </option>
469                 [% ELSE %]
470                     <option value="[% authorised_value_categories.category %]">
471                         [% authorised_value_categories.category %]
472                     </option>
473                 [% END %]
474             [% END %]
475         </select>
476     </li>
477     <li>
478     <label  style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
479         <select name="sort2_authcat" id="authorised_value_category2">
480             <option value=""></option>
481             [% FOREACH authorised_value_categories IN authorised_value_categories2 %]
482                 [% IF ( authorised_value_categories.selected ) %]
483                     <option value="[% authorised_value_categories.category %]" selected="selected">
484                         [% authorised_value_categories.category %]
485                     </option>
486                 [% ELSE %]
487                     <option value="[% authorised_value_categories.category %]">
488                         [% authorised_value_categories.category %]
489                     </option>
490                 [% END %]
491             [% END %]
492         </select>
493     </li>
494     </ol>
495
496     [% IF ( budget_id ) %]
497         <input type="hidden" name="budget_id" value="[% budget_id %]" />
498     [% END %]
499     </fieldset>
500
501     <fieldset class="action">
502         <input type="submit" value="Submit" onclick="Check(this.form); return false;" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
503         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
504     </fieldset>
505 </form>
506
507 [% END %] <!-- add_form -->
508
509 [% IF ( delete_confirm ) %]
510 <div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
511 <table>
512     <tr>
513     <th scope="row">Fund amount:</th>
514     <td>[% budget_amount %]</td>
515     </tr>
516 </table>
517
518 <form action="[% action %]" method="post">
519     <input type="hidden" name="op" value="delete_confirmed" />
520     <input type="hidden" name="budget_id" value="[% budget_id %]" />
521     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
522     <input type="submit" value="Delete" class="approve" />
523 </form>
524
525 <form action="[% action %]" method="get">
526     <input type="submit" class="deny" value="Cancel" />
527 </form>
528 </div>
529 [% END %]
530
531 </div>
532 </div>
533 <div class="yui-b">
534 [% IF ( else ) %]<form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
535     <a href="#" id="filterbutton">Filters</a>
536     <fieldset class="brief" id="fundfilters">
537     <h4>Fund filters</h4>
538         <ol>
539         <li>
540             <label for="filter_budgetbranch2">Library: </label>
541             <select name="filter_budgetbranch" id="filter_budgetbranch2" style="width:10em;">
542                 <option value=""></option>
543                 [% FOREACH branchloo IN branchloop %]
544                 [% UNLESS ( branchloo.selected ) %]<option value="[% branchloo.value %]">
545                 [% ELSE %]<option value="[% branchloo.value %]" selected="selected">[% END %]
546                 [% branchloo.branchname %]</option>
547                 [% END %]
548             </select>
549         </li>
550         <li class="radio">
551
552         <label for="show_mine">Show my funds only</label>
553             [% IF ( show_mine ) %]
554                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
555             [% ELSE %]
556                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" />
557         [% END %]
558         </li>
559         </ol>
560
561         <input type="hidden" name="show" value="1" />
562         <input type="hidden"  name="budget_period_id" value="[% budget_period_id %]" />
563         <input type="submit" class="submit" name="filter" value="Go" />
564     </fieldset>
565 </form>[% END %]
566 [% INCLUDE 'acquisitions-menu.inc' %]
567 </div>
568 </div>
569 [% INCLUDE 'intranet-bottom.inc' %]