Bugzilla – Attachment 41579 Details for
Bug 8352
Add automatic printing of 'hold to pull' notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8352 - Add automatic printing of 'hold to pull' notices
Bug-8352---Add-automatic-printing-of-hold-to-pull-.patch (text/plain), 9.30 KB, created by
Kyle M Hall (khall)
on 2015-08-18 13:47:49 UTC
(
hide
)
Description:
Bug 8352 - Add automatic printing of 'hold to pull' notices
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-08-18 13:47:49 UTC
Size:
9.30 KB
patch
obsolete
>From 537ffdb92a85af508f1e364f330d9c01911f0c30 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Tue, 3 Jul 2012 11:01:17 -0400 >Subject: [PATCH] Bug 8352 - Add automatic printing of 'hold to pull' notices > >Adds the ability to have a notice printed automatically >after a hold has been placed. > >The system has the ability to define a separate printer >for each branchcode, so each library can receive a printed >notice for any holds placed, assuming they have set up the >ability to print over the LAN, WAN, or Internet. Notices are >printed to the pickup library. > >Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> >--- > C4/Installer/PerlDependencies.pm | 5 + > installer/data/mysql/atomicupdate/bug_8352.sql | 8 + > .../data/mysql/en/mandatory/sample_notices.sql | 5 +- > installer/data/mysql/kohastructure.sql | 2 + > misc/cronjobs/holds/print_holds.pl | 159 ++++++++++++++++++++ > 5 files changed, 178 insertions(+), 1 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_8352.sql > create mode 100755 misc/cronjobs/holds/print_holds.pl > >diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm >index 0b845e4..3b80cd6 100644 >--- a/C4/Installer/PerlDependencies.pm >+++ b/C4/Installer/PerlDependencies.pm >@@ -611,6 +611,11 @@ our $PERL_DEPS = { > 'usage' => 'OpacSelfRegistration', > 'required' => '1', > 'min_ver' => '0.22', >+ }, >+ 'Net::Printer' => { >+ 'usage' => 'Push to printer', >+ 'required' => '0', >+ 'min_ver' => '1.11', > }, > 'File::Temp' => { > 'usage' => 'Plugins', >diff --git a/installer/data/mysql/atomicupdate/bug_8352.sql b/installer/data/mysql/atomicupdate/bug_8352.sql >new file mode 100644 >index 0000000..46fe717 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_8352.sql >@@ -0,0 +1,8 @@ >+ALTER TABLE reserves ADD printed BOOLEAN NULL AFTER suspend_until; >+ >+INSERT INTO letter ( module, code, branchcode, name, is_html, title, content ) VALUES ( >+ 'reserves', 'HOLD_PLACED_PRINT', '', 'Hold Placed ( Auto-Print )', '0', 'Hold Placed ( Auto-Print )', 'Hold to pull at <<branches.branchname>> >+ >+For <<borrowers.firstname>> <<borrowers.surname>> ( <<borrowers.cardnumber>> ) >+ >+<<biblio.title>> by <<biblio.author>>'); >diff --git a/installer/data/mysql/en/mandatory/sample_notices.sql b/installer/data/mysql/en/mandatory/sample_notices.sql >index 35625dd..65e9d4e 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.sql >+++ b/installer/data/mysql/en/mandatory/sample_notices.sql >@@ -154,4 +154,7 @@ Your library.' > ); > > INSERT INTO letter(module, code, branchcode, name, title, content, message_transport_type) >-VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email') >+VALUES ('acquisition', 'ACQ_NOTIF_ON_RECEIV', '', 'Notification on receiving', 'Order received', 'Dear <<borrowers.firstname>> <<borrowers.surname>>,\n\n The order <<aqorders.ordernumber>> (<<biblio.title>>) has been received.\n\nYour library.', 'email'); >+ >+INSERT INTO `letter` (`module`,`code`,`branchcode`,`name`,`is_html`,`title`,`content`) >+VALUES ('reserves', 'HOLD_PLACED_PRINT', 'Hold Placed ( Auto-Print )', 'Hold Placed ( Auto-Print )', 'Hold to pull at <<branches.branchname>>\r\nFor <<borrowers.firstname>> <<borrowers.surname>> ( <<borrowers.cardnumber>> )\r\n<<biblio.title>> by <<biblio.author>>'); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 13b6a6a..f4ba402 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1667,6 +1667,7 @@ CREATE TABLE `old_reserves` ( -- this table holds all holds/reserves that have b > `lowestPriority` tinyint(1) NOT NULL, -- has this hold been pinned to the lowest priority in the holds queue (1 for yes, 0 for no) > `suspend` BOOLEAN NOT NULL DEFAULT 0, -- in this hold suspended (1 for yes, 0 for no) > `suspend_until` DATETIME NULL DEFAULT NULL, -- the date this hold is suspended until (NULL for infinitely) >+ `printed` tinyint(1) DEFAULT NULL, > PRIMARY KEY (`reserve_id`), > KEY `old_reserves_borrowernumber` (`borrowernumber`), > KEY `old_reserves_biblionumber` (`biblionumber`), >@@ -1854,6 +1855,7 @@ CREATE TABLE `reserves` ( -- information related to holds/reserves in Koha > `lowestPriority` tinyint(1) NOT NULL, > `suspend` BOOLEAN NOT NULL DEFAULT 0, > `suspend_until` DATETIME NULL DEFAULT NULL, >+ `printed` tinyint(1) DEFAULT NULL, > PRIMARY KEY (`reserve_id`), > KEY priorityfoundidx (priority,found), > KEY `borrowernumber` (`borrowernumber`), >diff --git a/misc/cronjobs/holds/print_holds.pl b/misc/cronjobs/holds/print_holds.pl >new file mode 100755 >index 0000000..05d0db6 >--- /dev/null >+++ b/misc/cronjobs/holds/print_holds.pl >@@ -0,0 +1,159 @@ >+#!/usr/bin/perl >+ >+# Copyright 2009-2010 Kyle Hall >+# >+# 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., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+BEGIN { >+ >+ # find Koha's Perl modules >+ # test carefully before changing this >+ use FindBin; >+ eval { require "$FindBin::Bin/../kohalib.pl" }; >+} >+ >+use Getopt::Long; >+use Pod::Usage; >+use Net::Printer; >+ >+use C4::Context; >+use C4::Members qw(GetMember); >+use C4::Letters qw(GetPreparedLetter); >+ >+my $help = 0; >+my $test = 0; >+my $verbose = 0; >+my @printers; >+GetOptions( >+ "help|?" => \$help, >+ "verbose|v" => \$verbose, >+ "test|t" => \$test, >+ "printer|p=s" => \@printers, >+); >+pod2usage(1) if $help; >+pod2usage(1) unless @printers; >+ >+my %printers; >+foreach my $p (@printers) { >+ my ( $branchcode, $printer, $server, $port ) = split( /,/, $p ); >+ my %options; >+ $options{'printer'} = $printer if ($printer); >+ $options{'server'} = $server if ($server); >+ $options{'port'} = $port if ($port); >+ $printers{$branchcode} = new Net::Printer(%options); >+} >+ >+my $dbh = C4::Context->dbh; >+my $query = "SELECT * FROM reserves WHERE printed IS NULL"; >+my $sth = $dbh->prepare($query); >+$sth->execute(); >+ >+my $set_printed_query = " >+ UPDATE reserves >+ SET printed = 1 >+ WHERE reserve_id = ? >+"; >+my $set_printed_sth = $dbh->prepare($set_printed_query); >+ >+while ( my $hold = $sth->fetchrow_hashref() ) { >+ if ($verbose) { >+ print "\nFound Notice to Print\n"; >+ print "Borrowernumber: " . $hold->{'borrowernumber'} . "\n"; >+ print "Biblionumber: " . $hold->{'biblionumber'} . "\n"; >+ print "Branch: " . $hold->{'branchcode'} . "\n"; >+ } >+ >+ my $borrower = >+ C4::Members::GetMember( 'borrowernumber' => $hold->{'borrowernumber'} ); >+ >+ my $letter = GetPreparedLetter( >+ module => 'reserves', >+ letter_code => 'HOLD_PLACED_PRINT', >+ branchcode => $hold->{branchcode}, >+ tables => { >+ 'branches' => $hold->{'branchcode'}, >+ 'biblio' => $hold->{'biblionumber'}, >+ 'biblioitems' => $hold->{'biblionumber'}, >+ 'items' => $hold->{'itemnumber'}, >+ 'borrowers' => $borrower, >+ } >+ ); >+ >+ if ( defined( $printers{ $hold->{branchcode} } ) ) { >+ unless ($test) { >+ my $result = >+ $printers{ $hold->{'branchcode'} } >+ ->printstring( $letter->{'content'} ); >+ my $error = $printers{ $hold->{'branchcode'} }->printerror(); >+ >+ unless ($error) { >+ $set_printed_sth->execute( $hold->{'reserve_id'} ); >+ } >+ else { >+ warn "ERROR: $error"; >+ } >+ } >+ else { >+ print "TEST MODE, notice will not be printed\n"; >+ print $letter->{'content'} . "\n"; >+ } >+ } >+ else { >+ print "WARNING: No printer defined for branchcode " >+ . $hold->{'branchcode'} >+ if ($verbose); >+ } >+ >+} >+ >+__END__ >+ >+=head1 NAME >+ >+Print Holds >+ >+=head1 SYNOPSIS >+ >+print_holds.pl --printer <branchcode>,<printer>,<server>,<port> >+ >+=head1 OPTIONS >+ >+=over 8 >+ >+=item B<-help> >+ >+Print a brief help message and exits. >+ >+=item B<-printer> >+ >+Adds a printer, the value is the branchcode, printer name, server name and server port separated by commas. >+ >+e.g. print_holds.pl --printer MPL,lp,printserver,515 --printer CPL,lp2,printserver,516 >+ >+would add printers for branchcodes MPL and CPL. If a printer is not defined for a given branch, notices for >+that branch will not be printed. >+ >+=head1 DESCRIPTION >+ >+B<This program> will print on-demand notices for items in the holds queue as they appear. >+ >+=head1 AUTHOR >+ >+Kyle M Hall <kyle@bywatersolutions.com> >+ >+=cut >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8352
:
10627
|
10766
|
12523
|
13465
|
14394
|
16338
|
16543
|
27127
|
28333
|
28334
|
28335
|
28651
|
28652
|
28653
|
28654
|
36833
|
36834
|
40749
|
40750
|
40751
|
41579
|
41580
|
41581
|
41582
|
41583
|
44359
|
44360
|
44361
|
44362
|
44363
|
45275
|
45276
|
45277
|
45278
|
45279
|
45362
|
45365
|
45651
|
45652
|
45653
|
45654
|
45655
|
45656
|
45657
|
45658
|
45659
|
46878
|
46879
|
46880
|
46881
|
46882
|
46883
|
46884
|
48127
|
48128
|
48129
|
48130
|
48131
|
48132
|
48133
|
48134
|
48135