Lines 1219-1225
$filter->{fromDate} = '01/01/2013'; #Filters only serial issues by the serialite
Link Here
|
1219 |
$filter->{toDate} = '31/12/2014'; #Filters only serial issues by the serialitems.publisheddate |
1219 |
$filter->{toDate} = '31/12/2014'; #Filters only serial issues by the serialitems.publisheddate |
1220 |
#The ending date in C4::Context->preference('dateformat') format |
1220 |
#The ending date in C4::Context->preference('dateformat') format |
1221 |
$filter->{limit} = 15; #Limits the returning set to this many items |
1221 |
$filter->{limit} = 15; #Limits the returning set to this many items |
1222 |
|
1222 |
$filter->{itemnumber} = 165; #Returns the item with this itemnumber |
|
|
1223 |
|
1223 |
Filters are expected to be validated! If a filter is not defined, that filter is not present in the $filter-HASH |
1224 |
Filters are expected to be validated! If a filter is not defined, that filter is not present in the $filter-HASH |
1224 |
|
1225 |
|
1225 |
=cut |
1226 |
=cut |
Lines 1227-1246
Filters are expected to be validated! If a filter is not defined, that filter is
Link Here
|
1227 |
sub GetItemsInfo { |
1228 |
sub GetItemsInfo { |
1228 |
my ( $biblionumber, $filter ) = @_; |
1229 |
my ( $biblionumber, $filter ) = @_; |
1229 |
my $dbh = C4::Context->dbh; |
1230 |
my $dbh = C4::Context->dbh; |
1230 |
|
1231 |
|
1231 |
#Prepare the filter |
1232 |
#Prepare the filter |
1232 |
my $filterEnumchron = 0; |
1233 |
my $filterEnumchron = 0; |
1233 |
my $enumchronSQLRegexp; |
1234 |
my $enumchronSQLRegexp; |
1234 |
if (defined $filter && ref $filter eq 'HASH') { |
1235 |
if (defined $filter && ref $filter eq 'HASH') { |
1235 |
|
1236 |
|
1236 |
#Items enumchron can be filtered by volume or number or both. |
1237 |
#Items enumchron can be filtered by volume or number or both. |
1237 |
#Because the format of enumchron |
1238 |
#Because the format of enumchron |
1238 |
#For performance reasons regexp's need to be as simple as possible. |
1239 |
#For performance reasons regexp's need to be as simple as possible. |
1239 |
## It is entirely possible to search with just volume or just number or just issue. |
1240 |
## It is entirely possible to search with just volume or just number or just issue. |
1240 |
## We don't know which filters are used so it is safer and more efficient to just |
1241 |
## We don't know which filters are used so it is safer and more efficient to just |
1241 |
## prepare the enumeration parsing SQL every time. |
1242 |
## prepare the enumeration parsing SQL every time. |
1242 |
$enumchronSQLRegexp = C4::Context->preference('NumberingFormulaParsingRegexp'); |
1243 |
$enumchronSQLRegexp = C4::Context->preference('NumberingFormulaParsingRegexp'); |
1243 |
|
1244 |
|
1244 |
if (exists $filter->{volume}) { |
1245 |
if (exists $filter->{volume}) { |
1245 |
$filterEnumchron = 1; |
1246 |
$filterEnumchron = 1; |
1246 |
$enumchronSQLRegexp =~ s/volume/$filter->{volume}/; |
1247 |
$enumchronSQLRegexp =~ s/volume/$filter->{volume}/; |
Lines 1261-1274
sub GetItemsInfo {
Link Here
|
1261 |
} |
1262 |
} |
1262 |
else { |
1263 |
else { |
1263 |
$enumchronSQLRegexp =~ s/issue/[0-9]*/; |
1264 |
$enumchronSQLRegexp =~ s/issue/[0-9]*/; |
1264 |
} |
1265 |
} |
1265 |
} |
1266 |
} |
1266 |
#If we know that this item is a serial, we can better optimize our big SQL. |
1267 |
#If we know that this item is a serial, we can better optimize our big SQL. |
1267 |
# This is especially useful when we want to filter based on the publication date. |
1268 |
# This is especially useful when we want to filter based on the publication date. |
1268 |
# SELECTing a huge blob of serials just to remove unnecessary ones will be really sloooow. |
1269 |
# SELECTing a huge blob of serials just to remove unnecessary ones will be really sloooow. |
1269 |
my $search = C4::SQLHelper::SearchInTable("biblio",{biblionumber => $biblionumber}, undef, undef, ['serial'], undef, "exact"); |
1270 |
my $search = C4::SQLHelper::SearchInTable("biblio",{biblionumber => $biblionumber}, undef, undef, ['serial'], undef, "exact"); |
1270 |
my $serial = $search->[0]->{serial}; |
1271 |
my $serial = $search->[0]->{serial}; |
1271 |
|
1272 |
|
1272 |
# note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance. |
1273 |
# note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance. |
1273 |
#Because it is uncertain how many parameters the SQL query needs, we need to build the parameters dynamically |
1274 |
#Because it is uncertain how many parameters the SQL query needs, we need to build the parameters dynamically |
1274 |
# This is because we cannot predict what filters our users use. |
1275 |
# This is because we cannot predict what filters our users use. |
Lines 1294-1301
sub GetItemsInfo {
Link Here
|
1294 |
holding.branchname, |
1295 |
holding.branchname, |
1295 |
holding.opac_info as branch_opac_info "; |
1296 |
holding.opac_info as branch_opac_info "; |
1296 |
if ($serial) { |
1297 |
if ($serial) { |
1297 |
$query .= ", |
1298 |
$query .= ", |
1298 |
serial.serialseq, |
1299 |
serial.serialseq, |
1299 |
serial.publisheddate "; |
1300 |
serial.publisheddate "; |
1300 |
} |
1301 |
} |
1301 |
$query .= " |
1302 |
$query .= " |
Lines 1306-1320
sub GetItemsInfo {
Link Here
|
1306 |
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber |
1307 |
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber |
1307 |
LEFT JOIN itemtypes ON itemtypes.itemtype = " |
1308 |
LEFT JOIN itemtypes ON itemtypes.itemtype = " |
1308 |
. (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); |
1309 |
. (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); |
1309 |
|
1310 |
|
1310 |
if ($serial) { |
1311 |
if ($serial) { |
1311 |
$query .= " |
1312 |
$query .= " |
1312 |
LEFT JOIN serialitems ON serialitems.itemnumber = items.itemnumber |
1313 |
LEFT JOIN serialitems ON serialitems.itemnumber = items.itemnumber |
1313 |
LEFT JOIN serial ON serialitems.serialid = serial.serialid "; |
1314 |
LEFT JOIN serial ON serialitems.serialid = serial.serialid "; |
1314 |
} |
1315 |
} |
1315 |
|
1316 |
|
1316 |
$query .= " WHERE items.biblionumber = ? "; |
1317 |
$query .= " WHERE items.biblionumber = ? "; |
1317 |
|
1318 |
|
1318 |
if (exists $filter->{branch}) { |
1319 |
if (exists $filter->{branch}) { |
1319 |
$query .= " AND items.holdingbranch = ?"; |
1320 |
$query .= " AND items.holdingbranch = ?"; |
1320 |
push @$queryParams, $filter->{branch}; |
1321 |
push @$queryParams, $filter->{branch}; |
Lines 1341-1353
sub GetItemsInfo {
Link Here
|
1341 |
} |
1342 |
} |
1342 |
push @$queryParams, $filter->{toDate}; |
1343 |
push @$queryParams, $filter->{toDate}; |
1343 |
} |
1344 |
} |
1344 |
|
1345 |
if (exists $filter->{itemnumber}) { |
|
|
1346 |
push @$queryParams, $filter->{itemnumber}; |
1347 |
$query .= " AND items.itemnumber = ?"; |
1348 |
} |
1349 |
|
1350 |
|
1345 |
$query .= "ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; |
1351 |
$query .= "ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; |
1346 |
if (exists $filter->{limit}) { |
1352 |
if (exists $filter->{limit}) { |
1347 |
push @$queryParams, $filter->{limit}; |
1353 |
push @$queryParams, $filter->{limit}; |
1348 |
$query .= " LIMIT ?"; |
1354 |
$query .= " LIMIT ?"; |
1349 |
} |
1355 |
} |
1350 |
|
1356 |
|
1351 |
my $sth = $dbh->prepare($query); |
1357 |
my $sth = $dbh->prepare($query); |
1352 |
$sth->execute(@$queryParams); |
1358 |
$sth->execute(@$queryParams); |
1353 |
my $i = 0; |
1359 |
my $i = 0; |
Lines 1359-1365
sub GetItemsInfo {
Link Here
|
1359 |
WHERE itemnumber = ?" |
1365 |
WHERE itemnumber = ?" |
1360 |
); |
1366 |
); |
1361 |
|
1367 |
|
1362 |
|
1368 |
|
1363 |
while ( my $data = $sth->fetchrow_hashref ) { |
1369 |
while ( my $data = $sth->fetchrow_hashref ) { |
1364 |
my $datedue = ''; |
1370 |
my $datedue = ''; |
1365 |
$isth->execute( $data->{'itemnumber'} ); |
1371 |
$isth->execute( $data->{'itemnumber'} ); |
Lines 1372-1378
sub GetItemsInfo {
Link Here
|
1372 |
$datedue = $idata->{'date_due'}; |
1378 |
$datedue = $idata->{'date_due'}; |
1373 |
if (C4::Context->preference("IndependentBranches")){ |
1379 |
if (C4::Context->preference("IndependentBranches")){ |
1374 |
my $userenv = C4::Context->userenv; |
1380 |
my $userenv = C4::Context->userenv; |
1375 |
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { |
1381 |
if ( ($userenv) && ( $userenv->{flags} % 2 != 1 ) ) { |
1376 |
$data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch}); |
1382 |
$data->{'NOTSAMEBRANCH'} = 1 if ($idata->{'bcode'} ne $userenv->{branch}); |
1377 |
} |
1383 |
} |
1378 |
} |
1384 |
} |