From e9ae8c0686629747415ade8e2b8d69defeccbc62 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Wed, 8 Aug 2007 07:41:19 -0500 Subject: [PATCH] patches from paul --- C4/Z3950.pm | 380 ++++++++++++ about.pl | 3 +- admin/aqbookfund.pl | 2 +- catalogue/MARCdetail.pl | 4 +- cataloguing/z3950_search.pl | 3 +- circ/overdue.pl | 2 +- .../intranet-tmpl/prog/en/acqui/parcel.tmpl | 44 +- .../prog/en/cataloguing/z3950_search.tmpl | 2 +- .../prog/en/serials/subscription-add.tmpl | 8 +- .../prog/en/tools/koha-news.tmpl | 2 +- .../opac-tmpl/prog/en/opac-showreviews.tmpl | 23 + misc/amazonratings/get_ratings.pl | 70 +++ misc/amazonratings/ratings.sql | 18 + misc/cronjobs/reservelist.pl | 85 +++ misc/cronjobs/test_zebra_delete.pl | 77 +++ misc/notifys/attempted_contacts.sql | 19 + misc/notifys/contact_history.pl | 71 +++ misc/notifys/fines.pl | 587 ++++++++++++++++++ misc/notifys/printnote.pl | 97 +++ misc/notifys/templates/email-15.txt | 7 + misc/notifys/templates/email-29.txt | 17 + misc/notifys/templates/email-8.txt | 11 + misc/notifys/templates/fax-15.html | 15 + misc/notifys/templates/fax-29.html | 40 ++ misc/notifys/templates/fax-8.html | 15 + misc/notifys/templates/letter-29.html | 45 ++ misc/notifys/templates/sms-15.txt | 1 + misc/notifys/templates/sms-8.txt | 2 + misc/zebra/ccl.properties | 2 +- opac/opac-main.pl | 4 + opac/opac-reserve.pl | 8 +- opac/opac-showreviews.pl | 49 ++ serials/statecollection.pl | 97 +++ serials/subscription-copy.pl | 33 + 34 files changed, 1802 insertions(+), 41 deletions(-) create mode 100755 C4/Z3950.pm create mode 100644 koha-tmpl/opac-tmpl/prog/en/opac-showreviews.tmpl create mode 100755 misc/amazonratings/get_ratings.pl create mode 100644 misc/amazonratings/ratings.sql create mode 100755 misc/cronjobs/reservelist.pl create mode 100755 misc/cronjobs/test_zebra_delete.pl create mode 100644 misc/notifys/attempted_contacts.sql create mode 100755 misc/notifys/contact_history.pl create mode 100755 misc/notifys/fines.pl create mode 100755 misc/notifys/printnote.pl create mode 100644 misc/notifys/templates/email-15.txt create mode 100644 misc/notifys/templates/email-29.txt create mode 100644 misc/notifys/templates/email-8.txt create mode 100644 misc/notifys/templates/fax-15.html create mode 100644 misc/notifys/templates/fax-29.html create mode 100644 misc/notifys/templates/fax-8.html create mode 100644 misc/notifys/templates/letter-29.html create mode 100644 misc/notifys/templates/sms-15.txt create mode 100644 misc/notifys/templates/sms-8.txt create mode 100755 opac/opac-showreviews.pl create mode 100755 serials/statecollection.pl create mode 100755 serials/subscription-copy.pl diff --git a/C4/Z3950.pm b/C4/Z3950.pm new file mode 100755 index 0000000000..6ea1f89857 --- /dev/null +++ b/C4/Z3950.pm @@ -0,0 +1,380 @@ +package C4::Z3950; + +# $Id$ + +# Routines for handling Z39.50 lookups + +# Koha library project www.koha.org + +# Licensed under the GPL + + +# 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 + +use strict; + +# standard or CPAN modules used +use DBI; + +# Koha modules used +use C4::Input; +use C4::Biblio; + +#------------------ + +require Exporter; + +use vars qw($VERSION @ISA @EXPORT); + +# set the version for version checking +$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); }; + +=head1 NAME + +C4::Z3950 - Functions dealing with Z39.50 queries + +=head1 SYNOPSIS + + use C4::Z3950; + +=head1 DESCRIPTION + +This module contains functions for looking up Z39.50 servers, and for +entering Z39.50 lookup requests. + +=head1 FUNCTIONS + +=over 2 + +=cut + +@ISA = qw(Exporter); +@EXPORT = qw( + &getz3950servers + &z3950servername + &addz3950queue + &checkz3950searchdone +); + +#------------------------------------------------ +=item getz3950servers + + @servers= &getz3950servers(checked); + +Returns the list of declared z3950 servers + +C<$checked> should always be true (1) => returns only active servers. +If 0 => returns all servers + +=cut +sub getz3950servers { + my ($checked) = @_; + my $dbh = C4::Context->dbh; + my $sth; + if ($checked) { + $sth = $dbh->prepare("select * from z3950servers where checked=1"); + } else { + $sth = $dbh->prepare("select * from z3950servers"); + } + my @result; + while ( my ($host, $port, $db, $userid, $password,$servername) = $sth->fetchrow ) { + push @result, "$servername/$host\:$port/$db/$userid/$password"; + } # while + return @result; +} + +=item z3950servername + + $name = &z3950servername($dbh, $server_id, $default_name); + +Looks up a Z39.50 server by ID number, and returns its full name. If +the server is not found, returns C<$default_name>. + +C<$server_id> is the Z39.50 server ID to look up. + +C<$dbh> is ignored. + +=cut +#' + +sub z3950servername { + # inputs + my ($srvid, # server id number + $default,)=@_; + # return + my $longname; + #---- + + my $dbh = C4::Context->dbh; + + my $sti=$dbh->prepare("select name from z3950servers where id=?"); + + $sti->execute($srvid); + if ( ! $sti->err ) { + ($longname)=$sti->fetchrow; + } + if (! $longname) { + $longname="$default"; + } + return $longname; +} # sub z3950servername + +#--------------------------------------- + +=item addz3950queue + + $errmsg = &addz3950queue($query, $type, $request_id, @servers); + +Adds a Z39.50 search query for the Z39.50 server to look up. + +C<$query> is the term to search for. + +C<$type> is the query type, e.g. C, C, etc. + +C<$request_id> is a unique string that will identify this query. + +C<@servers> is a list of servers to query (obviously, this can be +given either as an array, or as a list of scalars). Each element may +be either a Z39.50 server ID from the z3950server table of the Koha +database, the string C or C, or a complete server +specification containing a colon. + +C and C are synonymous, and refer to those servers +in the z3950servers table whose 'checked' field is set and non-NULL. + +Once the query has been submitted to the Z39.50 daemon, +C<&addz3950queue> sends a SIGHUP to the daemon to tell it to process +this new request. + +C<&addz3950queue> returns an error message. If it was successful, the +error message is the empty string. + +=cut +#' +sub addz3950queue { + use strict; + # input + my ( + $query, # value to look up + $type, # type of value ("isbn", "lccn", "title", "author", "keyword") + $requestid, # Unique value to prevent duplicate searches from multiple HTML form submits + @z3950list, # list of z3950 servers to query + )=@_; + # Returns: + my $error; + + my ( + $sth, + @serverlist, + $server, + $failed, + $servername, + ); + + # FIXME - Should be configurable, probably in /etc/koha.conf. + my $pidfile='/var/log/koha/processz3950queue.pid'; + + $error=""; + + my $dbh = C4::Context->dbh; + # list of servers: entry can be a fully qualified URL-type entry + # or simply just a server ID number. + foreach $server (@z3950list) { + if ($server =~ /:/ ) { + push @serverlist, $server; + } elsif ($server eq 'DEFAULT' || $server eq 'CHECKED' ) { + $sth=$dbh->prepare("select host,port,db,userid,password ,name,syntax from z3950servers where checked <> 0 "); + $sth->execute; + while ( my ($host, $port, $db, $userid, $password,$servername,$syntax) = $sth->fetchrow ) { + push @serverlist, "$servername/$host\:$port/$db/$userid/$password/$syntax"; + } # while + } else { + $sth=$dbh->prepare("select host,port,db,userid,password,syntax from z3950servers where id=? "); + $sth->execute($server); + my ($host, $port, $db, $userid, $password,$syntax) = $sth->fetchrow; + push @serverlist, "$server/$host\:$port/$db/$userid/$password/$syntax"; + } + } + + my $serverlist=''; + + $serverlist = join("|", @serverlist); +# chop $serverlist; + + # FIXME - Is this test supposed to test whether @serverlist is + # empty? If so, then a) there are better ways to do that in + # Perl (e.g., "if (@serverlist eq ())"), and b) it doesn't + # work anyway, since it checks whether $serverlist is composed + # of one or more spaces, which is never the case, not even + # when there are 0 or 1 elements in @serverlist. + if ( $serverlist !~ /^ +$/ ) { + # Don't allow reinsertion of the same request identifier. + $sth=$dbh->prepare("select identifier from z3950queue + where identifier=?"); + $sth->execute($requestid); + if ( ! $sth->rows) { + $sth=$dbh->prepare("insert into z3950queue (term,type,servers, identifier) values (?, ?, ?, ?)"); + $sth->execute($query, $type, $serverlist, $requestid); + if ( -r $pidfile ) { + # FIXME - Perl is good at opening files. No need to + # spawn a separate 'cat' process. + my $pid=`cat $pidfile`; + chomp $pid; + warn "PID : $pid"; + # Kill -HUP the Z39.50 daemon to tell it to process + # this query. + my $processcount=kill 1, $pid; + if ($processcount==0) { + $error.="Z39.50 search daemon error: no process signalled. "; + } + } else { + # FIXME - Error-checking like this should go close + # to the test. + $error.="No Z39.50 search daemon running: no file $pidfile. "; + } # if $pidfile + } else { + # FIXME - Error-checking like this should go close + # to the test. + $error.="Duplicate request ID $requestid. "; + } # if rows + } else { + # FIXME - Error-checking like this should go close to the + # test. I.e., + # return "No Z39.50 search servers specified. " + # if @serverlist eq (); + + # server list is empty + $error.="No Z39.50 search servers specified. "; + } # if serverlist empty + + return $error; + +} # sub addz3950queue + +=item &checkz3950searchdone + + $numberpending= & &checkz3950searchdone($random); + +Returns the number of pending z3950 requests + +C<$random> is the random z3950 query number. + +=cut +sub checkz3950searchdone { + my ($z3950random) = @_; + my $dbh = C4::Context->dbh; + # first, check that the deamon already created the requests... + my $sth = $dbh->prepare("select count(*) from z3950queue,z3950results where z3950queue.id = z3950results.queryid and z3950queue.identifier=?"); + $sth->execute($z3950random); + my ($result) = $sth->fetchrow; + if ($result eq 0) { # search not yet begun => should be searches to do ! + return "??"; + } + # second, count pending requests + $sth = $dbh->prepare("select count(*) from z3950queue,z3950results where z3950queue.id = z3950results.queryid and z3950results.enddate is null and z3950queue.identifier=?"); + $sth->execute($z3950random); + ($result) = $sth->fetchrow; + return $result; +} + +1; +__END__ + +=back + +=head1 AUTHOR + +Koha Developement team + +=cut + +#-------------------------------------- +# $Log$ +# Revision 1.14 2007/03/09 14:31:47 tipaul +# rel_3_0 moved to HEAD +# +# Revision 1.10.10.1 2006/12/22 15:09:54 toins +# removing C4::Database; +# +# Revision 1.10 2003/10/01 15:08:14 tipaul +# fix fog bug #622 : processz3950queue fails +# +# Revision 1.9 2003/04/29 16:50:51 tipaul +# really proud of this commit :-) +# z3950 search and import seems to works fine. +# Let me explain how : +# * a "search z3950" button is added in the addbiblio template. +# * when clicked, a popup appears and z3950/search.pl is called +# * z3950/search.pl calls addz3950search in the DB +# * the z3950 daemon retrieve the records and stores them in z3950results AND in marc_breeding table. +# * as long as there as searches pending, the popup auto refresh every 2 seconds, and says how many searches are pending. +# * when the user clicks on a z3950 result => the parent popup is called with the requested biblio, and auto-filled +# +# Note : +# * character encoding support : (It's a nightmare...) In the z3950servers table, a "encoding" column has been added. You can put "UNIMARC" or "USMARC" in this column. Depending on this, the char_decode in C4::Biblio.pm replaces marc-char-encode by an iso 8859-1 encoding. Note that in the breeding import this value has been added too, for a better support. +# * the marc_breeding and z3950* tables have been modified : they have an encoding column and the random z3950 number is stored too for convenience => it's the key I use to list only requested biblios in the popup. +# +# Revision 1.8 2003/04/29 08:09:45 tipaul +# z3950 support is coming... +# * adding a syntax column in z3950 table = this column will say wether the z3950 must be called with PerferedRecordsyntax => USMARC or PerferedRecordsyntax => UNIMARC. I tried some french UNIMARC z3950 servers, and some only send USMARC, some only UNIMARC, some can answer with both. +# Note this is a 1st draft. More to follow (today ? I hope). +# +# Revision 1.7 2003/02/19 01:01:06 wolfpac444 +# Removed the unecessary $dbh argument from being passed. +# Resolved a few minor FIXMEs. +# +# Revision 1.6 2002/10/13 08:30:53 arensb +# Deleted unused variables. +# Removed trailing whitespace. +# +# Revision 1.5 2002/10/13 06:13:23 arensb +# Removed bogus #! line (this isn't a script!) +# Removed unused global variables. +# Added POD. +# Added some explanatory comments. +# Added some FIXME comments. +# +# Revision 1.4 2002/10/11 12:35:35 arensb +# Replaced &requireDBI with C4::Context->dbh +# +# Revision 1.3 2002/08/14 18:12:52 tonnesen +# Added copyright statement to all .pl and .pm files +# +# Revision 1.2 2002/07/02 20:31:33 tonnesen +# module added from rel-1-2 branch +# +# Revision 1.1.2.5 2002/06/29 17:33:47 amillar +# Allow DEFAULT as input to addz3950search. +# Check for existence of pid file (cat crashed otherwise). +# Return error messages in addz3950search. +# +# Revision 1.1.2.4 2002/06/28 18:07:27 tonnesen +# marcimport.pl will print an error message if it can not signal the +# processz3950queue program. The message contains instructions for starting the +# daemon. +# +# Revision 1.1.2.3 2002/06/28 17:45:39 tonnesen +# z3950queue now listens for a -HUP signal before processing the queue. Z3950.pm +# sends the -HUP signal when queries are added to the queue. +# +# Revision 1.1.2.2 2002/06/26 20:54:31 tonnesen +# use warnings breaks on perl 5.005... +# +# Revision 1.1.2.1 2002/06/26 07:26:41 amillar +# New module for Z39.50 searching +# diff --git a/about.pl b/about.pl index 0c268a75b5..99b9fd55d5 100755 --- a/about.pl +++ b/about.pl @@ -1,4 +1,4 @@ -�#!/usr/bin/perl +ö#!/usr/bin/perl # This file is part of Koha. # @@ -43,7 +43,6 @@ my $perlVersion = $]; my $mysqlVersion = `mysql -V`; my $apacheVersion = `httpd -v`; $apacheVersion = `httpd2 -v` unless $apacheVersion; -$apacheVersion = `apache2 -v` unless $apacheVersion; # path for ubuntu my $zebraVersion = `zebraidx -V`; # $apacheVersion = (`/usr/sbin/apache2 -V`)[0]; diff --git a/admin/aqbookfund.pl b/admin/aqbookfund.pl index 88b0008bc8..778bf11856 100755 --- a/admin/aqbookfund.pl +++ b/admin/aqbookfund.pl @@ -162,7 +162,7 @@ elsif ($op eq 'add_validate') { $input->param('branchcode')||'' ); } - $input->redirect('/cgi-bin/koha/aqbookfund.pl'); + $input->redirect('aqbookfund.pl'); # END $OP eq ADD_VALIDATE } ################## DELETE_CONFIRM ################################## diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index 08ce5d5cbe..c406234464 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -234,8 +234,8 @@ for ( my $tabloop = 0 ; $tabloop <= 10 ; $tabloop++ ) { $subfield_data{authority} = $fields[$x_i]->subfield(9); } $subfield_data{marc_value} = - GetAuthorisedValueDesc( $fields[$x_i]->tag(), - $subf[$i][0], $subf[$i][1], '', $tagslib ); + get_authorised_value_desc( $tagslib, $fields[$x_i]->tag(), + $subf[$i][0], $subf[$i][1], '', $dbh ); } $subfield_data{marc_subfield} = $subf[$i][0]; $subfield_data{marc_tag} = $fields[$x_i]->tag(); diff --git a/cataloguing/z3950_search.pl b/cataloguing/z3950_search.pl index ae50624665..87f7712ae3 100755 --- a/cataloguing/z3950_search.pl +++ b/cataloguing/z3950_search.pl @@ -82,8 +82,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( $template->param( frameworkcode => $frameworkcode, ); if ( $op ne "do_search" ) { - # FIXME : remove sql queries & put that in a specific package (Z3950.pm ?, but it's unused atm) - my $sth = $dbh->prepare("SELECT id,host,checked FROM z3950servers ORDER by host"); + my $sth = $dbh->prepare("select id,host,checked from z3950servers order by host"); $sth->execute(); my $serverloop = $sth->fetchall_arrayref( {} ); $template->param( diff --git a/circ/overdue.pl b/circ/overdue.pl index 037cb70643..33da5fe2e2 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -117,7 +117,7 @@ while ( my $data = $sth->fetchrow_hashref ) { } $template->param( - todaysdate => format_date($todaysdate), + todaysdate => $todaysdate, overdueloop => \@overduedata ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/acqui/parcel.tmpl b/koha-tmpl/intranet-tmpl/prog/en/acqui/parcel.tmpl index 670d5b7996..6ccca6e607 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/acqui/parcel.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/acqui/parcel.tmpl @@ -22,14 +22,14 @@
- - - - - - - - + + + + + + + + @@ -48,12 +48,12 @@ - - - - - - + + + + + +
BASKETSummaryQTY orderedEst CostACTUALP&PQTY receivedTOTALBASKETSummaryQTY orderedEst CostACTUALP&PQTY receivedTOTAL
SUBTOTALSSUBTOTALS
@@ -82,13 +82,13 @@ - - - - - - - + + + + + + + @@ -99,9 +99,9 @@
author :
Publisher : - + diff --git a/koha-tmpl/intranet-tmpl/prog/en/cataloguing/z3950_search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/cataloguing/z3950_search.tmpl index dd9bd605bd..9759e2e25a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/cataloguing/z3950_search.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/cataloguing/z3950_search.tmpl @@ -31,7 +31,7 @@ " /> " /> " /> - " /> + " />

diff --git a/koha-tmpl/intranet-tmpl/prog/en/serials/subscription-add.tmpl b/koha-tmpl/intranet-tmpl/prog/en/serials/subscription-add.tmpl index 3c7fa88c24..379962a438 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/serials/subscription-add.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/serials/subscription-add.tmpl @@ -731,12 +731,12 @@ function check_input(e){

- - + + - - + + diff --git a/koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl b/koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl index 87fc51092e..98f5c70f5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/tools/koha-news.tmpl @@ -62,7 +62,7 @@

- +

diff --git a/koha-tmpl/opac-tmpl/prog/en/opac-showreviews.tmpl b/koha-tmpl/opac-tmpl/prog/en/opac-showreviews.tmpl new file mode 100644 index 0000000000..c68c3adaab --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/opac-showreviews.tmpl @@ -0,0 +1,23 @@ + Catalog -- Library Home for + + + + + +
or select a pending orders
BASKETSummaryQTY OrderedEst. CostP&PQTY recievedTOTALBASKETSummaryEst. CostP&PQTY OrderedQTYTOTAL
Patron alert with
+ + + + + + + + +
+ +
+ +

+
+ + diff --git a/misc/amazonratings/get_ratings.pl b/misc/amazonratings/get_ratings.pl new file mode 100755 index 0000000000..0f249ad649 --- /dev/null +++ b/misc/amazonratings/get_ratings.pl @@ -0,0 +1,70 @@ +#!/usr/bin/perl +# get_ratings.pl +# +# A script to fetch the ratings of a given title, using the isbn number +# Initially just books, but ill expand to handle dvd's and cd's as well + +# uses a new table, ratings, pipe the ratings.sql script into mysql to create the table. + +use warnings; +use strict; +use HTTP::Cookies; +use LWP::UserAgent; +use C4::Context; + +my $dbh = C4::Context->dbh(); + +my $query = +"SELECT isbn,biblioitemnumber,biblionumber FROM biblioitems where isbn is NOT NULL and isbn <> '' + group by isbn"; +my $sth = $dbh->prepare($query); +$sth->execute(); +while ( my $data = $sth->fetchrow_hashref() ) { + $data->{'isbn'} =~ s/\-//g; + $data->{'isbn'} =~ s/ +//g; + + # append isbn + # isbn must appear without spaces or - + my $url = "http://www.amazon.com/exec/obidos/search-handle-url/index%3Dbooks%26field-isbn%3D"; + $url .= $data->{'isbn'}; + my $ua = LWP::UserAgent->new; + my $content = $ua->get($url)->content; + + #print $content; + + my $rating; + + if ( $content =~ /alt="(.*?) out of 5 stars"/ ) { + $rating = $1; + + } + if ($rating) { + + # first check we dont already have a rating, if so, and its different update it + # otherwise insert a new rating + my $query2 = "SELECT * FROM ratings WHERE biblioitemnumber=?"; + my $sth2 = $dbh->prepare($query2); + $sth2->execute( $data->{'biblioitemnumber'} ); + if ( my $ratings = $sth2->fetchrow_hashref() ) { + if ( $rating ne $ratings->{'rating'} ) { + my $query3 = + "UPDATE ratings SET rating=? WHERE biblioitemnumber=?"; + my $sth3 = $dbh->prepare($query3); + $sth3->execute( $rating, $data->{'biblioitemnumber'} ); + $sth3->finish(); + } + } + else { + my $query3 = +"INSERT INTO ratings (rating,biblioitemnumber,biblionumber) VALUES (?,?,?)"; + my $sth3 = $dbh->prepare($query3); + $sth3->execute( + $rating, $data->{'biblioitemnumber'}, + $data->{'biblionumber'} + ); + $sth3->finish(); + } + $sth2->finish(); + + } +} diff --git a/misc/amazonratings/ratings.sql b/misc/amazonratings/ratings.sql new file mode 100644 index 0000000000..d287dee526 --- /dev/null +++ b/misc/amazonratings/ratings.sql @@ -0,0 +1,18 @@ +-- MySQL dump 8.21 +-- +-- Host: localhost Database: Koha2 +--------------------------------------------------------- +-- Server version 3.23.49-log + +-- +-- Table structure for table 'ratings' +-- + +CREATE TABLE ratings ( + biblioitemnumber int(11) NOT NULL default '0', + biblionumber int(11) default NULL, + rating varchar(10) default NULL, + modified timestamp(14) NOT NULL, + PRIMARY KEY (biblioitemnumber) +) TYPE=MyISAM; + diff --git a/misc/cronjobs/reservelist.pl b/misc/cronjobs/reservelist.pl new file mode 100755 index 0000000000..dc7374c208 --- /dev/null +++ b/misc/cronjobs/reservelist.pl @@ -0,0 +1,85 @@ +#!/usr/bin/perl +#----------------------------------- +# Script Name: reservelist.pl +# Script Version: 1.0 +# Date: 2003/9/18 +# Author: Stephen Hedges shedges@skemotah.com +# Description: produces a comma separated list of currently +# available reserves, with item and borrower details +# Usage: reservelist.pl. +# Revision History: +# 1.0 2003/9/18: original version +# 1.1 2003/10/1: modified to load into a MySQL table +#----------------------------------- + +use lib '/usr/local/koha/intranet/modules/'; + +use strict; +use C4::Context; +use C4::Biblio; + +my ($biblionumber,$barcode,$holdingbranch,$pickbranch,$notes,$cardnumber,$lastname,$firstname,$phone,$title,$callno,$rdate,$borrno); + +my $dbh = C4::Context->dbh; + +$dbh->do("DELETE FROM reservelist"); # clear the old table for new info + +my $sth=$dbh->prepare("SELECT biblionumber,reserves.branchcode,reservenotes,borrowers.borrowernumber,cardnumber,surname,firstname,phone,reservedate FROM reserves,borrowers WHERE reserves.borrowernumber=borrowers.borrowernumber AND priority=1 AND cancellationdate IS NULL GROUP BY biblionumber"); + +my $sth_load=$dbh->prepare("INSERT INTO reservelist (biblionumber,barcode,lastname,firstname,phone,borrowernumber,cardnumber,reservedate,title,callno,holdingbranch,pickbranch,notes) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"); + +$sth->execute(); # get the list of biblionumbers for unfilled reserves + +GETIT: while (my $data=$sth->fetchrow_hashref){ + $biblionumber = $data->{'biblionumber'}; # get the basic reserve info + $pickbranch = $data->{'branchcode'}; + $notes = $data->{'reservenotes'}; + $borrno = $data->{'borrowernumber'}; + $cardnumber = $data->{'cardnumber'}; + $lastname = $data->{'surname'}; + $firstname = $data->{'firstname'}; + $phone = $data->{'phone'}; + $rdate = $data->{'reservedate'}; + my @items = GetItemsInfo($biblionumber,''); # get the items for this biblio + my @itemorder; # prepare a new array to hold re-ordered items + +# The following lines take the retrieved items and run them through various +# tests to decide if they are to be used and then put them in the preferred +# 'pick' order. + foreach my $itm (@items) { + if ($itm->{"datedue"} eq "Reserved") { # is item ready for member? + if ($itm->{'holdingbranch'} eq $pickbranch) { + $itemorder[0]=$itm; + } elsif ($itm->{'homebranch'} eq 'NPL') { + $itemorder[1]=$itm; + } elsif ($itm->{'homebranch'} eq 'CPL') { + $itemorder[2]=$itm; + } elsif ($itm->{'homebranch'} eq 'COV') { + $itemorder[3]=$itm; + } elsif ($itm->{'homebranch'} eq 'GPL') { + $itemorder[4]=$itm; + } elsif ($itm->{'homebranch'} eq 'ALB') { + $itemorder[5]=$itm; + } elsif ($itm->{'homebranch'} eq 'PPL') { + $itemorder[6]=$itm; + } elsif ($itm->{'homebranch'} eq 'APL') { + $itemorder[7]=$itm; + } + } + } + my $count = @itemorder; + next GETIT if $count<1; # if the re-ordered array is empty, skip to next + PREP: foreach my $itmlist (@itemorder) { + if ($itmlist) { + $barcode = $itmlist->{'barcode'}; + $holdingbranch = $itmlist->{'holdingbranch'}; + $title = $itmlist->{'title'}; + $callno = $itmlist->{'classification'}; + last PREP; # we only want the first def item in the array + } + } + $sth_load->execute($biblionumber,$barcode,$lastname,$firstname,$phone,$borrno,$cardnumber,$rdate,$title,$callno,$holdingbranch,$pickbranch,$notes); + $sth_load->finish; +} +$sth->finish; +$dbh->disconnect; diff --git a/misc/cronjobs/test_zebra_delete.pl b/misc/cronjobs/test_zebra_delete.pl new file mode 100755 index 0000000000..378da1bb86 --- /dev/null +++ b/misc/cronjobs/test_zebra_delete.pl @@ -0,0 +1,77 @@ +#!/usr/bin/perl +use C4::Context; +use C4::Biblio; + +use strict; + +my $Zconn=C4::Context->Zconn('biblioserver', 0, 1); +my $Zpackage = $Zconn->package(); +$Zpackage->option(action => 'recordDelete'); +$Zpackage->option(record => ' + + + 00577 a2200193 4500 + 19980415162006.0 + + TOB*M*9074254 + + + 8 + 8 + + + 19910405d1976 y1frea0103 ba + + + fre + + + Lune vole fJacqueline Held, et Claude Held + illustrations d\' Yvan Pommaux + LIVR + + + Ecole des loisirs + cop. 1976 + + + 20p + + + Chanterime + + + Migration GEAC + + + Held + Jacqueline + 187392 + + + HELLVOL99000 + + + MIRMJE + ISTISP + + + IST + IST + 9991088063 + P HEL + 2004-06-22 + 2.9 + LIVR + 14 + J + 16 + +'); +$Zpackage->send("update"); +$Zpackage->send('commit'); +$Zpackage->destroy(); +$Zconn->destroy(); diff --git a/misc/notifys/attempted_contacts.sql b/misc/notifys/attempted_contacts.sql new file mode 100644 index 0000000000..893465d0a3 --- /dev/null +++ b/misc/notifys/attempted_contacts.sql @@ -0,0 +1,19 @@ +-- MySQL dump 9.08 +-- +-- Host: localhost Database: Koha +--------------------------------------------------------- +-- Server version 4.0.13-log + +-- +-- Table structure for table 'attempted_contacts' +-- + +CREATE TABLE attempted_contacts ( + borrowernumber int(11) default NULL, + method varchar(50) default NULL, + address varchar(255) default NULL, + result int(11) default NULL, + message text, + date datetime default NULL +) TYPE=MyISAM; + diff --git a/misc/notifys/contact_history.pl b/misc/notifys/contact_history.pl new file mode 100755 index 0000000000..368e0bee53 --- /dev/null +++ b/misc/notifys/contact_history.pl @@ -0,0 +1,71 @@ +#!/usr/bin/perl + +# Display a history of attempts to contact this borrower +# regarding overdues and fines. +# +# Tony McCrae +# tony@katipo.co.nz 5/July/2003 +# 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 + +use strict; +use CGI; + + +use C4::Circulation; +use C4::Overdues; + +use Data::Dumper; + +my $input = new CGI; +my $borrowernumber = $input->param('borrowernumber'); +my $date= $input->param('date'); +my $edate=$input->param('edate'); +print $input->header; +if ($borrowernumber) { + my $borrower = BorType($borrowernumber); + + + my $querystring = " select date, method, address, result, message, borrowernumber + from attempted_contacts + where date >= ? and date < ? + "; + + + my $dbh=C4Connect(); + my $sth=$dbh->prepare($querystring); + $sth->execute($date,$edate); + + while (my $row=$sth->fetchrow_hashref()) { + print "{'borrowernumber'}>Borrwer Record "; + if ($row->{'method'} ne 'email'){ + my $tidydate=$row->{'date'}; + $tidydate=~ s/ /%20/g; + print "   {'borrowernumber'}&date=$tidydate>Print Note
"; + } + print $row->{'date'}."
\n"; + print $row->{'method'}."
\n"; + print $row->{'address'}."
\n"; + print $row->{'result'}."
\n"; + print $row->{'message'}."
\n"; + print "

"; + } + + } + + + diff --git a/misc/notifys/fines.pl b/misc/notifys/fines.pl new file mode 100755 index 0000000000..58f63adb52 --- /dev/null +++ b/misc/notifys/fines.pl @@ -0,0 +1,587 @@ +#!/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 + + +use C4::Members; +use C4::Circulation; +use C4::Overdues; +use Date::Manip; + +use Mail::Sendmail; +use Mail::RFC822::Address; +use C4::Biblio; +use strict; + + +#levyFines(); # Do not levy real fines in testing situation. +notifyOverdues(); + + + +# Todo +# - Need to calculate the fine on each book; no idea how to get this information from Koha +# - Need to diffentricate between the total_fines including replacement costs, +# and the total fines if the books are returned in the day 29 notices (see above). +# - clean up the %actions hash creation code. + +#Done +# - preferedcont field in borrowers hash; does this do anything? +# - logging +# - which 'address' to send sms to? +# - senders returning success or fail + + + +sub levyFines { + # Look at the current overdues, and levy fines on the offenders. + # arguments: + # $date + # $maxfine + + # Work out what today is as an integer value. + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time); + $mon++; $year=$year+1900; + my $date=Date_DaysSince1BC($mon,$mday,$year); + my $maxfine =5; + + + # Retrieve an array of overdues. + my ($count, $overduesReference) = Getoverdues(); + print "$count overdue items where found.\n\n"; + my @overdues=@$overduesReference; + + foreach my $overdue (@overdues) { + my @dates=split('-',$overdue->{'date_due'}); + my $due_day=Date_DaysSince1BC($dates[1],$dates[2],$dates[0]); + + + # Check that the item is really overdue. The output of Getoverdues() will normally + # always be overdue items. However, if you are running this script with a value of $date other than the current time, this check is needed. + if ($due_day <= $date) { + my $difference=$date-$due_day; + print "Itemnumber ".$overdue->{'itemnumber'}." is issued to ".$overdue->{'borrowernumber'}." is overdue by $difference days.\n"; + + # Calculate the cost of this overdue. + # Fines vary according to borrower type, but cannot exceed the maximum fine. + print $overdue->{'borrowernumber'}; + my $borrower=BorType($overdue->{'borrowernumber'}); + + my ($amount,$type,$printout)=CalcFine($overdue->{'itemnumber'}, $borrower->{'categorycode'}, $difference); + if ($amount > $maxfine){ + $amount=$maxfine; + } + + if ($amount > 0){ + my $due="$dates[2]/$dates[1]/$dates[0]"; + UpdateFine($overdue->{'itemnumber'}, $overdue->{'borrowernumber'}, $amount, $type, $due); + print $overdue->{'borrowernumber'}." has been fined $amount for itemnumber ".$overdue->{'itemnumber'}." overdue for $difference days.\n"; + } + + + + # After 28 days, the item is marked lost and the replacement charge is added as a fine + if ($difference >= 28) { + my $borrower=BorType($overdue->{'borrowernumber'}); + if ($borrower->{'cardnumber'} ne ''){ + my $cost=ReplacementCost($overdue->{'itemnumber'}); + my $dbh=C4Connect(); + my $accountno=C4::Circulation::getnextacctno($overdue->{'borrowernumber'}); + my $item=GetBiblioFromItemNumber($overdue->{'itemnumber'}); + if ($item->{'itemlost'} ne '1' && $item->{'itemlost'} ne '2' ){ + $item->{'title'}=~ s/\'/\\'/g; + my $query="Insert into accountlines (borrowernumber,itemnumber,accountno,date,amount, description,accounttype,amountoutstanding) + values ($overdue->{'borrowernumber'}, $overdue->{'itemnumber'}, + '$accountno',now(),'$cost','Lost item $item->{'title'} $item->{'barcode'}','L','$cost')"; + + my $sth=$dbh->prepare($query); + $sth->execute(); + $sth->finish(); + + $query="update items set itemlost=2 where itemnumber='$overdue->{'itemnumber'}'"; + $sth=$dbh->prepare($query); + $sth->execute(); + $sth->finish(); + } + } + } + } + } + + return 1; + } + + + + + + +sub notifyOverdues { + # Look up the overdues for today. + # Capture overdues which fall on our dates of interest. + + + + +#################################################################################################### +# Creating a big hash of available templates +my %email; +%email->{'template'}='email-8.txt'; +my %sms; +%sms->{'template'}='sms-8.txt'; + +my %fax1; +%fax1->{'template'}='fax-8.html'; + +my %firstReminder->{'email'} = \%email; +%firstReminder->{'sms'} = \%sms; +%firstReminder->{'fax'} = \%fax1; + +my %email2; +%email2->{'template'}='email-15.txt'; + +my %fax2; +%fax2->{'template'}='fax-15.html'; + +my %letter2; +%letter2->{'template'}='fax-15.html'; + +my %sms2->{'template'}='sms-15.txt'; +my %secondReminder->{'email'} = \%email2; +%secondReminder->{'sms'} = \%sms2; +%secondReminder->{'fax'} = \%fax2; +%secondReminder->{'letter'} = \%letter2; + + +my %email3; +%email3->{'template'}='email-29.txt'; +my %fax3; +%fax3->{'template'}='fax-29.html'; +my %letter3; +%letter3->{'template'}='letter-29.html'; + +my %finalReminder->{'email'} = \%email3; +%finalReminder->{'fax'} = \%fax3; +%finalReminder->{'letter'} = \%letter3; + +my $fines; +my %actions; +%actions->{'8'}=\%firstReminder; +%actions->{'15'}=\%secondReminder; +%actions->{'29'}=\%finalReminder; + +################################################################################################################## + + + # Work out what today is as an integer value. + my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time); + $mon++; $year=$year+1900; + my $date=Date_DaysSince1BC($mon,$mday,$year); + + + # Retrieve an array of overdues. + my ($count, $overduesReference) = Getoverdues(); + print "$count overdue items where found.\n\n"; + my @overdues=@$overduesReference; + + + # We're going to build a hash of arrays, containing the items requiring action. + # ->borrowernumber, date, @overdues + my %actionItems; + foreach my $actionday (keys(%actions)) { + my @items=(); + %actionItems->{$actionday} = \@items; + } + + + + foreach my $overdue (@overdues) { + my @dates=split('-',$overdue->{'date_due'}); + my $due_day=Date_DaysSince1BC($dates[1],$dates[2],$dates[0]); + + my $difference=$date-$due_day; +# $overdue->{'fine'}=GetFine($overdue->{'itemnumber'}); + # If does this item fall on a day of interest? + $overdue->{'difference'}=$difference; + foreach my $actiondate (keys(%actions)) { + if ($actiondate == $difference) { + my @items = @{%actionItems->{$actiondate}}; + + my %o = %$overdue; + push (@items, \%o); + %actionItems->{$actiondate} = \@items; + } + } + } + + + + + # We now have a hash containing overdues which need actioning, we can step through each set. + # Work from earilest to latest. We only wish to send the most urgent message. + my %messages; + my %borritem; + + foreach my $actiondate (sort {$a <=> $b} (keys(%actions))) { + print "\n\nThe following items are $actiondate days overdue.\n"; + my @items = @{%actionItems->{$actiondate}}; + + + foreach my $overdue (@items) { + if ($overdue->{'difference'} eq $actiondate) { + # Detemine which borrower is responsible for this overdue; + # if the offender is a child, then the garentor is the person to notify + my $borrower=responsibleBorrower($overdue); + + + my ($method, $address) = preferedContactMethod($borrower); + if ($method) { + + # Do we have to send something, using this method on this day? + if (%actions->{$actiondate}->{$method}->{'template'}) { + # If this user has one overdue, then they may have offers as well. + # No point in sending a notice without mentioning all of the items. + my @alloverdues; + foreach my $over (@overdues) { + my $responisble= responsibleBorrower($over); + if ($responisble->{'borrowernumber'} eq $borrower->{'borrowernumber'}) { + $over->{'borrowernumber'}=$responisble->{'borrowernumber'}; + my %o = %$over; + push (@alloverdues, \%o); + } + } + + my $dbh=C4Connect(); # FIXME disconnect this + + # Template the message + my $template = HTML::Template->new(filename => 'templates/'.%actions->{$actiondate}->{$method}->{'template'}, die_on_bad_params => 0); + + my @bookdetails; + my $total_fines = 0; + foreach my $over (@alloverdues) { + my %row_data; + if ( my $item = GetBiblioFromItemNumber( $over->{'itemnumber'})){ + print "getting fine ($over->{'itemnumber'} $overdue->{'borrowernumber'} $over->{'borrowernumber'}\n"; + my $fine = GetFine($over->{'itemnumber'},$overdue->{'borrowernumber'}); + + + print "fine=$fine "; + + my $rep = ReplacementCost2($over->{'itemnumber'},$overdue->{'borrowernumber'}); + + if ($rep){ + $rep+=0.00; + } + if ($fine){ + $fine+=0.00; + $borritem{"$over->{'itemnumber'} $over->{'borrowernumber'}"}=$fine; + } else { + $borritem{"$over->{'itemnumber'} $over->{'borrowernumber'}"}+=$fine; + } + print $borritem{"$over->{'itemnumber'} $over->{'borrowernumber'}"},"\n"; + $total_fines += $borritem{"$over->{'itemnumber'} $over->{'borrowernumber'}"}; + $item->{'title'}=substr($item->{'title'},0,25); + my $len=length($item->{'title'}); + if ($len < 25){ + my $diff=25-$len; + $item->{'title'}.=" " x $diff; + } + + $row_data{'BARCODE'}=$item->{'barcode'}; + $row_data{'TITLE'}=$item->{'title'}; + $row_data{'DATE_DUE'}=$over->{'date_due'}; + $row_data{'FINE'}=$borritem{"$over->{'itemnumber'} $over->{'borrowernumber'}"}; + $row_data{'REP'}=$rep; + + push(@bookdetails, \%row_data); + } else { + print "Missing item $over->{'itemnumber'}\n"; + } + } + + $template->param(BOOKDETAILS => \@bookdetails); + my %params; + %params->{'borrowernumber'} = $overdue->{'borrowernumber'}; + my ($total, $acctlines, $count) = &GetMemberAccountRecords($overdue->{'borrowernumber'}); + $template->param(FINES_TOTAL => $total_fines); + $template->param(OWING => $total); + my $name= "$borrower->{'firstname'} $borrower->{'surname'}"; + $template->param(NAME=> $name); + + %messages->{$borrower->{'borrowernumber'}} = $template->output(); + } + else { + print "No $method needs to be sent at $overdue->{'difference'} days; not sending\n"; + } + + } + else { + print "This borrower has an overdue item, but no means of contact\n"; + } + + } #end of 'if this overdue falls on an action date' + + } #end of 'foreach overdue' + + } # end of foreach actiondate + + + # How that all of the messsages to be sent have been composed, send them. + foreach my $borrowernumber (keys(%messages)) { + print "$borrowernumber\n"; + + my $borrower=BorType($borrowernumber); + my ($method, $address) = preferedContactMethod($borrower); + + my $result=0; + if ($method eq 'email') { + $result = sendEmail($address, 'lep@library.org.nz', 'Overdue Library Items', %messages->{$borrowernumber}); + } + elsif ($method eq 'sms') { + $result = sendSMS($address, %messages->{$borrowernumber}); + } + elsif ($method eq 'fax') { + $result = sendFax($address, %messages->{$borrowernumber}); + } + elsif ($method eq 'letter') { + $result = printLetter($address, %messages->{$borrowernumber}); + } + + + #print %messages->{$borrowernumber}; # debug + + + # Log the outcome of this attempt + logContact($borrowernumber, $method, $address, $result, %messages->{$borrowernumber}); + } + + + + return 1; + } + + + + + + + + + + +sub responsibleBorrower { + # Given an overdue item, return the details of the borrower responible as a hash of database columns. + my $overdue=$_[0]; + + if ($overdue->{'borrowernumber'}) { + my $borrower=BorType($overdue->{'borrowernumber'}); + + + # Overdue books assigned to children have notices sent to the guarantor. + if ($borrower->{'categorycode'} eq 'C') { + my $dbh=C4Connect(); + my $query="Select borrowernumber from borrowers + where borrowernumber=?"; + + my $sth=$dbh->prepare($query); + $sth->execute($borrower->{'guarantor'}); + + my $tdata=$sth->fetchrow_hashref(); + $sth->finish(); + $dbh->disconnect(); + + my $guarantor=BorType($tdata->{'borrowernumber'}); + $borrower = $guarantor; + } + + return $borrower; + } + + } + + + + + + + + + +sub preferedContactMethod { + # Given a reference to borrower details, in the format + # returned by BorType(), determine the prefered contact method, and address to use. + my $borrower=$_[0]; +# print "finding borrower method $borrower->{'preferredcont'} $borrower->{'emailaddress'} $borrower->{'streetaddress'}\n"; + + # Possible contact methods, in order of preference are: + my @methods = ('email', 'sms', 'fax', 'letter'); + + my $method=''; + my $address=''; + + + # Does this borrower have a borrower.preferredcont set? + # If so, push it to the head of our array of methods to try. + # If it's a method unheard of by this system, then we'll drop though to the prefined methods above. + # Note use of unshift to push onto the front of the array. + if ($borrower->{'preferredcont'}) { + unshift(@methods, $borrower->{'preferredcont'}); + } + + + # Cycle through the possible methods until one is accepted + while ((@methods) and (!$address)) { + $method=shift(@methods); + + + if ($method eq 'email') { + if (($borrower->{'emailaddress'}) and (Mail::RFC822::Address::valid($borrower->{'emailaddress'}))) { + $address = $borrower->{'emailaddress'}; + } + } + elsif ($method eq 'fax') { + if ($borrower->{'faxnumber'}) { + $address = $borrower->{'faxnumber'}; + } + } + elsif ($method eq 'sms') { + if ($borrower->{'textmessaging'}) { + $address = $borrower->{'textmessaging'}; + } + } + elsif ($method eq 'letter') { + if ($borrower->{'streetaddress'}) { + $address = mailingAddress($borrower); + } + } + } +print "$method, $address\n"; + return ($method, $address); + } + + + + + + + + +sub logContact { + # Given the details of an attempt to contact a borrower, + # log them in the attempted_contacts table of the koha database. + my ($borrowernumber, $method, $address, $result, $message) = @_; + + my $dbh=C4Connect(); # FIXME - disconnect me + my $querystring = " insert into attempted_contacts + (borrowernumber, method, address, result, message, date) + values (?, ?, ?, ?, ?, now())"; + my $sth= $dbh->prepare($querystring); + $sth->execute($borrowernumber, $method, $address, $result, $message); + $sth->finish(); + } + + + + + + + + +sub mailingAddress { + # Given a hash of borrower information, such as that returned by BorType, + # return a mailing address. + my $borrower=$_[0]; + + my $address = $borrower->{'firstname'}."\n". + $borrower->{'streetaddress'}."\n". + $borrower->{'streetcity'}; + + return $address; + } + + + + + + + +sub itemFine { + # Given an overdue item, return the current fines on it + my $overdue=$_[0]; + # FIXME + return 1; + } + + + + + + + + + +sub sendEmail { + # Given an email address, and a subject and message, attempt to send email. + my $to=$_[0]; + my $from=$_[1]; + my $subject=$_[2]; + my $message=$_[3]; + +# print "in email area"; + +# print "\nSending Email To: $to\n$message\n"; + + my %mail = ( To => $to, +# CC => 'rosalie@library.org.nz', + From => $from, + Subject => $subject, + Message => $message); + + + if (not(sendmail %mail)) { + warn "sendEmail to $to failed."; + return 0; + } + + return 1; +# die "got to here"; + } + + +sub sendSMS { + # Given a cell number and a message, attempt to send an SMS message. + # FIXME - needs information about how to do this at HLT + return 1; + } + + +sub sendFax { + print "in fax \n"; + # Given a fax number, and a message, attempt to send a fax. + # FIXME - needs information about how to do this at HLT + # This is fairly easy. + # We will be past the body of the fax as HTML. + # We can pass this through html2ps to generate Postscript suitable + # for passing to the fax server. + return 1; + } + + +sub printLetter { + # Print a letter + # FIXME - needs information about how to do this at HLT + return 1; + } diff --git a/misc/notifys/printnote.pl b/misc/notifys/printnote.pl new file mode 100755 index 0000000000..b915fc5538 --- /dev/null +++ b/misc/notifys/printnote.pl @@ -0,0 +1,97 @@ +#!/usr/bin/perl + +# Display a history of attempts to contact this borrower +# regarding overdues and fines. +# +# Tony McCrae +# tony@katipo.co.nz 5/July/2003 +# 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 + +#use lib ('/usr/local/koha/intranet/modules'); +use strict; +use CGI; + + +use C4::Circulation; +use C4::Overdues; + +my $input = new CGI; +my $borrowernumber = $input->param('borrowernumber'); +my $date= $input->param('date'); +print $input->header; +if ($borrowernumber) { + my $borrower = BorType($borrowernumber); + my $dbh=C4Connect(); + my $querystring = "select * from borrowers where borrowernumber = ?"; + my $sth=$dbh->prepare($querystring); + $sth->execute($borrowernumber); + my $row=$sth->fetchrow_hashref(); +# print "

"; + print " + + + + + + "; + print "
"; + print "

 

 

\n "; + print "

$row->{'firstname'} $row->{'surname'}
+ $row->{'streetaddress'}
+ $row->{'city'}

 

"; + $sth->finish(); + + $querystring = " select date, method, address, result, message, borrowernumber + from attempted_contacts + where date = ? and borrowernumber= ? + "; + + + + $sth=$dbh->prepare($querystring); + $sth->execute($date,$borrowernumber); + + $row=$sth->fetchrow_hashref(); +# print $row->{'date'}."
\n"; +# print $row->{'method'}."
\n"; +# print $row->{'address'}."
\n"; +# print $row->{'result'}."
\n"; + print $row->{'message'}."
\n"; + print "

"; + +#print $querystring,$date,$borrowernumber; + } + + + diff --git a/misc/notifys/templates/email-15.txt b/misc/notifys/templates/email-15.txt new file mode 100644 index 0000000000..eb31e975b2 --- /dev/null +++ b/misc/notifys/templates/email-15.txt @@ -0,0 +1,7 @@ +Dear Library Member +According to the library's records, you or your children have the following +overdue items borrowed from a Horowhenua Library and not yet returned. +Please return them immediately to avoid increasing fines. + + $ + diff --git a/misc/notifys/templates/email-29.txt b/misc/notifys/templates/email-29.txt new file mode 100644 index 0000000000..d48ef68ffb --- /dev/null +++ b/misc/notifys/templates/email-29.txt @@ -0,0 +1,17 @@ +Invoice for lost book(s) +This is an invoice for the replacement cost of items you +or your children borrowed from the library which have not been returned. + + $ $ + + +Total Owing: $ + + +If you return all overdue items, the total owing in fines will be $ + +Please deal with this matter immediately. If you need more time to search or pay, or you think a mistake +has been made, please contact the library straight away. If you do not respond to this letter, this +account will be handed to a debt collection agency. + diff --git a/misc/notifys/templates/email-8.txt b/misc/notifys/templates/email-8.txt new file mode 100644 index 0000000000..cd0d59e103 --- /dev/null +++ b/misc/notifys/templates/email-8.txt @@ -0,0 +1,11 @@ +Dear Library member +This is a reminder about some items you or your children borrowed from the library +recently, which are now overdue and incurring fines. + +They are: + $ + + +Please return or renew them as soon as you can. +Rosalie Blake +Head of Libraries diff --git a/misc/notifys/templates/fax-15.html b/misc/notifys/templates/fax-15.html new file mode 100644 index 0000000000..4d25ba27c7 --- /dev/null +++ b/misc/notifys/templates/fax-15.html @@ -0,0 +1,15 @@ +Dear

+According to the library's records, you or your children have the following overdue +items borrowed from a Horowhenua Library and not yet returned. Please return them immediately to avoid increasing fines. +

+ + + + + + + + + + +
$
diff --git a/misc/notifys/templates/fax-29.html b/misc/notifys/templates/fax-29.html new file mode 100644 index 0000000000..57b24c7473 --- /dev/null +++ b/misc/notifys/templates/fax-29.html @@ -0,0 +1,40 @@ +Dear

+ +Invoice for lost book(s)
+This is an invoice for the replacement cost of items you or your children +borrowed from the library which have not been returned. + +

+

+ + + + + + + + + + +
$$
+Total Owing: $

+If you return all overdue items, the total owing in fines will be $ +
+Please deal with this matter +immediately. If you need more time to search or pay, or you think a mistake +has been made, please contact the library straight away. If you do not +respond to this letter, this +account will be handed to a debt collection agency. + + + + + + + + + + + + + diff --git a/misc/notifys/templates/fax-8.html b/misc/notifys/templates/fax-8.html new file mode 100644 index 0000000000..1af20cbfd4 --- /dev/null +++ b/misc/notifys/templates/fax-8.html @@ -0,0 +1,15 @@ +Dear

+According to the library's records, you or your children have the following overdue +items borrowed from a Horowhenua Library and not yet returned. Please return them immediately to avoid increasing fines. +

+

+ + + + + + + + + +
$
diff --git a/misc/notifys/templates/letter-29.html b/misc/notifys/templates/letter-29.html new file mode 100644 index 0000000000..ef8effc594 --- /dev/null +++ b/misc/notifys/templates/letter-29.html @@ -0,0 +1,45 @@ +Dear

+Invoice for lost book(s)
+This is an invoice for the replacement cost of items you or your children +borrowed from the library which have not been returned. + +

+ + + + + + + + + + + + +
$$
+Total Owing: $

+If you return all overdue items, the total owing in fines will be $ +
+Please deal with this matter +immediately. If you need more time to search or pay, or you think a mistake +has been made, please contact the library straight away. If you do not +respond to this letter, this +account will be handed to a debt collection agency. + + + + + + + + + + + + + + + + + + diff --git a/misc/notifys/templates/sms-15.txt b/misc/notifys/templates/sms-15.txt new file mode 100644 index 0000000000..6a1309a234 --- /dev/null +++ b/misc/notifys/templates/sms-15.txt @@ -0,0 +1 @@ +ovdues @lib ret immed diff --git a/misc/notifys/templates/sms-8.txt b/misc/notifys/templates/sms-8.txt new file mode 100644 index 0000000000..c1cdac3be8 --- /dev/null +++ b/misc/notifys/templates/sms-8.txt @@ -0,0 +1,2 @@ +ovdues @lib pls ret + diff --git a/misc/zebra/ccl.properties b/misc/zebra/ccl.properties index 8e4e37262e..110345abfd 100644 --- a/misc/zebra/ccl.properties +++ b/misc/zebra/ccl.properties @@ -793,7 +793,7 @@ ut Title-uniform # for an authority to be searched subfield $9 in the # for cataloging purposes. following: 700,701,702,710, # 711,712 and some 6XX fields (Unimarc) -Authority-Number 1=8910 +Authority-number 1=8910 an Authority-Number Koha-Auth-Number Authority-Number diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 28de699b84..cc42d1e50f 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -116,4 +116,8 @@ $template->param( koha_news_count => $koha_news_count ); +$template->param( + 'Disable_Dictionary' => C4::Context->preference("Disable_Dictionary") ) + if ( C4::Context->preference("Disable_Dictionary") ); + output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 3480e01f73..5e85aa8b15 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -296,12 +296,12 @@ else { debarred => 1 ); } - my (@reserves) = GetReservesFromBorrowernumber( $borrowernumber ); - $template->param( RESERVES => $reserves ); - if ( $#reserves+1 >= $MAXIMUM_NUMBER_OF_RESERVES ) { + my @reserves = GetReservesFromBorrowernumber( $borrowernumber ); + $template->param( RESERVES => \@reserves ); + if ( scalar(@$reserves) >= $MAXIMUM_NUMBER_OF_RESERVES ) { $template->param( message => 1 ); $noreserves = 1; - $template->param( too_many_reserves => $#reserves+1 ); + $template->param( too_many_reserves => scalar($reserves)); } foreach my $res (@$reserves) { if ( $res->{'biblionumber'} == $biblionumber ) { diff --git a/opac/opac-showreviews.pl b/opac/opac-showreviews.pl new file mode 100755 index 0000000000..e9ce1210d1 --- /dev/null +++ b/opac/opac-showreviews.pl @@ -0,0 +1,49 @@ +#!/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 + +use strict; +require Exporter; +use CGI; +use C4::Auth; +use C4::Koha; +use C4::Output; +use C4::Circulation; +use C4::Review; +use C4::Biblio; + +my $query = new CGI; +my $biblionumber = $query->param('biblionumber'); + +my ( $template, $borrowernumber, $cookie ) = &get_template_and_user( + { + template_name => "opac-showreviews.tmpl", + query => $query, + type => "opac", + authnotrequired => 1, + } +); + +my $biblio = GetBiblioData( $biblionumber ); +my $reviews = getreviews( $biblionumber, 1 ); + +$template->param( + reviews => $reviews, + title => $biblio->{'title'}, +); + +output_html_with_http_headers $query, $cookie, $template->output; + diff --git a/serials/statecollection.pl b/serials/statecollection.pl new file mode 100755 index 0000000000..8f42e704ef --- /dev/null +++ b/serials/statecollection.pl @@ -0,0 +1,97 @@ +#!/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 + +# $Id$ + +use strict; +use CGI; +use C4::Auth; +use C4::Date; +use C4::Output; +use C4::Context; +use C4::Serials; + +my $query = new CGI; +my $op = $query->param('op'); +my $dbh = C4::Context->dbh; +my $subscriptionid = $query->param('subscriptionid'); +my $auser = $query->param('user'); +my $histstartdate = format_date_in_iso($query->param('histstartdate')); +my $enddate = format_date_in_iso($query->param('enddate')); +my $recievedlist = $query->param('recievedlist'); +my $missinglist = $query->param('missinglist'); +my $opacnote = $query->param('opacnote'); +my $librariannote = $query->param('librariannote'); +my @serialids = $query->param('serialid'); +my @serialseqs = $query->param('serialseq'); +my @planneddates = $query->param('planneddate'); +my @notes = $query->param('notes'); +my @status = $query->param('status'); + +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "serials/statecollection.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {serials => 1}, + debug => 1, + }); + +my $HasSubscriptionExpired = HasSubscriptionExpired($subscriptionid); +my $subscription=GetSubscription($subscriptionid); +if ($op eq 'modsubscriptionhistory') { + modsubscriptionhistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote); +} +# change status except, if subscription has expired, for the "waited" issue. +if ($op eq 'serialchangestatus') { + my $sth = $dbh->prepare("select status from serial where serialid=?"); + for (my $i=0;$i<=$#serialids;$i++) { + $sth->execute($serialids[$i]); + my ($oldstatus) = $sth->fetchrow; + if ($serialids[$i]) { + serialchangestatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),$status[$i],$notes[$i]) unless ($HasSubscriptionExpired && $oldstatus == 1); + } else { + # add a special issue + if ($serialseqs[$i]) { + my $subscription=getsubscription($subscriptionid); + newissue($serialseqs[$i],$subscriptionid,$subscription->{biblionumber},$status[$i], format_date_in_iso($planneddates[$i])); + } + } + } +} +my $subs = &GetSubscription($subscriptionid); +my ($totalissues,@serialslist) = GetSerials($subscriptionid,10); + +my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?"); +$sth->execute($subscriptionid); +my $solhistory = $sth->fetchrow_hashref; + + $template->param( + serialslist => \@serialslist, + biblionumber => $subscription->{biblionumber}, + histstartdate => format_date($solhistory->{'histstartdate'}), + enddate => format_date($solhistory->{'enddate'}), + recievedlist => $solhistory->{'recievedlist'}, + missinglist => $solhistory->{'missinglist'}, + opacnote => $solhistory->{'opacnote'}, + librariannote => $solhistory->{'librariannote'}, + subscriptionid => $subscriptionid, + bibliotitle => $subs->{bibliotitle}, + biblionumber => $subs->{biblionumber}, + hassubscriptionexpired =>$HasSubscriptionExpired, + ); +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/serials/subscription-copy.pl b/serials/subscription-copy.pl new file mode 100755 index 0000000000..7993f12abc --- /dev/null +++ b/serials/subscription-copy.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl + + +use strict; +use CGI; +use Date::Manip; + +use C4::Koha; +use C4::Auth; +use C4::Date; +use C4::Output; +use C4::Acquisition; +use C4::Context; +use C4::Serials; + +my $query = new CGI; +my $subscriptionid = $query->param('subscriptionid'); +my $dbh = C4::Context->dbh; +# get old subscription +my $subs = &GetSubscription($subscriptionid); + +# make newsubscription() +my $subscriptionid = old_newsubscription($subs->{'auser'},$subs->{'aqbooksellerid'},$subs->{'cost'},$subs->{'aqbudgetid'}, + $subs->{'biblionumber'},$subs->{'startdate'},$subs->{'periodicity'},$subs->{'firstacquidate'}, + $subs->{'dow'},$subs->{'irregularity'},$subs->{'numberpattern'},$subs->{'numberlength'}, + $subs->{'weeklength'},$subs->{'monthlength'},$subs->{'add1'},$subs->{'every1'}, + $subs->{'whenmorethan1'},$subs->{'setto1'},$subs->{'lastvalue1'},$subs->{'add2'}, + $subs->{'every2'},$subs->{'whenmorethan2'},$subs->{'setto2'},$subs->{'lastvalue2'},$subs->{'add3'}, + $subs->{'every3'},$subs->{'whenmorethan3'},$subs->{'setto3'},$subs->{'lastvalue3'}, + $subs->{'numberingmethod'},$subs->{'status'},$subs->{'notes'}, + ); +print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); + -- 2.39.5