(MT #2920) fix reading record scripts
This patch fix some perl ugly code to be more readable and lesser complex. And it allow in intranet to order by issues.timestamp. Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
parent
576e544d02
commit
c5c83ed8d7
4 changed files with 61 additions and 37 deletions
|
@ -1040,16 +1040,15 @@ sub GetAllIssues {
|
|||
|
||||
#FIXME: sanity-check order and limit
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $count = 0;
|
||||
my $query =
|
||||
"SELECT *,issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
|
||||
"SELECT *, issues.timestamp as issuestimestamp, issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
|
||||
FROM issues
|
||||
LEFT JOIN items on items.itemnumber=issues.itemnumber
|
||||
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
|
||||
LEFT JOIN biblioitems ON items.biblioitemnumber=biblioitems.biblioitemnumber
|
||||
WHERE borrowernumber=?
|
||||
UNION ALL
|
||||
SELECT *,old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
|
||||
SELECT *, old_issues.timestamp as issuestimestamp, old_issues.renewals AS renewals,items.renewals AS totalrenewals,items.timestamp AS itemstimestamp
|
||||
FROM old_issues
|
||||
LEFT JOIN items on items.itemnumber=old_issues.itemnumber
|
||||
LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber
|
||||
|
@ -1066,9 +1065,7 @@ sub GetAllIssues {
|
|||
my @result;
|
||||
my $i = 0;
|
||||
while ( my $data = $sth->fetchrow_hashref ) {
|
||||
$result[$i] = $data;
|
||||
$i++;
|
||||
$count++;
|
||||
push @result, $data;
|
||||
}
|
||||
|
||||
# get all issued items for borrowernumber from oldissues table
|
||||
|
@ -1086,7 +1083,7 @@ sub GetAllIssues {
|
|||
WHERE borrowernumber=?
|
||||
ORDER BY $order";
|
||||
if ( $limit != 0 ) {
|
||||
$limit = $limit - $count;
|
||||
$limit = $limit - scalar(@result);
|
||||
$query2 .= " limit $limit";
|
||||
}
|
||||
|
||||
|
@ -1094,12 +1091,11 @@ sub GetAllIssues {
|
|||
$sth2->execute($borrowernumber);
|
||||
|
||||
while ( my $data2 = $sth2->fetchrow_hashref ) {
|
||||
$result[$i] = $data2;
|
||||
$i++;
|
||||
push @result, $data2;
|
||||
}
|
||||
}
|
||||
|
||||
return ( $i, \@result );
|
||||
return \@result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&limit=full">Show All Items</a><!-- /TMPL_IF --></p>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&order=issuestimestamp&limit=<!-- TMPL_VAR name="limit" -->">Date</a>
|
||||
</th>
|
||||
<th>
|
||||
<a href="readingrec.pl?borrowernumber=<!-- TMPL_VAR name="borrowernumber" -->&order=title&limit=<!-- TMPL_VAR name="limit" -->">Title</a>
|
||||
</th>
|
||||
|
@ -42,21 +45,20 @@
|
|||
<!-- TMPL_ELSE -->
|
||||
<!-- TMPL_IF NAME="returndate" --><tr><!-- TMPL_ELSE --><tr class="onissue"><!-- /TMPL_IF -->
|
||||
<!-- /TMPL_UNLESS -->
|
||||
|
||||
<td>
|
||||
<td>
|
||||
<!-- TMPL_VAR name="issuestimestamp" -->
|
||||
</td>
|
||||
<td>
|
||||
<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">
|
||||
<!-- TMPL_VAR name="title" escape="html" -->
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<!-- TMPL_VAR name="author" --></td>
|
||||
<td><!-- TMPL_VAR name="author" --></td>
|
||||
|
||||
<td>
|
||||
<!-- TMPL_VAR NAME="classification" --></td>
|
||||
<td><!-- TMPL_VAR NAME="classification" --></td>
|
||||
|
||||
<td>
|
||||
<!-- TMPL_VAR NAME="barcode" --></td>
|
||||
<td><!-- TMPL_VAR NAME="barcode" --></td>
|
||||
|
||||
<td>
|
||||
<!-- TMPL_VAR NAME="renewals" --></td>
|
||||
|
|
|
@ -29,6 +29,8 @@ use C4::Auth;
|
|||
use C4::Output;
|
||||
use C4::Members;
|
||||
use C4::Branch;
|
||||
use List::MoreUtils qw/any/;
|
||||
|
||||
use C4::Dates qw/format_date/;
|
||||
|
||||
my $input = CGI->new;
|
||||
|
@ -54,6 +56,17 @@ if ($order2 eq ''){
|
|||
$order2="date_due desc";
|
||||
}
|
||||
my $limit=$input->param('limit');
|
||||
=======
|
||||
my $borrowernumber = $input->param('borrowernumber');
|
||||
my $limit = $input->param('limit');
|
||||
my $order = $input->param('order') || '';
|
||||
|
||||
$order = "issuestimestamp desc" if not any { $order =~ $_ } ('issuestimestamp', 'title', 'author', 'returndate');
|
||||
|
||||
#get borrower details
|
||||
my $data=GetMember('borrowernumber'=>$borrowernumber);
|
||||
|
||||
>>>>>>> (MT #2920) fix reading record scripts:members/readingrec.pl
|
||||
|
||||
if ($limit){
|
||||
if ($limit eq 'full'){
|
||||
|
@ -63,7 +76,7 @@ if ($limit){
|
|||
else {
|
||||
$limit=50;
|
||||
}
|
||||
my ($count,$issues)=GetAllIssues($borrowernumber,$order2,$limit);
|
||||
my ( $issues ) = GetAllIssues($borrowernumber,$order,$limit);
|
||||
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "members/readingrec.tmpl",
|
||||
|
@ -76,18 +89,19 @@ my ($template, $loggedinuser, $cookie)
|
|||
|
||||
my @loop_reading;
|
||||
|
||||
for (my $i=0;$i<$count;$i++){
|
||||
foreach my $issue (@{$issues}){
|
||||
my %line;
|
||||
$line{biblionumber}=$issues->[$i]->{'biblionumber'};
|
||||
$line{title}=$issues->[$i]->{'title'};
|
||||
$line{author}=$issues->[$i]->{'author'};
|
||||
$line{classification} = $issues->[$i]->{'classification'} || $issues->[$i]->{'itemcallnumber'};
|
||||
$line{date_due}=format_date($issues->[$i]->{'date_due'});
|
||||
$line{returndate}=format_date($issues->[$i]->{'returndate'});
|
||||
$line{issuedate}=format_date($issues->[$i]->{'issuedate'});
|
||||
$line{renewals}=$issues->[$i]->{'renewals'};
|
||||
$line{barcode}=$issues->[$i]->{'barcode'};
|
||||
$line{volumeddesc}=$issues->[$i]->{'volumeddesc'};
|
||||
$line{issuestimestamp} = format_date($issue->{'issuestimestamp'});
|
||||
$line{biblionumber} = $issue->{'biblionumber'};
|
||||
$line{title} = $issue->{'title'};
|
||||
$line{author} = $issue->{'author'};
|
||||
$line{classification} = $issue->{'classification'} || $issue->{'itemcallnumber'};
|
||||
$line{date_due} = format_date($issue->{'date_due'});
|
||||
$line{returndate} = format_date($issue->{'returndate'});
|
||||
$line{issuedate} = format_date($issue->{'issuedate'});
|
||||
$line{renewals} = $issue->{'renewals'};
|
||||
$line{barcode} = $issue->{'barcode'};
|
||||
$line{volumeddesc} = $issue->{'volumeddesc'};
|
||||
push(@loop_reading,\%line);
|
||||
}
|
||||
|
||||
|
@ -130,7 +144,7 @@ $template->param(
|
|||
branchcode => $data->{'branchcode'},
|
||||
is_child => ($data->{'category_type'} eq 'C'),
|
||||
branchname => GetBranchName($data->{'branchcode'}),
|
||||
showfulllink => ($count > 50),
|
||||
showfulllink => (scalar @loop_reading > 50),
|
||||
loop_reading => \@loop_reading);
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ else {
|
|||
$limit = 50;
|
||||
}
|
||||
|
||||
my ( $count, $issues ) = GetAllIssues( $borrowernumber, $order, $limit );
|
||||
my ( $issues ) = GetAllIssues( $borrowernumber, $order, $limit );
|
||||
|
||||
my @bordat;
|
||||
$bordat[0] = $borr;
|
||||
|
@ -80,14 +80,15 @@ $template->param( BORROWER_INFO => \@bordat );
|
|||
|
||||
my @loop_reading;
|
||||
|
||||
for ( my $i = 0 ; $i < $count ; $i++ ) {
|
||||
foreach my $issue (@{$issues} ) {
|
||||
my %line;
|
||||
|
||||
my $record = GetMarcBiblio($issues->[$i]->{'biblionumber'});
|
||||
|
||||
# XISBN Stuff
|
||||
my $isbn = GetNormalizedISBN($issues->[$i]->{'isbn'});
|
||||
my $isbn = GetNormalizedISBN($issue->{'isbn'});
|
||||
$line{normalized_isbn} = $isbn;
|
||||
<<<<<<< HEAD:opac/opac-readingrecord.pl
|
||||
$line{biblionumber} = $issues->[$i]->{'biblionumber'};
|
||||
$line{title} = $issues->[$i]->{'title'};
|
||||
$line{author} = $issues->[$i]->{'author'};
|
||||
|
@ -100,6 +101,17 @@ for ( my $i = 0 ; $i < $count ; $i++ ) {
|
|||
$line{'itypedescription'} = $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'description'};
|
||||
$line{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'imageurl'} );
|
||||
}
|
||||
=======
|
||||
$line{biblionumber} = $issue->{'biblionumber'};
|
||||
$line{title} = $issue->{'title'};
|
||||
$line{author} = $issue->{'author'};
|
||||
$line{itemcallnumber} = $issue->{'itemcallnumber'};
|
||||
$line{date_due} = format_date( $issue->{'date_due'} );
|
||||
$line{returndate} = format_date( $issue->{'returndate'} );
|
||||
$line{volumeddesc} = $issue->{'volumeddesc'};
|
||||
$line{'description'} = $itemtypes->{ $issue->{'itemtype'} }->{'description'};
|
||||
$line{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $issue->{'itemtype'} }->{'imageurl'} );
|
||||
>>>>>>> (MT #2920) fix reading record scripts:opac/opac-readingrecord.pl
|
||||
push( @loop_reading, \%line );
|
||||
$line{subtitle} = GetRecordValue('subtitle', $record, GetFrameworkCode($issues->[$i]->{'biblionumber'}));
|
||||
}
|
||||
|
@ -128,11 +140,11 @@ for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
|
|||
}
|
||||
|
||||
$template->param(
|
||||
count => $count,
|
||||
READING_RECORD => \@loop_reading,
|
||||
limit => $limit,
|
||||
showfulllink => 1,
|
||||
readingrecview => 1
|
||||
readingrecview => 1,
|
||||
count => scalar @loop_reading,
|
||||
);
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
|
|
Loading…
Reference in a new issue