From 2b8ef909457e3ac081831552787d300dd5154d19 Mon Sep 17 00:00:00 2001 From: finlayt Date: Wed, 4 Dec 2002 22:25:01 +0000 Subject: [PATCH] merged in changes from the rel-1-2 branch into the main branch. Some of the default templates are a bit broken now.... --- opac/opac-account.pl | 28 ++++-- opac/opac-detail.pl | 43 ++------- opac/opac-main.pl | 21 ++--- opac/opac-membership.pl | 18 ++++ opac/opac-readingrecord.pl | 54 +++++++++++ opac/opac-renew.pl | 25 +++++ opac/opac-reserve.pl | 183 ++++++++++++++++++++++++++++++------- opac/opac-search.pl | 30 ++++-- opac/opac-searchresults.pl | 36 +++++--- opac/opac-sidebar.pl | 30 ++++++ opac/opac-user.pl | 81 +++++++++++----- opac/opac-userdetails.pl | 33 +++++++ opac/opac-userupdate.pl | 21 ++--- 13 files changed, 454 insertions(+), 149 deletions(-) create mode 100644 opac/opac-membership.pl create mode 100755 opac/opac-readingrecord.pl create mode 100755 opac/opac-renew.pl create mode 100755 opac/opac-sidebar.pl create mode 100755 opac/opac-userdetails.pl diff --git a/opac/opac-account.pl b/opac/opac-account.pl index 94fc308ab8..9a658c2e85 100755 --- a/opac/opac-account.pl +++ b/opac/opac-account.pl @@ -11,16 +11,16 @@ use C4::Circulation::Circ2; use C4::Auth; my $query = new CGI; - -my $flagsrequired; -$flagsrequired->{borrow}=1; - -my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0, $flagsrequired); - -my $template = gettemplate("opac-account.tmpl", "opac"); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-account.tmpl", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => {borrow => 1}, + debug => 1, + }); # get borrower information .... -my $borrowernumber = getborrowernumber($loggedinuser); my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); my @bordat; @@ -40,9 +40,17 @@ for (my $i=0;$i<$numaccts;$i++){ } } +# add the row parity +my $num = 0; +foreach my $row (@$accts) { + $row->{'even'} = 1 if $num % 2 == 0; + $row->{'odd'} = 1 if $num % 2 == 1; + $num++; +} + + $template->param( ACCOUNT_LINES => $accts ); $template->param( total => $total ); -$template->param( loggedinuser => $loggedinuser ); -print "Content-Type: text/html\n\n", $template->output; +print $query->header(-cookie => $cookie), $template->output; diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index ce5362e1cc..0b32a357d7 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1,23 +1,18 @@ #!/usr/bin/perl use strict; require Exporter; -use C4::Output; # contains gettemplate use CGI; use C4::Search; use C4::Auth; my $query=new CGI; - - -my $flagsrequired; -$flagsrequired->{borrow}=1; - -my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1, $flagsrequired); - - -my $template = gettemplate ("opac-detail.tmpl", "opac"); - -$template->param(loggedinuser => $loggedinuser); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-detail.tmpl", + query => $query, + type => "opac", + authnotrequired => 1, + flagsrequired => {borrow => 1}, + }); my $biblionumber=$query->param('bib'); $template->param(biblionumber => $biblionumber); @@ -40,40 +35,22 @@ for (my $i = 1; $i < $authorcount; $i++) { my $norequests = 1; foreach my $itm (@items) { $norequests = 0 unless $itm->{'notforloan'}; + $itm->{$itm->{'publictype'}} = 1; } $template->param(norequests => $norequests); - - -my @results; - -$results[0]=$dat; +my @results = ($dat,); my $resultsarray=\@results; my $itemsarray=\@items; my $webarray=\@webbiblioitems; my $sitearray=\@websites; - -my $startfrom=$query->param('startfrom'); -($startfrom) || ($startfrom=0); - -my $count=1; - -# now to get the items into a hash we can use and whack that thru -$template->param(startfrom => $startfrom+1); -$template->param(endat => $startfrom+20); -$template->param(numrecords => $count); -my $nextstartfrom=($startfrom+20<$count-20) ? ($startfrom+20) : ($count-20); -my $prevstartfrom=($startfrom-20>0) ? ($startfrom-20) : (0); -$template->param(nextstartfrom => $nextstartfrom); -$template->param(prevstartfrom => $prevstartfrom); - $template->param(BIBLIO_RESULTS => $resultsarray); $template->param(ITEM_RESULTS => $itemsarray); $template->param(WEB_RESULTS => $webarray); $template->param(SITE_RESULTS => $sitearray); -print "Content-Type: text/html\n\n", $template->output; +print $query->header(-cookie => $cookie), $template->output; diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 8ad7e92ab9..4cc12bca59 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -4,19 +4,16 @@ require Exporter; use CGI; use HTML::Template; -use C4::Output; # gettemplate -use C4::Auth; # checkauth +use C4::Auth; # get_template_and_user my $query = new CGI; -my $flagsrequired; -$flagsrequired->{borrow}=1; +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-main.tmpl", + query => $query, + type => "opac", + authnotrequired => 1, + flagsrequired => {borrow => 1}, + }); -my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1, $flagsrequired); - - -my $template = gettemplate("opac-main.tmpl", "opac"); - -$template->param(loggedinuser => $loggedinuser); - -print "Content-Type: text/html\n\n", $template->output; +print $query->header(-cookie => $cookie), $template->output; diff --git a/opac/opac-membership.pl b/opac/opac-membership.pl new file mode 100644 index 0000000000..220df6361c --- /dev/null +++ b/opac/opac-membership.pl @@ -0,0 +1,18 @@ +#!/usr/bin/perl +use strict; +require Exporter; +use CGI; + +use C4::Auth; # get_template_and_user + +my $query = new CGI; + +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-membership.tmpl", + query => $query, + type => "opac", + authnotrequired => 1, + flagsrequired => {borrow => 1}, + }); + +print $query->header(-cookie => $cookie), $template->output; diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl new file mode 100755 index 0000000000..5cd31e8e65 --- /dev/null +++ b/opac/opac-readingrecord.pl @@ -0,0 +1,54 @@ +#!/usr/bin/perl +use strict; +require Exporter; +use CGI; + +use C4::Auth; +use C4::Koha; +use C4::Circulation::Circ2; +use C4::Search; + +my $query = new CGI; +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-readingrecord.tmpl", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => {borrow => 1}, + debug => 1, + }); + +# get borrower information .... +my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); + + +$template->param($borr); + +# get the record +my $order=$query->param('order'); +my $order2=$order; +if ($order2 eq ''){ + $order2="date_due desc"; +} +my $limit=$query->param('limit'); +if ($limit eq 'full'){ + $limit=0; +} else { + $limit=50; +} +my ($count,$issues)=allissues($borrowernumber,$order2,$limit); + +# add the row parity +my $num = 0; +foreach my $row (@$issues) { + $row->{'even'} = 1 if $num % 2 == 0; + $row->{'odd'} = 1 if $num % 2 == 1; + $num++; +} + +$template->param(count => $count); +$template->param(READING_RECORD => $issues); + + +print $query->header(-cookie => $cookie), $template->output; + diff --git a/opac/opac-renew.pl b/opac/opac-renew.pl new file mode 100755 index 0000000000..41f1d73304 --- /dev/null +++ b/opac/opac-renew.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl + +#written 18/1/2000 by chris@katipo.co.nz +# adapted for use in the hlt opac by finlay@katipo.co.nz 29/11/2002 +#script to renew items from the web + +use CGI; +use C4::Circulation::Renewals2; + +my $query = new CGI; + +my $itemnumber = $query->param('item'); +my $borrowernumber = $query->param("bornum"); + + + +my %env; +my $status = renewstatus(\%env,$borrowernumber,$itemnumber); +if ($status == 1){ + renewbook(\%env,$borrowernumber,$itemnumber); +} + +if ($query->param('from') eq 'opac_user') { + print $query->redirect("/cgi-bin/koha/opac-user.pl"); +} diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 3826f7c992..21a7617687 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -4,21 +4,22 @@ require Exporter; use CGI; use C4::Search; -use C4::Output; # gettemplate use C4::Auth; # checkauth, getborrowernumber. use C4::Koha; use C4::Circulation::Circ2; use C4::Reserves2; my $query = new CGI; - - -my ($loggedinuser, $cookie, $sessionID) = checkauth($query); - -my $template = gettemplate("opac-reserve.tmpl", "opac"); +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "opac-reserve.tmpl", + query => $query, + type => "opac", + authnotrequired => 0, + flagsrequired => {borrow => 1}, + debug => 1, + }); # get borrower information .... -my $borrowernumber = getborrowernumber($loggedinuser); my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); my @bordat; $bordat[0] = $borr; @@ -33,6 +34,8 @@ $template->param($bibdata); # get the rank number.... my ($rank,$reserves) = FindReserves($biblionumber); +$template->param(reservecount => $rank); + foreach my $res (@$reserves) { if ($res->{'found'} eq 'W') { $rank--; @@ -53,6 +56,7 @@ $template->param(branchname => $branches->{$branch}->{'branchname'}); # make branch selection options... my $branchoptions = ''; +my @branches; foreach my $br (keys %$branches) { (next) unless $branches->{$br}->{'IS'}; my $selected = ""; @@ -60,45 +64,154 @@ foreach my $br (keys %$branches) { $selected = "selected"; } $branchoptions .= "\n"; + push @branches, {branchcode => $br, branchname => $branches->{$br}->{'branchname'}, selected => $selected}; } $template->param( branchoptions => $branchoptions); +$template->param(BRANCHES => \@branches); + +#### THIS IS A BIT OF A HACK BECAUSE THE BIBLIOITEMS DATA IS A LITTLE MESSED UP! +# get the itemtype data.... +my @items = ItemInfo(undef, $biblionumber, 'opac'); +my @temp; +foreach my $itm (@items) { + push @temp, $itm if $itm->{'itemtype'}; +} +@items = @temp; +my $itemcount = @items; +$template->param(itemcount => $itemcount); + +my %types; +my %itemtypes; +my @duedates; +foreach my $itm (@items) { + push @duedates, {date_due => slashifyDate($itm->{'date_due'})} if defined $itm->{'date_due'}; + $itm->{$itm->{'publictype'}} = 1; + my $fee = CalcReserveFee(undef, $borrowernumber, $itm->{'biblionumber'},'a',($itm->{'biblioitemnumber'})); + $fee = sprintf "%.02f", $fee; + $itm->{'reservefee'} = $fee; + my $pty = $itm->{'publictype'}; + $itemtypes{$itm->{'itemtype'}} = $itm; + unless ($types {$pty}) { + $types{$pty}->{'count'} = 1; + $types{$pty}->{$itm->{'itemtype'}} = 1; + push @{$types{$pty}->{'items'}}, $itm; + } else { + unless ($types{$pty}->{$itm->{'itemtype'}}) { + $types{$pty}->{'count'}++; + $types{$pty}->{$itm->{'itemtype'}} = 1; + push @{$types{$pty}->{'items'}}, $itm; + } + } +} -#get the bibitem data.... -my ($count,@data) = bibitems($biblionumber); +$template->param(ITEMS => \@duedates); -foreach my $bibitem (@data) { - my @barcodes = barcodes($bibitem->{'biblioitemnumber'}); - my $barcodestext = ""; - foreach my $num (@barcodes) { - my $message = $num->{'itemlost'} == 1 ? "(lost)" : - $num->{'itemlost'} == 2 ? "(long overdue)" : "($branches->{$num->{'holdingbranch'}}->{'branchname'})"; - $barcodestext .= "$num->{'barcode'} $message
"; +my $width = keys %types; +my @publictypes = sort {$b->{'count'} <=> $a->{'count'}} values %types; +my $typecount; +foreach my $pt (@publictypes) { + $typecount += $pt->{'count'}; +} +$template->param(onlyone => 1) if $typecount == 1; + +my @typerows; +for (my $rownum=0;$rownum<$publictypes[0]->{'count'} ;$rownum++) { + my @row; + foreach my $pty (@publictypes) { + my @items = @{$pty->{'items'}}; + push @row, $items[$rownum] if defined $items[$rownum]; } - $barcodestext = substr($barcodestext, 0, -4); - $bibitem->{'copies'} = $barcodestext; + my $last = @row; + $row[$last-1]->{'last'} =1 if $last == $width; + my $fill = ($width - $last)*2; + $fill-- if $fill; + push @typerows, {ROW => \@row, fill => $fill}; } +$template->param(TYPE_ROWS => \@typerows); +$width = 2*$width -1; +$template->param(totalwidth => 2*$width-1); + +if ($query->param('item_types_selected')) { +# this is what happens after the itemtypes have been selected. Stage 2 + my @itemtypes = $query->param('itemtype'); + my $fee = 0; + my $proceed = 0; + if (@itemtypes) { + my %newtypes; + foreach my $itmtype (@itemtypes) { + $newtypes{$itmtype} = $itemtypes{$itmtype}; + } + my @types = values %newtypes; + $template->param(TYPES => \@types); + foreach my $type (@itemtypes) { + my @reqbibs; + foreach my $item (@items) { + if ($item->{'itemtype'} eq $type) { + push @reqbibs, $item->{'biblioitemnumber'}; + } + } + $fee += CalcReserveFee(undef,$borrowernumber,$biblionumber,'o',\@reqbibs); + } + $proceed = 1; + } elsif ($query->param('all')) { + $template->param(all => 1); + $fee = 1; + $proceed = 1; + } + if ($proceed) { + $fee = sprintf "%.02f", $fee; + $template->param(fee => $fee); + $template->param(item_types_selected => 1); + } else { + $template->param(message => 1); + $template->param(no_items_selected => 1); + } - -my @reqbibs = $query->param('reqbib'); -if ($query->param('bibitemsselected')) { - $template->param(bibitemsselected => 1); - my @tempdata; - foreach my $bibitem (@data) { - foreach my $reqbib (@reqbibs){ - push @tempdata, $bibitem if ($bibitem->{'biblioitemnumber'} == $reqbib) ; +} elsif ($query->param('place_reserve')) { +# here we actually do the reserveration. Stage 3. + my $title = $bibdata->{'title'}; + my @itemtypes = $query->param('itemtype'); + foreach my $type (@itemtypes) { + my @reqbibs; + foreach my $item (@items) { + if ($item->{'itemtype'} eq $type) { + push @reqbibs, $item->{'biblioitemnumber'}; + } } + CreateReserve(undef,$branch,$borrowernumber,$biblionumber,'o',\@reqbibs,$rank,'',$title); + } + if ($query->param('all')) { + CreateReserve(undef,$branch,$borrowernumber,$biblionumber,'a', undef, $rank,'',$title); } - @data = @tempdata; -} elsif ($query->param('placereserve')) { -# here we actually do the reserveration.... - my $title = $bibdata->{'title'}; - CreateReserve(undef,$branch,$borrowernumber,$biblionumber,'o',\@reqbibs,$rank,'',$title); - warn "reserve created\n"; print $query->redirect("/cgi-bin/koha/opac-user.pl"); } else { - $template->param(selectbibitems => 1); +# Here we check that the borrower can actually make reserves Stage 1. + my $noreserves = 0; + if ($borr->{'amountoutstanding'} > 5) { + my $amount = sprintf "\$%.02f", $borr->{'amountoutstanding'}; + $template->param(message => 1); + $noreserves = 1; + $template->param(too_much_oweing => $amount); + } + my ($resnum, $reserves) = FindReserves(undef, $borrowernumber); + $template->param(RESERVES => $reserves); + if ($resnum >= $MAXIMUM_NUMBER_OF_RESERVES) { + $template->param(message => 1); + $noreserves = 1; + $template->param(too_many_reserves => $resnum); + } + foreach my $res (@$reserves) { + if ($res->{'biblionumber'} == $biblionumber) { + $template->param(message => 1); + $noreserves = 1; + $template->param(already_reserved => 1); + } + } + unless ($noreserves) { + $template->param(select_item_types => 1); + } } # check that you can actually make the reserve. @@ -106,5 +219,5 @@ if ($query->param('bibitemsselected')) { $template->param(BIBLIOITEMS => \@data); -$template->param(loggedinuser => $loggedinuser); -print "Content-Type: text/html\n\n", $template->output; + +print $query->header(-cookie => $cookie), $template->output; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 824190457d..43a5141f93 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -2,19 +2,31 @@ use strict; require Exporter; -use C4::Output; -use CGI; use C4::Auth; +use CGI; +use C4::Database; -my $query = new CGI; +my $classlist=''; -my $flagsrequired; -$flagsrequired->{borrow}=1; +my $dbh=C4Connect; +my $sth=$dbh->prepare("select groupname,itemtypes from itemtypesearchgroups order by groupname"); +$sth->execute; +while (my ($groupname,$itemtypes) = $sth->fetchrow) { + $classlist.="