[3.0.x](bug #3560) This add a filter to search by itemtype
authorJean-André Santoni <jeanandre.santoni@biblibre.com>
Thu, 27 Aug 2009 11:16:01 +0000 (13:16 +0200)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 16 Sep 2009 21:19:31 +0000 (23:19 +0200)
The value builder for 4XX should be able to filter results by itemtype.

Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
cataloguing/value_builder/unimarc_field_4XX.pl
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/value_builder/unimarc_field_4XX.tmpl

index a55ceef..195fb5c 100755 (executable)
@@ -31,6 +31,7 @@ use C4::Biblio;
 use C4::Koha;
 use MARC::Record;
 use C4::Branch;    # GetBranches
+use C4::ItemType;
 
 sub plugin_parameters {
     my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
@@ -327,9 +328,11 @@ sub plugin {
     }
     elsif ( $op eq "do_search" ) {
         my $search         = $query->param('search');
+        my $itype          = $query->param('itype');
         my $startfrom      = $query->param('startfrom');
         my $resultsperpage = $query->param('resultsperpage') || 20;
         my $orderby;
+        $search = 'kw,wrdl='.$search.' and mc-itemtype='.$itype if $itype;
         my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
         my $total = scalar(@$results);
 
@@ -530,10 +533,13 @@ sub plugin {
 #         }
 #         $sth->finish;
 
+        my @itemtypes = C4::ItemType->all;
+
         $template->param(    #classlist => $classlist,
             CGIitemtype  => $CGIitemtype,
             CGIbranch    => $CGIbranch,
             CGIPublisher => $CGIpublisher,
+            itypeloop    => \@itemtypes,
             index        => $query->param('index'),
             Search       => 1,
         );
index cbcb961..253e8a3 100644 (file)
                                <input type="hidden" name="result" value="unimarc field 4 <!--TMPL_VAR Name="index" -->">
                                <input type="hidden" name="op" value="do_search">
                                <label class="label100" for="searchbox">Any word</label>
-                               <input type="text" name="search" id="searchbox" size="35">
+                               <input type="text" name="search" id="searchbox" size="35"><br />
+                               <label for="itypeloop">Item type:</label>
+                               <select name="itype">
+                               <option value="">All Item Types</option>
+                               <!-- TMPL_LOOP NAME="itypeloop" -->
+                               <!-- TMPL_IF NAME="selected" -->
+                               <option value="<!-- TMPL_VAR NAME="itemtype" -->" selected="selected"><!-- TMPL_VAR NAME="description" --></option>
+                               <!-- TMPL_ELSE -->
+                               <option value="<!-- TMPL_VAR NAME="itemtype" -->"><!-- TMPL_VAR NAME="description" --></option>
+                               <!-- /TMPL_IF -->
+                               <!-- /TMPL_LOOP -->
+                               </select>
                        </p>
                        <p>
                                <input type="submit" value="Start search">