Final update to holds queue work: adds link to holds queue

from circulation dashboard, creates new sysprefs, assigns
the sysprefs to the proper tab in sysprefs (Circulation),
updatedatabase changes to do the previous, and fixing one
redundent limit in the query for build_holds_queue.pl

Note: still need to address item-level holds
This commit is contained in:
Joshua Ferraro 2008-05-20 12:36:40 -05:00
parent a9a4965277
commit 2ee27fb1cc
8 changed files with 216 additions and 5 deletions

View file

@ -147,6 +147,8 @@ my %tabsysprefs;
$tabsysprefs{previousIssuesDefaultSortOrder}="Circulation";
$tabsysprefs{todaysIssuesDefaultSortOrder}="Circulation";
$tabsysprefs{HomeOrHoldingBranch}="Circulation";
$tabsysprefs{RandomizeHoldsQueueWeight}="Circulation";
$tabsysprefs{StaticHoldsQueueWeight}="Circulation";
# Staff Client
$tabsysprefs{TemplateEncoding}="StaffClient";

107
circ/view_holdsqueue.pl Executable file
View file

@ -0,0 +1,107 @@
#!/usr/bin/perl
# 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
=head1 view_holdsqueue
This script displays items in the tmp_holdsqueue table
=cut
use strict;
use CGI;
use C4::Auth;
use C4::Output;
use C4::Biblio;
use C4::Items;
use C4::Koha; # GetItemTypes
use C4::Branch; # GetBranches
use C4::Dates qw/format_date/;
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "circ/view_holdsqueue.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { circulation => 1 },
debug => 1,
}
);
my $params = $query->Vars;
my $run_report = $params->{'run_report'};
my $branchlimit = $params->{'branchlimit'};
my $itemtypeslimit = $params->{'itemtypeslimit'};
if ( $run_report ) {
my $items = GetHoldsQueueItems( $branchlimit,$itemtypeslimit );
$template->param(
branch => $branchlimit,
total => scalar @$items,
itemsloop => $items,
run_report => $run_report
);
}
# getting all branches.
my $branches = GetBranches;
my $branch = C4::Context->userenv->{"branchname"};
my @branchloop;
foreach my $thisbranch ( keys %$branches ) {
my $selected = 1 if $thisbranch eq $branch;
my %row = (
value => $thisbranch,
selected => $selected,
branchname => $branches->{$thisbranch}->{'branchname'},
);
push @branchloop, \%row;
}
# getting all itemtypes
my $itemtypes = &GetItemTypes();
my @itemtypesloop;
foreach my $thisitemtype ( sort keys %$itemtypes ) {
my %row = (
value => $thisitemtype,
description => $itemtypes->{$thisitemtype}->{'description'},
);
push @itemtypesloop, \%row;
}
$template->param( branchloop => \@branchloop,
itemtypeloop => \@itemtypesloop,
);
sub GetHoldsQueueItems {
my ($branchlimit,$itemtypelimit) = @_;
my $dbh = C4::Context->dbh;
my $query = "SELECT * FROM tmp_holdsqueue";
$query.=" WHERE holdingbranch = \"$branchlimit\"" if $branchlimit;
my $sth = $dbh->prepare($query);
$sth->execute();
my $items = [];
while ( my $row = $sth->fetchrow_hashref ){
$row->{reservedate} = format_date($row->{reservedate});
push @$items, $row;
}
return $items;
}
# writing the template
output_html_with_http_headers $query, $cookie, $template->output;

View file

@ -186,3 +186,6 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RenewSerialAddsSuggestion','0','If ON, adds a new suggestion at serial subscription renewal',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RandomizeHoldsQueueWeight','0','if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaticHoldsQueueWeight','0','Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective',NULL,'TextArea');

View file

@ -188,3 +188,5 @@ INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('RenewSerialAddsSuggestion','0','Si activé, génère une suggestion d''achat à chaque Renouvellement d''abonnement',NULL,'YesNo');
INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GoogleJackets','0','if ON, displays jacket covers from Google Books API',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RandomizeHoldsQueueWeight','0','if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight',NULL,'YesNo');
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaticHoldsQueueWeight','0','Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective',NULL,'TextArea');

View file

@ -1595,6 +1595,10 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
`pickbranch` varchar(10) default NULL,
`notes` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8");
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('RandomizeHoldsQueueWeight','0','if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight',NULL,'YesNo')");
$dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('StaticHoldsQueueWeight','0','Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective',NULL,'TextArea')");
print "Upgrade to $DBversion done (Table structure for table `tmp_holdsqueue`)\n";
SetVersion ($DBversion);
}

View file

@ -28,6 +28,7 @@
<h5>Circulation Reports</h5>
<ul>
<li> <a href="/cgi-bin/koha/circ/view_holdsqueue.pl" title="holds queue">Holds Queue</a></li>
<li> <a href="/cgi-bin/koha/circ/pendingreserves.pl" title="holds to retrieve off the shelf">Holds to pull</a></li>
<li> <a href="/cgi-bin/koha/circ/waitingreserves.pl" title="holds waiting for patron pickup">Holds awaiting pickup</a></li>
<li> <a href="/cgi-bin/koha/circ/reserveratios.pl">Hold ratios</a></li>

View file

@ -0,0 +1,93 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Circulation &rsaquo; Holds Queue</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cat-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a><!-- TMPL_IF NAME="run_report" --> &rsaquo; <a href="/cgi-bin/koha/circ/view_holdsqueue.pl">Holds Queue</a> &rsaquo; Results<!-- TMPL_ELSE --> &rsaquo; Holds Queue<!-- /TMPL_IF --></div>
<div id="doc3" class="yui-t2">
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<h1>Holds Queue</h1>
<!-- TMPL_IF NAME="run_report" -->
<div class="results">
<!-- TMPL_IF NAME="total" -->
<!-- TMPL_VAR NAME="total" --> items found for <!-- TMPL_VAR NAME="branch" -->
<!-- TMPL_ELSE-->
No items found
<!-- /TMPL_IF -->
</div>
<!-- TMPL_IF NAME="itemsloop" --><table>
<tr>
<th>Title</th>
<th>Call Number</th>
<th>Patron</th>
<th>Phone Number</th>
<th>Date</th>
<th>Send To</th>
</tr>
<!-- TMPL_LOOP NAME="itemsloop"-->
<tr>
<td><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber"-->">
<!-- TMPL_VAR NAME="title"--></td>
</a></td>
<td><!-- TMPL_VAR NAME="itemcallnumber"--></td>
<td><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber"-->">
<!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR NAME="firstname" -->
<!-- TMPL_VAR NAME="barcode"-->
</a></td>
<td><!-- TMPL_VAR NAME="phone"--></td>
<td><!-- TMPL_VAR NAME="reservedate" --></td>
<td><!-- TMPL_VAR NAME="pickbranch" --></td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<!-- /TMPL_IF -->
<!-- TMPL_ELSE -->
<form name="f" action="/cgi-bin/koha/circ/view_holdsqueue.pl" method="post">
<li><label for="branchlimit">Library: </label><select name="branchlimit" id="branchlimit">
<option value="">All</option>
<!-- TMPL_LOOP name="branchloop" -->
<!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="branchname" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select></li>
<!-- Not working yet
<li><label for="itemtypeslimit">Item Type: </label><select name="itemtypeslimit" id="itemtypeslimit">
<option value="">All</option>
<!-- TMPL_LOOP name="itemtypeloop" -->
<!-- TMPL_IF NAME="selected" --><option value="<!-- TMPL_VAR NAME="value" -->" selected="selected"><!-- TMPL_VAR NAME="description" --></option>
<!-- TMPL_ELSE -->
<option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="description" --></option>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</select></li>
-->
</ol></fieldset>
<fieldset class="action"> <input type="submit" value="Submit" />
<input type="hidden" name="run_report" value="1" /></fieldset>
</form>
<!-- /TMPL_IF -->
</div>
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="circ-menu.inc" -->
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -49,7 +49,6 @@ SELECT biblionumber,itemnumber,reserves.branchcode,reservenotes,borrowers.borrow
WHERE reserves.found IS NULL
AND reserves.borrowernumber=borrowers.borrowernumber
AND priority=1
AND cancellationdate IS NULL
GROUP BY biblionumber");
my $sth_load=$dbh->prepare("
@ -102,21 +101,21 @@ while (my $data=$sth->fetchrow_hashref){
# Item is not notforloan
(!$itm->{"notforloan"}) ) ) {
warn "patron requested pickup at $pickbranch for item in ".$itm->{'holdingbranch'};
#warn "patron requested pickup at $pickbranch for item in ".$itm->{'holdingbranch'};
# This selects items for fulfilment, and weights them based on
# a static list
my $weight=0;
# always prefer a direct match
if ($itm->{'holdingbranch'} eq $pickbranch) {
warn "Found match in pickuplibrary";
#warn "Found match in pickuplibrary";
$itemorder[$weight]=$itm;
}
else {
for my $branchcode (@branch_loop) {
$weight++;
if ($itm->{'homebranch'} eq $branchcode) {
warn "Match found with weight $weight in ".$branchcode;
#warn "Match found with weight $weight in ".$branchcode;
$itemorder[$weight]=$itm;
}
}
@ -124,7 +123,7 @@ while (my $data=$sth->fetchrow_hashref){
}
}
my $count = @itemorder;
warn "Empty array" if $count<1;
#warn "Empty array" if $count<1;
next GETIT if $count<1; # if the re-ordered array is empty, skip to next
PREP: