[Koha-patches] [PATCH] (bug #3825) improve waiting holds

Nahuel ANGELINETTI nahuel.angelinetti at biblibre.com
Wed Dec 2 11:46:10 CET 2009


This patch :
 * fix indentation
 * Separate waiting holds from holds over with tabs
 * Select only holds for librarian library
---
 circ/waitingreserves.pl                            |   27 ++++--
 .../prog/en/modules/circ/waitingreserves.tmpl      |  105 +++++++++++++++-----
 2 files changed, 97 insertions(+), 35 deletions(-)

diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl
index 812027f..6a9d58e 100755
--- a/circ/waitingreserves.pl
+++ b/circ/waitingreserves.pl
@@ -91,10 +91,11 @@ if ($item) {
     }
 }
 
-my @reservloop;
-my @getreserves = C4::Context->preference('IndependantBranches') ? GetReservesForBranch($default) : GetReservesForBranch();
+my (@reservloop, @overloop);
+my ($reservcount, $overcount);
+my @getreserves = $default ? GetReservesForBranch($default) : GetReservesForBranch();
 # get reserves for the branch we are logged into, or for all branches
-	
+
 my $today = Date_to_Days(&Today);
 foreach my $num (@getreserves) {
     next unless ($num->{'waitingdate'} && $num->{'waitingdate'} ne '0000-00-00');
@@ -106,21 +107,18 @@ foreach my $num (@getreserves) {
     my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} );  # using the fixed up itype/itemtype
     $getreserv{'waitingdate'} = format_date( $num->{'waitingdate'} );
 
-    my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/, $num->{'waitingdate'};
+    my ( $waiting_year, $waiting_month, $waiting_day ) = split (/-/, $num->{'waitingdate'});
     ( $waiting_year, $waiting_month, $waiting_day ) =
       Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day,
         C4::Context->preference('ReservesMaxPickUpDelay'));
     my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day );
 
-    if ($today > $calcDate) {
-        $getreserv{'messcompa'} = 1;
-    }
     $getreserv{'itemtype'}       = $itemtypeinfo->{'description'};
     $getreserv{'title'}          = $gettitle->{'title'};
     $getreserv{'itemnumber'}     = $gettitle->{'itemnumber'};
     $getreserv{'biblionumber'}   = $gettitle->{'biblionumber'};
     $getreserv{'barcode'}        = $gettitle->{'barcode'};
-    $getreserv{'homebranch'}     = $gettitle->{'homebranch'};
+    $getreserv{'homebranch'}     = GetBranchName($gettitle->{'homebranch'});
     $getreserv{'holdingbranch'}  = $gettitle->{'holdingbranch'};
     $getreserv{'itemcallnumber'} = $gettitle->{'itemcallnumber'};
     if ( $gettitle->{'homebranch'} ne $gettitle->{'holdingbranch'} ) {
@@ -133,11 +131,22 @@ foreach my $num (@getreserves) {
     if ( $getborrower->{'emailaddress'} ) {
         $getreserv{'borrowermail'}  = $getborrower->{'emailaddress'};
     }
-    push @reservloop, \%getreserv;
+ 
+    if ($today > $calcDate) {
+        push @overloop,   \%getreserv;
+        $overcount++;
+    }else{
+        push @reservloop, \%getreserv;
+        $reservcount++;
+    }
+    
 }
 
 $template->param(
     reserveloop => \@reservloop,
+    reservecount => $reservcount,
+    overloop    => \@overloop,
+    overcount   => $overcount,
     show_date   => format_date(C4::Dates->today('iso')),
 	dateformat  => C4::Context->preference("dateformat"),
 );
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl
index 0b42a14..7f7f3dc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tmpl
@@ -10,15 +10,16 @@ $.tablesorter.addParser({
     format: function(s) { return s.toLowerCase().replace(/^(the|an|a) /,''); }, 
     type: 'text' 
 });
-	 $(document).ready(function() {
-	 	$("th a").hide();
-		$.tablesorter.defaults.widgets = ['zebra'];
-		$("#holdst").tablesorter({<!-- TMPL_IF EXPR="dateformat eq 'metric'" -->
-		dateFormat: 'uk',<!-- /TMPL_IF -->
-			sortList: [[3,0]],
-			headers: { 1:{sorter:'articles'},3: { sorter: 'articles' },4:{sorter:false}}
-		}); 
- 	 });
+     $(document).ready(function() {
+         $('#resultlist > ul').tabs();
+         $("th a").hide();
+         $.tablesorter.defaults.widgets = ['zebra'];
+         $("#holdst").tablesorter({<!-- TMPL_IF EXPR="dateformat eq 'metric'" -->
+            dateFormat: 'uk',<!-- /TMPL_IF -->
+            sortList: [[3,0]],
+            headers: { 1:{sorter:'articles'},3: { sorter: 'articles' },4:{sorter:false}}
+        }); 
+      });
 //]]>
 </script>
 </head>
@@ -34,8 +35,8 @@ $.tablesorter.addParser({
 <div id="doc" class="yui-t7">
    
    <div id="bd">
-	<div id="yui-main">
-	<div class="yui-g">
+    <div id="yui-main">
+    <div class="yui-g">
 
         <h2>Holds awaiting pickup for your library on: <!-- TMPL_VAR NAME="show_date" --></h2>
         <!-- TMPL_IF NAME="messagetransfert" -->
@@ -60,7 +61,12 @@ $.tablesorter.addParser({
             </div>
         <!-- /TMPL_IF -->
         <!-- TMPL_UNLESS NAME="message" -->
-        <div id="resultlist">
+        <div id="resultlist" class="toptabs">
+            <ul>
+                <li><a href="/cgi-bin/koha/circ/waitingreserves.pl#holdswaiting"><!-- TMPL_VAR NAME="reservecount" --> Hold(s) waiting</a></li>
+                <li><a href="/cgi-bin/koha/circ/waitingreserves.pl#holdsover"><!-- TMPL_VAR NAME="overcount" --> Hold(s) over</a></li>
+            </ul>
+            <div id="holdswaiting">
             <!-- TMPL_IF NAME="reserveloop" -->
                <table id="holdst">
                <thead><tr>
@@ -71,27 +77,73 @@ $.tablesorter.addParser({
                     <th>Action</th>
                </tr></thead>
                <tbody><!-- TMPL_LOOP NAME="reserveloop" -->
-                <!-- TMPL_IF NAME="messcompa" --><tr class="problem"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
-                    <td><p><!-- TMPL_VAR NAME="waitingdate" --></p>
-                        <!-- TMPL_IF NAME="messcompa" -->Hold Over<!-- /TMPL_IF -->
+                <tr>
+                    <td><p><!-- TMPL_VAR NAME="waitingdate" --></p></td>
+                    <td>
+                        <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
+                        <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- TMPL_ELSIF NAME="BiblioDefaultViewisbd" -->
+                        <a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- TMPL_ELSE -->
+                        <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- /TMPL_IF -->
+                        <!-- TMPL_VAR NAME="title" escape="html" --> <!-- TMPL_VAR NAME="subtitle" ESCAPE="html" -->
+                        </a>
+                            &nbsp; (<b><!-- TMPL_VAR NAME="itemtype" --></b>)
+                            <br />Barcode: <!-- TMPL_VAR NAME="barcode" -->
+                    </td>
+                    <td>
+                        <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!--TMPL_VAR Name="borrowernum"-->"><!-- TMPL_VAR NAME="borrowername" -->, <!-- TMPL_VAR NAME="borrowerfirstname" --></a><br /><!-- TMPL_VAR NAME="borrowerphone" --><br />
+                        <!-- TMPL_IF NAME="borrowermail" --><a href="mailto:<!-- TMPL_VAR NAME="email" -->?subject=Reservation: <!-- TMPL_VAR NAME="title" -->">
+                        <!-- TMPL_VAR NAME="borrowermail" --></a><!--/TMPL_IF-->
                     </td>
+                    <td><!-- TMPL_VAR NAME="homebranch" --><br /><!-- TMPL_VAR NAME="itemcallnumber" --></td>
                     <td>
-    <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
-    <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
-    <!-- TMPL_ELSIF NAME="BiblioDefaultViewisbd" -->
-    <a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
-    <!-- TMPL_ELSE -->
-    <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
-    <!-- /TMPL_IF -->
-    <!-- TMPL_VAR NAME="title" escape="html" --> <!-- TMPL_VAR NAME="subtitle" ESCAPE="html" -->
-    </a>
-        &nbsp; (<b><!-- TMPL_VAR NAME="itemtype" --></b>)
+                        <form name="cancelReserve" action="waitingreserves.pl" method="post">
+                            <input type="hidden" name="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernum" -->" />
+                            <input type="hidden" name="itemnumber" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+                            <input type="hidden" name="fbr" value="<!-- TMPL_VAR NAME="holdingbranch" -->" />
+                            <input type="hidden" name="tbr" value="<!-- TMPL_VAR NAME="homebranch" -->" />
+                            <!-- TMPL_IF NAME="dotransfer" -->
+                            <input type="submit" value="Cancel hold and return to : <!-- TMPL_VAR NAME="homebranch" -->" /> 
+                            <!-- TMPL_ELSE -->
+                            <input type="submit" value="Cancel hold" />
+                            <!-- /TMPL_IF -->
+                       </form>
+                    </td>
+                </tr>
+                <!-- /TMPL_LOOP --></tbody>
+        </table>
+        </div>
+        <div id="holdsover">
+               <table id="holdso">
+               <thead><tr>
+                    <th>Available since</th>
+                    <th>Title</th>
+                    <th>Patron</th>
+                    <th>Location</th>
+                    <th>Action</th>
+               </tr></thead>
+               <tbody><!-- TMPL_LOOP NAME="overloop" -->
+                    <tr>
+                        <td><p><!-- TMPL_VAR NAME="waitingdate" --></p></td>
+                        <td>
+                        <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
+                        <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- TMPL_ELSIF NAME="BiblioDefaultViewisbd" -->
+                        <a href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- TMPL_ELSE -->
+                        <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+                        <!-- /TMPL_IF -->
+                        <!-- TMPL_VAR NAME="title" escape="html" --> <!-- TMPL_VAR NAME="subtitle" ESCAPE="html" -->
+                        </a>
+                            &nbsp; (<b><!-- TMPL_VAR NAME="itemtype" --></b>)
                         <br />Barcode: <!-- TMPL_VAR NAME="barcode" -->
                     </td>
                     <td>
                         <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!--TMPL_VAR Name="borrowernum"-->"><!-- TMPL_VAR NAME="borrowername" -->, <!-- TMPL_VAR NAME="borrowerfirstname" --></a><br /><!-- TMPL_VAR NAME="borrowerphone" --><br />
                         <!-- TMPL_IF NAME="borrowermail" --><a href="mailto:<!-- TMPL_VAR NAME="email" -->?subject=Reservation: <!-- TMPL_VAR NAME="title" -->">
-        <!-- TMPL_VAR NAME="borrowermail" --></a><!--/TMPL_IF-->
+        				<!-- TMPL_VAR NAME="borrowermail" --></a><!--/TMPL_IF-->
                     </td>
                     <td><!-- TMPL_VAR NAME="homebranch" --> <!-- TMPL_VAR NAME="itemcallnumber" --></td>
                     <td>
@@ -110,6 +162,7 @@ $.tablesorter.addParser({
                 </tr>
                 <!-- /TMPL_LOOP --></tbody>
         </table>
+        </div>
         <!-- TMPL_ELSE -->
             <div class="dialog message">No holds found.</div>
         <!-- /TMPL_IF -->
-- 
1.6.3.3




More information about the Koha-patches mailing list