From 1767390817aa772fc3c9af65ede991d13210b09c Mon Sep 17 00:00:00 2001 From: tonnesen Date: Mon, 28 Oct 2002 19:56:01 +0000 Subject: [PATCH] Merging from trunk to rel-1-2 --- C4/Print.pm | 103 +++++++++++++++++++++++++++++++++---- C4/Scan.pm | 17 +++++- mainpage.pl | 1 - marc/koha2marc | 8 +-- opac/opac-detail.pl | 6 +-- opac/opac-logout.pl | 8 +-- opac/opac-moredetail.pl | 26 +++++----- opac/opac-reserve.pl | 4 +- opac/opac-search.pl | 2 +- opac/opac-searchresults.pl | 17 ++---- opac/opac-user.pl | 10 ++-- opac/opac-userupdate.pl | 4 +- 12 files changed, 144 insertions(+), 62 deletions(-) diff --git a/C4/Print.pm b/C4/Print.pm index c83921a499..46b5bf2cde 100644 --- a/C4/Print.pm +++ b/C4/Print.pm @@ -30,33 +30,89 @@ use vars qw($VERSION @ISA @EXPORT); # set the version for version checking $VERSION = 0.01; +=head1 NAME + +C4::Print - Koha module dealing with printing + +=head1 SYNOPSIS + + use C4::Print; + +=head1 DESCRIPTION + +The functions in this module handle sending text to a printer. + +=head1 FUNCTIONS + +=over 2 + +=cut + @ISA = qw(Exporter); @EXPORT = qw(&remoteprint &printreserve &printslip); +=item remoteprint + + &remoteprint($env, $items, $borrower); + +Prints the list of items in C<$items> to a printer. + +C<$env> is a reference-to-hash. C<$env-E{queue}> specifies the +queue to print to; if it is empty or has the special value C, +C<&remoteprint> will print to the file F. +C<$borrower> is a reference-to-hash giving information about a patron. +This may be gotten from C<&getpatroninformation>. The patron's name +will be printed in the output. + +C<$items> is a reference-to-list, where each element is a +reference-to-hash describing a borrowed item. C<$items> may be gotten +from C<¤tissues>. + +=cut +#' +# FIXME - It'd be nifty if this could generate pretty PostScript. sub remoteprint { my ($env,$items,$borrower)=@_; (return) unless (C4::Context->preference('printcirculationslips')); - my $file=time; + my $file=time; # FIXME - Not used my $queue = $env->{'queue'}; + # FIXME - If 'queue' is undefined or empty, then presumably it should + # mean "use the default queue", whatever the default is. Presumably + # the default depends on the physical location of the machine. + # FIXME - Perhaps "print to file" should be a supported option. Just + # set the queue to "file" (or " file", if real queues aren't allowed + # to have spaces in them). Or perhaps if $queue eq "" and + # $env->{file} ne "", then that should mean "print to $env->{file}". if ($queue eq "" || $queue eq 'nulllp') { open (PRINTER,">/tmp/kohaiss"); - } else { - open(PRINTER, "| lpr -P $queue >/dev/null") or die "Couldn't write to queue:$queue!\n"; - } + } else { + # FIXME - This assumes that 'lpr' exists, and works as expected. + # This is a reasonable assumption, but only because every other + # printing package has a wrapper script called 'lpr'. It'd still + # be better to be able to customize this. + open(PRINTER, "| lpr -P $queue > /dev/null") or die "Couldn't write to queue:$queue!\n"; + } +# print $queue; #open (FILE,">/tmp/$file"); my $i=0; - my $brdata = $env->{'brdata'}; + my $brdata = $env->{'brdata'}; # FIXME - Not used + # FIXME - This is HLT-specific. Put this stuff in a customizable + # site-specific file somewhere. print PRINTER "Horowhenua Library Trust\r\n"; # print PRINTER "$brdata->{'branchname'}\r\n"; - print PRINTER "Phone: 368-1953\r\n"; - print PRINTER "Fax: 367-9218\r\n"; + print PRINTER "Phone: 368-1953\r\n"; + print PRINTER "Fax: 367-9218\r\n"; print PRINTER "Email: renewals\@library.org.nz\r\n\r\n\r\n"; print PRINTER "$borrower->{'cardnumber'}\r\n"; print PRINTER "$borrower->{'title'} $borrower->{'initials'} $borrower->{'surname'}\r\n"; + # FIXME - Use for ($i = 0; $items->[$i]; $i++) + # Or better yet, foreach $item (@{$items}) while ($items->[$i]){ +# print $i; my $itemdata = $items->[$i]; + # FIXME - This is just begging for a Perl format. print PRINTER "$i $itemdata->{'title'}\r\n"; print PRINTER "$itemdata->{'barcode'}"; print PRINTER " "x15; @@ -66,7 +122,7 @@ sub remoteprint { print PRINTER "\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; if ($env->{'printtype'} eq "docket"){ #print chr(27).chr(105); - } + } close PRINTER; #system("lpr /tmp/$file"); } @@ -112,8 +168,20 @@ EOF return $slip; } +=item printslip + + &printslip($env, $text) + +Prints the string C<$text> to a printer. C<$env-E{queue}> +specifies the queue to print to. + +If C<$env-E{queue}> is empty or set to C, C<&printslip> +will print to the file F. + +=cut +#' +# FIXME - There's also a &printslip in circ/circulation.pl sub printslip { - warn "PRINTSLIP\n"; my($env, $slip)=@_; my $printer = $env->{'printer'}; (return) unless (C4::Context->preference('printcirculationslips')); @@ -127,5 +195,18 @@ sub printslip { } END { } # module clean-up code here (global destructor) - - + +1; +__END__ + +=back + +=head1 AUTHOR + +Koha Developement team + +=head1 SEE ALSO + +C4::Circulation::Circ2(3) + +=cut diff --git a/C4/Scan.pm b/C4/Scan.pm index d89193c104..3770930153 100644 --- a/C4/Scan.pm +++ b/C4/Scan.pm @@ -26,12 +26,25 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); # set the version for version checking $VERSION = 0.01; +=head1 NAME + +C4::Scan - Does nothing + +=head1 SYNOPSIS + + use C4::Scan; + +=head1 DESCRIPTION + +This module doesn't do anything. + +=cut + @ISA = qw(Exporter); @EXPORT = qw(&getbarcode); +# FIXME - Never used sub Getbarcode { } END { } # module clean-up code here (global destructor) - - diff --git a/mainpage.pl b/mainpage.pl index 0243ec8948..78c7080b6d 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -12,5 +12,4 @@ my ($loggedinuser, $cookie, $sessionID) = checkauth($query); my $template = gettemplate("intranet-main.tmpl"); -#$template->param(SITE_RESULTS => $sitearray); print "Content-Type: text/html\n\n", $template->output; diff --git a/marc/koha2marc b/marc/koha2marc index 2ce26a69a9..6ca5aca4a0 100644 --- a/marc/koha2marc +++ b/marc/koha2marc @@ -7,7 +7,7 @@ system("mysql Koha -pkohapass < deletemarc"); -use C4::Database; +use C4::Context; use C4::Catalogue; use CGI; use DBI; @@ -15,13 +15,9 @@ use DBI; use C4::Acquisitions; use C4::Biblio; use C4::Output; -my $dbh=C4Connect; +my $dbh = C4::Context->dbh; my $userid=$ENV{'REMOTE_USER'}; - -my $dbh=C4Connect; - - my $sth=$dbh->prepare("select * from biblio,biblioitems where biblio.biblionumber=biblioitems.biblionumber"); $sth->execute; my $env; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index a73960fede..ce5362e1cc 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1,11 +1,11 @@ #!/usr/bin/perl use strict; require Exporter; -use C4::Output; # contains picktemplate +use C4::Output; # contains gettemplate use CGI; use C4::Search; use C4::Auth; - + my $query=new CGI; @@ -24,7 +24,7 @@ $template->param(biblionumber => $biblionumber); # change back when ive fixed request.pl -my @items = &ItemInfo(undef, $biblionumber, 'intra'); +my @items = &ItemInfo(undef, $biblionumber, 'opac'); my $dat = &bibdata($biblionumber); my ($authorcount, $addauthor) = &addauthor($biblionumber); my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber); diff --git a/opac/opac-logout.pl b/opac/opac-logout.pl index 969e77d832..1d707135d1 100755 --- a/opac/opac-logout.pl +++ b/opac/opac-logout.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl use CGI; -use C4::Database; +use C4::Context; use C4::Output; my $query=new CGI; @@ -27,6 +27,7 @@ browser. my $sessions; open (S, "/tmp/sessions"); + # FIXME - Come up with a better logging mechanism while (my ($sid, $u, $lasttime) = split(/:/, )) { chomp $lasttime; (next) unless ($sid); @@ -41,7 +42,7 @@ foreach (keys %$sessions) { print S "$_:$userid:$lasttime\n"; } -my $dbh=C4Connect; +my $dbh = C4::Context->dbh; # Check that this is the ip that created the session before deleting it @@ -56,8 +57,7 @@ if ($sth->rows) { } } -$sth=$dbh->prepare("delete from sessions where sessionID=?"); -$sth->execute($sessionID); +$dbh->do("delete from sessions where sessionID=?", $sessionID); open L, ">>/tmp/sessionlog"; my $time=localtime(time()); printf L "%20s from %16s logged out at %30s (manual log out).\n", $userid, $ip, $time; diff --git a/opac/opac-moredetail.pl b/opac/opac-moredetail.pl index 49b6b57c3f..4cc77b498f 100755 --- a/opac/opac-moredetail.pl +++ b/opac/opac-moredetail.pl @@ -43,14 +43,14 @@ my $count=@items; my $i=0; print center(); -my $dewey = $data->{'dewey'}; -$dewey =~ s/0+$//; -if ($dewey eq "000.") { $dewey = "";}; -if ($dewey < 10){$dewey='00'.$dewey;} -if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;} +my $dewey = $data->{'dewey'}; +$dewey =~ s/0+$//; +if ($dewey eq "000.") { $dewey = "";}; +if ($dewey < 10){$dewey='00'.$dewey;} +if ($dewey < 100 && $dewey > 10){$dewey='0'.$dewey;} if ($dewey <= 0){ - $dewey=''; -} + $dewey=''; +} $dewey=~ s/\.$//; print < @@ -73,8 +73,8 @@ print < - - + +
Biblionumber: $bib
@@ -97,7 +97,7 @@ printend ; if ($type eq 'catmain'){ print "
{'biblioitemnumber'}&bib=$data->{'biblionumber'}>Shift to another biblio"; - + } print < - +
@@ -122,8 +122,8 @@ print < {'itemnumber'}> - - + +
printend ; diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 2ab5de3262..2b9f9dfaf9 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -63,7 +63,7 @@ my $branchoptions = ''; foreach my $br (keys %$branches) { (next) unless $branches->{$br}->{'IS'}; my $selected = ""; - if ($br eq 'L') { + if ($br eq $branch) { $selected = "selected"; } $branchoptions .= "\n"; @@ -172,4 +172,4 @@ if ($query->param('item_types_selected')) { $template->param(loggedinuser => $loggedinuser); -print "Content-Type: text/html\n\n", $template->output; +print "Content-Type: text/html\n\n", $template->output; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index cee90e4ecb..824190457d 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -2,7 +2,7 @@ use strict; require Exporter; -use C4::Output; +use C4::Output; use CGI; use C4::Auth; diff --git a/opac/opac-searchresults.pl b/opac/opac-searchresults.pl index 83c05b202b..999a866a9f 100755 --- a/opac/opac-searchresults.pl +++ b/opac/opac-searchresults.pl @@ -4,8 +4,8 @@ require Exporter; use CGI; use C4::Search; use C4::Auth; -use C4::Output; # now contains picktemplate - +use C4::Output; # now contains gettemplate + my $query=new CGI; my $flagsrequired; @@ -55,8 +55,8 @@ $template->param(FORMINPUTS => $forminputs); # do the searchs .... my $env; -$env->{'itemcount'}=1; -my $num = 10; +$env->{itemcount}=1; +my $num=10; my @results; my $count; my $startfrom = $query->param('startfrom'); @@ -77,12 +77,6 @@ foreach my $res (@results) { $res->{'norequests'} = $norequests; } -my $debug = ""; -foreach my $res (@results) { - $debug .= "title : $res->{'title'}
"; - $debug .= "biblionumber : $res->{'biblionumber'}
"; - $debug .= "location : $res->{'location'}


x"; -} my $startfrom=$query->param('startfrom'); ($startfrom) || ($startfrom=0); @@ -125,6 +119,5 @@ $template->param(numbers => $numbers); $template->param(loggedinuser => $loggedinuser); -#print $query->header(-cookie => $cookie), $debug, $template->output; -print $query->header(-cookie => $cookie), $template->output; +print $query->header(-cookie => $cookie), $template->output; diff --git a/opac/opac-user.pl b/opac/opac-user.pl index dd9158ec49..d1aa63eefe 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -64,13 +64,13 @@ foreach my $key (keys %$issues) { $issue->{'status'} .= " Reserved"; } my ($charges, $itemtype) = calc_charges(undef, undef, $issue->{'itemnumber'}, $borrowernumber); - $issue->{'charges'} = $charges; + $issue->{'charges'} = $charges; push @issuedat, $issue; $count++; -} +} -$template->param(ISSUES => \@issuedat); -$template->param(issues_count => $count); +$template->param(ISSUES => \@issuedat); +$template->param(issues_count => $count); # now the reserved items.... my ($rcount, $reserves) = FindReserves(undef, $borrowernumber); @@ -96,4 +96,4 @@ $template->param(WAITING => \@waiting); $template->param(waiting_count => $wcount); $template->param(loggedinuser => $loggedinuser); -print "Content-Type: text/html\n\n", $template->output; +print "Content-Type: text/html\n\n", $template->output; diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl index 1d26255964..3fda4a9ab1 100755 --- a/opac/opac-userupdate.pl +++ b/opac/opac-userupdate.pl @@ -51,7 +51,7 @@ EOF # do something if it doesnt work.... warn "Error sending mail: $Mail::Sendmail::error \n"; } -} +} my $template = gettemplate("opac-userupdate.tmpl", "opac"); @@ -70,4 +70,4 @@ $template->param(BORROWER_INFO => \@bordat); $template->param(loggedinuser => $loggedinuser); -print "Content-Type: text/html\n\n", $template->output; +print "Content-Type: text/html\n\n", $template->output; -- 2.39.5
BARCODE $items[$i]->{'barcode'}