Bug 10651 - (follow-up) add DataTables include to admin/aqbudgets.tt
[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">
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                 "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
194                 "iDisplayLength": 20,
195                 "sPaginationType": "four_button"
196             }));
197         [% ELSE %]
198         $("#budgeth").treeTable();
199         [% END %]
200
201         $("#filterbutton").click(function() {
202             $("#fundfilters").slideToggle(0);
203         });
204     });
205 //]]>
206 </script>
207 [% END %]
208
209 </head>
210 <body id="admin_aqbudgets" class="admin">
211 [% INCLUDE 'header.inc' %]
212 [% INCLUDE 'budgets-admin-search.inc' %]
213
214 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
215     <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 ) %]
216     <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 ) %]
217     <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> &rsaquo; Delete fund?[% END %]</div>
218
219 <div id="doc3" class="yui-t2">
220 <div id="bd">
221 <div id="yui-main">
222 <div class="yui-b" id="content">
223
224
225 [% UNLESS ( delete_confirm ) %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
226
227 [% IF (error_not_authorised_to_modify) %]
228     <div class="error">
229         <p>You are not authorized to modify this fund</p>
230     </div>
231 [% END %]
232
233 [% IF ( else ) %]
234
235 <h1>Funds for '[% budget_period_description %]'</h1>
236
237 [% INCLUDE 'budgets-active-currency.inc' %]
238
239 [% IF ( budget ) %]
240
241 <table id="budgeth">
242     <thead>
243         <tr>
244             <th>Fund code</th>
245             <th>Fund name</th>
246             <th>Total<br />allocated</th>
247             <th>Base-level<br />allocated</th>
248             <th>Base-level<br />spent</th>
249             <th>Total sublevels<br />spent</th>
250             <th>Base-level<br />remaining</th>
251             <th class="tooltipcontent">&nbsp;</th>
252             <th>Actions</th>
253         </tr>
254     </thead>
255 <tfoot>
256     <tr>
257     <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
258     <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
259     <th nowrap="nowrap"  class="data"> [% base_alloc_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_spent %] </td>
280     <td class="data">[% budge.total_levels_spent %]</td>
281     [% IF ( budge.remaining_pos ) %]
282         <td class="data" style="color: green;">
283     [% ELSIF ( budge.remaining_neg ) %] 
284         <td class="data" style="color: red;">
285     [% ELSE %]
286         <td class="data">
287     [% END %]
288             [% budge.budget_remaining %] </td>
289
290     <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 %]
291         [% IF ( budge.budget_branchcode ) %]<br /><strong>Library: </strong>[% budge.budget_branchcode %][% END %]
292         [% IF ( budge.budget_notes ) %]<br /><strong>Notes: </strong>[% budge.budget_notes %][% END %]
293         [% IF ( budge.budget_hierarchy ) %]
294             <ul class="budget_hierarchy">[% FOREACH budget_hierarch IN budge.budget_hierarchy %]
295                 [% IF ( budget_hierarch.element_id ) %]
296                     <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>
297                 [% ELSE %]
298                     <li><strong>[% budget_hierarch.element_name %] : </strong></li>
299                 [% END %]
300                 [% END %]
301             </ul>
302         [% END %]</td>
303     [% IF ( budge.budget_lock ) %]
304         <td> <span style="color: gray;"> Edit Delete </span> </td>
305     [% ELSE %]
306         <td>
307             <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>
308             <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>
309             <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>
310         </td>
311     [% END %]
312     </tr>
313     [% END %]
314     </tbody>
315 </table>
316
317 [% ELSE %]
318     No fund found
319 [% END %]
320
321 [% IF ( pagination_bar ) %]<div class="pages">[% pagination_bar %]</div>[% END %]
322 [% END %] <!-- else -->
323
324 <!-- ********************************************************************************************** -->
325 <!-- create add/mod entry form -->
326 [% IF ( add_form && !error_not_authorised_to_modify ) %]
327 <form action="/cgi-bin/koha/admin/aqbudgets.pl" name="Aform" method="post">
328     <fieldset class="rows">
329     <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
330     [% IF ( budget_period_description ) %]
331         [% budget_name %] for Budget '[% budget_period_description %]'
332     [% END %]
333     </legend>
334
335     <input type="hidden" name="op" value="add_validate" />
336     <input type="hidden" name="checked" value="0" />
337     <ol>
338     [% IF ( budget_parent_id ) %]
339     <li>
340         <span class="label">Fund parent: </span>
341         [% budget_parent_name %]
342         [% budget_parent_id %] - [% budget_parent_name %]
343         <input type="hidden" name="budget_parent_id" value="[% budget_parent_id %]" />
344     </li>
345     [% END %]
346     <li>
347     <label class="required"  for="budget_code">Fund code: </label>
348     <input type="text" name="budget_code" id="budget_code" value="[% budget_code %]" size="30" />
349     </li>
350
351     <li>
352     <label class="required" for="budget_name">Fund name: </label>
353     <input type="text" name="budget_name" id="budget_name" value="[% budget_name %]" size="60" />
354     </li>
355
356     <li>
357     <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
358     <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount %]" size="8" />
359     </li>
360
361     <li style="display:none;">
362     <label for="budget_encumb">Encumbrance: </label>
363     <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="8" />
364     </li>
365
366     <li style="display:none;">
367     <label for="budget_expend">Expenditure: </label>
368     <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend %]" size="8" />
369     </li>
370
371     <li>
372         <span class="label">Owner: </span>
373         <span  id="budget_owner_name">
374         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner_id %]">
375             [% budget_owner_name %]
376         </a>
377         </span>
378         <input type="hidden" name="budget_owner_id" id="budget_owner_id"
379             value="[% budget_owner_id %]" />
380
381         <!-- FIXME: hardcoded button positions :/ -->
382         <input type="button" id="edit_owner" value="Edit owner"
383             onclick="ownerPopup(); return false;" />
384         <input type="button" id="remove_owner" value="Remove owner"
385             onclick="ownerRemove(); return false;" />
386     </li>
387
388     <li>
389         <span class="label">Users:</span>
390         <ul style="float:left;" id="budget_users">
391             [% FOREACH user IN budget_users %]
392                 <li id="user_[% user.borrowernumber %]">
393                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber %]">
394                         [% user.firstname %] [% user.surname %]
395                     </a>
396                     [<a style="cursor:pointer"
397                     onclick="del_user([% user.borrowernumber %])">Remove</a>]
398                 </li>
399             [% END %]
400             <li id="add_user_button">
401                 <input type="button" onclick="userPopup()" value="Add users" />
402             </li>
403         </ul>
404         <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids %]" />
405     <li>
406     <label for="budget_branchcode">Library: </label>
407     <select name="budget_branchcode" id="budget_branchcode">
408     <option value=""></option>
409     [% FOREACH branchloop_selec IN branchloop_select %]
410         [% 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>
411     [% END %]
412     </select>
413     </li>
414
415     <li>
416     <label for="budget_permission">Restrict access to: </label>
417     <select name="budget_permission" id="budget_permission">
418         [% IF ( budget_perm_0 ) %]
419             <option value="0" selected="selected">
420         [% ELSE %]
421             <option value="0">
422         [% END %]
423             None
424         </option>
425
426         [% IF ( budget_perm_1 ) %]
427             <option value="1" selected="selected">
428         [% ELSE %]
429             <option value="1">
430         [% END %]
431             Owner
432         </option>
433
434         [% IF ( budget_perm_3) %]
435             <option value="3" selected="selected">
436         [% ELSE %]
437             <option value="3">
438         [% END %]
439             Owner and users
440         </option>
441
442         [% IF ( budget_perm_2 ) %]
443             <option value="2" selected="selected">
444         [% ELSE %]
445             <option value="2">
446         [% END %]
447             Owner, users and library
448         </option>
449     </select>
450     </li>
451
452     <li>
453     <label for="budget_notes">Notes: </label>
454     <textarea name="budget_notes" id="budget_notes"  cols="80" rows="6">[% budget_notes %]</textarea>
455     </li>
456
457     <li>
458     <label  style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
459         <select name="sort1_authcat" id="authorised_value_category1">
460             <option value=""></option>
461             [% FOREACH authorised_value_categories IN authorised_value_categories1 %]
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     <li>
475     <label  style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
476         <select name="sort2_authcat" id="authorised_value_category2">
477             <option value=""></option>
478             [% FOREACH authorised_value_categories IN authorised_value_categories2 %]
479                 [% IF ( authorised_value_categories.selected ) %]
480                     <option value="[% authorised_value_categories.category %]" selected="selected">
481                         [% authorised_value_categories.category %]
482                     </option>
483                 [% ELSE %]
484                     <option value="[% authorised_value_categories.category %]">
485                         [% authorised_value_categories.category %]
486                     </option>
487                 [% END %]
488             [% END %]
489         </select>
490     </li>
491     </ol>
492
493     [% IF ( budget_id ) %]
494         <input type="hidden" name="budget_id" value="[% budget_id %]" />
495     [% END %]
496     </fieldset>
497
498     <fieldset class="action">
499         <input type="submit" value="Submit" onclick="Check(this.form); return false;" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
500         <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
501     </fieldset>
502 </form>
503
504 [% END %] <!-- add_form -->
505
506 [% IF ( delete_confirm ) %]
507 <div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
508 <table>
509     <tr>
510     <th scope="row">Fund amount:</th>
511     <td>[% budget_amount %]</td>
512     </tr>
513 </table>
514
515 <form action="[% action %]" method="post">
516     <input type="hidden" name="op" value="delete_confirmed" />
517     <input type="hidden" name="budget_id" value="[% budget_id %]" />
518     <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
519     <input type="submit" value="Delete" class="approve" />
520 </form>
521
522 <form action="[% action %]" method="get">
523     <input type="submit" class="deny" value="Cancel" />
524 </form>
525 </div>
526 [% END %]
527
528 </div>
529 </div>
530 <div class="yui-b">
531 [% IF ( else ) %]<form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
532     <a href="#" id="filterbutton">Filters</a>
533     <fieldset class="brief" id="fundfilters">
534     <h4>Fund filters</h4>
535         <ol>
536         <li>
537             <label for="filter_budgetbranch2">Library: </label>
538             <select name="filter_budgetbranch" id="filter_budgetbranch2" style="width:10em;">
539                 <option value=""></option>
540                 [% FOREACH branchloo IN branchloop %]
541                 [% UNLESS ( branchloo.selected ) %]<option value="[% branchloo.value %]">
542                 [% ELSE %]<option value="[% branchloo.value %]" selected="selected">[% END %]
543                 [% branchloo.branchname %]</option>
544                 [% END %]
545             </select>
546         </li>
547         <li class="radio">
548
549         <label for="show_mine">Show my funds only</label>
550             [% IF ( show_mine ) %]
551                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
552             [% ELSE %]
553                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" />
554         [% END %]
555         </li>
556         </ol>
557
558         <input type="hidden" name="show" value="1" />
559         <input type="hidden"  name="budget_period_id" value="[% budget_period_id %]" />
560         <input type="submit" class="submit" name="filter" value="Go" />
561     </fieldset>
562 </form>[% END %]
563 [% INCLUDE 'acquisitions-menu.inc' %]
564 </div>
565 </div>
566 [% INCLUDE 'intranet-bottom.inc' %]