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