Bug 5358: Show cancelled orders in basket page

Signed-off-by: Christophe Croullebois <christophe.croullebois@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
Julian Maurice 2011-11-05 15:05:48 +05:30 committed by Paul Poulain
parent d57da73c2f
commit 7a3f77de8c
3 changed files with 87 additions and 0 deletions

View File

@ -54,6 +54,7 @@ BEGIN {
&GetOrderNumber &GetLateOrders &GetOrderFromItemnumber
&SearchOrder &GetHistory &GetRecentAcqui
&ModReceiveOrder &ModOrderBiblioitemNumber
&GetCancelledOrders
&NewOrderItem &ModOrderItem
@ -1041,6 +1042,42 @@ sub ModOrderBiblioitemNumber {
$sth->execute( $biblioitemnumber, $ordernumber, $biblionumber );
}
=head3 GetCancelledOrders
my @orders = GetCancelledOrders($basketno, $orderby);
Returns cancelled orders for a basket
=cut
sub GetCancelledOrders {
my ( $basketno, $orderby ) = @_;
return () unless $basketno;
my $dbh = C4::Context->dbh;
my $query = "
SELECT biblio.*, biblioitems.*, aqorders.*, aqbudgets.*
FROM aqorders
LEFT JOIN aqbudgets ON aqbudgets.budget_id = aqorders.budget_id
LEFT JOIN biblio ON biblio.biblionumber = aqorders.biblionumber
LEFT JOIN biblioitems ON biblioitems.biblionumber = biblio.biblionumber
WHERE basketno = ?
AND (datecancellationprinted IS NOT NULL
AND datecancellationprinted <> '0000-00-00')
";
$orderby = "aqorders.datecancellationprinted desc, aqorders.timestamp desc"
unless $orderby;
$query .= " ORDER BY $orderby";
my $sth = $dbh->prepare($query);
$sth->execute($basketno);
my $results = $sth->fetchall_arrayref( {} );
return @$results;
}
#------------------------------------------------------------#
=head3 ModReceiveOrder

View File

@ -343,6 +343,11 @@ my $total_est_gste;
last;
}
my @cancelledorders = GetCancelledOrders($basketno);
foreach (@cancelledorders) {
$_->{'line_total'} = sprintf("%.2f", $_->{'ecost'} * $_->{'quantity'});
}
$template->param(
basketno => $basketno,
basketname => $basket->{'basketname'},
@ -359,6 +364,7 @@ my $total_est_gste;
name => $bookseller->{'name'},
entrydate => C4::Dates->new($results[0]->{'entrydate'},'iso')->output,
books_loop => \@books_loop,
cancelledorders_loop => \@cancelledorders,
gist_rate => sprintf( "%.2f", $gist * 100 ) . '%',
total_rrp_gste => sprintf( "%.2f", $total_rrp_gste ),
total_est_gste => sprintf( "%.2f", $total_est_gste ),

View File

@ -12,6 +12,7 @@
10: { sorter: false }
}
});
$("#cancelledorderst").tablesorter();
});
function confirm_close() {
var is_confirmed = confirm(_('Are you sure you want to close this basket?'));
@ -332,6 +333,49 @@
[% IF ( listincgst ) %]<small class="highlight">** Vendor's listings already include tax.</small>
[% END %]
</div>
[% IF (cancelledorders_loop) %]
<div id="cancelledorders">
<h2>Cancelled orders</h2>
<table id="cancelledorderst">
<thead>
<tr>
<th>Order</th>
<th>RRP</th>
<th>Est.</th>
<th>Qty.</th>
<th>Total</th>
<th>Fund</th>
</tr>
</thead>
<tbody>
[% FOREACH order IN cancelledorders_loop %]
<tr style="color:grey">
<td>
<p>
[% IF ( order.order_received ) %] (rcvd)[% END %]
[% IF (order.title) %]
[% order.title |html %] by [% order.author %]<br />
[% ELSE %]
<em>Deleted bibliographic record, can't find title</em><br />
[% END %]
[% IF ( order.notes ) %] [% order.notes %][% END %]
[% IF ( order.isbn ) %] - [% order.isbn %][% END %]
[% IF ( order.issn ) %] - [% order.issn %][% END %]
[% IF ( order.publishercode ) %], [% order.publishercode %][% END %]
[% IF ( order.publicationyear ) %], [% order.publicationyear %][% END %]
</p>
</td>
<td><p>[% order.rrp %]</p></td>
<td><p>[% order.ecost %]</p></td>
<td><p>[% order.quantity %]</p></td>
<td><p>[% order.line_total %]</p></td>
<td><p>[% order.budget_name %]</p></td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
<br />
[% UNLESS ( closedate ) %]
[% INCLUDE 'acquisitions-add-to-basket.inc' %]