added these files from the rel-1-2 branch. This is the beging of the new opac
authorfinlayt <finlayt>
Thu, 3 Oct 2002 08:51:29 +0000 (08:51 +0000)
committerfinlayt <finlayt>
Thu, 3 Oct 2002 08:51:29 +0000 (08:51 +0000)
opac/opac-detail.pl [new file with mode: 0755]
opac/opac-logout.pl [new file with mode: 0755]
opac/opac-main.pl [new file with mode: 0755]
opac/opac-moredetail.pl [new file with mode: 0755]
opac/opac-reserve.pl [new file with mode: 0755]
opac/opac-search.pl [new file with mode: 0755]
opac/opac-searchresults.pl [new file with mode: 0755]
opac/opac-user.pl [new file with mode: 0755]
opac/opac-userupdate.pl [new file with mode: 0755]

diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
new file mode 100755 (executable)
index 0000000..3e48936
--- /dev/null
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use C4::Output;  # contains picktemplate
+use CGI;
+use C4::Search;
+use C4::Auth;
+my $query=new CGI;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
+
+my $template = gettemplate ("opac-detail.tmpl", "opac");
+
+$template->param(loggedinuser => $loggedinuser);
+
+my $biblionumber=$query->param('bib');
+
+
+# change back when ive fixed request.pl
+my @items                                 = &ItemInfo(undef, $biblionumber, 'opac');
+my $dat                                   = &bibdata($biblionumber);
+my ($authorcount, $addauthor)             = &addauthor($biblionumber);
+my ($webbiblioitemcount, @webbiblioitems) = &getwebbiblioitems($biblionumber);
+my ($websitecount, @websites)             = &getwebsites($biblionumber);
+
+$dat->{'count'}=@items;
+
+$dat->{'additional'}=$addauthor->[0]->{'author'};
+for (my $i = 1; $i < $authorcount; $i++) {
+        $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
+} # for
+
+my @results;
+
+$results[0]=$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;
+
diff --git a/opac/opac-logout.pl b/opac/opac-logout.pl
new file mode 100755 (executable)
index 0000000..969e77d
--- /dev/null
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+use CGI;
+use C4::Database;
+use C4::Output;
+
+my $query=new CGI;
+
+my $sessionID=$query->cookie('sessionID');
+
+
+if ($ENV{'REMOTE_USER'}) {
+    print $query->header();
+    print startpage();
+    print startmenu('catalogue');
+    print qq|
+<h1>Logout Feature Not Available</h1>
+Your Koha server is configured to use a type of authentication called "Basic
+Authentication" instead of using a cookies-based authentication system.  With
+Basic Authentication, the only way to logout of Koha is by exiting your
+browser.
+|;
+    print endmenu('catalogue');
+    print endpage();
+    exit;
+}
+
+my $sessions;
+open (S, "/tmp/sessions");
+while (my ($sid, $u, $lasttime) = split(/:/, <S>)) {
+    chomp $lasttime;
+    (next) unless ($sid);
+    (next) if ($sid eq $sessionID);
+    $sessions->{$sid}->{'userid'}=$u;
+    $sessions->{$sid}->{'lasttime'}=$lasttime;
+}
+open (S, ">/tmp/sessions");
+foreach (keys %$sessions) {
+    my $userid=$sessions->{$_}->{'userid'};
+    my $lasttime=$sessions->{$_}->{'lasttime'};
+    print S "$_:$userid:$lasttime\n";
+}
+
+my $dbh=C4Connect;
+
+# Check that this is the ip that created the session before deleting it
+
+my $sth=$dbh->prepare("select userid,ip from sessions where sessionID=?");
+$sth->execute($sessionID);
+my ($userid, $ip);
+if ($sth->rows) {
+    ($userid,$ip) = $sth->fetchrow;
+    if ($ip ne $ENV{'REMOTE_ADDR'}) {
+       # attempt to logout from a different ip than cookie was created at
+       exit;
+    }
+}
+
+$sth=$dbh->prepare("delete from sessions where sessionID=?");
+$sth->execute($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;
+close L;
+
+my $cookie=$query->cookie(-name => 'sessionID',
+                         -value => '',
+                         -expires => '+1y');
+
+# Should redirect to opac home page after logging out
+
+print $query->redirect("/cgi-bin/koha/opac-main.pl");
+
+exit;
+if ($sessionID) {
+    print "Logged out of $sessionID<br>\n";
+    print "<a href=shelves.pl>Login</a>";
+} else {
+    print "Not logged in.<br>\n";
+    print "<a href=shelves.pl>Login</a>";
+}
+
+
+
diff --git a/opac/opac-main.pl b/opac/opac-main.pl
new file mode 100755 (executable)
index 0000000..1c615a7
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use CGI;
+
+use C4::Output;       # gettemplate
+use C4::Auth;         # checkauth
+
+my $query = new CGI;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
+
+my $template = gettemplate("opac-main.tmpl", "opac");
+
+$template->param(loggedinuser => $loggedinuser);
+
+print "Content-Type: text/html\n\n", $template->output;
diff --git a/opac/opac-moredetail.pl b/opac/opac-moredetail.pl
new file mode 100755 (executable)
index 0000000..49b6b57
--- /dev/null
@@ -0,0 +1,199 @@
+#!/usr/bin/perl
+
+#script to display detailed information
+#written 8/11/99
+
+use strict;
+#use DBI;
+use C4::Search;
+use C4::Koha;
+use C4::Output;
+use C4::Acquisitions;
+use C4::Biblio;
+
+use CGI;
+my $input = new CGI;
+print $input->header;
+#whether it is called from the opac of the intranet
+my $type=$input->param('type');
+#setup colours
+my $main;
+my $secondary;
+if ($type eq 'opac'){
+  $main='#99cccc';
+  $secondary='#efe5ef';
+} else {
+  $main='#cccc99';
+  $secondary='#ffffcc';
+}
+print startpage();
+print startmenu($type);
+my $blah;
+
+my $bib=$input->param('bib');
+my $title=$input->param('title');
+my $bi=$input->param('bi');
+my $data=bibitemdata($bi);
+
+my (@items)=itemissues($bi);
+my ($order,$ordernum)=getorder($bi,$bib);
+#print @items;
+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;}                           
+if ($dewey <= 0){
+  $dewey='';                                                                   
+}               
+$dewey=~ s/\.$//;
+print <<printend
+<br>
+<a href=/cgi-bin/koha/request.pl?bib=$bib><img src=/images/requests.gif width=120 height=42 border=0 align=right border=0></a>
+printend
+;
+if ($type eq 'catmain'){
+  print "<FONT SIZE=6><em>Catalogue Maintenance</em></FONT><br>";
+}
+print <<printend
+<FONT SIZE=6><em><a href=/cgi-bin/koha/detail.pl?bib=$bib&type=intra>$data->{'title'} ($data->{'author'})</a></em></FONT><P>
+<p>
+<form action=/cgi-bin/koha/modbibitem.pl>
+<input type=hidden name=bibitem value=$bi>
+<input type=hidden name=biblio value=$bib>
+<!-------------------BIBLIO ITEM------------>
+<TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left>
+<TR VALIGN=TOP>
+<td  bgcolor="99cc33" background="/images/background-mem.gif" ><B>$data->{'biblioitemnumber'} GROUP - $data->{'description'} </b> </TD>
+</TR>
+<tr VALIGN=TOP  >
+<TD width=210 >
+<INPUT TYPE="image" name="submit"  VALUE="modify" height=42  WIDTH=93 BORDER=0 src="/images/modify-mem.gif"> 
+<INPUT TYPE="image" name="delete"  VALUE="delete" height=42  WIDTH=93 BORDER=0 src="/images/delete-mem.gif"> 
+<br>
+<FONT SIZE=2  face="arial, helvetica">
+<b>Biblionumber:</b> $bib<br>
+<b>Item Type:</b> $data->{'itemtype'}<br>
+<b>Loan Length:</b> $data->{'loanlength'}<br>
+<b>Rental Charge:</b> $data->{'rentalcharge'}<br>
+<b>Classification:</b> $data->{'classification'}$dewey$data->{'subclass'}<br>
+<b>ISBN:</b> $data->{'isbn'}<br>
+<b>Publisher:</b> $data->{'publishercode'} <br>
+<b>Place:</b> $data->{'place'}<br>
+<b>Date:</b> $data->{'publicationyear'}<br>
+<b>Volume:</b> $data->{'volumeddesc'}<br>
+<b>Pages:</b> $data->{'pages'}<br>
+<b>Illus:</b> $data->{'illus'}<br>
+<b>Size:</b> $data->{'size'}<br>
+<b>Notes:</b> $data->{'bnotes'}<br>
+<b>No. of Items:</b> $count
+
+printend
+;
+if ($type eq 'catmain'){
+  print "<br><a href=/cgi-bin/koha/maint/shiftbib.pl?bi=$data->{'biblioitemnumber'}&bib=$data->{'biblionumber'}>Shift to another biblio</a>";
+}
+print <<printend
+
+</font>
+</TD>
+</tr>
+</table>
+</form>
+printend
+;
+
+for (my $i=0;$i<$count;$i++){
+print <<printend
+<img src="/images/holder.gif" width=16 height=300 align=left>
+<TABLE  CELLSPACING=0  CELLPADDING=5 border=1 align=left width=220 >                           
+<TR VALIGN=TOP>
+<td  bgcolor="99cc33" background="/images/background-mem.gif"><B>BARCODE $items[$i]->{'barcode'}</b></TD>
+</TR>
+<tr VALIGN=TOP  >
+<TD width=220 >
+<form action=/cgi-bin/koha/moditem.pl method=post>
+<input type=hidden name=bibitem value=$bi>
+<input type=hidden name=item value=$items[$i]->{'itemnumber'}>
+<input type=hidden name=type value=$type>
+<INPUT TYPE="image" name="submit"  VALUE="modify" height=42  WIDTH=93 BORDER=0 src="/images/modify-mem.gif"> 
+<INPUT TYPE="image" name="delete"  VALUE="delete" height=42  WIDTH=93 BORDER=0 src="/images/delete-mem.gif"> 
+<br>
+printend
+;
+$items[$i]->{'itemlost'}=~ s/0/No/;
+$items[$i]->{'itemlost'}=~ s/1/Yes/;
+$items[$i]->{'withdrawn'}=~ s/0/No/;
+$items[$i]->{'withdrawn'}=~ s/1/Yes/;
+$items[$i]->{'replacementprice'}+=0.00;
+
+my $year=substr($items[$i]->{'timestamp0'},0,4);
+my $mon=substr($items[$i]->{'timestamp0'},4,2);
+my $day=substr($items[$i]->{'timestamp0'},6,2);
+$items[$i]->{'timestamp0'}="$day/$mon/$year";
+
+$items[$i]->{'dateaccessioned'} = slashifyDate($items[$i]->{'dateaccessioned'});
+$items[$i]->{'datelastseen'} = slashifyDate($items[$i]->{'datelastseen'});
+
+print <<printend
+<FONT SIZE=2  face="arial, helvetica">
+<b>Home Branch:</b> $items[$i]->{'homebranch'}<br>
+<b>Last seen:</b> $items[$i]->{'datelastseen'}<br>
+<b>Last borrowed:</b> $items[$i]->{'timestamp0'}<br>
+printend
+;
+if ($items[$i] eq 'Available'){
+  print "<b>Currently on issue to:</b><br>";
+} else {
+  print "<b>Currently on issue to:</b> <a href=/cgi-bin/koha/moremember.pl?bornum=$items[$i]->{'borrower0'}>$items[$i]->{'card'}</a><br>";
+}
+print <<printend
+<b>Last Borrower 1:</b> $items[$i]->{'card0'}<br>
+<b>Last Borrower 2:</b> $items[$i]->{'card1'}<br>
+<b>Current Branch:</b> $items[$i]->{'holdingbranch'}<br>
+<b>Replacement Price:</b> $items[$i]->{'replacementprice'}<br>
+<b>Item lost:</b> $items[$i]->{'itemlost'}<br>
+<b>Paid for:</b> $items[$i]->{'paidfor'}<br>
+<b>Notes:</b> $items[$i]->{'itemnotes'}<br>
+<b>Renewals:</b> $items[$i]->{'renewals'}<br>
+<b><a href=/cgi-bin/koha/acqui/acquire.pl?recieve=$ordernum&biblio=$bib&invoice=$order->{'booksellerinvoicenumber'}&catview=yes>Accession</a> Date: $items[$i]->{'dateaccessioned'}<br>
+printend
+;
+if ($items[$i]->{'wthdrawn'} eq '1'){
+  $items[$i]->{'wthdrawn'}="Yes";
+} else {
+  $items[$i]->{'wthdrawn'}="No";
+}
+print <<printend
+<b>Cancelled: $items[$i]->{'wthdrawn'}<br>
+<b>Total Issues:</b> $items[$i]->{'issues'}<br>
+<b>Group Number:</b> $bi <br>
+<b>Biblio number:</b> $bib <br>
+
+
+
+</font>
+</TD>
+</tr>
+</table>
+</form>
+printend
+;
+}
+print <<printend
+<p>
+</form>
+printend
+;
+
+
+print endcenter();
+
+print endmenu($type);
+print endpage();
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
new file mode 100755 (executable)
index 0000000..86f5ab8
--- /dev/null
@@ -0,0 +1,110 @@
+#!/usr/bin/perl
+use strict;
+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");
+
+# get borrower information ....
+my $borrowernumber = getborrowernumber($loggedinuser);
+my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
+my @bordat;
+$bordat[0] = $borr;
+$template->param(BORROWER_INFO => \@bordat);
+
+# get biblionumber.....
+my $biblionumber = $query->param('bib');
+$template->param(biblionumber => $biblionumber);
+
+my $bibdata = bibdata($biblionumber);
+$template->param($bibdata);
+
+# get the rank number....
+my ($rank,$reserves) = FindReserves($biblionumber);
+foreach my $res (@$reserves) {
+    if ($res->{'found'} eq 'W') {
+       $rank--;
+    }
+}
+$rank++;
+$template->param(rank => $rank);
+
+
+
+# pass the pickup branch along....
+my $branch = $query->param('branch');
+$template->param(branch => $branch);
+
+my $branches = getbranches();
+$template->param(branchname => $branches->{$branch}->{'branchname'});
+
+
+# make branch selection options...
+my $branchoptions = '';
+foreach my $br (keys %$branches) {
+    (next) unless $branches->{$br}->{'IS'};
+    my $selected = "";
+    if ($br eq $branch) {
+       $selected = "selected";
+    }
+    $branchoptions .= "<option value=$br $selected>$branches->{$br}->{'branchname'}</option>\n";
+}
+$template->param( branchoptions => $branchoptions);
+
+
+#get the bibitem data....
+my ($count,@data) = bibitems($biblionumber);
+
+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 <br>";
+    }
+    $barcodestext = substr($barcodestext, 0, -4);
+    $bibitem->{'copies'} = $barcodestext;
+}
+
+
+
+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) ;
+       }
+    }
+    @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);
+}
+# check that you can actually make the reserve.
+
+
+
+$template->param(BIBLIOITEMS => \@data);
+
+$template->param(loggedinuser => $loggedinuser);
+print "Content-Type: text/html\n\n", $template->output; 
diff --git a/opac/opac-search.pl b/opac/opac-search.pl
new file mode 100755 (executable)
index 0000000..cf6c7a3
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+
+use C4::Output;  
+use CGI;
+use C4::Auth;
+
+my $query = new CGI;
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query ,1);
+
+my $template = gettemplate("opac-search.tmpl", "opac");
+
+$template->param(loggedinuser => $loggedinuser);
+
+print "Content-Type: text/html\n\n", $template->output;
diff --git a/opac/opac-searchresults.pl b/opac/opac-searchresults.pl
new file mode 100755 (executable)
index 0000000..8e86232
--- /dev/null
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use CGI;
+use C4::Search;
+use C4::Auth;
+use C4::Output; # now contains picktemplate
+  
+my $query=new CGI;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
+
+
+my $template = gettemplate ("opac-searchresults.tmpl", "opac");
+
+
+
+my $subject=$query->param('subject');
+
+
+if ($subject) {
+    $template->param(subjectsearch => $subject);
+}
+
+# get all the search variables
+# we assume that C4::Search will validate these values for us
+my @fields = ('keyword', 'subject', 'author', 'illustrator', 'itemnumber', 'isbn', 'date-before', 'date-after', 'class', 'dewey', 'branch', 'title', 'abstract', 'publisher');
+
+
+
+# collect all the fields ...
+my %search;
+my $forminputs;
+my $searchdesc = '';
+foreach my $field (@fields) {
+    $search{$field} = $query->param($field);
+    if ($search{$field}) {
+       push @$forminputs, {field => $field, value => $search{$field}};
+       $searchdesc .= "$field = $search{$field}, ";
+    }
+}
+$search{'ttype'} = $query->param('ttype');
+push @$forminputs, {field => 'ttype', value => $search{'ttype'}};
+
+if (my $subjectitems=$query->param('subjectitems')){
+    $search{'subject'} = $subjectitems;
+    $searchdesc.="subject = $subjectitems, ";
+}
+
+@$forminputs=() unless $forminputs;
+$template->param(FORMINPUTS => $forminputs);
+
+# do the searchs ....
+my $env;
+$env->{itemcount}=1;
+my $num=10;
+my @results;
+my $count;
+my $startfrom = $query->param('startfrom');
+my $subjectitems=$query->param('subjectitems');
+if ($subjectitems) {
+    my $blah;
+    @results = subsearch(\$blah,$subjectitems, $num, $startfrom);
+    $count = $#results+1;
+} else {
+    ($count, @results) = catalogsearch($env,'',\%search,$num,$startfrom);
+}
+
+foreach my $res (@results) {
+    my @items = ItemInfo(undef, $res->{'biblionumber'}, "intra");
+    my $norequests = 1;
+    foreach my $itm (@items) {
+       $norequests = 0 unless $itm->{'notforloan'};
+    }
+    $res->{'norequests'} = $norequests;
+}
+
+
+my $startfrom=$query->param('startfrom');
+($startfrom) || ($startfrom=0);
+
+my $resultsarray=\@results;
+($resultsarray) || (@$resultsarray=());
+
+
+# sorting out which results to display.
+$template->param(startfrom => $startfrom+1);
+($startfrom+$num<=$count) ? ($template->param(endat => $startfrom+$num)) : ($template->param(endat => $count));
+$template->param(numrecords => $count);
+my $nextstartfrom=($startfrom+$num<$count) ? ($startfrom+$num) : (-1);
+my $prevstartfrom=($startfrom-$num>=0) ? ($startfrom-$num) : (-1);
+$template->param(nextstartfrom => $nextstartfrom);
+my $displaynext=1;
+my $displayprev=0;
+($nextstartfrom==-1) ? ($displaynext=0) : ($displaynext=1);
+($prevstartfrom==-1) ? ($displayprev=0) : ($displayprev=1);
+$template->param(displaynext => $displaynext);
+$template->param(displayprev => $displayprev);
+$template->param(prevstartfrom => $prevstartfrom);
+
+$template->param(searchdesc => $searchdesc);
+$template->param(SEARCH_RESULTS => $resultsarray);
+$template->param(loggedinuser => $loggedinuser);
+
+my $numbers;
+@$numbers = ();
+if ($count>10) {
+    for (my $i=1; $i<$count/10+1; $i++) {
+       my $highlight=0;
+       my $themelang = $template->param('themelang');
+       ($startfrom==($i-1)*10) && ($highlight=1);
+       push @$numbers, { number => $i, highlight => $highlight , startfrom => ($i-1)*10 };
+    }
+}
+
+$template->param(numbers => $numbers);
+
+$template->param(loggedinuser => $loggedinuser);
+
+print $query->header(-cookie => $cookie), $template->output;
+
diff --git a/opac/opac-user.pl b/opac/opac-user.pl
new file mode 100755 (executable)
index 0000000..29503f9
--- /dev/null
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use CGI;
+
+use C4::Search;       # borrdata
+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-user.tmpl", "opac");
+
+# get borrower information ....
+my $borrowernumber = getborrowernumber($loggedinuser);
+my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
+
+$borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'});
+$borr->{'expiry'}       = slashifyDate($borr->{'expiry'});
+$borr->{'dateofbirth'}  = slashifyDate($borr->{'dateofbirth'});
+$borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
+
+if ($borr->{'amountoutstanding'} > 5) {
+    $borr->{'amountoverfive'} = 1;
+} else {
+    $borr->{'amountoverfive'} = 0;
+}
+
+$borr->{'amountoutstanding'} = sprintf "\$%.02f", $borr->{'amountoutstanding'};
+
+my @bordat;
+$bordat[0] = $borr;
+
+$template->param(BORROWER_INFO => \@bordat);
+
+#get issued items ....
+my $issues = getissues($borr);
+
+my $count=0;
+my @issuedat;
+foreach my $key (keys %$issues) {
+    my $issue = $issues->{$key};
+    $issue->{'date_due'}  = slashifyDate($issue->{'date_due'});
+    if ($issue->{'overdue'}) {
+       $issue->{'status'} = "OVERDUE";
+    } else {
+       $issue->{'status'} = "Issued";
+    }
+# check for reserves
+    my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
+    if ($restype) {
+       $issue->{'status'} .= "Reserved";
+    }
+    my ($charges, $itemtype) = calc_charges(undef, undef, $issue->{'itemnumber'}, $borrowernumber);
+    $issue->{'charges'} = $charges; 
+    push @issuedat, $issue;
+    $count++;
+} 
+
+$template->param(ISSUES => \@issuedat); 
+$template->param(issues_count => $count); 
+
+# now the reserved items....
+my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
+
+$template->param(RESERVES => $reserves);
+$template->param(reserves_count => $rcount);
+
+my $branches = getbranches();
+my @waiting;
+my $wcount = 0;
+foreach my $res (@$reserves) {
+    if ($res->{'itemnumber'}) {
+       $res->{'branch'} = $branches->{$res->{'branchcode'}}->{'branchname'};
+       push @waiting, $res;
+       $wcount++;
+    }
+}
+
+$template->param(WAITING => \@waiting);
+$template->param(waiting_count => $wcount);
+
+$template->param(loggedinuser => $loggedinuser);
+print "Content-Type: text/html\n\n", $template->output; 
diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl
new file mode 100755 (executable)
index 0000000..87b9c49
--- /dev/null
@@ -0,0 +1,70 @@
+#!/usr/bin/perl
+use strict;
+require Exporter;
+use CGI;
+use Mail::Sendmail;
+
+use C4::Output;       # gettemplate
+use C4::Auth;         # checkauth, getborrowernumber.
+use C4::Koha;
+use C4::Circulation::Circ2;
+
+
+my $query = new CGI;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
+
+# get borrower information ....
+my $borrowernumber = getborrowernumber($loggedinuser);
+my ($borr, $flags) = getpatroninformation(undef, $borrowernumber);
+
+
+# handle the new information....
+# collect the form values and send an email.
+my @fields = ('title', 'surname', 'firstname', 'phone', 'faxnumber', 'streetaddress', 'emailaddress', 'city');
+my $update;
+my $updateemailaddress = "finlay\@katipo.co.nz";      #Will have to change this! !!!!!!!!!!!!!!!!!!!
+if ($query->{'title'}) {
+    # get all the fields:
+    my $message = <<"EOF";
+Borrower $borr->{'cardnumber'} http://intradev.katipo.co.nz/cgi-bin/koha/moremember.pl?bornum=$borrowernumber
+
+has requested to change their personal details. Please check these new details and make the changes:
+EOF
+    foreach my $field (@fields){
+       my $newfield = $query->param($field);
+       $message .= "$field : $borr->{$field}  -->  $newfield\n";
+    }
+    $message .= "\n\nThanks,\nKoha\n\n";
+    my %mail = ( To      => $updateemailaddress ,
+                From    => $updateemailaddress ,
+                Subject => "User Request for update of Record.",
+                Message => $message );
+    if (sendmail %mail) {
+# do something if it works....
+       warn "Mail sent ok\n";
+       print $query->redirect('/cgi-bin/koha/opac-user.pl');
+    } else {
+# do something if it doesnt work....
+        warn "Error sending mail: $Mail::Sendmail::error \n";
+    }
+} 
+
+my $template = gettemplate("opac-userupdate.tmpl", "opac");
+
+
+$borr->{'dateenrolled'} = slashifyDate($borr->{'dateenrolled'});
+$borr->{'expiry'}       = slashifyDate($borr->{'expiry'});
+$borr->{'dateofbirth'}  = slashifyDate($borr->{'dateofbirth'});
+$borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
+
+
+my @bordat;
+$bordat[0] = $borr;
+
+$template->param(BORROWER_INFO => \@bordat);
+
+
+$template->param(loggedinuser => $loggedinuser);
+
+print "Content-Type: text/html\n\n", $template->output;