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