Merge remote-tracking branch 'origin/new/bug_7001'
authorPaul Poulain <paul.poulain@biblibre.com>
Tue, 13 Mar 2012 11:27:32 +0000 (12:27 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Tue, 13 Mar 2012 11:27:32 +0000 (12:27 +0100)
12 files changed:
C4/Reserves.pm
cataloguing/value_builder/callnumber-KU.pl
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/neworderempty.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/orderreceive.tt
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt
kohaversion.pl
suggestion/suggestion.pl

index d2af1c5..a63e30f 100644 (file)
@@ -861,10 +861,12 @@ Cancels all reserves with an expiration date from before today.
 
 sub CancelExpiredReserves {
 
+    # Cancel reserves that have passed their expiration date.
     my $dbh = C4::Context->dbh;
     my $sth = $dbh->prepare( "
         SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) 
         AND expirationdate IS NOT NULL
+        AND found IS NULL
     " );
     $sth->execute();
 
@@ -872,6 +874,24 @@ sub CancelExpiredReserves {
         CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
     }
   
+    # Cancel reserves that have been waiting too long
+    if ( C4::Context->preference("ExpireReservesMaxPickUpDelay") ) {
+        my $max_pickup_delay = C4::Context->preference("ReservesMaxPickUpDelay");
+        my $charge = C4::Context->preference("ExpireReservesMaxPickUpDelayCharge");
+
+        my $query = "SELECT * FROM reserves WHERE TO_DAYS( NOW() ) - TO_DAYS( waitingdate ) > ? AND found = 'W' AND priority = 0";
+        $sth = $dbh->prepare( $query );
+        $sth->execute( $max_pickup_delay );
+
+        while (my $res = $sth->fetchrow_hashref ) {
+            if ( $charge ) {
+                manualinvoice($res->{'borrowernumber'}, $res->{'itemnumber'}, 'Hold waiting too long', 'F', $charge);
+            }
+
+            CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
+        }
+    }
+
 }
 
 =head2 CancelReserve
@@ -1138,13 +1158,9 @@ sub ModReserveStatus {
 
     #first : check if we have a reservation for this item .
     my ($itemnumber, $newstatus) = @_;
-    my $dbh          = C4::Context->dbh;
-    my $query = " UPDATE reserves
-    SET    found=?,waitingdate = now()
-    WHERE itemnumber=?
-      AND found IS NULL
-      AND priority = 0
-    ";
+    my $dbh = C4::Context->dbh;
+
+    my $query = "UPDATE reserves SET found = ?, waitingdate = NOW() WHERE itemnumber = ? AND found IS NULL AND priority = 0";
     my $sth_set = $dbh->prepare($query);
     $sth_set->execute( $newstatus, $itemnumber );
 
@@ -1197,15 +1213,15 @@ sub ModReserveAffect {
     }
     else {
     # affect the reserve to Waiting as well.
-    $query = "
-        UPDATE reserves
-        SET     priority = 0,
-                found = 'W',
-                waitingdate=now(),
-                itemnumber = ?
-        WHERE borrowernumber = ?
-          AND biblionumber = ?
-    ";
+        $query = "
+            UPDATE reserves
+            SET     priority = 0,
+                    found = 'W',
+                    waitingdate = NOW(),
+                    itemnumber = ?
+            WHERE borrowernumber = ?
+              AND biblionumber = ?
+        ";
     }
     $sth = $dbh->prepare($query);
     $sth->execute( $itemnumber, $borrowernumber,$biblionumber);
@@ -1908,7 +1924,6 @@ sub MergeHolds {
     }
 }
 
-
 =head2 ReserveSlip
 
   ReserveSlip($branchcode, $borrowernumber, $biblionumber)
index e0fa444..201f9c8 100755 (executable)
@@ -104,7 +104,7 @@ sub plugin {
             if ( my $first = $dbh->selectrow_array("SELECT itemcallnumber
                                                     FROM items
                                                     WHERE itemcallnumber = ?", undef, $padded) ) {
-                my $icn = $dbh->selectcol_arrayref("SELECT itemcallnumber
+                my $icn = $dbh->selectcol_arrayref("SELECT DISTINCT itemcallnumber
                                                     FROM items
                                                     WHERE itemcallnumber LIKE ?
                                                       AND itemcallnumber >   ?
index 47b2483..d16ff81 100644 (file)
@@ -346,3 +346,5 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerRelink',1,'If ON the authority linker will relink headings that have previously been linked every time it runs.',NULL,'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo');
+INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay',  '0',  '',  'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay',  'YesNo');
+INSERT INTO systempreferences` (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelayCharge', '0', NULL , 'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.',  'free')
index 06eded1..b844560 100755 (executable)
@@ -4884,6 +4884,14 @@ Date due: <<issues.date_due>><br />
     SetVersion($DBversion);
 }
 
+$DBversion = "3.07.00.024";
+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelayCharge', '0', NULL , 'If ExpireReservesMaxPickUpDelay is enabled, and this field has a non-zero value, than a borrower whose waiting hold has expired will be charged this amount.',  'free')");
+    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('ExpireReservesMaxPickUpDelay', '0', '', 'Enabling this allows holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay', 'YesNo')");
+    print "Upgrade to $DBversion done (Added system preference ExpireReservesMaxPickUpDelay, system preference ExpireReservesMaxPickUpDelayCharge, add reseves.charge_if_expired)\n";
+    SetVersion($DBversion);
+}
+
 =head1 FUNCTIONS
 
 =head2 DropAllForeignKeys($table)
index 59f647c..88578b2 100644 (file)
                                     [% IF ( books_loo.suggestionid ) %]
                                         <br/>
                                         Suggested by: [% books_loo.surnamesuggestedby %][% IF ( books_loo.firstnamesuggestedby ) %], [% books_loo.firstnamesuggestedby %] [% END %]
-                                        (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid %]">suggestion #[% books_loo.suggestionid %]</a>)
+                                        (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% books_loo.suggestionid %]&op=show">suggestion #[% books_loo.suggestionid %]</a>)
                                     [% END %]
                                     [% IF ( books_loo.editionstatement ) %], [% books_loo.editionstatement %][% END %]
                             </p>
index a27d151..e6464f2 100644 (file)
@@ -326,7 +326,7 @@ $(document).ready(function()
         <ol>
           <li>
             <span class="label">Suggested by: </span>
-            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>)
+            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]&amp;op=show">suggestion #[% suggestionid %]</a>)
           </li>
         </ol>
         </fieldset>
index e238278..3eb3e23 100644 (file)
@@ -42,7 +42,7 @@
         <ol>
           <li>
             <span class="label">Suggested by: </span>
-            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]">suggestion #[% suggestionid %]</a>)
+            [% surnamesuggestedby %][% IF ( firstnamesuggestedby ) %], [% firstnamesuggestedby %][% END %] (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% suggestionid %]&amp;op=show">suggestion #[% suggestionid %]</a>)
           </li>
         </ol>
         </fieldset>
index afc9b65..786c5be 100644 (file)
                 [% IF ( loop_order.suggestionid ) %]
                     <br/>
                     Suggested by: [% loop_order.surnamesuggestedby %][% IF ( loop_order.firstnamesuggestedby ) %], [% loop_order.firstnamesuggestedby %] [% END %]
-                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]">suggestion #[% loop_order.suggestionid %]</a>)
+                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_order.suggestionid %]&amp;op=show">suggestion #[% loop_order.suggestionid %]</a>)
                 [% END %]
                 </td>
                 <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_order.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
                 [% IF ( loop_receive.suggestionid ) %]
                     <br/>
                     Suggested by: [% loop_receive.surnamesuggestedby %][% IF ( loop_receive.firstnamesuggestedby ) %], [% loop_receive.firstnamesuggestedby %] [% END %]
-                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]">suggestion #[% loop_receive.suggestionid %]</a>)
+                    (<a href="/cgi-bin/koha/suggestion/suggestion.pl?suggestionid=[% loop_receive.suggestionid %]&amp;op=show">suggestion #[% loop_receive.suggestionid %]</a>)
                 [% END %]
                 </td>
                 <td><a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=[% loop_receive.biblionumber %]" title="MARC" rel="gb_page_center[600,500]">Card</a></td>
index b020a92..64fe299 100644 (file)
@@ -284,6 +284,17 @@ Circulation:
               class: integer
             - days.
         -
+            - pref: ExpireReservesMaxPickUpDelay
+              choices:
+                  yes: Allow
+                  no: "Don't allow"
+            - "holds to expire automatically if they have not been picked by within the time period specified in ReservesMaxPickUpDelay"
+        -
+            - If using ExpireReservesMaxPickUpDelay, charge a borrower who allows his or her waiting hold to expire a fee of
+            - pref: ExpireReservesMaxPickUpDelayCharge
+              class: currency
+            - [% local_currency %].
+        -
             - Satisfy holds from the libraries
             - pref: StaticHoldsQueueWeight
               class: multi
index 47ee96a..91c5a8f 100644 (file)
@@ -1,5 +1,19 @@
-[% INCLUDE 'doc-head-open.inc' %]<title>Koha &rsaquo; Acquisitions  &rsaquo;
-[% IF ( op_save ) %][% IF ( suttesionid ) %]Edit purchase suggestion #[% suggestionid %][% ELSE %]Enter a new purchase suggestion[% END %][% ELSE %]Suggestions Management[% END %]</title>
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Acquisitions  &rsaquo;
+    [% IF ( op_save ) %]
+        [% IF ( suggestionid) %]
+            [% IF ( op == 'show' ) %]
+                Show purchase suggestion #[% suggestionid %]
+            [% ELSE %]
+                Edit purchase suggestion #[% suggestionid %]
+            [% END %]
+        [% ELSE %]
+            Enter a new purchase suggestion
+        [% END %]
+    [% ELSE %]
+        Suggestions Management
+    [% END %]
+</title>
 [% INCLUDE 'doc-head-close.inc' %]
 [% INCLUDE 'calendar.inc' %]
 [% IF ( op_else ) %] <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
@@ -91,7 +105,114 @@ $(document).ready(function() { calcNewsuggTotal(); });
 <body>
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo; [% IF ( op_save ) %] <a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a> &rsaquo; [% IF ( suggestionid ) %]Suggestion edit #[% suggestionid %][% ELSE %]New purchase suggestion[% END %][% ELSE %]Suggestions Management[% END %] </div>
+<div id="breadcrumbs">
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/acqui/acqui-home.pl">Acquisitions</a> &rsaquo;
+    [% IF ( op_save ) %]
+        <a href="/cgi-bin/koha/suggestion/suggestion.pl">Suggestions</a> &rsaquo;
+        [% IF ( op == 'show' ) %]
+            Show suggestion #[% suggestionid %]
+        [% ELSE %]
+            Suggestion edit #[% suggestionid %]
+        [% END %]
+    [% ELSE %]
+        Suggestions Management
+    [% END %]
+</div>
+
+[% IF ( op == 'show' ) %]
+<div id="doc" class="yui-t7"> <!-- <div id="doc3" class="yui-t2"> -->
+<div id="bd">
+    <div id="yui-main">
+    <div class="yui-b">
+
+    <fieldset class="rows">
+      <legend>Bibliographic information</legend>
+      <ol>
+        <li><span class="label">Title:</span>[% title |html %]</li>
+        <li><span class="label">Author:</span>[% author %]</li>
+        <li><span class="label">Copyright date:</span>[% copyrightdate %]</li>
+        <li><span class="label">ISBN or ISSN or other standard number:</span>[% isbn %]</li>
+        <li><span class="label">Publisher:</span>[% publishercode %]</li>
+        <li><span class="label">Publication Place:</span>[% place %]</li>
+        <li><span class="label">Collection Title:</span>[% collectiontitle %]</li>
+        <li><span class="label">Document Type:</span>
+            [% FOREACH itemtypeloo IN itemtypeloop %]
+                [% IF ( itemtypeloo.selected ) %][% itemtypeloo.description %][% END %]
+            [% END %]
+        </li>
+        [% IF ( patron_reason_loop ) %]
+          <li><span class="label">Reason for suggestion: </span>
+            [% FOREACH patron_reason_loo IN patron_reason_loop %]
+              [% IF ( patron_reason_loo.selected ) %][% patron_reason_loo.lib %][% END %]
+            [% END %]
+          </li>
+        [% END %]
+        <li><span class="label">Notes:</span>[% note %]</li>
+      </ol>
+    </fieldset>
+    <fieldset class="rows"> <legend>Suggestion management</legend>
+      <ol>
+        <li>
+          <span class="label">Status:</span>
+          [% IF ( STATUS == 'ASKED' ) %]Pending
+          [% ELSIF ( STATUS == 'ACCEPTED' ) %]Accepted
+          [% ELSIF ( STATUS == 'CHECKED' ) %]Checked
+          [% ELSIF ( STATUS == 'REJECTED' ) %]Rejected
+          [% ELSE %]No Status
+          [% END %]
+        </li>
+        <li>
+          <table>
+            <thead><tr><th>&nbsp;</th><th>Date</th><th>By</th></tr></thead>
+            <tbody>
+            <tr>
+                <th><span class="label">Suggestion creation</span> </th>
+                <td>[% suggesteddate %]</td>
+                <td>[% IF ( suggestedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% suggestedby_borrowernumber %]">[% suggestedby_surname %], [% suggestedby_firstname %]</a>  [% suggestedby_branchcode %] ([% suggestedby_description %])[% END %]
+                </td>
+            </tr>
+            <tr>
+                <th><span class="label">Suggestion management</span> </th>
+                <td>[% manageddate %]</td>
+                <td>[% IF ( managedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% managedby_borrowernumber %]">[% managedby_surname %], [% managedby_firstname %]</a> [% managedby_branchcode %] ([% managedby_description %])[% END %]</td>
+            </tr>
+            <tr>
+                <th><span class="label">Suggestion Accepted</span> </th>
+                <td>[% accepteddate %]</td>
+                <td>[% IF ( acceptedby_borrowernumber ) %]<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% acceptedby_borrowernumber %]">[% acceptedby_surname %], [% acceptedby_firstname %]</a> [% acceptedby_branchcode %] ([% acceptedby_description %])[% END %]</td>
+            </tr>
+            </tbody>
+        </table></li></ol>
+    </fieldset>
+    <fieldset class="rows"> <legend>Acquisition information</legend>
+      <ol>
+        <li>
+          <span class="label">Library:</span> [% branchname %]
+        </li>
+        <li>
+          <span class="label">Budget:</span> [% budgetname %]
+        </li>
+        <li>
+          <span class="label">Copies:</span>[% quantity %]
+        </li>
+        <li>
+          <span class="label">Currency:</span>[% currency %]
+        </li>
+        <li>
+          <span class="label">Price:</span>[% price %]
+        </li>
+        <li>
+          <span class="label">Total</span>[% total %]
+        </li>
+      </ol>
+    </fieldset>
+
+    <a class="cancel" href="suggestion.pl">&lt;&lt;Back to the list</a>
+
+    </div>
+    </div>
+</div>
+[% ELSE %]
 
 [% IF ( op_save ) %]<div id="doc" class="yui-t7">[% ELSE %]<div id="doc3" class="yui-t2">[% END %]
 <div id="bd">
@@ -189,7 +310,7 @@ $(document).ready(function() { calcNewsuggTotal(); });
                        <input type="text" readonly="readonly" id="total" name="total" size="10" value="[% total %]"/>
                 </li></ol>
     </fieldset><input type="hidden" id="returnsuggested" name="returnsuggested" value="[% IF ( returnsuggestedby ) %][% returnsuggestedby %][% ELSE %]noone[% END %]"/>
-    <fieldset class="action"><input type="hidden" name="op" value="[% op %]" />[% IF ( suggestionid ) %]<input type="submit" value="Save" /> <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby %]#suggestions[% ELSE %]suggestion.pl?suggestionid=[% suggestionid %][% END %]">Cancel</a>[% ELSE %]<input type="submit" value="Submit Your Suggestion" /> <a class="cancel" href="suggestion.pl">Cancel</a>[% END %]
+    <fieldset class="action"><input type="hidden" name="op" value="[% op %]" />[% IF ( suggestionid ) %]<input type="submit" value="Save" /> <a class="cancel" href="[% IF ( returnsuggestedby ) %]/cgi-bin/koha/members/moremember.pl?borrowernumber=[% returnsuggestedby %]#suggestions[% ELSE %]suggestion.pl?suggestionid=[% suggestionid %]&amp;op=show[% END %]">Cancel</a>[% ELSE %]<input type="submit" value="Submit Your Suggestion" /> <a class="cancel" href="suggestion.pl">Cancel</a>[% END %]
     </fieldset>
     </form>
 [% END %]
@@ -245,9 +366,9 @@ $(document).ready(function() { calcNewsuggTotal(); });
                     <input type="checkbox" name="edit_field" value="[% suggestions_loo.suggestionid %]" />
                 </td>
                 <td>
-                    <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid %]&amp;op=edit" title="suggestion" >
-                        [% suggestions_loo.title |html %][% IF ( suggestions_loo.author ) %], by [% suggestions_loo.author %][% END %]
-                    </a>
+                    <a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid %]&amp;op=show" title="suggestion" >
+                        [% suggestions_loo.title |html %][% IF ( suggestions_loo.author ) %], by [% suggestions_loo.author %][% END %]</a>
+                    [<a href="suggestion.pl?suggestionid=[% suggestions_loo.suggestionid %]&amp;op=edit" title="suggestion" >edit</a>]
                     <br />
                     [% IF ( suggestions_loo.copyrightdate ) %]&copy; [% suggestions_loo.copyrightdate %] [% END %]
                         [% IF ( suggestions_loo.volumedesc ) %]; Volume:<i>[% suggestions_loo.volumedesc %]</i> [% END %]
@@ -314,7 +435,7 @@ $(document).ready(function() { calcNewsuggTotal(); });
 </div>
 </div>
 
-      [% UNLESS ( op_save ) %] <div class="yui-b">
+      [% UNLESS ( op_save ) %] [% UNLESS ( op == 'show' ) %]<div class="yui-b">
 <form name="suggestionfilter" action="suggestion.pl" method="get">
 <fieldset class="brief"><ol style="display:block;"><li><label for="displayby">Organize by: </label>
                 <select name="displayby" id="displayby" style="width:auto;">
@@ -458,7 +579,10 @@ $(document).ready(function() { calcNewsuggTotal(); });
                 </fieldset>
     </div>
             </form>
-        </div>[% END %]
+        </div>
+    [% END %]
+    [% END %]
 </div>
+[% END %]
 [% INCLUDE 'intranet-bottom.inc' %]
 
index db0faf5..328624a 100644 (file)
@@ -16,7 +16,7 @@ the kohaversion is divided in 4 parts :
 use strict;
 
 sub kohaversion {
-    our $VERSION = '3.07.00.023';
+    our $VERSION = '3.07.00.024';
     # version needs to be set this way
     # so that it can be picked up by Makefile.PL
     # during install
index 272ca6f..64f00d4 100755 (executable)
@@ -34,13 +34,13 @@ use C4::Debug;
 
 sub Init{
     my $suggestion= shift @_;
-    foreach my $date qw(suggesteddate manageddate){
+    foreach my $date ( qw(suggesteddate manageddate) ){
         $suggestion->{$date}=(($suggestion->{$date} eq "0000-00-00" ||$suggestion->{$date} eq "")?
                                 $suggestion->{$date}=C4::Dates->today:
                                 format_date($suggestion->{$date}) 
                               );
     }               
-    foreach my $date qw(rejecteddate accepteddate){
+    foreach my $date ( qw(rejecteddate accepteddate) ){
     $suggestion->{$date}=(($suggestion->{$date} eq "0000-00-00" ||$suggestion->{$date} eq "")?
                                 "":
                                 format_date($suggestion->{$date}) 
@@ -173,6 +173,13 @@ elsif ($op eq "change" ) {
     }
     $op = 'else';
 }
+elsif ( $op eq 'show' ) {
+    $suggestion_ref=&GetSuggestion($$suggestion_ref{'suggestionid'});
+    $$suggestion_ref{branchname} = GetBranchName $$suggestion_ref{branchcode};
+    my $budget = GetBudget $$suggestion_ref{budgetid};
+    $$suggestion_ref{budgetname} = $$budget{budget_name};
+    Init($suggestion_ref);
+}
 if ($op=~/else/) {
     $op='else';
     
@@ -193,7 +200,7 @@ if ($op=~/else/) {
                 my $budget = GetBudget($suggestion->{budgetid});
                 $suggestion->{budget_name}=$budget->{budget_name} if $budget;
             }
-            foreach my $date qw(suggesteddate manageddate accepteddate){
+            foreach my $date ( qw(suggesteddate manageddate accepteddate) ){
                 if ($suggestion->{$date} ne "0000-00-00" && $suggestion->{$date} ne "" ){
                 $suggestion->{$date}=format_date($suggestion->{$date}) ;
                 } else {
@@ -219,7 +226,7 @@ if ($op=~/else/) {
     );
 }
 
-foreach my $element qw(managedby suggestedby acceptedby) {
+foreach my $element ( qw(managedby suggestedby acceptedby) ) {
 #    $debug || warn $$suggestion_ref{$element};
     if ($$suggestion_ref{$element}){
         my $member=GetMember(borrowernumber=>$$suggestion_ref{$element});
@@ -333,7 +340,7 @@ $template->param(
 );
 
 my %hashlists;
-foreach my $field qw(managedby acceptedby suggestedby budgetid) {
+foreach my $field ( qw(managedby acceptedby suggestedby budgetid) ) {
     my $values_list;
     $values_list=GetDistinctValues("suggestions.".$field) ;
     my @codes_list = map{