Lines 25-30
use warnings;
Link Here
|
25 |
use CGI qw ( -utf8 ); |
25 |
use CGI qw ( -utf8 ); |
26 |
use C4::Auth; |
26 |
use C4::Auth; |
27 |
use C4::Context; |
27 |
use C4::Context; |
|
|
28 |
use C4::Languages; |
28 |
use C4::Search; |
29 |
use C4::Search; |
29 |
use C4::Output; |
30 |
use C4::Output; |
30 |
use C4::Koha; |
31 |
use C4::Koha; |
Lines 77-87
my $whereclause = '';
Link Here
|
77 |
$whereclause .= ' AND items.homebranch='.$dbh->quote($branch) if ($branch); |
78 |
$whereclause .= ' AND items.homebranch='.$dbh->quote($branch) if ($branch); |
78 |
$whereclause .= ' AND TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30) if $timeLimit < 999; |
79 |
$whereclause .= ' AND TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30) if $timeLimit < 999; |
79 |
$whereclause =~ s/ AND $// if $whereclause; |
80 |
$whereclause =~ s/ AND $// if $whereclause; |
80 |
my $query; |
81 |
my $sth; |
81 |
|
|
|
82 |
if($advanced_search_types eq 'ccode'){ |
82 |
if($advanced_search_types eq 'ccode'){ |
83 |
$whereclause .= ' AND authorised_values.authorised_value='.$dbh->quote($itemtype) if $itemtype; |
83 |
$whereclause .= ' AND authorised_values.authorised_value='.$dbh->quote($itemtype) if $itemtype; |
84 |
$query = "SELECT datecreated, biblio.biblionumber, title, |
84 |
my $query = "SELECT datecreated, biblio.biblionumber, title, |
85 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
85 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
86 |
biblioitems.publishercode, biblioitems.place, biblioitems.publicationyear, biblio.copyrightdate, |
86 |
biblioitems.publishercode, biblioitems.place, biblioitems.publicationyear, biblio.copyrightdate, |
87 |
authorised_values.lib as description, biblioitems.pages, biblioitems.size |
87 |
authorised_values.lib as description, biblioitems.pages, biblioitems.size |
Lines 98-103
if($advanced_search_types eq 'ccode'){
Link Here
|
98 |
LIMIT ? |
98 |
LIMIT ? |
99 |
"; |
99 |
"; |
100 |
$template->param(ccodesearch => 1); |
100 |
$template->param(ccodesearch => 1); |
|
|
101 |
$sth = $dbh->prepare($query); |
102 |
$sth->execute($limit); |
101 |
}else{ |
103 |
}else{ |
102 |
if ($itemtype){ |
104 |
if ($itemtype){ |
103 |
if (C4::Context->preference('item-level_itypes')){ |
105 |
if (C4::Context->preference('item-level_itypes')){ |
Lines 107-120
if($advanced_search_types eq 'ccode'){
Link Here
|
107 |
$whereclause .= ' AND biblioitems.itemtype='.$dbh->quote($itemtype); |
109 |
$whereclause .= ' AND biblioitems.itemtype='.$dbh->quote($itemtype); |
108 |
} |
110 |
} |
109 |
} |
111 |
} |
110 |
$query = "SELECT datecreated, biblio.biblionumber, title, |
112 |
my $query = "SELECT datecreated, biblio.biblionumber, title, |
111 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
113 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
112 |
biblioitems.publishercode, biblioitems.place, biblioitems.publicationyear, biblio.copyrightdate, |
114 |
biblioitems.publishercode, biblioitems.place, biblioitems.publicationyear, biblio.copyrightdate, |
113 |
itemtypes.description, biblioitems.pages, biblioitems.size |
115 |
itemtypes.description, biblioitems.pages, biblioitems.size, |
|
|
116 |
COALESCE( localization.translation, itemtypes.description ) AS translated_description |
114 |
FROM biblio |
117 |
FROM biblio |
115 |
LEFT JOIN items USING (biblionumber) |
118 |
LEFT JOIN items USING (biblionumber) |
116 |
LEFT JOIN biblioitems USING (biblionumber) |
119 |
LEFT JOIN biblioitems USING (biblionumber) |
117 |
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype |
120 |
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype |
|
|
121 |
LEFT JOIN localization ON itemtypes.itemtype = localization.code |
122 |
AND localization.entity = 'itemtypes' |
123 |
AND localization.lang = ? |
118 |
WHERE 1 |
124 |
WHERE 1 |
119 |
$whereclause |
125 |
$whereclause |
120 |
GROUP BY biblio.biblionumber |
126 |
GROUP BY biblio.biblionumber |
Lines 122-134
if($advanced_search_types eq 'ccode'){
Link Here
|
122 |
ORDER BY tot DESC |
128 |
ORDER BY tot DESC |
123 |
LIMIT ? |
129 |
LIMIT ? |
124 |
"; |
130 |
"; |
125 |
$template->param(itemtypesearch => 1); |
131 |
$template->param(itemtypesearch => 1); |
|
|
132 |
$sth = $dbh->prepare($query); |
133 |
my $language = C4::Languages::getlanguage(); |
134 |
$sth->execute($language, $limit); |
126 |
} |
135 |
} |
127 |
|
136 |
|
128 |
my $sth = $dbh->prepare($query); |
|
|
129 |
$sth->execute($limit); |
130 |
my @results; |
137 |
my @results; |
131 |
while (my $line= $sth->fetchrow_hashref) { |
138 |
while (my $line= $sth->fetchrow_hashref) { |
|
|
139 |
if ( $advanced_search_types ne 'ccode' ) { |
140 |
$line->{description} = $line->{translated_description}; |
141 |
} |
142 |
|
132 |
push @results, $line; |
143 |
push @results, $line; |
133 |
} |
144 |
} |
134 |
|
145 |
|
Lines 138-144
if($timeLimit eq 999){ $timeLimitFinite = 0 };
Link Here
|
138 |
$template->param(do_it => 1, |
149 |
$template->param(do_it => 1, |
139 |
limit => $limit, |
150 |
limit => $limit, |
140 |
branch => $branches->{$branch}->{branchname}, |
151 |
branch => $branches->{$branch}->{branchname}, |
141 |
itemtype => $itemtypes->{$itemtype}->{description}, |
152 |
itemtype => $itemtypes->{$itemtype}->{translated_description}, |
142 |
timeLimit => $timeLimit, |
153 |
timeLimit => $timeLimit, |
143 |
timeLimitFinite => $timeLimitFinite, |
154 |
timeLimitFinite => $timeLimitFinite, |
144 |
results_loop => \@results, |
155 |
results_loop => \@results, |
Lines 151-159
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'
Link Here
|
151 |
$itemtypes = GetItemTypes; |
162 |
$itemtypes = GetItemTypes; |
152 |
my @itemtypesloop; |
163 |
my @itemtypesloop; |
153 |
if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { |
164 |
if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { |
154 |
foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { |
165 |
foreach my $thisitemtype ( sort {$itemtypes->{$a}->{translated_description} cmp $itemtypes->{$b}->{translated_description} } keys %$itemtypes ) { |
155 |
my %row =( value => $thisitemtype, |
166 |
my %row =( value => $thisitemtype, |
156 |
description => $itemtypes->{$thisitemtype}->{'description'}, |
167 |
description => $itemtypes->{$thisitemtype}->{translated_description}, |
157 |
selected => $thisitemtype eq $itemtype, |
168 |
selected => $thisitemtype eq $itemtype, |
158 |
); |
169 |
); |
159 |
push @itemtypesloop, \%row; |
170 |
push @itemtypesloop, \%row; |