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