Merging from rel-1-2 to trunk
authortonnesen <tonnesen>
Mon, 28 Oct 2002 20:02:57 +0000 (20:02 +0000)
committertonnesen <tonnesen>
Mon, 28 Oct 2002 20:02:57 +0000 (20:02 +0000)
C4/Print.pm
mainpage.pl
opac/opac-detail.pl
opac/opac-main.pl
opac/opac-search.pl
opac/opac-searchresults.pl
opac/opac-user.pl
opac/opac-userupdate.pl

index 54dc135..46b5bf2 100644 (file)
@@ -22,6 +22,9 @@ use strict;
 require Exporter;
 #use C4::InterfaceCDK;
 
+use C4::Context;
+
+
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
@@ -46,7 +49,7 @@ The functions in this module handle sending text to a printer.
 =cut
 
 @ISA = qw(Exporter);
-@EXPORT = qw(&remoteprint &printslip);
+@EXPORT = qw(&remoteprint &printreserve &printslip);
 
 =item remoteprint
 
@@ -71,10 +74,8 @@ from C<&currentissues>.
 # FIXME - It'd be nifty if this could generate pretty PostScript.
 sub remoteprint {
   my ($env,$items,$borrower)=@_;
-  #open (FILE,">/tmp/olwen");
-  #print FILE "queue $env->{'queue'}";
-  #close FILE;
-  #debug_msg($env,"In print");
+
+  (return) unless (C4::Context->preference('printcirculationslips'));
   my $file=time;               # FIXME - Not used
   my $queue = $env->{'queue'};
   # FIXME - If 'queue' is undefined or empty, then presumably it should
@@ -91,7 +92,7 @@ sub remoteprint {
     # 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") or die "Couldn't write to queue:$queue!\n";
+    open(PRINTER, "| lpr -P $queue > /dev/null") or die "Couldn't write to queue:$queue!\n";
   }
 #  print $queue;
   #open (FILE,">/tmp/$file");
@@ -126,6 +127,47 @@ sub remoteprint {
   #system("lpr /tmp/$file");
 }
 
+sub printreserve {
+  my($env, $branchname, $bordata, $itemdata)=@_;
+  my $file=time;
+  my $printer = $env->{'printer'};
+  (return) unless (C4::Context->preference('printreserveslips'));
+  if ($printer eq "" || $printer eq 'nulllp') {
+    open (PRINTER,">>/tmp/kohares");
+  } else {
+    open (PRINTER, "| lpr -P $printer >/dev/null") or die "Couldn't write to queue:$!\n";
+  }
+  my @da = localtime(time());
+  my $todaysdate = "$da[2]:$da[1]  $da[3]/$da[4]/$da[5]";
+
+#(1900+$datearr[5]).sprintf ("%0.2d", ($datearr[4]+1)).sprintf ("%0.2d", $datearr[3]);
+  my $slip = <<"EOF";
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Date: $todaysdate;
+
+ITEM RESERVED: 
+$itemdata->{'title'} ($itemdata->{'author'})
+barcode: $itemdata->{'barcode'}
+
+COLLECT AT: $branchname
+
+BORROWER:
+$bordata->{'surname'}, $bordata->{'firstname'}
+card number: $bordata->{'cardnumber'}
+Phone: $bordata->{'phone'}
+$bordata->{'streetaddress'}
+$bordata->{'suburb'}
+$bordata->{'town'}
+$bordata->{'emailaddress'}
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+EOF
+    print PRINTER $slip;
+  close PRINTER;
+  return $slip;
+}
+
 =item printslip
 
   &printslip($env, $text)
@@ -142,10 +184,11 @@ will print to the file F</tmp/kohares>.
 sub printslip {
   my($env, $slip)=@_;
   my $printer = $env->{'printer'};
+  (return) unless (C4::Context->preference('printcirculationslips'));
   if ($printer eq "" || $printer eq 'nulllp') {
     open (PRINTER,">/tmp/kohares");
   } else {
-    open (PRINTER, "| lpr -P $printer") or die "Couldn't write to queue:$!\n";
+    open (PRINTER, "| lpr -P $printer >/dev/null") or die "Couldn't write to queue:$!\n";
   }
   print PRINTER $slip;
   close PRINTER;
index 45e4d53..78c7080 100755 (executable)
@@ -3,13 +3,13 @@ use HTML::Template;
 use strict;
 require Exporter;
 use C4::Database;
-use C4::Output;  # contains picktemplate
+use C4::Output;  # contains gettemplate
 use CGI;
 use C4::Auth;
 
 my $query = new CGI;
 my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
 
-my $template=gettemplate("intranet-main.tmpl");
+my $template = gettemplate("intranet-main.tmpl");
 
 print "Content-Type: text/html\n\n", $template->output;
index 11c3ee4..ce5362e 100755 (executable)
@@ -8,13 +8,19 @@ use C4::Auth;
 
 my $query=new CGI;
 
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
+
+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 $biblionumber=$query->param('bib');
+$template->param(biblionumber => $biblionumber);
 
 
 # change back when ive fixed request.pl
@@ -31,6 +37,15 @@ for (my $i = 1; $i < $authorcount; $i++) {
         $dat->{'additional'} .= "|" . $addauthor->[$i]->{'author'};
 } # for
 
+my $norequests = 1;
+foreach my $itm (@items) {
+    $norequests = 0 unless $itm->{'notforloan'};
+}
+
+$template->param(norequests => $norequests);
+
+
+
 my @results;
 
 $results[0]=$dat;
index 1c615a7..c030609 100755 (executable)
@@ -8,7 +8,11 @@ use C4::Auth;         # checkauth
 
 my $query = new CGI;
 
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
+my $flagsrequired;
+$flagsrequired->{borrow}=1;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1, $flagsrequired);
+
 
 my $template = gettemplate("opac-main.tmpl", "opac");
 
index 200531c..8241904 100755 (executable)
@@ -7,7 +7,11 @@ use CGI;
 use C4::Auth;
 
 my $query = new CGI;
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query ,1);
+
+my $flagsrequired;
+$flagsrequired->{borrow}=1;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query ,1, $flagsrequired);
 
 my $template = gettemplate("opac-search.tmpl", "opac");
 
index e29c380..999a866 100755 (executable)
@@ -8,7 +8,10 @@ use C4::Output; # now contains gettemplate
 
 my $query=new CGI;
 
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1);
+my $flagsrequired;
+$flagsrequired->{borrow}=1;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 1, $flagsrequired);
 
 
 my $template = gettemplate ("opac-searchresults.tmpl", "opac");
@@ -59,8 +62,7 @@ my $count;
 my $startfrom = $query->param('startfrom');
 my $subjectitems=$query->param('subjectitems');
 if ($subjectitems) {
-    my $blah;
-    @results = subsearch(\$blah,$subjectitems, $num, $startfrom);
+    @results = subsearch($env,$subjectitems, $num, $startfrom);
     $count = $#results+1;
 } else {
     ($count, @results) = catalogsearch($env,'',\%search,$num,$startfrom);
index fe0f7e2..d1aa63e 100755 (executable)
@@ -3,7 +3,6 @@ use strict;
 require Exporter;
 use CGI;
 
-use C4::Search;       # borrdata
 use C4::Output;       # gettemplate
 use C4::Auth;         # checkauth, getborrowernumber.
 use C4::Koha;
@@ -12,7 +11,10 @@ use C4::Reserves2;
 
 my $query = new CGI;
 
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
+my $flagsrequired;
+$flagsrequired->{borrow}=1;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0, $flagsrequired);
 
 my $template = gettemplate("opac-user.tmpl", "opac");
 
@@ -27,8 +29,13 @@ $borr->{'ethnicity'}    = fixEthnicity($borr->{'ethnicity'});
 
 if ($borr->{'amountoutstanding'} > 5) {
     $borr->{'amountoverfive'} = 1;
-} else {
-    $borr->{'amountoverfive'} = 0;
+}
+if (5 >= $borr->{'amountoutstanding'} && $borr->{'amountoutstanding'} > 0 ) {
+    $borr->{'amountoverzero'} = 1;
+}
+if ($borr->{'amountoutstanding'} < 0) {
+    $borr->{'amountlessthanzero'} = 1;
+    $borr->{'amountoutstanding'} = -1*($borr->{'amountoutstanding'});
 }
 
 $borr->{'amountoutstanding'} = sprintf "\$%.02f", $borr->{'amountoutstanding'};
@@ -47,14 +54,14 @@ foreach my $key (keys %$issues) {
     my $issue = $issues->{$key};
     $issue->{'date_due'}  = slashifyDate($issue->{'date_due'});
     if ($issue->{'overdue'}) {
-       $issue->{'status'} = "OVERDUE";
+       $issue->{'status'} = "<font color='red'>OVERDUE</font>";
     } else {
        $issue->{'status'} = "Issued";
     }
 # check for reserves
     my ($restype, $res) = CheckReserves($issue->{'itemnumber'});
     if ($restype) {
-       $issue->{'status'} .= "Reserved";
+       $issue->{'status'} .= " Reserved";
     }
     my ($charges, $itemtype) = calc_charges(undef, undef, $issue->{'itemnumber'}, $borrowernumber);
     $issue->{'charges'} = $charges;
@@ -67,6 +74,9 @@ $template->param(issues_count => $count);
 
 # now the reserved items....
 my ($rcount, $reserves) = FindReserves(undef, $borrowernumber);
+foreach my $res (@$reserves) {
+    $res->{'reservedate'}  = slashifyDate($res->{'reservedate'});
+}
 
 $template->param(RESERVES => $reserves);
 $template->param(reserves_count => $rcount);
index 08b5d97..3fda4a9 100755 (executable)
@@ -12,7 +12,10 @@ use C4::Circulation::Circ2;
 
 my $query = new CGI;
 
-my ($loggedinuser, $cookie, $sessionID) = checkauth($query);
+my $flagsrequired;
+$flagsrequired->{borrow}=1;
+
+my ($loggedinuser, $cookie, $sessionID) = checkauth($query, 0, $flagsrequired);
 
 # get borrower information ....
 my $borrowernumber = getborrowernumber($loggedinuser);