From 2ee27fb1ccdb99532f612c81aa7d47db3c367654 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Tue, 20 May 2008 12:36:40 -0500 Subject: [PATCH] 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 --- admin/systempreferences.pl | 2 + circ/view_holdsqueue.pl | 107 ++++++++++++++++++ .../data/mysql/en/mandatory/sysprefs.sql | 3 + .../unimarc_standard_systemprefs.sql | 2 + installer/data/mysql/updatedatabase.pl | 4 + .../en/modules/circ/circulation-home.tmpl | 1 + .../prog/en/modules/circ/view_holdsqueue.tmpl | 93 +++++++++++++++ misc/cronjobs/holds/build_holds_queue.pl | 9 +- 8 files changed, 216 insertions(+), 5 deletions(-) create mode 100755 circ/view_holdsqueue.pl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tmpl diff --git a/admin/systempreferences.pl b/admin/systempreferences.pl index 3c22d3177d..771c3661fe 100755 --- a/admin/systempreferences.pl +++ b/admin/systempreferences.pl @@ -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"; diff --git a/circ/view_holdsqueue.pl b/circ/view_holdsqueue.pl new file mode 100755 index 0000000000..7e0490795a --- /dev/null +++ b/circ/view_holdsqueue.pl @@ -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; diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql b/installer/data/mysql/en/mandatory/sysprefs.sql index 00adb4c3e1..07a96c3850 100644 --- a/installer/data/mysql/en/mandatory/sysprefs.sql +++ b/installer/data/mysql/en/mandatory/sysprefs.sql @@ -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'); + diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql index 451e67c1ed..fa0ce562e1 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql @@ -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'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 5f1edb5e56..d904e7ec99 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -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); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl index e3bfdb87d0..a2e33aa1fd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tmpl @@ -28,6 +28,7 @@
Circulation Reports