From edf5485626a2fef24175ba07f14dcd2a8ceb0ed9 Mon Sep 17 00:00:00 2001 From: tipaul Date: Mon, 10 Mar 2003 15:16:29 +0000 Subject: [PATCH] templating circulation.pl works poorly for instance --- circ/circulation.pl | 449 +++++------------- .../default/en/circ/circulation.tmpl | 243 ++++++++++ 2 files changed, 360 insertions(+), 332 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl diff --git a/circ/circulation.pl b/circ/circulation.pl index d7f2e144c2..96ec103da2 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -31,26 +31,28 @@ use C4::Print; use DBI; use C4::Auth; use C4::Interface::CGI::Output; +use C4::Koha; +use HTML::Template; my $query=new CGI; -my ($loggedinuser, $sessioncookie, $sessionID) = checkauth - ($query, 0, { circulate => 1 }); +#my ($loggedinuser, $sessioncookie, $sessionID) = checkauth +# ($query, 0, { circulate => 1 }); -#my ($template, $loggedinuser, $sessioncookie) = get_template_and_user -# ({ -# template_name => 'circ/circulation.tmpl', -# query => $query, -# type => "intranet", -# authnotrequired => 0, -# flagsrequired => { circulate => 1 }, -# }); +my ($template, $loggedinuser, $cookie) = get_template_and_user + ({ + template_name => 'circ/circulation.tmpl', + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => { circulate => 1 }, + }); my %env; -my $headerbackgroundcolor='#99cc33'; +#my $headerbackgroundcolor='#99cc33'; my $linecolor1='#ffffcc'; my $linecolor2='white'; -my $backgroundimage="/images/background-mem.gif"; +#my $backgroundimage="/images/background-mem.gif"; my $branches = getbranches(); my $printers = getprinters(\%env); @@ -60,12 +62,11 @@ my $printer = getprinter($query, $printers); #set up cookie..... -my $info = ''; my $branchcookie; my $printercookie; if ($query->param('setcookies')) { - $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y'); - $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y'); + $branchcookie = $query->cookie(-name=>'branch', -value=>"$branch", -expires=>'+1y'); + $printercookie = $query->cookie(-name=>'printer', -value=>"$printer", -expires=>'+1y'); } $env{'branchcode'}=$branch; @@ -83,17 +84,17 @@ my $borrowerslist; # if there is a list of find borrowers.... my $findborrower = $query->param('findborrower'); if ($findborrower) { - my ($borrowers, $flags) = findborrower(\%env, $findborrower); - my @borrowers=@$borrowers; - if ($#borrowers == -1) { - $query->param('findborrower', ''); - $message = "No borrower matched '$findborrower'"; - } elsif ($#borrowers == 0) { - $query->param('borrnumber', $borrowers[0]->{'borrowernumber'}); - $query->param('barcode',''); - } else { - $borrowerslist = \@borrowers; - } + my ($borrowers, $flags) = findborrower(\%env, $findborrower); + my @borrowers=@$borrowers; + if ($#borrowers == -1) { + $query->param('findborrower', ''); + $message = "No borrower matched '$findborrower'"; + } elsif ($#borrowers == 0) { + $query->param('borrnumber', $borrowers[0]->{'borrowernumber'}); + $query->param('barcode',''); + } else { + $borrowerslist = \@borrowers; + } } my $borrowernumber = $query->param('borrnumber'); @@ -102,16 +103,14 @@ my $bornum = $query->param('borrnumber'); my $print=$query->param('print'); my $barcode = $query->param('barcode'); if ($barcode eq '' && $print eq 'maybe'){ - $print = 'yes'; + $print = 'yes'; } if ($print eq 'yes' && $borrowernumber ne ''){ - printslip(\%env,$borrowernumber); - $query->param('borrnumber',''); - $borrowernumber=''; + printslip(\%env,$borrowernumber); + $query->param('borrnumber',''); + $borrowernumber=''; } - - # get the borrower information..... my $borrower; my $flags; @@ -122,16 +121,14 @@ if ($borrowernumber) { # get the responses to any questions..... my %responses; foreach (sort $query->param) { - if ($_ =~ /response-(\d*)/) { - $responses{$1} = $query->param($_); - } + if ($_ =~ /response-(\d*)/) { + $responses{$1} = $query->param($_); + } } if (my $qnumber = $query->param('questionnumber')) { - $responses{$qnumber} = $query->param('answer'); + $responses{$qnumber} = $query->param('answer'); } - - my ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer); my $year=$query->param('year'); @@ -140,171 +137,34 @@ my $day=$query->param('day'); # if the barcode is set if ($barcode) { - $barcode = cuecatbarcodedecode($barcode); - my ($datedue, $invalidduedate) = fixdate($year, $month, $day); - - unless ($invalidduedate) { - $env{'datedue'}=$datedue; - my @time=localtime(time); - my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3]; - ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) - = issuebook(\%env, $borrower, $barcode, \%responses, $date); - } + $barcode = cuecatbarcodedecode($barcode); + my ($datedue, $invalidduedate) = fixdate($year, $month, $day); + + unless ($invalidduedate) { + $env{'datedue'}=$datedue; + my @time=localtime(time); + my $date= (1900+$time[5])."-".($time[4]+1)."-".$time[3]; + ($iteminformation, $duedate, $rejected, $question, $questionnumber, $defaultanswer, $message) + = issuebook(\%env, $borrower, $barcode, \%responses, $date); + } } # reload the borrower info for the sake of reseting the flags..... if ($borrowernumber) { - ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0); + ($borrower, $flags) = getpatroninformation(\%env,$borrowernumber,0); } - ################################################################################## # HTML code.... - -my $rejectedtext; -if ($rejected) { - if ($rejected == -1) { - } else { - $rejectedtext = << "EOF"; - - - -
Error Issuing Book
$rejected
-
-EOF - } -} - -my $selectborrower; -if ($borrowerslist) { - $selectborrower = <<"EOF"; -
- - - -\n -
-Select a borrower
-
- -
-EOF -} - -# title.... -my $title = <<"EOF"; -
- -Next Borrower   - -ReturnsTransfers -
-Circulation: Issues
-Branch: $branches->{$branch}->{'branchname'}   -Printer: $printers->{$printer}->{'printername'}
-Change Settings - - -

-EOF - -my $titlenoborrower = <<"EOF"; -
- -ReturnsTransfers -
-Circulation: Issues
-Branch: $branches->{$branch}->{'branchname'}   -Printer: $printers->{$printer}->{'printername'}
-Change Settings - - -

-EOF - - - -my $cardnumberinput = << "EOF"; - - - - - - -
-Enter borrower card number
or partial last name
-

-EOF - my $responsesform = ''; foreach (keys %responses) { $responsesform.="\n"; } my $questionform; +my $stickyduedate; if ($question) { - my $stickyduedate=$query->param('stickyduedate'); - $questionform = <<"EOF"; - - - - -
-Issuing Question
-Attempting to issue $iteminformation->{'title'} -by $iteminformation->{'author'} to $borrower->{'firstname'} $borrower->{'surname'}. -

-$question -

- - - - -
-
- - - - - - - - - -$responsesform - - -
-
-
- - - - - - - - - -$responsesform - - -
-
-
- - -EOF + $stickyduedate=$query->param('stickyduedate'); } @@ -339,61 +199,6 @@ my $selected=''; ($query->param('stickyduedate')) && ($selected='checked'); -my $barcodeentrytext = <<"EOF"; -
- - -
- - -
-Enter Book Barcode
- - - -
Item Barcode:
- - -
- - - - - -
- Sticky Due Date -
- - - - -EOF -if ($flags->{'CHARGES'}){ - $barcodeentrytext.=""; -} -my $amountold=$flags->{'CHARGES'}->{'message'}; -my @temp=split(/\$/,$amountold); -$amountold=$temp[1]; -$barcodeentrytext.=""; -$barcodeentrytext.=<<"EOF"; -
-
-
-EOF - - -# collect the messages and put into message table.... -my $messagetable; -if ($message) { - $messagetable = << "EOF"; - - -
Messages
$message
-EOF -} - - - # make the issued books table..... my $todaysissues=''; my $previssues=''; @@ -460,96 +265,76 @@ EOF } } -my $issuedbookstable; -if ($todaysissues) { - $issuedbookstable .= <<"EOF"; - - - -$todaysissues -
-Todays Issues
Due DateBar CodeTitleAuthorClass
-EOF -} -if ($previssues) { - $issuedbookstable .= <<"EOF"; - - - -$previssues -
-Previous Issues
Due DateBar CodeTitleAuthorClass
-EOF -} - - - - - # actually print the page! - - -if ($branchcookie && $printercookie) { - print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie,$sessioncookie]); -} else { - print $query->header(-cookie=>[$sessioncookie]); -} - -print startpage(); -my @inp=startmenu('circulation'); -if ($query->param('barcode') eq '' && $query->param('charges') eq 'yes'){ - my $count=@inp; - for (my $i=0;$i<$count;$i++){ - $inp[$i]=~ s/onLoad=focusinput\(\)/onLoad=focusinput\(\)\;messenger\(\"\/cgi-bin\/koha\/pay.pl?bornum=$bornum\",700,600\)\;window1.focus\(\)/; - } -} - -print @inp; - - -#print startmenu('circulation'); -if ($borrower) { - print $title; -} else { - print $titlenoborrower; -} - - -print $info; - -if ($question) { - print $questionform; -} - -print $rejectedtext; -print $messagetable; - - -unless ($borrower) { - if ($borrowerslist) { - print $selectborrower; - } else { - print $cardnumberinput; - } -} - - - -if ($borrower) { - my ($patrontable, $flaginfotable) = patrontable($borrower); - print $patrontable; - print $flaginfotable; - print $barcodeentrytext; - print "



"; - print $issuedbookstable; +#if ($branchcookie && $printercookie) { +# print $query->header(-type=>'text/html',-expires=>'now', -cookie=>[$branchcookie,$printercookie,$sessioncookie]); +#} else { +# print $query->header(-cookie=>[$sessioncookie]); +#} + +#if ($query->param('barcode') eq '' && $query->param('charges') eq 'yes'){ +# my $count=@inp; +# for (my $i=0;$i<$count;$i++){ +# $inp[$i]=~ s/onLoad=focusinput\(\)/onLoad=focusinput\(\)\;messenger\(\"\/cgi-bin\/koha\/pay.pl?bornum=$bornum\",700,600\)\;window1.focus\(\)/; +# } +#} + +my @values; +my %labels; +my $CGIselectborrower; +if ($borrowerslist) { + foreach (sort {$a->{'surname'}.$a->{'firstname'} cmp $b->{'surname'}.$b->{'firstname'}} @$borrowerslist){ + push @values,$_->{'borrowernumber'}; + $labels{$_->{'borrowernumber'}} ="$_->{'surname'}, $_->{'firstname'} ($_->{'cardnumber'})"; + } + $CGIselectborrower=CGI::scrolling_list( -name => 'borrnumber', + -values => \@values, + -labels => \%labels, + -size => 7, + -multiple => 0 ); } +#title - - - -print endmenu('circulation'); -print endpage(); - +my ($patrontable, $flaginfotable) = patrontable($borrower); +my $amountold=$flags->{'CHARGES'}->{'message'}; +my @temp=split(/\$/,$amountold); +$amountold=$temp[1]; +$template->param( + findborrower => $findborrower, + borrower => $borrower, + borrowernumber => $borrowernumber, + branch => $branch, + printer => $printer, + branchname => $branches->{$branch}->{'branchname'}, + printername => $printers->{$printer}->{'printername'}, + + #question form + question => $question, + title => $iteminformation->{'title'}, + author => $iteminformation->{'author'}, + firstname => $borrower->{'firstname'}, + surname => $borrower->{'surname'}, + question => $question, + barcode => $barcode, + questionnumber => $questionnumber, + dayoptions => $dayoptions, + monthoptions => $monthoptions, + yearoptions => $yearoptions, + stickyduedate => $stickyduedate, + responseform => $responsesform, + rejected => $rejected, + message => $message, + CGIseleborrower => $CGIselectborrower, + + patrontable => $patrontable, + flaginfotable => $flaginfotable, + CHARGES => $flags->{'CHARGES'}, + amountold => $amountold, + todayissues => $todaysissues, + previssues => $previssues, + ); + +output_html_with_http_headers $query, $cookie, $template->output; #################################################################### # Extra subroutines,,, @@ -641,12 +426,12 @@ sub patrontable { } } } - ($flaginfotext) && ($flaginfotext="Flags$flaginfotext\n"); + ($flaginfotext) && ($flaginfotext="Flags$flaginfotext\n"); $flaginfotext.=""; my $patrontable= << "EOF";

- + EOF diff --git a/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl new file mode 100644 index 0000000000..2657e3d98b --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/circ/circulation.tmpl @@ -0,0 +1,243 @@ + + + +
Patron Information
Patron Information
{'borrowernumber'} onClick="openWindow(this,'Member', 480, 640)">$borrower->{'cardnumber'} $borrower->{'surname'}, $borrower->{'title'} $borrower->{'firstname'}
$borrower->{'streetaddress'} $borrower->{'city'} Cat: $borrower->{'categorycode'}
+ + + +
+ &branch=&printer=&print=yes> + //images/2rightarrow.png" border="0" alt="Next Borrower">   + + /images/button-returns.gif" width="110" height="42" border="0" alt="Returns"> +  /images/button-transfers.gif" width="127" height="42" border="0" alt="Transfers"> +
+ Circulation: Issues
+ Branch:   + Printer:
+ Change Settings + > + > +

+ + + + + +
+ + /images/button-returns.gif" width="110" height="42" border="0" alt="Returns"> +  /images/button-transfers.gif" width="127" height="42" border="0" alt="Transfers"> +
+ Circulation: Issues
+ Branch:   + Printer:
+ Change Settings + > + > +

+ + + + + + + + + + + + + +
/images/background-mem.gif"> + Issuing Question +
+ + + + +
+ Attempting to issue + by to . +

+

+
+ + + + + +
+
+ > + > + > + > + > + > + > + > + > + + + + +
+
+ > + > + > + > + > + > + > + > + > + + + + +
+
+ +
+ + + + + +
Error Issuing Book
+
+
+ + + + + +
/images/background-mem.gif">Messages
+
+ + +

+ > + > + + + + + + + +
/images/background-mem.gif"> + Select a borrower +
+ +
+ +
+ + + + + + + + + +
/images/background-mem.gif"> + Enter borrower card number
or partial last name
+
+ + > + > +
+ + + + + + +
+ + + + +
+ + + + + + + +
/images/background-mem.gif"> + Enter Book Barcode +
+ + + + + + + + + +
Item Barcode:
+ + + + + + +
+ + + + + +
+ > Sticky Due Date +
+ > + > + > + + + + > + +
+
+
+
+



+ + + + + + + + + +
/images/background-mem.gif"> + + Todays Issues +
Due DateBar CodeTitleAuthorClass
+
+ + + + + + + + + + +
/images/background-mem.gif"> + + Previous Issues +
Due DateBar CodeTitleAuthorClass
+
+ -- 2.39.5