Bug 16242 - Move staff client JavaScript out of language directory
[koha_ffzg] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgets.tt
index 9f96af5..2719a43 100644 (file)
@@ -1,3 +1,4 @@
+[% USE Price %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Administration &rsaquo; Funds[% IF op == 'add_form' %] &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -9,13 +10,13 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 //]]>
 </script>
 
-<script type="text/javascript" src="[% themelang %]/js/acq.js"></script>
+<script type="text/javascript" src="[% interface %]/[% theme %]/js/acq.js"></script>
 [% IF op == 'add_form' %]
 <script type="text/javascript">
 //<![CDATA[
 
     function userPopup() {
-        window.open("/cgi-bin/koha/admin/aqbudget_user_search.pl?type=user",
+        window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
             'PatronPopup',
             'width=740,height=450,location=yes,toolbar=no,'
             + 'scrollbars=yes,resize=yes'
@@ -23,35 +24,36 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
     }
 
     function ownerPopup() {
-        window.open("/cgi-bin/koha/admin/aqbudget_user_search.pl?type=owner",
+        window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
             'PatronPopup',
             'width=740,height=450,location=yes,toolbar=no,'
             + 'scrollbars=yes,resize=yes'
         );
     }
 
-    function edit_owner(borrowernumber, surname, firstname) {
-        $('#budget_owner_name').empty();
-        $('#budget_owner_id').val('');
+    function select_user(borrowernumber, borrower) {
+        ownerRemove();
+        var borrowername = borrower.firstname + ' ' + borrower.surname
         if (borrowernumber) {
             var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
                 + '?borrowernumber=' + borrowernumber + '">'
-                + firstname + ' ' + surname + '</a>';
+                + borrowername + '</a>';
             $('#budget_owner_name').html(ownerlink);
             $('#budget_owner_id').val(borrowernumber);
         }
     }
 
     function ownerRemove() {
-        edit_owner(0);
+        $('#budget_owner_name').empty();
+        $('#budget_owner_id').val('');
     }
 
-    function add_user(borrowernumber, surname, firstname) {
+    function add_user(borrowernumber, borrowername) {
         var ids = $("#budget_users_id").val().split(':');
         if(borrowernumber && ids.indexOf(borrowernumber) == -1) {
             var li = '<li id="user_' + borrowernumber + '">'
                 + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
-                + borrowernumber + '">' + firstname + ' ' + surname
+                + borrowernumber + '">' + borrowername
                 + '</a> [<a style="cursor:pointer"'
                 + 'onclick="del_user(' + borrowernumber +')">Remove</a>]</li>';
             $(li).insertBefore("li#add_user_button");
@@ -143,7 +145,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 //]]>
 </script>
 [% ELSIF op == 'list' %]
-    <link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+    <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
     [% INCLUDE 'datatables.inc' %]
     <link href="[% interface %]/lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css" rel="stylesheet" type="text/css" />
     <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/treetable/jquery.treetable.js"></script>
@@ -152,6 +154,8 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 //<![CDATA[
     //
     $(document).ready(function() {
+
+
         var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
             "fnDrawCallback": function ( oSettings ) {
                 if ( oSettings.aiDisplay.length == 0 )
@@ -160,7 +164,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
                 }
 
                 var nTrs = $('#budgeth tbody tr');
-                var iColspan = nTrs[1].getElementsByTagName('td').length;
+                var iColspan = nTrs[0].getElementsByTagName('td').length;
                 var sLastGroup = "";
                 for ( var i=0 ; i<nTrs.length ; i++ )
                 {
@@ -179,12 +183,17 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
                     }
                 }
             },
+            "footerCallback": function ( row, data, start, end, display ) {
+                var api = this.api(), data;
+                footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
+            },
             "aoColumnDefs": [
-                { "bVisible": false, "aTargets": [ 0, 1 ] }
+                { "bVisible": false, "aTargets": [ 0, 1 ] },
+                { "bSortable": false, "aTargets": ["_all"] }
             ],
-            "aaSortingFixed": [[ 1, 'asc' ]],
-            "aaSorting": [[ 2, 'asc' ]],
-            'bSort': false,
+            'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
+            'bSort': true,
+            'aaSortingFixed': [[ 1, 'asc' ]],
             'bPaginate': false,
             "bAutoWidth": false
         }));
@@ -202,19 +211,27 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
             $(oTable).treetable('collapseAll');
         });
 
-        $("#hide_inactive").click(function(e){
+        [% UNLESS budget_period_id %]
+          $("#hide_inactive").click(function(e){
             e.preventDefault();
-            oTable.fnFilter( 0, 0 ); // Hide active=0
-        });
-        $("#show_inactive").click(function(e){
+            oTable.fnFilter( 1, 0 ); // Show only active=1
+          });
+          $("#show_inactive").click(function(e){
             e.preventDefault();
             oTable.fnFilter( '', 0 );
-        });
+          });
+          $("#hide_inactive").click();
+        [% END %]
+        oTable.fnAddFilters("filter", 750);
 
         $("#filterbutton").click(function() {
             $("#fundfilters").slideToggle(0);
         });
-        $("#hide_inactive").click();
+
+        $(".deletefund-disabled").tooltip().on("click", function(e){
+            e.preventDefault();
+            alert(_("This fund has children. It cannot be deleted."));
+        });
     });
 //]]>
 </script>
@@ -263,13 +280,15 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 
 [% IF budgets %]
 
-<table id="budgeth">
-    <caption>
+<table id="budgeth" class="group">
+    [% UNLESS budget_period_id %]
+      <caption>
         <span class="actions"><a href="#" id="expand_all">Expand all</a>
         | <a href="#" id="collapse_all">Collapse all</a>
         | <a href="#" id="hide_inactive">Hide inactive budgets</a>
         | <a href="#" id="show_inactive">Show inactive budgets</a></span>
-    </caption>
+      </caption>
+    [% END %]
     <thead>
         <tr>
             <th>Active</th>
@@ -290,57 +309,61 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
     <tr>
     <th></th>
     <th></th>
-    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF ( budget_period_total ) %][% budget_period_total %][% END %]  </th>
-    <th nowrap="nowrap" class="data"> [% period_alloc_total %]</th>
+    <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %]  </th>
+    <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
     <th></th>
-    <th class="data">[% ordered_total %]</th>
+    <th class="data">[% ordered_total | $Price %]</th>
     <th></th>
-    <th class="data">[% spent_total %]</th>
+    <th class="data">[% spent_total | $Price %]</th>
     <th></th>
-    <th class="data">[% available_total %]</th>
+    <th class="data">[% available_total | $Price %]</th>
     <th></th>
     </tr>
     </tfoot>
     <tbody>
     [% FOREACH budget IN budgets %]
-    <tr data-tt-id="[% budget.budget_id %]" [% IF ( budget.budget_parent_id ) %]data-tt-parent-id="[% budget.budget_parent_id %]"[% END %]>
+    [% IF budget.budget_parent_id %]
+      <tr data-tt-id="[% budget.budget_id %]" data-tt-parent-id="[% budget.budget_parent_id %]">
+    [% ELSE %]
+      <tr data-tt-id="[% budget.budget_id %]">
+    [% END %]
     <td>[% budget.budget_period_active %]</td>
-    <td>Budget [% budget.budget_period_description %]</td>
-    <td>[% budget.budget_code_indent %]</td>
+    <td>Budget [% budget.budget_period_description %] [id=[% budget.budget_period_id %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
+    <td>[% budget.budget_code %]</td>
     <td>[% budget.budget_name %]</td>
     <td class="data">
       [% IF budget.budget_parent_id %]
-        <span class="child_fund_amount">[% budget.budget_amount %]</span>
+        <span class="child_fund_amount">[% budget.budget_amount | $Price %]</span>
       [% ELSE %]
-        [% budget.budget_amount %]
+        <span class="total_amount">[% budget.budget_amount | $Price %]</span>
       [% END %]
     </td>
     <td class="data">
       [% IF budget.budget_parent_id %]
-        <span class="child_fund_amount">[% budget.budget_ordered %]</span>
+        <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
       [% ELSE %]
-        [% budget.budget_ordered %]
+        <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
       [% END %]
     </td>
     <td class="data">
       [% IF budget.budget_parent_id %]
-        <span class="child_fund_amount">[% budget.total_ordered %]</span>
+        <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
       [% ELSE %]
-        [% budget.total_ordered %]
+        <span class="total_amount">[% budget.total_ordered | $Price %]</span>
       [% END %]
     </td>
     <td class="data">
       [% IF budget.budget_parent_id %]
-        <span class="child_fund_amount">[% budget.budget_spent %]</span>
+        <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
       [% ELSE %]
-        [% budget.budget_spent %]
+        <span class="total_amount">[% budget.budget_spent | $Price %]</span>
       [% END %]
     </td>
     <td class="data">
       [% IF budget.budget_parent_id %]
-        <span class="child_fund_amount">[% budget.total_spent %]</span>
+        <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
       [% ELSE %]
-        [% budget.total_spent %]
+        <span class="total_amount">[% budget.total_spent | $Price %]</span>
       [% END %]
     </td>
 
@@ -356,29 +379,40 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
             [% END %]
          [% ELSE %]
             [% IF (value > 0) %]
-                <span style="color: green;">
+                <span class="total_amount" style="color: green;">
             [% ELSIF (value < 0) %]
-                <span style="color: red;">
+                <span class="total_amount" style="color: red;">
             [% ELSE %]
-                <span>
+                <span class="totalamount">
             [% END %]
         [% END %]
-            [% text %]
+            [% value | $Price %]
         </span>
     [% END %]
     <td class="data">
-        [% INCLUDE colorcellvalue value=budget.budget_remaining text=budget.budget_remaining_display parent=budget.budget_parent_id %]
+        [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
     </td>
     <td class="data">
-        [% INCLUDE colorcellvalue value=budget.total_remaining text=budget.total_remaining_display parent=budget.budget_parent_id %]
+        [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
     </td>
     [% IF ( budget.budget_lock ) %]
-        <td> <span style="color: gray;"> Edit Delete </span> </td>
+        <td> <span></span> </td>
     [% ELSE %]
         <td>
-            <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]" >Edit</a>
-            <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&amp;budget_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]">Delete</a>
-            <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_parent_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]">Add child fund</a>
+            <div class="dropdown dropup">
+                <a class="btn btn-mini dropdown-toggle" id="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]" role="button" data-toggle="dropdown" href="#">
+                   Actions <b class="caret"></b>
+                </a>
+                <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id %]_[% budget.budget_period_id %]">
+                    <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-pencil"></i> Edit</a></li>
+                    [% IF budget.budget_has_children %]
+                        <li class="disabled"><a href="#" class="deletefund-disabled" data-toggle="tooltip" data-placement="left" title="This fund has children"><i class="fa fa-trash"></i> Delete</a></li>
+                    [% ELSE %]
+                        <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&amp;budget_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-trash"></i> Delete</a></li>
+                    [% END %]
+                    <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_parent_id=[% budget.budget_id %]&amp;budget_period_id=[% budget.budget_period_id %]"><i class="fa fa-plus"></i> Add child fund</a></li>
+                </ul>
+            </div>
         </td>
     [% END %]
     </tr>
@@ -387,7 +421,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 </table>
 
 [% ELSE %]
-    No fund found
+    <p>No fund found</p>
 [% END %]
 
 [% END %] <!-- list -->
@@ -426,19 +460,19 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 
     <li>
     <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
-    <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount %]" size="8" />
+    <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
     </li>
 
     <li>
       <label for="budget_encumb">Warning at (%): </label>
       <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb %]" size="10" />
-      <span style="color:grey">0 to disable</span>
+      <span class="hint">0 to disable</span>
     </li>
 
     <li>
       <label for="budget_expend">Warning at (amount): </label>
-      <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend %]" size="10" /><input type="hidden" name="budget_owner_id" id="budget_owner_id" value="[% budget_owner_id %]" />
-      <span style="color:grey">0 to disable</span>
+      <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
+      <span class="hint">0 to disable</span>
     </li>
 
     <li>
@@ -451,13 +485,22 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
         <input type="hidden" name="budget_owner_id" id="budget_owner_id"
             value="[% budget_owner_id %]" />
 
-        <!-- FIXME: hardcoded button positions :/ -->
         <input type="button" id="edit_owner" value="Edit owner"
             onclick="ownerPopup(); return false;" />
         <input type="button" id="remove_owner" value="Remove owner"
             onclick="ownerRemove(); return false;" />
     </li>
 
+    [% IF budget_has_children %]
+        <li class="radio">
+            <label>
+                <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
+                Update all child funds with this owner
+            </label>
+            <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
+        </li>
+    [% END %]
+
     <li>
         <span class="label">Users:</span>
         <ul style="float:left;" id="budget_users">
@@ -577,25 +620,26 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
 [% END %] <!-- add_form -->
 
 [% IF op == 'delete_confirm' %]
-<div class="dialog alert"> <h3>Delete fund [% budget_name %]?</h3>
-<table>
-    <tr>
-    <th scope="row">Fund amount:</th>
-    <td>[% budget_amount %]</td>
-    </tr>
-</table>
-
-<form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
-    <input type="hidden" name="op" value="delete_confirmed" />
-    <input type="hidden" name="budget_id" value="[% budget_id %]" />
-    <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
-    <input type="submit" value="Delete" class="approve" />
-</form>
-
-<form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
-    <input type="submit" class="deny" value="Cancel" />
-</form>
-</div>
+    <div class="dialog alert">
+        <h3>Delete fund [% budget_name %]?</h3>
+        If you delete this fund, all orders linked to this fund will be deleted!
+        <table>
+            <tr>
+            <th scope="row">Fund amount:</th>
+            <td>[% budget_amount | $Price %]</td>
+            </tr>
+        </table>
+
+        <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
+            <input type="hidden" name="op" value="delete_confirmed" />
+            <input type="hidden" name="budget_id" value="[% budget_id %]" />
+            <input type="hidden" name="budget_period_id" value="[% budget_period_id %]" />
+            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
+        </form>
+        <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
+            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
+        </form>
+    </div>
 [% END %]
 
 </div>
@@ -620,7 +664,7 @@ var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget")
         </li>
         <li class="radio">
 
-        <label for="show_mine">Show my funds only</label>
+        <label for="show_mine">Show my funds only:</label>
             [% IF ( show_mine ) %]
                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
             [% ELSE %]