Bug 9573: Lost items report - Add items.notforloan as a filter
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 5 Oct 2017 16:02:58 +0000 (13:02 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Sat, 17 Feb 2018 21:32:13 +0000 (18:32 -0300)
This patch adds a new "Not for loan" status filter to the lost items
report.

Test plan:
0/ Apply all patches from this patch set
1/ Use the new "Not for loan" filter to search lost items
2/ The table result must be consistent and a new "Not for loan" column
should be there
3/ Confirm that you are able to hide/show this column with the column
settings tool.

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

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Koha/Template/Plugin/AuthorisedValues.pm
admin/columns_settings.yml
koha-tmpl/intranet-tmpl/prog/en/modules/reports/itemslost.tt
reports/itemslost.pl

index 7e0ef5d..2692c15 100644 (file)
@@ -68,6 +68,28 @@ sub GetCategories {
     ];
 }
 
+sub GetDescriptionsByKohaField {
+    my ( $self, $params ) = @_;
+    return Koha::AuthorisedValues->get_descriptions_by_koha_field(
+        { kohafield => $params->{kohafield} } );
+}
+
+sub GetDescriptionByKohaField {
+    my ( $self, $params ) = @_;
+    my $av = Koha::AuthorisedValues->get_description_by_koha_field(
+        {
+            kohafield        => $params->{kohafield},
+            authorised_value => $params->{authorised_value},
+        }
+    );
+    return %$av
+            ? $params->{opac}
+                ? $av->{opac_description}
+                : $av->{lib}
+            : ''; # Maybe we should return $params->{authorised_value}?
+
+}
+
 1;
 
 =head1 NAME
@@ -93,6 +115,14 @@ the following TT code: [% AuthorisedValues.GetByCode( 'CATEGORY', 'AUTHORISED_VA
 
 The parameters are identical to those used by the subroutine C4::Koha::GetAuthValueDropbox
 
+=head2 GetDescriptionsByKohaField
+
+The parameters are identical to those used by the subroutine Koha::AuthorisedValues->get_descriptions_by_koha_field
+
+=head2 GetDescriptionByKohaField
+
+The parameters are identical to those used by the subroutine Koha::AuthorisedValues->get_description_by_koha_field
+
 =head1 AUTHOR
 
 Kyle M Hall <kyle@bywatersolutions.com>
index 61fa864..7011052 100644 (file)
@@ -310,6 +310,8 @@ modules:
         -
           columnname: location
         -
+          columnname: notforloan
+        -
           columnname: notes
 
   circ:
index 0651231..b88ead7 100644 (file)
@@ -49,6 +49,7 @@
                     <th>Item type</th>
                     <th>Current location</th>
                     <th>Location</th>
+                    <th>Not for loan status</th>
                     <th>Notes</th>
                 </tr>
             </thead>
@@ -59,7 +60,7 @@
                             <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item.biblionumber %]" title="[% item.itemnotes %]">[% item.biblio.title |html %]</a>
                         </td>
                         <td>[% item.biblio.author %]</td>
-                        <td>[% AuthorisedValues.GetByCode( 'LOST', item.itemlost ) %]</td>
+                        <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.itemlost', authorised_value => item.itemlost ) %]
                         <td>
                             <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% item.biblionumber %]" title="[% item.itemnotes %]">[% item.barcode %]</a>
                         </td>
@@ -71,6 +72,7 @@
                         <td>[% item.effective_itemtype %]</td>
                         <td>[% Branches.GetName(item.holdingbranch) %]</td>
                         <td>[% item.location %]</td>
+                        <td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.notforloan', authorised_value => item.notforloan ) %]
                         <td>[% item.itemnotes %]</td>
                     </tr>
                 [% END %]
                 [% END %]
             </select></li>
 
-    <li><label for="loststatusfilter">Lost status: </label><select name="loststatusfilter" id="loststatusfilter">
-                <option value="">All</option>
-                [% FOREACH loststatusloo IN loststatusloop %]
-                [% IF ( loststatusloo.selected ) %]<option value="[% loststatusloo.authorised_value %]" selected="selected">[% loststatusloo.lib %]</option>
-               [% ELSE %]
-               <option value="[% loststatusloo.authorised_value %]">[% loststatusloo.lib %]</option>
-               [% END %]
+    <li>
+        <label for="loststatusfilter">Lost status: </label>
+        <select name="loststatusfilter" id="loststatusfilter">
+            <option value="">All</option>
+            [% FOREACH l IN AuthorisedValues.GetDescriptionsByKohaField( kohafield => 'items.itemlost') %]
+                [% IF l.authorised_value == lostfilter %]
+                    <option value="[% l.authorised_value %]" selected="selected">[% l.lib %]</option>
+                [% ELSE %]
+                    <option value="[% l.authorised_value %]">[% l.lib %]</option>
                 [% END %]
-            </select></li>
+            [% END %]
+        </select>
+    </li>
+
+    <li>
+        <label for="notforloanfilter">Not for loan: </label>
+        <select name="notforloanfilter" id="notforloanfilter">
+            <option value="">All</option>
+            [% FOREACH n IN AuthorisedValues.GetDescriptionsByKohaField( kohafield => 'items.notforloan') %]
+                [% IF n.authorised_value == notforloanfilter %]
+                    <option value="[% n.authorised_value %]" selected="selected">[% n.lib %]</option>
+                [% ELSE %]
+                    <option value="[% n.authorised_value %]">[% n.lib %]</option>
+                [% END %]
+            [% END %]
+        </select>
+    </li>
+
 </ol></fieldset>
 <fieldset class="action">    <input type="submit" value="Submit" />
     <input type="hidden" name="get_items" value="1" /></fieldset>
index 6ca5a78..fad09a4 100755 (executable)
@@ -32,6 +32,8 @@ use C4::Auth;
 use C4::Output;
 use C4::Biblio;
 use C4::Items;
+
+use Koha::AuthorisedValues;
 use Koha::DateUtils;
 
 my $query = new CGI;
@@ -54,6 +56,7 @@ if ($get_items) {
     my $barcodefilter    = $params->{'barcodefilter'}    || undef;
     my $itemtypesfilter  = $params->{'itemtypesfilter'}  || undef;
     my $loststatusfilter = $params->{'loststatusfilter'} || undef;
+    my $notforloanfilter = $params->{'notforloanfilter'} || undef;
 
     my $params = {
         ( $branchfilter ? ( homebranch => $branchfilter ) : () ),
@@ -62,6 +65,11 @@ if ($get_items) {
             ? ( itemlost => $loststatusfilter )
             : ( itemlost => { '!=' => 0 } )
         ),
+        (
+            $notforloanfilter
+            ? ( notforloan => $notforloanfilter )
+            : ()
+        ),
         ( $barcodefilter ? ( barcode => { like => "%$barcodefilter%" } ) : () ),
     };
 
@@ -88,12 +96,8 @@ if ($get_items) {
 # getting all itemtypes
 my $itemtypes = Koha::ItemTypes->search_with_localization;
 
-# get lost statuses
-my $lost_status_loop = C4::Koha::GetAuthorisedValues( 'LOST' );
-
 $template->param(
-                  itemtypes => $itemtypes,
-                  loststatusloop => $lost_status_loop,
+    itemtypes => $itemtypes,
 );
 
 # writing the template