[Koha-patches] [PATCH] Reserves Updates Ported From Dev_Week

Kyle M Hall kyle.m.hall at gmail.com
Tue Sep 22 15:31:44 CEST 2009


This is a much improved re-implementation of the reserves updates from dev_week.
Less new code has been added, and more existing functions are used instead of adding new ones.

The 'Lock Hold' function has been removed due to it not working as intended.
---
 C4/Reserves.pm                                     |  117 ++++++++++++++++++--
 installer/data/mysql/updatedatabase.pl             |   10 ++
 .../prog/en/modules/reserve/request.tmpl           |   74 ++++++++++++
 koha-tmpl/intranet-tmpl/prog/img/go-bottom.png     |  Bin 0 -> 663 bytes
 koha-tmpl/intranet-tmpl/prog/img/go-down.png       |  Bin 0 -> 683 bytes
 koha-tmpl/intranet-tmpl/prog/img/go-top.png        |  Bin 0 -> 636 bytes
 koha-tmpl/intranet-tmpl/prog/img/go-up.png         |  Bin 0 -> 652 bytes
 koha-tmpl/intranet-tmpl/prog/img/x.png             |  Bin 0 -> 655 bytes
 .../opac-tmpl/prog/en/modules/opac-reserve.tmpl    |   33 ++++++
 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl |    8 +-
 misc/cronjobs/cancel_expired_reserves.pl           |   39 +++++++
 opac/opac-reserve.pl                               |   18 ++--
 opac/opac-user.pl                                  |    7 +
 reserve/placerequest.pl                            |    9 +-
 reserve/request.pl                                 |   26 ++++-
 15 files changed, 313 insertions(+), 28 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/img/go-bottom.png
 create mode 100644 koha-tmpl/intranet-tmpl/prog/img/go-down.png
 create mode 100644 koha-tmpl/intranet-tmpl/prog/img/go-top.png
 create mode 100644 koha-tmpl/intranet-tmpl/prog/img/go-up.png
 create mode 100644 koha-tmpl/intranet-tmpl/prog/img/x.png
 create mode 100755 misc/cronjobs/cancel_expired_reserves.pl

diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index 8610036..6265e63 100644
--- a/C4/Reserves.pm
+++ b/C4/Reserves.pm
@@ -113,19 +113,22 @@ BEGIN {
         &CancelReserve
 
         &IsAvailableForItemLevelRequest
+        
+        &AlterPriority
+        &ToggleLowestPriority
     );
 }    
 
 =item AddReserve
 
-    AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$notes,$title,$checkitem,$found)
+    AddReserve($branch,$borrowernumber,$biblionumber,$constraint,$bibitems,$priority,$resdate,$expdate,$notes,$title,$checkitem,$found)
 
 =cut
 
 sub AddReserve {
     my (
         $branch,    $borrowernumber, $biblionumber,
-        $constraint, $bibitems,  $priority, $resdate,  $notes,
+        $constraint, $bibitems,  $priority, $resdate, $expdate, $notes,
         $title,      $checkitem, $found
     ) = @_;
     my $fee =
@@ -135,6 +138,7 @@ sub AddReserve {
     my $const   = lc substr( $constraint, 0, 1 );
     $resdate = format_date_in_iso( $resdate ) if ( $resdate );
     $resdate = C4::Dates->today( 'iso' ) unless ( $resdate );
+    $expdate = format_date_in_iso( $expdate ) if ( $expdate );
     if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
 	# Make room in reserves for this before those of a later reserve date
 	$priority = _ShiftPriorityByDateAndPriority( $biblionumber, $resdate, $priority );
@@ -165,16 +169,16 @@ sub AddReserve {
     my $query = qq/
         INSERT INTO reserves
             (borrowernumber,biblionumber,reservedate,branchcode,constrainttype,
-            priority,reservenotes,itemnumber,found,waitingdate)
+            priority,reservenotes,itemnumber,found,waitingdate,expirationdate)
         VALUES
              (?,?,?,?,?,
-             ?,?,?,?,?)
+             ?,?,?,?,?,?)
     /;
     my $sth = $dbh->prepare($query);
     $sth->execute(
         $borrowernumber, $biblionumber, $resdate, $branch,
         $const,          $priority,     $notes,   $checkitem,
-        $found,          $waitingdate
+        $found,          $waitingdate,	$expdate
     );
 
     #}
@@ -217,7 +221,9 @@ sub GetReservesFromBiblionumber {
                 constrainttype,
                 found,
                 itemnumber,
-                reservenotes
+                reservenotes,
+                expirationdate,
+                lowestPriority
         FROM     reserves
         WHERE biblionumber = ? ";
     unless ( $all_dates ) {
@@ -660,6 +666,26 @@ sub CheckReserves {
     }
 }
 
+=item CancelExpiredReserves
+
+  CancelExpiredReserves();
+  
+  Cancels all reserves with an expiration date from before today.
+  
+=cut
+
+sub CancelExpiredReserves {
+
+  my $dbh = C4::Context->dbh;
+  my $sth = $dbh->prepare( "SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) AND expirationdate != '0000-00-00'" );
+  $sth->execute();
+
+  while ( my $res = $sth->fetchrow_hashref() ) {
+    CancelReserve( $res->{'biblionumber'}, '', $res->{'borrowernumber'} );
+  }
+  
+}
+
 =item CancelReserve
 
   &CancelReserve($biblionumber, $itemnumber, $borrowernumber);
@@ -1165,9 +1191,75 @@ sub IsAvailableForItemLevelRequest {
     }
 }
 
+=item AlterPriority
+AlterPriority( $where, $borrowernumber, $biblionumber, $reservedate );
+
+This function changes a reserve's priority up, down, to the top, or to the bottom.
+Input: $where is 'up', 'down', 'top' or 'bottom'. Biblionumber, Date reserve was placed
+Output: None on success, -1 on failure
+
+=cut
+sub AlterPriority {
+    my ( $where, $borrowernumber, $biblionumber ) = @_;
+
+    my $newPriority = -1;
+
+    my $dbh = C4::Context->dbh;
+
+    ## Find this reserve
+    my $sth = $dbh->prepare('SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? AND cancellationdate IS NULL');
+    $sth->execute( $biblionumber, $borrowernumber );
+    my $reserve = $sth->fetchrow_hashref();
+    $sth->finish();
+
+    if ( $where eq 'up' || $where eq 'down' ) {
+    
+      my $priority = $reserve->{'priority'};        
+      $priority = $where eq 'up' ? $priority - 1 : $priority + 1;
+      _FixPriority( $biblionumber, $borrowernumber, $priority )
+
+    } elsif ( $where eq 'top' ) {
+
+      _FixPriority( $biblionumber, $borrowernumber, '1' )
+
+    } elsif ( $where eq 'bottom' ) {
+
+      _FixPriority( $biblionumber, $borrowernumber, '999999' )
+
+    }
+
+    return $newPriority;
+
+}
+
+=item ToggleLowestPriority
+ToggleLowestPriority( $borrowernumber, $biblionumber );
+
+This function sets the lowestPriority field to true if is false, and false if it is true.
+=cut
+
+sub ToggleLowestPriority {
+    my ( $borrowernumber, $biblionumber ) = @_;
+
+    my $dbh = C4::Context->dbh;
+
+    my $sth = $dbh->prepare(
+        "UPDATE reserves SET lowestPriority = NOT lowestPriority
+         WHERE biblionumber = ?
+         AND borrowernumber = ?"
+    );
+    $sth->execute(
+        $biblionumber,
+        $borrowernumber,
+    );
+    $sth->finish;
+    
+    _FixPriority( $biblionumber, $borrowernumber, '999999' );
+}
+
 =item _FixPriority
 
-&_FixPriority($biblio,$borrowernumber,$rank);
+&_FixPriority($biblio,$borrowernumber,$rank,$ignoreSetLowestRank);
 
  Only used internally (so don't export it)
  Changed how this functions works #
@@ -1179,7 +1271,7 @@ sub IsAvailableForItemLevelRequest {
 =cut 
 
 sub _FixPriority {
-    my ( $biblio, $borrowernumber, $rank ) = @_;
+    my ( $biblio, $borrowernumber, $rank, $ignoreSetLowestRank ) = @_;
     my $dbh = C4::Context->dbh;
      if ( $rank eq "del" ) {
          CancelReserve( $biblio, undef, $borrowernumber );
@@ -1255,6 +1347,15 @@ sub _FixPriority {
         );
         $sth->finish;
     }
+    
+    $sth = $dbh->prepare( "SELECT borrowernumber FROM reserves WHERE lowestPriority = 1 ORDER BY priority" );
+    $sth->execute();
+    
+    unless ( $ignoreSetLowestRank ) {
+      while ( my $res = $sth->fetchrow_hashref() ) {
+        _FixPriority( $biblio, $res->{'borrowernumber'}, '999999', 1 );
+      }
+    }
 }
 
 =item _Findgroupreserve
diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl
index 10c3451..5dd5ecf 100755
--- a/installer/data/mysql/updatedatabase.pl
+++ b/installer/data/mysql/updatedatabase.pl
@@ -2675,6 +2675,16 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
     SetVersion ($DBversion);
 }
 
+$DBversion = '3.01.00.061';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+    $dbh->do("ALTER TABLE `reserves` ADD `expirationdate` DATE NOT NULL");
+    $dbh->do("ALTER TABLE `reserves` ADD `lowestPriority` BOOL NOT NULL");
+    $dbh->do("ALTER TABLE `old_reserves` ADD `expirationdate` DATE NOT NULL");
+    $dbh->do("ALTER TABLE `old_reserves` ADD `lowestPriority` BOOL NOT NULL");
+    print "Upgrade to $DBversion done ( Added Additional Fields to Reserves tables )\n";
+    SetVersion ($DBversion);
+}
+
 =item DropAllForeignKeys($table)
 
   Drop all foreign keys of the table $table
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl
index 9fd20c4..3fec9d4 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl
@@ -282,6 +282,7 @@ function checkMultiHold() {
             <label for="pickup">Pickup at:</label>
             <!-- TMPL_VAR NAME="CGIbranch" -->
         </li>
+
 	<!-- TMPL_IF NAME="reserve_in_future" -->
 	<li>
 	    <label for="reserve_date">Hold starts on date:</label>
@@ -314,6 +315,37 @@ function checkMultiHold() {
 	</li>
 	<!-- /TMPL_IF -->
 
+	<li>
+	    <label for="expiration_date">Hold expires on date:</label>
+	    <input name="expiration_date" id="expiration_date" size="10" readonly="readonly">
+	    <img src="<!-- TMPL_VAR NAME="themelang" -->/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="CalendarExpirationDate" style="cursor: pointer;" />
+	    <script language="JavaScript" type="text/javascript">
+		//<![CDATA[
+		function validate1(date) {
+			var today = new Date();
+			if ( (date > today) ||
+                    ( date.getDate() == today.getDate() &&
+                      date.getMonth() == today.getMonth() &&
+                      date.getFullYear() == today.getFullYear() ) ) {
+				return false;
+			} else {
+				return true;
+			}
+		};
+		Calendar.setup(
+			{
+				inputField : "expiration_date",
+				ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+				button : "CalendarExpirationDate",
+				disableFunc : validate1,
+				dateStatusFunc : validate1,
+			}
+		);
+		//]]>
+	    </script>
+		<a href='#' onClick="document.getElementById('expiration_date').value='';">Clear Date</a>
+	</li>
+
         <!-- TMPL_UNLESS NAME="multi_hold" -->
           <li> <label for="requestany">Place a hold on the next available copy </label>
                <input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
@@ -530,11 +562,15 @@ function checkMultiHold() {
       <!-- /TMPL_IF -->
       <tr>
         <th>Priority</th>
+	<th>&nbsp</th>
         <th>Patron</th>
         <th>Notes</th>
         <th>Date</th>
+	<th>Expiration</th>
         <th>Pick up Library</th>
         <th>Details</th>
+        <th><img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/go-bottom.png" border="0" title="Toggle Set to Lowest Priority"></th>
+	<th>&nbsp;</th>
       </tr>
   <!-- TMPL_LOOP Name="reserveloop" -->
   <!-- TMPL_UNLESS Name="__odd__" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_UNLESS -->
@@ -551,6 +587,25 @@ function checkMultiHold() {
             <option value="del">del</option>
           </select>
         </td>
+
+        <td style="white-space:nowrap;">
+	        <a title="Move Reserve Up" href="request.pl?action=move&where=up&borrowernumber=<!-- TMPL_VAR Name="borrowernumber" -->&biblionumber=<!-- TMPL_VAR Name="biblionumber" -->&date=<!-- TMPL_VAR Name="date" -->">
+			<img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/go-up.png" border="0" />
+                </a>
+
+		<a title="Move Reserve To Top" href="request.pl?action=move&where=top&borrowernumber=<!-- TMPL_VAR Name="borrowernumber" -->&biblionumber=<!-- TMPL_VAR Name="biblionumber" -->&date=<!-- TMPL_VAR Name="date" -->">
+                	<img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/go-top.png" border="0" />
+                </a>
+
+                <a title="Move Reserve To Bottom" href="request.pl?action=move&where=bottom&borrowernumber=<!-- TMPL_VAR Name="borrowernumber" -->&biblionumber=<!-- TMPL_VAR Name="biblionumber" -->&date=<!-- TMPL_VAR Name="date" -->">
+                	<img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/go-bottom.png" border="0" />
+                </a>
+
+                <a title="Move Reserve Down" href="request.pl?action=move&where=down&borrowernumber=<!-- TMPL_VAR Name="borrowernumber" -->&biblionumber=<!-- TMPL_VAR Name="biblionumber" -->&date=<!-- TMPL_VAR Name="date" -->">
+                	<img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img//go-down.png" border="0" />
+                </a>
+        </td>
+
         <td>
           <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->" >
 	  <!-- TMPL_IF NAME="hidename" -->
@@ -562,6 +617,7 @@ function checkMultiHold() {
         </td>
         <td><!-- TMPL_VAR NAME="notes" --></td>
         <td><!-- TMPL_VAR NAME="date" --></td>
+	<td><!-- TMPL_VAR NAME="expirationdate" --></td>
         <td>
     <!-- TMPL_IF Name="wait" -->
     	<!-- TMPL_IF NAME="atdestination" -->
@@ -621,7 +677,25 @@ function checkMultiHold() {
       <!-- /TMPL_IF -->
     <!-- /TMPL_IF -->
         </td>
+
+	<td>
+		<a title="Toggle Lowest Priority" href="request.pl?action=setLowestPriority&borrowernumber=<!-- TMPL_VAR Name="borrowernumber" -->&biblionumber=<!-- TMPL_VAR Name="biblionumber" -->&date=<!-- TMPL_VAR Name="date" -->"> 
+			<!-- TMPL_IF NAME="lowestPriority" -->
+	                	<img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/go-bottom.png" border="0"/ title="Unset Lowest Priority" />
+		        <!-- TMPL_ELSE -->
+		                <img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/go-down.png" border="0"/ title="Set To Lowest Priority" />
+		        <!-- /TMPL_IF -->
+		</a>
+	</td> 
+
+	<td>
+		<a title="Cancel Reserve" href="request.pl?action=cancel&borrowernumber=<!-- TMPL_VAR Name="borrowernumber" -->&biblionumber=<!-- TMPL_VAR Name="biblionumber" -->&date=<!-- TMPL_VAR Name="date" -->">
+                	<img src="/intranet-tmpl/<!-- TMPL_VAR NAME='theme' -->/img/x.png" border="0" />
+                </a>
+	</td>
+
       </tr>
+
   <!-- /TMPL_LOOP --> <!-- existing reserveloop -->
      </table>
   <!-- /TMPL_IF --><!-- /reserveloop -->
diff --git a/koha-tmpl/intranet-tmpl/prog/img/go-bottom.png b/koha-tmpl/intranet-tmpl/prog/img/go-bottom.png
new file mode 100644
index 0000000000000000000000000000000000000000..2c5a80385cca2f80f829819f25e943bee4fbb759
GIT binary patch
literal 663
zcmV;I0%-k-P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004b3#c}2nYxW
zd<bNS0000PbVXQnQ*UN;cVTj60C#tHE@^ISb7Ns}WiD at WXPfRk8UO$SDM>^@R5*>5
zQafl<VHiFCeIz$hEJRH at Bt@yOMX+`<tq2_iB^`>0i$fhnu!z>dT at ZRl2cb)*4pLDG
zZG=odu7yxbG&DksLWh*3HCi!E at 4f%ybBM&$q+$>J%i-gE|2f}bM1)ohPMBp7qUZ#M
ziZjW3S}CJ#h!C}JK7mjILiv!2Lnsa|Jv>a^ZWC at 70Kk}r+-e%0*oG^%;PEY-Ju=$y
zQ(8wB42=DLU;tx~itk0BkqZ%lKmgIM0>;oi(;<aKbGHtch%BWfh!ltve7Oy-d at vpE
z;9awsI at 9pZAca&c($|0M@`I3}2SB7ONdk&VKo<Z6%A3nz`X$`Bdfx&8ocox`rt05+
zd`&ST!q9{{bMExT<nX{~uvmEm$$Uuo_~w?dR{I35e1Hf<8qW7#!(w5<D=z2LZzuT`
zt>G18uk)G8m+}(D!pA`x$GW$IlKT-XC=du~Fhe@}W5cL!R;jp>uMpvSGepPcH4u{1
zFCV)GvtXJgHvG>pEgb<%Lm;Fh9zKRhs1Mm!vo0wl9h=v7T*0w<K?rYrI`gQ0a9<o<
zp>CML#^(K9-8dDwfOPh0opXQOv3a5686BHXl{Qv0xety%&@%$fU@!t2&O}F$dq3~5
zSJ&non@{aHV_O3h#uf_mOTDqf at uT4c(+v&P(of1QI%OprzW-Sy$L2MXNX}+oxQB2O
x2h<5XpL^yi`NwxFSmKUBf0KK`E>- at 2`~s>b4Ju;H8xa5i002ovPDHLkV1l6R8=C+C

literal 0
HcmV?d00001

diff --git a/koha-tmpl/intranet-tmpl/prog/img/go-down.png b/koha-tmpl/intranet-tmpl/prog/img/go-down.png
new file mode 100644
index 0000000000000000000000000000000000000000..3dd7fccdf06321880f69d65631a363e4b813ba04
GIT binary patch
literal 683
zcmV;c0#yBpP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004b3#c}2nYxW
zd<bNS0000PbVXQnQ*UN;cVTj60C#tHE@^ISb7Ns}WiD at WXPfRk8UO$SJxN4CR5*==
zlTBz7K^TVLne65dYrtUAL;S(2^&%RNNwna>i}4~9FCHr5K@{qtRq-ka(iJ?ZP=uTm
zA)-=KTXM11RS2~$6nm&uv{cQSuKf$?CbP4jht?XK7~kVJ-#qia^UW|KLbc-EY953z
z>WRV7dqi_}NvUZfgl}C)!*&F0M_|b+V97E80CykVr~%gk05Haon|Y41T|%KagO77#
zXg_$ht|?xxSRKlv`0H+L2mld?91sx{?rsQB5|>q-9K_b`yI?say^?H5vawt?QN0%L
zQr8VKjyDQ9NJT;|(TgXq`xKW7BF8I9f|vxjL{S!?dO5hlaQ at UaF9;B#f^;@jnqQnt
zF(N{uTTQn`k0*~rlb-kaSCCvlqKp-L5!3TI5NItHN89$(7 at Zg?Pfm^Zz3vh1d at XXv
z%dw2{#h9W<a4(2g0GEwIWg4oF!R_NveJ(^JM`13QH2GoNAi|mTOVl+{1R?ow at Sf%6
zO$hjdDA7-pU5jvgIov)Mwr$yikgo;Vp^QZilDZ~}e@#Kx#6(4`bUqloQ`!+Y0GpMd
zdR9-~yeWYFp=0RFJ}wDS>C`nbQFn~GCVFR$PcMeY21IKx0j at A8ZjM9Y6Ue=LTlryr
z>(@2W+wdKbgN~t*f$yfVK)ah_*yWGG{JKoJQ9bX-)!YpMx+aPwk<4VDSzECWL8lc@
z`=3~j{FA#{Y~yeIt$3GuF4Da7HUP}#KVRBt{l5SJIDAFD4*<hA#o2%L`~q`I5-Nsh
R9LoRz002ovPDHLkV1n2dD_Z~n

literal 0
HcmV?d00001

diff --git a/koha-tmpl/intranet-tmpl/prog/img/go-top.png b/koha-tmpl/intranet-tmpl/prog/img/go-top.png
new file mode 100644
index 0000000000000000000000000000000000000000..70f2c996cd72a79328be5bd0ef9b39cc86be7086
GIT binary patch
literal 636
zcmV-?0)zdDP)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004b3#c}2nYxW
zd<bNS0000PbVXQnQ*UN;cVTj60C#tHE@^ISb7Ns}WiD at WXPfRk8UO$S4oO5oR5*>L
zlTS!gQ51)N=l*%UXM%2Q)F>(p+zgmdf)8?0hB*|-MC$<?Xi<>(Y7uSP)<6hBv<Ta@
z3X;H0w2KT}1qlUW7)gyXOf!tbIPbmt-f=NXWP=u7xSPYdAHVP1dueb|G4`><ehvcw
zG5;OF^>p%pb#VTA`mW=f8m3=A+VF$gz+5g|*fW9a=~fVCub#hVuLlKG!y<+UFWVr@
zx}I*`6F`LLL;b0)!-tO1O8E;`N}ti*)<%831DzmD?+S1|ojsB`IeM-?t-lsNLXv_Y
zi4Wgq(ARs$>S*s8bv>PJ3UEE0w6rsoxp>?8Sy_bP08%N`;|ezT7d{o<Vq|EnMJa2_
z^>p$Nz_$1Jr8{;^A=dpOl#<YvL^=8a?FbajGD^IR3ujX{iQn at O+up;c)15utNy=B2
zAS6L*LNzMD7iCzEgyje<R^B1e-9gFTQwb7{dC=gb${y|PnVPur&{5Jt41*X3^Z8d;
zD87LaHAqQF9rpkL%#0ui at M7j!tyn7DQY4W1zPjX0JRWN}Db#Z}UfPvl6-LycEdi+;
ziE>Zx*NxBimVOIKWYqfyp}XTIm^nr{$U_L)(rG}9&-Pp{q+Q<u0K{xi^^0KU#*P_r
z)cnh+W<?Vj_ at NJGh7k<r7*Y5ifG9Q?IdKyt03iSpgvk6WfUtJ&$#|k!GYPEitZf3y
Wz0B;ZgpY0j0000<MNUMnLSTYaff%F!

literal 0
HcmV?d00001

diff --git a/koha-tmpl/intranet-tmpl/prog/img/go-up.png b/koha-tmpl/intranet-tmpl/prog/img/go-up.png
new file mode 100644
index 0000000000000000000000000000000000000000..fa9a7d71b5615dde4c5f702f95df533adadd56e0
GIT binary patch
literal 652
zcmV;70(1R|P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004b3#c}2nYxW
zd<bNS0000PbVXQnQ*UN;cVTj60C#tHE@^ISb7Ns}WiD at WXPfRk8UO$S9!W$&R5*>5
zlTT<9K@`TnH at h?0jfHw>O#jh>1nt2<DyY!aifBY)MJ*I^Yf8yUkYX0WtH)B2pcfBC
zPadU0@#0M?UPMsPLn*W>m6SAzrkW<%*%=Q}tRboP9pC%r$9&(LA+0sq)ybQD9srhR
zz3Fxu)^6aqJl)?FN%nOeOgb)4?+M_zJQ@)DvRBSb2FFH|!GH*69hXP{3*flC1BAti
zbJNzAm&ca3iTKDR3xq|-<sJV75aH42aH6L-G)SLIAMmmC9-W<?6dO9x4Z_1+0glVl
z{Rbk6vq#7IO8yND#$hs!S8EH14ILMu{XL21JlKxIQNitOD&gAe<z;B{AcToJeaAKx
z at h<-y7fxRdnx^<G54O|y)L6z+<e?%<5CH)m;3&&=2-`qGuA-<`asJdri`bt$*l*wQ
zW8>Y2`eKx?tij|4I5$vH1yqf%5H^Fb8J54jK)5$VM-C5%i8b<|k&Kxh=#FG>Ox&>r
z4?sb}hlkg>1-vahgJcyDBP0eg&{{(&pkA-x at zeQAv9vj35<}`!ZpEItce&w-qk8xH
z6RRw9 at QrP7!N5#{!3lE at ZdYYZTfgiFi6Lb!&3aDLCbZTHrTP~zgJ5t59%w*hO<OPL
zJlgdg0D#gye$<PNEBhL<uAo)xKV!CP`bwf&+lDeVpcQ;c at Vz|%q%RR4yar+bF#-|x
m03dAKx<46iB__f~bMGfG_r=?`(3&Cu0000<MNUMnLSTZayC59^

literal 0
HcmV?d00001

diff --git a/koha-tmpl/intranet-tmpl/prog/img/x.png b/koha-tmpl/intranet-tmpl/prog/img/x.png
new file mode 100644
index 0000000000000000000000000000000000000000..1514d51a3cf1b67e1c5b9ada36f1fd474e2d214a
GIT binary patch
literal 655
zcmV;A0&x9_P)<h;3K|Lk000e1NJLTq000mG000mO1^@s6AM^iV00004XF*Lt006JZ
zHwB960000PbVXQnQ*UN;cVTj606}DLVr3vnZDD6+Qe|Oed2z{QJOBU!AxT6*R5;6(
zlj}|sQ51!ViOGr2pjL^7$dQ1=8$w$KD6I_$CeZtZUZjAurR}6mp*HFdO?(oc3q-}<
zu+o`!I at 9H@m`W`r;m1zSWX}5bthM(H02sJT)z?DT&OUcv5HmU|-dF4oa at p;T*KAHh
zFQ6^X?4p&<LW?JRAa!4W*8^cRHn#BV<;v&k;?li;fWKno-=RgNB}6ngw>uEoyT++I
zn$b9r%cFfhHe2K68Pk<hKq}2z2~lh9z5zadf|kv-0cZq5T=w`mb%(MY1L(c%58!zI
zxmp(Hu69|_VhN_cj;WfM0p5Rrno6S{41>Bu*@^<$y+7xQ$wJ~;c5aBx$R=xq*41Wo
zhwQus_VOgm0hughj}MhOvs#{>Vg09Y8WxjWUJY5Y<Msg#Hz1}_nVr{4MuGi*zXu>W
zJ?&8eG!59Cz=|E%Ns at 013KLWOLV)CObIIj_5{>{#k%TEAMs_GbdDV`x-iYsG<NRDe
z&F<oo(+wrG4$v4ShYJ*zTAVUyCyUEKWCOJq%P2g2jKiT}-UXn|;?x~V at D+7UK%!5l
zu+-wDffb%iu%q!uYSm;0f+3t(tT-AO#lfvX-T}~N2{oGoN+1Mj)d31iEk4tC0{b>H
z#=Z{USAQA>NY(}X7=3{K8#<xO0&SL1U06cNFs)HoJ!v1_9b#Vw at 2F?RJt3C#MxpR@
plJ)zU4s^HK{`H%}g=4&I{RVQoq{rLsz7zle002ovPDHLkV1j2<C=vhw

literal 0
HcmV?d00001

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
index 3ac7343..8ea59b7 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
@@ -242,6 +242,7 @@
 		  <!-- TMPL_IF NAME="reserve_in_future" -->
 		  <th>Hold Starts on Date</th>
 		  <!-- /TMPL_IF -->
+		  <th>Hold Not Needed After</th>
                   <!-- TMPL_IF NAME="OPACItemHolds" -->
                     <th id="place_on_hdr" style="display:none">Place On:</th>
                   <!-- /TMPL_IF -->
@@ -337,7 +338,39 @@
 			//]]>
 			</script>
 		    </td>
+
 		    <!-- /TMPL_IF -->
+	<td>
+	    <input name="expiration_date_<!-- TMPL_VAR NAME="biblionumber" -->" id="expiration_date_<!-- TMPL_VAR NAME="biblionumber" -->" size="10" readonly="readonly">
+	    <img src="<!-- TMPL_VAR NAME="themelang" -->/lib/calendar/cal.gif" alt="Show Calendar" border="0" id="CalendarExpirationDate" style="cursor: pointer;" />
+	    <script language="JavaScript" type="text/javascript">
+		//<![CDATA[
+		function validate1(date) {
+			var today = new Date();
+			if ( (date > today) ||
+                    ( date.getDate() == today.getDate() &&
+                      date.getMonth() == today.getMonth() &&
+                      date.getFullYear() == today.getFullYear() ) ) {
+				return false;
+			} else {
+				return true;
+			}
+		};
+		Calendar.setup(
+			{
+				inputField : "expiration_date_<!-- TMPL_VAR NAME="biblionumber" -->",
+				ifFormat : "<!-- TMPL_VAR NAME="DHTMLcalendar_dateformat" -->",
+				button : "CalendarExpirationDate",
+				disableFunc : validate1,
+				dateStatusFunc : validate1,
+			}
+		);
+		//]]>
+	    </script>
+		<br/>
+		<a href='#' onClick="document.getElementById('expiration_date_<!-- TMPL_VAR NAME="biblionumber" -->').value='';">Clear Date</a>
+	</td>
+
                     <!-- TMPL_IF NAME="OPACItemHolds" -->
                       <td class="place_on_type" style="display:none">
                         <table>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
index 77ee406..4c39619 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tmpl
@@ -323,10 +323,11 @@ $.tablesorter.addParser({
             <thead><tr>
                 <th>Title</th>
                 <th>Placed On</th>
+		<th>Expires On</th>
                 <th>Pick Up Location</th>
-				<!-- TMPL_IF NAME="showpriority" -->
-				<th>Priority</th>
-				<!-- /TMPL_IF -->
+		<!-- TMPL_IF NAME="showpriority" -->
+			<th>Priority</th>
+		<!-- /TMPL_IF -->
                 <th>Status</th>
 		<th>Modify</th>
             </tr></thead>
@@ -349,6 +350,7 @@ $.tablesorter.addParser({
                     <!-- TMPL_VAR NAME="author" -->
                 </td>
                 <td><!-- TMPL_VAR NAME="reservedate" --></td>
+		<td><!-- TMPL_IF NAME="expirationdate" --><!-- TMPL_VAR NAME="expirationdate" --><!-- TMPL_ELSE -->Never Expires<!-- /TMPL_IF --></td>
                 <td><!-- TMPL_VAR NAME="branch" --></td>
 				<!-- TMPL_IF NAME="showpriority" -->
 				<td><!-- TMPL_VAR NAME="priority" --> </td>
diff --git a/misc/cronjobs/cancel_expired_reserves.pl b/misc/cronjobs/cancel_expired_reserves.pl
new file mode 100755
index 0000000..41a810e
--- /dev/null
+++ b/misc/cronjobs/cancel_expired_reserves.pl
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+#  This script loops through each overdue item, determines the fine,
+#  and updates the total amount of fines due by each user.  It relies on
+#  the existence of /tmp/fines, which is created by ???
+# Doesnt really rely on it, it relys on being able to write to /tmp/
+# It creates the fines file
+#
+#  This script is meant to be run nightly out of cron.
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+# $Id: sendoverdues.pl,v 1.1.2.1 2007/03/26 22:38:09 tgarip1957 Exp $
+
+BEGIN {
+    # find Koha's Perl modules
+    # test carefully before changing this
+    use FindBin;
+    eval { require "$FindBin::Bin/../kohalib.pl" };
+}
+
+use C4::Reserves;
+
+CancelExpiredReserves();
\ No newline at end of file
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 4471dff..02d7c5e 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -199,6 +199,8 @@ if ( $query->param('place_reserve') ) {
 	    ) {
 	    $startdate = $query->param("reserve_date_$biblioNum");
 	}
+	
+	my $expiration_date = $query->param("expiration_date_$biblioNum");
 
         # If a specific item was selected and the pickup branch is the same as the
         # holdingbranch, force the value $rank and $found.
@@ -216,7 +218,7 @@ if ( $query->param('place_reserve') ) {
         }
         
         # Here we actually do the reserveration. Stage 3.
-        AddReserve($branch, $borrowernumber, $biblioNum, 'a', [$biblioNum], $rank, $startdate, $notes,
+        AddReserve($branch, $borrowernumber, $biblioNum, 'a', [$biblioNum], $rank, $startdate, $expiration_date, $notes,
                    $biblioData->{'title'}, $itemNum, $found);
     }
 
@@ -475,15 +477,13 @@ $template->param(itemtable_colspan => $itemTableColspan);
 # display infos
 $template->param(bibitemloop => $biblioLoop);
 
-# can set reserve date in future
-if (
-    C4::Context->preference( 'AllowHoldDateInFuture' ) &&
-    C4::Context->preference( 'OPACAllowHoldDateInFuture' )
-    ) {
-    $template->param(
-	reserve_in_future         => 1,
+$template->param(
 	DHTMLcalendar_dateformat  => C4::Dates->DHTMLcalendar(),
-	);
+);
+
+# can set reserve date in future
+if ( C4::Context->preference( 'AllowHoldDateInFuture' ) && C4::Context->preference( 'OPACAllowHoldDateInFuture' ) ) {
+    $template->param( reserve_in_future => 1 );
 }
 
 output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
index 487c136..e92d50c 100755
--- a/opac/opac-user.pl
+++ b/opac/opac-user.pl
@@ -184,6 +184,13 @@ $template->param( branchloop => \@branch_loop );
 my @reserves  = GetReservesFromBorrowernumber( $borrowernumber );
 foreach my $res (@reserves) {
     $res->{'reservedate'} = format_date( $res->{'reservedate'} );
+
+    if ( $res->{'expirationdate'} ne '0000-00-00' ) {
+      $res->{'expirationdate'} = format_date( $res->{'expirationdate'} ) 
+    } else {
+      $res->{'expirationdate'} = '';
+    }
+    
     my $publictype = $res->{'publictype'};
     $res->{$publictype} = 1;
     $res->{'waiting'} = 1 if $res->{'found'} eq 'W';
diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl
index 7026140..84096cc 100755
--- a/reserve/placerequest.pl
+++ b/reserve/placerequest.pl
@@ -51,6 +51,7 @@ my $type=$input->param('type');
 my $title=$input->param('title');
 my $borrowernumber=GetMember($borrower,'cardnumber');
 my $checkitem=$input->param('checkitem');
+my $expirationdate = $input->param('expiration_date');
 
 my $multi_hold = $input->param('multi_hold');
 my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
@@ -98,17 +99,17 @@ if ($type eq 'str8' && $borrowernumber ne ''){
         if ($multi_hold) {
             my $bibinfo = $bibinfos{$biblionumber};
             AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
-                       $bibinfo->{rank},$startdate,$notes,$bibinfo->{title},$checkitem,$found);
+                       $bibinfo->{rank},$startdate,$expirationdate,$notes,$bibinfo->{title},$checkitem,$found);
         } else {
             if ($input->param('request') eq 'any'){
                 # place a request on 1st available
-                AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$notes,$title,$checkitem,$found);
+                AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem,$found);
             } elsif ($reqbib[0] ne ''){
                 # FIXME : elsif probably never reached, (see top of the script)
                 # place a request on a given item
-                AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$notes,$title,$checkitem, $found);
+                AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
             } else {
-                AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$notes,$title,$checkitem, $found);
+                AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$startdate,$expirationdate,$notes,$title,$checkitem, $found);
             }
         }
     }
diff --git a/reserve/request.pl b/reserve/request.pl
index 2a744e3..6780d5b 100755
--- a/reserve/request.pl
+++ b/reserve/request.pl
@@ -91,6 +91,24 @@ my $warnings;
 my $messages;
 
 my $date = C4::Dates->today('iso');
+my $action = $input->param('action');
+
+if ( $action eq 'move' ) {
+  my $where = $input->param('where');
+  my $borrowernumber = $input->param('borrowernumber');
+  my $biblionumber = $input->param('biblionumber');
+                     
+  AlterPriority( $where, $borrowernumber, $biblionumber );
+
+} elsif ( $action eq 'cancel' ) {
+  my $borrowernumber = $input->param('borrowernumber');
+  my $biblionumber = $input->param('biblionumber');
+  CancelReserve( $biblionumber, '', $borrowernumber );
+} elsif ( $action eq 'setLowestPriority' ) {
+  my $borrowernumber = $input->param('borrowernumber');
+  my $biblionumber   = $input->param('biblionumber');
+  ToggleLowestPriority( $borrowernumber, $biblionumber );
+}
 
 if ($findborrower) {
     my ( $count, $borrowers ) =
@@ -482,6 +500,7 @@ foreach my $biblionumber (@biblionumbers) {
 	    $reserve{'hidename'} = 1;
 	    $reserve{'cardnumber'} = $reserveborrowerinfo->{'cardnumber'};
 	}
+        $reserve{'expirationdate'} = format_date( $res->{'expirationdate'} ) unless ( $res->{'expirationdate'} eq '0000-00-00' );
         $reserve{'date'}           = format_date( $res->{'reservedate'} );
         $reserve{'borrowernumber'} = $res->{'borrowernumber'};
         $reserve{'biblionumber'}   = $res->{'biblionumber'};
@@ -497,6 +516,7 @@ foreach my $biblionumber (@biblionumbers) {
         $reserve{'ccode'}           = $res->{'ccode'};
         $reserve{'barcode'}         = $res->{'barcode'};
         $reserve{'priority'}    = $res->{'priority'};
+        $reserve{'lowestPriority'}    = $res->{'lowestPriority'};
         $reserve{'branchloop'} = GetBranchesLoop($res->{'branchcode'});
         $reserve{'optionloop'} = \@optionloop;
         
@@ -549,16 +569,14 @@ foreach my $biblionumber (@biblionumbers) {
 
 $template->param( biblioloop => \@biblioloop );
 $template->param( biblionumbers => $biblionumbers );
+$template->param( DHTMLcalendar_dateformat  => C4::Dates->DHTMLcalendar() );
 
 if ($multihold) {
     $template->param( multi_hold => 1 );
 }
 
 if ( C4::Context->preference( 'AllowHoldDateInFuture' ) ) {
-    $template->param(
-	reserve_in_future         => 1,
-	DHTMLcalendar_dateformat  => C4::Dates->DHTMLcalendar(),
-	);
+  template->param( reserve_in_future => 1 );
 }
     
 # printout the page
-- 
1.5.6.5




More information about the Koha-patches mailing list