[Patches] [PATCH] Bug 5358: Show cancelled orders in basket page

koha-patchbot at kohaaloha.com koha-patchbot at kohaaloha.com
Sat Nov 5 22:40:03 NZDT 2011


From: Julian Maurice <julian.maurice at biblibre.com>
Date: Sat, 5 Nov 2011 15:05:48 +0530
Subject: [PATCH] Bug 5358: Show cancelled orders in basket page

---
 C4/Acquisition.pm                                  |   37 +++++++++++
 acqui/basket.pl                                    |    6 ++
 .../intranet-tmpl/prog/en/modules/acqui/basket.tt  |   65 +++++++++++++++++--
 3 files changed, 101 insertions(+), 7 deletions(-)

diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm
index 19c4f08..3e6362b 100644
--- a/C4/Acquisition.pm
+++ b/C4/Acquisition.pm
@@ -54,6 +54,7 @@ BEGIN {
         &GetOrderNumber &GetLateOrders &GetOrderFromItemnumber
         &SearchOrder &GetHistory &GetRecentAcqui
         &ModReceiveOrder &ModOrderBiblioitemNumber
+        &GetCancelledOrders
 
         &NewOrderItem &ModOrderItem
 
@@ -1044,6 +1045,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
diff --git a/acqui/basket.pl b/acqui/basket.pl
index b836280..c528156 100755
--- a/acqui/basket.pl
+++ b/acqui/basket.pl
@@ -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 ),
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
index 90ddacb..f7d00ef 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt
@@ -12,6 +12,7 @@
                 10: { sorter: false }
             }
         });
+        $("#cancelledorderst").tablesorter();
     });
 //]]>
 </script>
@@ -228,13 +229,13 @@
                     <th> </th>
                     <th>[% qty_total %]</th>
                     <th>[% total_est_gste %]</th>
-                        [% IF ( active ) %]
-                            [% IF ( closedate ) %]
-                            <td colspan="1" rowspan="3"> </td>
-                            [% ELSE %]
-                            <td colspan="3" rowspan="3"> </td>
-                            [% END %]
-                        [% END %]
+                    [% IF ( active ) %]
+                      [% IF ( closedate ) %]
+                        <th colspan="1" rowspan="3"></th>
+                      [% ELSE %]
+                        <th colspan="3" rowspan="3"></th>
+                      [% END %]
+                    [% END %]
                 </tr>
                 <tr>
                     <th>Tax ([% gist_rate %])</th>
@@ -257,6 +258,13 @@
                     <th> </th>
                     <th>[% qty_total %]</th>
                     <th>[% total_est_gsti %]</th>
+                    [% IF ( active ) %]
+                      [% IF ( closedate ) %]
+                        <th colspan="1"></th>
+                      [% ELSE %]
+                        <th colspan="3"></th>
+                      [% END %]
+                    [% END %]
                 </tr>
                 [% END %]
                 </tfoot>
@@ -321,6 +329,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' %]
-- 
1.7.7.1




More information about the Patches mailing list