[Koha-patches] [PATCH] Bug 9744 - Add a column Fund name on the home page of acquisitions

Owen Leonard oleonard at myacpl.org
Tue Mar 12 14:31:35 CET 2013


This patch offers an alternative option to fix Bug 9744. In this version
the table of funds swaps positions with the suggestions block so that
the table has the whole width of the screen. This eliminates the need to
adjust its float property.

Other changes:

- Simplification of the column and row-hiding JavaScript
- The addition of an "Active" column to be shown when all funds
  are shown (this helps indicate to the user which rows were hidden)
- Linking the fund owner to their patron record
- Linking the fund id, given the correct permissions, to the view of all
  funds for that budget (the best alternative to linking to a view of
  the fund details, which we do not have).
- Correcting permission level required to add a budget

To test, view the acquisitions home page. The layout should feel
comfortable. The table of available funds thsould show the fund name.
The checkbox to show all funds should work correctly.
---
 acqui/acqui-home.pl                                |    5 +-
 .../prog/en/modules/acqui/acqui-home.tt            |  154 ++++++++++++--------
 2 files changed, 93 insertions(+), 66 deletions(-)

diff --git a/acqui/acqui-home.pl b/acqui/acqui-home.pl
index 8b6c584..5688452 100755
--- a/acqui/acqui-home.pl
+++ b/acqui/acqui-home.pl
@@ -102,8 +102,9 @@ foreach my $budget ( @{$budget_arr} ) {
 
     my $member = GetMember( borrowernumber => $budget->{budget_owner_id} );
     if ($member) {
-        $budget->{budget_owner} =
-          $member->{'firstname'} . ' ' . $member->{'surname'};
+        $budget->{budget_owner_firstname} = $member->{'firstname'};
+        $budget->{budget_owner_surname} = $member->{'surname'};
+        $budget->{budget_owner_borrowernumber} = $member->{'borrowernumber'};
     }
 
     if ( !defined $budget->{budget_amount} ) {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
index fa6ae53..b41029c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/acqui-home.tt
@@ -11,19 +11,21 @@
 dt_overwrite_html_sorting_localeCompare();
 
 $(document).ready(function() {
+
+    var inactive = $(".b_inactive,.bu_active");
+    var active = $(".bu_inactive");
+    inactive.hide();
+    active.show();
+
     $('#showallbudgets').click(function() {
-	if ( $('#showallbudgets:checked').val() !== undefined) {
-	    $('.b_inactive').show();
-	    $('#b_inactive').show();
-	    $('.bu_active').show();
-	    $('.bu_inactive').hide();
-	}
-	else {
-	    $('.b_inactive').hide();
-	    $('#b_inactive').hide();
-	    $('.bu_inactive').show();
-	    $('.bu_active').hide();
-	}
+        if ( $('#showallbudgets:checked').val() !== undefined) {
+            inactive.show();
+            active.hide();
+        }
+        else {
+            inactive.hide();
+            active.show();
+        }
     });
     var srlt = $("#accounts").dataTable($.extend(true, {}, dataTablesDefaults, {
         "aoColumns": [
@@ -31,13 +33,15 @@ $(document).ready(function() {
             null,
             null,
             null,
+            null,
+            null,
             { "sType": "num-html" },
             { "sType": "num-html" },
-            null,
+            null
         ],
         'bPaginate': false,
         'bFilter': false,
-        'bInfo': false,
+        'bInfo': false
     } ) );
 });
 //]]>
@@ -59,18 +63,16 @@ $(document).ready(function() {
 [% INCLUDE 'acquisitions-toolbar.inc' %]
 
 <h1>Acquisitions</h1>
-<div class="yui-g">
-<div class="yui-u first">
-<div id="acqui_acqui_home_order">
-
     [% UNLESS ( loop_budget ) %]
-        [% IF ( CAN_user_parameters ) %]
+        [% IF ( CAN_user_acquisition_period_manage ) %]
         <div class="dialog alert">You must <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">define a budget</a> in Administration</div>
         [% ELSE %]
         <div class="dialog alert">Your administrator must define a budget in Administration</div>
         [% END %]
     [% END %]
-
+<div class="yui-g">
+<div class="yui-u first">
+<div id="acqui_acqui_home_order">
     <fieldset>
         <legend>Manage orders</legend>
         <form name="findsupplier" action="/cgi-bin/koha/acqui/booksellers.pl" method="post">
@@ -80,20 +82,22 @@ $(document).ready(function() {
         </form>
     </fieldset>
 </div>
-
-[% IF ( suggestion ) %][% IF ( suggestions_count ) %]
-<div id="acqui_acqui_home_suggestions">
-    <fieldset>
-    <legend>Pending suggestions</legend>
-        <p>[% suggestions_count %] suggestions waiting. <a href="/cgi-bin/koha/suggestion/suggestion.pl">Manage suggestions</a>.</p>
-    </fieldset>
-</div>[% END %][% END %]
-
 </div>
 
+[% IF ( suggestion && suggestions_count ) %]
 <div class="yui-u">
+    <div id="acqui_acqui_home_suggestions">
+        <fieldset>
+        <legend>Pending suggestions</legend>
+            <p>[% suggestions_count %] suggestions waiting. <a href="/cgi-bin/koha/suggestion/suggestion.pl">Manage suggestions</a>.</p>
+        </fieldset>
+    </div>
+</div>
+[% END %]
+
+</div>
 
-        [% IF ( loop_budget ) %]
+[% IF ( loop_budget ) %]
 
             <h3>All available funds[% IF ( branchname ) %] for [% branchname %] library[% END %]</h3>
 
@@ -103,10 +107,13 @@ $(document).ready(function() {
 
 
     <div id="BudgetsAndFunds">
+    <p><label for="showallbudgets">Show active and inactive:</label> <input type="checkbox" id="showallbudgets" /></p>
     <table id="accounts">
         <thead>
         <tr>
             <th>Fund</th>
+            <th>Fund name</th>
+            <th class="b_inactive">Active</th>
             <th>Owner</th>
             <th>Library</th>
             <th>Amount</th>
@@ -119,53 +126,72 @@ $(document).ready(function() {
         <tr>
             <th>Total</th>
             <th> </th>
+            <th class="b_inactive"> </th>
             <th> </th>
-            <th align="right" ><span class="bu_active" style="display : none;">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
-            <th align="right" ><span class="bu_active" style="display : none;">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
-            <th align="right" ><span class="bu_active" style="display : none;">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
-            <th align="right" ><span class="bu_active" style="display : none;">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
+            <th> </th>
+            <th class="data"><span class="bu_active">[% total %]</span><span class="bu_inactive" >[% total_active %]</span></th>
+            <th class="data"><span class="bu_active">[% totordered %]</span><span class="bu_inactive" >[% totordered_active %]</span></th>
+            <th class="data"><span class="bu_active">[% totspent %]</span><span class="bu_inactive" >[% totspent_active %]</span></th>
+            <th class="data"><span class="bu_active">[% totavail %]</span><span class="bu_inactive" >[% totavail_active %]</span></th>
         </tr>
         </tfoot>
         <tbody>
         [% FOREACH loop_budge IN loop_budget %]
-	    [% IF ( loop_budge.budget_period_active ) %]
-            [% IF ( loop.odd ) %]
-                <tr>
-            [% ELSE %]
-                <tr class="highlight">
-            [% END %]
-                <td align="center">[% loop_budge.budget_code %]</td>
-                <td align="center">[% loop_budge.budget_owner %]</td>
-                <td align="center">[% loop_budge.budget_branchname %]</td>
-                <td align="right" >[% loop_budge.budget_amount %]</td>
-                <td align="right" ><a href="ordered.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
-                <td align="right" ><a href="spent.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
-                <td align="right" >[% loop_budge.budget_avail %]</td>
+        [% IF ( loop_budge.budget_period_active ) %]
+            <tr>
+                <td>
+                    [% IF ( CAN_user_acquisition_budget_manage ) %]
+                        <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id %]">[% loop_budge.budget_code %]</a>
+                    [% ELSE %]
+                        [% loop_budge.budget_code %]
+                    [% END %]
+                </td>
+                <td>[% loop_budge.budget_name %]</td>
+                <td class="b_inactive">Active</td>
+                <td>[% IF ( loop_budge.budget_owner_borrowernumber ) %]
+                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loop_budge.budget_owner_borrowernumber %]">[% loop_budge.budget_owner_surname %], [% loop_budge.budget_owner_firstname %]</a>
+                    [% ELSE %]
+                         
+                    [% END %]
+                </td>
+                <td>[% loop_budge.budget_branchname %]</td>
+                <td class="data">[% loop_budge.budget_amount %]</td>
+                <td class="data"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
+                <td class="data"><a href="spent.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
+                <td class="data">[% loop_budge.budget_avail %]</td>
+            </tr>
+        [% ELSE %]
+            <tr class="b_inactive">
+                <td>
+                    [% IF ( CAN_user_acquisition_budget_manage ) %]
+                        <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% loop_budge.budget_period_id %]">[% loop_budge.budget_code %]</a>
+                    [% ELSE %]
+                        [% loop_budge.budget_code %]
+                    [% END %]
+                </td>
+                <td>[% loop_budge.budget_name %]</td>
+                <td class="b_inactive">Inactive</td>
+                <td>[% IF ( loop_budge.budget_owner_borrowernumber ) %]
+                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% loop_budge.budget_owner_borrowernumber %]">[% loop_budge.budget_owner_surname %], [% loop_budge.budget_owner_firstname %]</a>
+                    [% ELSE %]
+                         
+                    [% END %]
+                </td>
+                <td>[% loop_budge.budget_branchname %]</td>
+                <td class="data">[% loop_budge.budget_amount %]</td>
+                <td class="data"><a href="ordered.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
+                <td class="data"><a href="spent.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
+                <td class="data">[% loop_budge.budget_avail %]</td>
             </tr>
-            [% ELSE %]
-            [% IF ( loop.odd ) %]
-                <tr class="b_inactive" style="display : none;">
-            [% ELSE %]
-                <tr class="highlight" id = "b_inactive" style="display : none;">
-            [% END %]
-            <td align="center" >[% loop_budge.budget_code %]</td>
-                <td align="center">[% loop_budge.budget_owner %]</td>
-                <td align="center">[% loop_budge.budget_branchname %]</td>
-                <td align="right" >[% loop_budge.budget_amount %]</td>
-                <td align="right" ><a href="ordered.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_ordered %]</a></td>
-                <td align="right" ><a href="spent.pl?fund=[% loop_budge.budget_id %]&fund_code=[% loop_budge.budget_code %]">[% loop_budge.budget_spent %]</a></td>
-                <td align="right" >[% loop_budge.budget_avail %]</td>
-            [% END %]
+        [% END %]
         [% END %]
         </tbody>
     </table>
-    </div><span class="label">Show all : </span><input type="checkbox" id="showallbudgets" />
+    </div>
     [% END %]
-</div>
 
 </div>
 </div>
-</div>
 <div class="yui-b">
 [% INCLUDE 'acquisitions-menu.inc' %]
 </div>
-- 
1.7.9.5


More information about the Koha-patches mailing list