Lines 2285-2379
sub searchResults {
Link Here
|
2285 |
return @newresults; |
2285 |
return @newresults; |
2286 |
} |
2286 |
} |
2287 |
|
2287 |
|
2288 |
=head2 SearchAcquisitions |
|
|
2289 |
Search for acquisitions |
2290 |
=cut |
2291 |
|
2292 |
sub SearchAcquisitions{ |
2293 |
my ($datebegin, $dateend, $itemtypes,$criteria, $orderby) = @_; |
2294 |
|
2295 |
my $dbh=C4::Context->dbh; |
2296 |
# Variable initialization |
2297 |
my $str=qq| |
2298 |
SELECT marcxml |
2299 |
FROM biblio |
2300 |
LEFT JOIN biblioitems ON biblioitems.biblionumber=biblio.biblionumber |
2301 |
LEFT JOIN items ON items.biblionumber=biblio.biblionumber |
2302 |
WHERE dateaccessioned BETWEEN ? AND ? |
2303 |
|; |
2304 |
|
2305 |
my (@params,@loopcriteria); |
2306 |
|
2307 |
push @params, $datebegin->output("iso"); |
2308 |
push @params, $dateend->output("iso"); |
2309 |
|
2310 |
if (scalar(@$itemtypes)>0 and $criteria ne "itemtype" ){ |
2311 |
if(C4::Context->preference("item-level_itypes")){ |
2312 |
$str .= "AND items.itype IN (?".( ',?' x scalar @$itemtypes - 1 ).") "; |
2313 |
}else{ |
2314 |
$str .= "AND biblioitems.itemtype IN (?".( ',?' x scalar @$itemtypes - 1 ).") "; |
2315 |
} |
2316 |
push @params, @$itemtypes; |
2317 |
} |
2318 |
|
2319 |
if ($criteria =~/itemtype/){ |
2320 |
if(C4::Context->preference("item-level_itypes")){ |
2321 |
$str .= "AND items.itype=? "; |
2322 |
}else{ |
2323 |
$str .= "AND biblioitems.itemtype=? "; |
2324 |
} |
2325 |
|
2326 |
if(scalar(@$itemtypes) == 0){ |
2327 |
my $itypes = GetItemTypes(); |
2328 |
for my $key (keys %$itypes){ |
2329 |
push @$itemtypes, $key; |
2330 |
} |
2331 |
} |
2332 |
|
2333 |
@loopcriteria= @$itemtypes; |
2334 |
}elsif ($criteria=~/itemcallnumber/){ |
2335 |
$str .= "AND (items.itemcallnumber LIKE CONCAT(?,'%') |
2336 |
OR items.itemcallnumber is NULL |
2337 |
OR items.itemcallnumber = '')"; |
2338 |
|
2339 |
@loopcriteria = ("AA".."ZZ", "") unless (scalar(@loopcriteria)>0); |
2340 |
}else { |
2341 |
$str .= "AND biblio.title LIKE CONCAT(?,'%') "; |
2342 |
@loopcriteria = ("A".."z") unless (scalar(@loopcriteria)>0); |
2343 |
} |
2344 |
|
2345 |
if ($orderby =~ /date_desc/){ |
2346 |
$str.=" ORDER BY dateaccessioned DESC"; |
2347 |
} else { |
2348 |
$str.=" ORDER BY title"; |
2349 |
} |
2350 |
|
2351 |
my $qdataacquisitions=$dbh->prepare($str); |
2352 |
|
2353 |
my @loopacquisitions; |
2354 |
foreach my $value(@loopcriteria){ |
2355 |
push @params,$value; |
2356 |
my %cell; |
2357 |
$cell{"title"}=$value; |
2358 |
$cell{"titlecode"}=$value; |
2359 |
|
2360 |
eval{$qdataacquisitions->execute(@params);}; |
2361 |
|
2362 |
if ($@){ warn "recentacquisitions Error :$@";} |
2363 |
else { |
2364 |
my @loopdata; |
2365 |
while (my $data=$qdataacquisitions->fetchrow_hashref){ |
2366 |
push @loopdata, {"summary"=>GetBiblioSummary( $data->{'marcxml'} ) }; |
2367 |
} |
2368 |
$cell{"loopdata"}=\@loopdata; |
2369 |
} |
2370 |
push @loopacquisitions,\%cell if (scalar(@{$cell{loopdata}})>0); |
2371 |
pop @params; |
2372 |
} |
2373 |
$qdataacquisitions->finish; |
2374 |
return \@loopacquisitions; |
2375 |
} |
2376 |
|
2377 |
=head2 enabled_staff_search_views |
2288 |
=head2 enabled_staff_search_views |
2378 |
|
2289 |
|
2379 |
%hash = enabled_staff_search_views() |
2290 |
%hash = enabled_staff_search_views() |
2380 |
- |
|
|