Bug 20366: Add subscription info to the acq tab on the biblio detail page
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 8 May 2018 16:31:55 +0000 (13:31 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 30 Aug 2018 13:48:09 +0000 (13:48 +0000)
On the "Acquisition details" tab of the bibliographic detail page, the
subscription information are missing.
This patch replace the call to GetHistory with Koha::Acquisition::Orders
in order to simplify the code and make use of new Koha::
packages/methods.

TODO: Add column settings (show/hide columns) to this table (?)

Sponsored-by: BULAC - http://www.bulac.fr/

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

catalogue/detail.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt

index 1c6b234..fe59fa1 100755 (executable)
@@ -20,7 +20,6 @@ use Modern::Perl;
 
 use CGI qw ( -utf8 );
 use HTML::Entities;
-use C4::Acquisition qw( GetHistory );
 use C4::Auth;
 use C4::Koha;
 use C4::Serials;    #uses getsubscriptionfrom biblionumber
@@ -180,7 +179,14 @@ foreach my $subscription (@subscriptions) {
 
 # Get acquisition details
 if ( C4::Context->preference('AcquisitionDetails') ) {
-    my $orders = C4::Acquisition::GetHistory( biblionumber => $biblionumber, get_canceled_order => 1 );
+    my $orders = Koha::Acquisition::Orders->search(
+        { biblionumber => $biblionumber },
+        {
+            join => 'basketno',
+            order_by => 'basketno.booksellerid'
+        }
+    );    # GetHistory sorted by aqbooksellerid, but does it make sense?
+
     $template->param(
         orders => $orders,
     );
index e4fd62b..b96aba5 100644 (file)
           <th class="title-string">Receive date</th>
           <th>Status</th>
           <th>Quantity</th>
+          <th>Subscription</th>
+          <th>Subscription callnumber</th>
         </tr>
       </thead>
       <tbody>
       [% FOR order IN orders %]
+        [% SET basket = order.basket %]
+        [% SET vendor = basket.bookseller %]
           <tr>
             <td>
-            [% IF (order.id) %]
-                <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% order.id | html %]" title="Vendor detail page">[% order.name | html %]</a>
-            [% END %]
+                <a href="/cgi-bin/koha/acqui/supplier.pl?booksellerid=[% vendor.id | uri %]" title="Vendor detail page">[% vendor.name | html %]</a>
             </td>
             <td>
-            [% IF (order.invoiceid) %]
+            [% IF order.invoiceid %]
                 [% IF CAN_user_acquisition %]
-                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid | html %]"
+                    <a href="/cgi-bin/koha/acqui/invoice.pl?invoiceid=[% order.invoiceid | uri %]"
                        title="Invoice detail page">
-                       [% order.invoicenumber | html %]</a>
+                       [% order.invoice.invoicenumber | hrml %]</a>
                 [% ELSE %]
-                    [% order.invoicenumber | html %]
+                    [% order.invoice.invoicenumber | html %]
                 [% END %]
             [% END %]
             </td>
             <td>
-            [% IF (order.basketgroupid) %]
+            [% IF basket.basketgroupid %]
+                [% SET basket_group = basket.basket_group %]
                 [% IF CAN_user_acquisition_group_manage %]
-                    <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% order.id | html %]&basketgroupid=[% order.basketgroupid | html %]">[% order.groupname | html %] ([% order.basketgroupid | html %])</a>
+                    <a href="/cgi-bin/koha/acqui/basketgroup.pl?op=add&booksellerid=[% vendor.id | uri %]&basketgroupid=[% basket_group.id | uri %]">[% basket_group.name | html%] ([% basket_group.id | html %])</a>
                 [% ELSE %]
-                    [% order.groupname | html %] ([% order.basketgroupid | html %])
+                    [% basket_group.name | html %] ([% basket_group.id | html %])
                 [% END %]
             [% END %]
             </td>
             <td>[% IF CAN_user_acquisition_order_manage %]
-                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% order.basketno | html %]">[% order.basketname | html %] ([% order.basketno | html %])</a>
+                <a href="/cgi-bin/koha/acqui/basket.pl?basketno=[% basket.basketno | uri %]">[% basket.basketname | html %] ([% basket.basketno | html %])</a>
             [% ELSE %]
-                [% order.basketname | html %] ([% order.basketno | html %])
+                [% basket.basketname | html %] ([% basket.basketno | html %])
             [% END %]</td>
             <td>[% order.ordernumber | html %]</td>
-            <td><span title="[% order.creationdate | html %]">[% order.creationdate | $KohaDates%]</span></td>
-            <td><span title="[% order.datereceived | html %]">[% order.datereceived | $KohaDates%]</span></td>
+            <td><span title="[% basket.creationdate | uri %]">[% basket.creationdate | $KohaDates%]</span></td>
+            <td><span title="[% order.datereceived | uri %]">[% order.datereceived | $KohaDates%]</span></td>
             <td>
               [% SWITCH order.orderstatus %]
                 [% CASE 'new' %]New
               [% END %]
             </td>
             <td>[% order.quantity | html %]</td>
+            <td>
+                [% IF order.subscriptionid %]
+                    <a href="g/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=[% order.subscriptionid | uri %]">[% order.subscriptionid | html %]</a>
+                [% END %]
+            </td>
+            <td>
+                [% IF order.subscriptionid %]
+                    [% order.subscription.callnumber | html %]
+                [% END %]
+            </td>
           </tr>
       [% END %]
       </tbody>