Lines 56-82
my $branch = $input->param('branch');
Link Here
|
56 |
my $itemtype = $input->param('itemtype'); |
56 |
my $itemtype = $input->param('itemtype'); |
57 |
my $timeLimit = $input->param('timeLimit') || 3; |
57 |
my $timeLimit = $input->param('timeLimit') || 3; |
58 |
my $whereclause; |
58 |
my $whereclause; |
59 |
$whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch); |
59 |
$whereclause .= ' AND items.homebranch='.$dbh->quote($branch) if ($branch); |
60 |
$whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype; |
60 |
$whereclause .= ' AND TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30) if $timeLimit < 999; |
61 |
$whereclause .= ' TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30).' AND ' if $timeLimit < 999; |
|
|
62 |
$whereclause =~ s/ AND $//; |
61 |
$whereclause =~ s/ AND $//; |
63 |
$whereclause = " WHERE ".$whereclause if $whereclause; |
62 |
my $query; |
64 |
|
63 |
if(C4::Context->preference('AdvancedSearchTypes') eq 'ccode'){ |
65 |
my $query = "SELECT datecreated, biblio.biblionumber, title, |
64 |
$whereclause .= ' AND authorised_values.authorised_value='.$dbh->quote($itemtype) if $itemtype; |
66 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
65 |
$query = "SELECT datecreated, biblio.biblionumber, title, |
67 |
biblioitems.publishercode,biblioitems.publicationyear, |
66 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
68 |
itemtypes.description |
67 |
biblioitems.publishercode,biblioitems.publicationyear, |
69 |
FROM biblio |
68 |
authorised_values.lib as description |
70 |
LEFT JOIN items USING (biblionumber) |
69 |
FROM biblio |
71 |
LEFT JOIN biblioitems USING (biblionumber) |
70 |
LEFT JOIN items USING (biblionumber) |
72 |
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype |
71 |
LEFT JOIN biblioitems USING (biblionumber) |
73 |
$whereclause |
72 |
LEFT JOIN authorised_values ON items.ccode = authorised_values.authorised_value |
74 |
GROUP BY biblio.biblionumber |
73 |
WHERE 1 |
75 |
HAVING tot >0 |
74 |
$whereclause |
76 |
ORDER BY tot DESC |
75 |
AND authorised_values.category = 'ccode' |
77 |
LIMIT $limit |
76 |
GROUP BY biblio.biblionumber |
78 |
"; |
77 |
HAVING tot >0 |
79 |
|
78 |
ORDER BY tot DESC |
|
|
79 |
LIMIT $limit |
80 |
"; |
81 |
}else{ |
82 |
$whereclause .= ' AND biblioitems.itemtype='.$dbh->quote($itemtype) if $itemtype; |
83 |
$query = "SELECT datecreated, biblio.biblionumber, title, |
84 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
85 |
biblioitems.publishercode,biblioitems.publicationyear, |
86 |
itemtypes.description |
87 |
FROM biblio |
88 |
LEFT JOIN items USING (biblionumber) |
89 |
LEFT JOIN biblioitems USING (biblionumber) |
90 |
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype |
91 |
WHERE 1 |
92 |
$whereclause |
93 |
GROUP BY biblio.biblionumber |
94 |
HAVING tot >0 |
95 |
ORDER BY tot DESC |
96 |
LIMIT $limit |
97 |
"; |
98 |
} |
80 |
my $sth = $dbh->prepare($query); |
99 |
my $sth = $dbh->prepare($query); |
81 |
$sth->execute(); |
100 |
$sth->execute(); |
82 |
my @results; |
101 |
my @results; |
83 |
- |
|
|