+ if ( $record_type eq 'bibs' or $record_type eq 'auths' ) {
+ # No need to retrieve the record_ids if we already get them
+ unless ( @record_ids ) {
+ if ( $record_type eq 'bibs' ) {
+ my $starting_biblionumber = $query->param("StartingBiblionumber");
+ my $ending_biblionumber = $query->param("EndingBiblionumber");
+ my $itemtype = $query->param("itemtype");
+ my $start_callnumber = $query->param("start_callnumber");
+ my $end_callnumber = $query->param("end_callnumber");
+ my $start_accession =
+ ( $query->param("start_accession") )
+ ? dt_from_string( scalar $query->param("start_accession") )
+ : '';
+ my $end_accession =
+ ( $query->param("end_accession") )
+ ? dt_from_string( scalar $query->param("end_accession") )
+ : '';
+
+
+ my $conditions = {
+ ( $starting_biblionumber or $ending_biblionumber )
+ ? (
+ "me.biblionumber" => {
+ ( $starting_biblionumber ? ( '>=' => $starting_biblionumber ) : () ),
+ ( $ending_biblionumber ? ( '<=' => $ending_biblionumber ) : () ),
+ }
+ )
+ : (),
+
+ ( $start_callnumber or $end_callnumber )
+ ? (
+ 'items.itemcallnumber' => {
+ ( $start_callnumber ? ( '>=' => $start_callnumber ) : () ),
+ ( $end_callnumber ? ( '<=' => $end_callnumber ) : () ),
+ }
+ )
+ : (),
+
+ ( $start_accession or $end_accession )
+ ? (
+ 'items.dateaccessioned' => {
+ ( $start_accession ? ( '>=' => $start_accession ) : () ),
+ ( $end_accession ? ( '<=' => $end_accession ) : () ),
+ }
+ )
+ : (),
+ ( @branchcodes ? ( 'items.homebranch' => { in => \@branchcodes } ) : () ),
+ ( $itemtype
+ ?
+ C4::Context->preference('item-level_itypes')
+ ? ( 'items.itype' => $itemtype )
+ : ( 'me.itemtype' => $itemtype )
+ : ()
+ ),
+
+ };
+ my $biblioitems = Koha::Biblioitems->search( $conditions, { join => 'items', columns => 'biblionumber' } );
+ while ( my $biblioitem = $biblioitems->next ) {
+ push @record_ids, $biblioitem->biblionumber;
+ }
+ }
+ elsif ( $record_type eq 'auths' ) {
+ my $starting_authid = $query->param('starting_authid');
+ my $ending_authid = $query->param('ending_authid');
+ my $authtype = $query->param('authtype');
+
+ my $conditions = {
+ ( $starting_authid or $ending_authid )
+ ? (
+ authid => {
+ ( $starting_authid ? ( '>=' => $starting_authid ) : () ),
+ ( $ending_authid ? ( '<=' => $ending_authid ) : () ),
+ }
+ )
+ : (),
+ ( $authtype ? ( authtypecode => $authtype ) : () ),
+ };
+ # Koha::MetadataRecord::Authority is not a Koha::Object...
+ my $authorities = Koha::Database->new->schema->resultset('AuthHeader')->search( $conditions );
+ @record_ids = map { $_->authid } $authorities->all;
+ }