|
Lines 57-83
my $limit = $input->param('limit') || 10;
Link Here
|
| 57 |
my $branch = $input->param('branch') || ''; |
57 |
my $branch = $input->param('branch') || ''; |
| 58 |
my $itemtype = $input->param('itemtype') || ''; |
58 |
my $itemtype = $input->param('itemtype') || ''; |
| 59 |
my $timeLimit = $input->param('timeLimit') || 3; |
59 |
my $timeLimit = $input->param('timeLimit') || 3; |
|
|
60 |
my $advanced_search_types = C4::Context->preference('AdvancedSearchTypes'); |
| 61 |
|
| 60 |
my $whereclause = ''; |
62 |
my $whereclause = ''; |
| 61 |
$whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch); |
63 |
$whereclause .= ' AND items.homebranch='.$dbh->quote($branch) if ($branch); |
| 62 |
$whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype; |
64 |
$whereclause .= ' AND TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30) if $timeLimit < 999; |
| 63 |
$whereclause .= ' TO_DAYS(NOW()) - TO_DAYS(biblio.datecreated) <= '.($timeLimit*30).' AND ' if $timeLimit < 999; |
|
|
| 64 |
$whereclause =~ s/ AND $// if $whereclause; |
65 |
$whereclause =~ s/ AND $// if $whereclause; |
| 65 |
$whereclause = " WHERE ".$whereclause if $whereclause; |
66 |
my $query; |
| 66 |
|
67 |
|
| 67 |
my $query = "SELECT datecreated, biblio.biblionumber, title, |
68 |
if($advanced_search_types eq 'ccode'){ |
| 68 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
69 |
$whereclause .= ' AND authorised_values.authorised_value='.$dbh->quote($itemtype) if $itemtype; |
| 69 |
biblioitems.publishercode,biblioitems.publicationyear, |
70 |
$query = "SELECT datecreated, biblio.biblionumber, title, |
| 70 |
itemtypes.description |
71 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
| 71 |
FROM biblio |
72 |
biblioitems.publishercode,biblioitems.publicationyear, |
| 72 |
LEFT JOIN items USING (biblionumber) |
73 |
authorised_values.lib as description |
| 73 |
LEFT JOIN biblioitems USING (biblionumber) |
74 |
FROM biblio |
| 74 |
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype |
75 |
LEFT JOIN items USING (biblionumber) |
| 75 |
$whereclause |
76 |
LEFT JOIN biblioitems USING (biblionumber) |
| 76 |
GROUP BY biblio.biblionumber |
77 |
LEFT JOIN authorised_values ON items.ccode = authorised_values.authorised_value |
| 77 |
HAVING tot >0 |
78 |
WHERE 1 |
| 78 |
ORDER BY tot DESC |
79 |
$whereclause |
| 79 |
LIMIT $limit |
80 |
AND authorised_values.category = 'ccode' |
| 80 |
"; |
81 |
GROUP BY biblio.biblionumber |
|
|
82 |
HAVING tot >0 |
| 83 |
ORDER BY tot DESC |
| 84 |
LIMIT $limit |
| 85 |
"; |
| 86 |
$template->param(ccodesearch => 1); |
| 87 |
}else{ |
| 88 |
$whereclause .= ' AND biblioitems.itemtype='.$dbh->quote($itemtype) if $itemtype; |
| 89 |
$query = "SELECT datecreated, biblio.biblionumber, title, |
| 90 |
author, sum( items.issues ) AS tot, biblioitems.itemtype, |
| 91 |
biblioitems.publishercode,biblioitems.publicationyear, |
| 92 |
itemtypes.description |
| 93 |
FROM biblio |
| 94 |
LEFT JOIN items USING (biblionumber) |
| 95 |
LEFT JOIN biblioitems USING (biblionumber) |
| 96 |
LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype |
| 97 |
WHERE 1 |
| 98 |
$whereclause |
| 99 |
GROUP BY biblio.biblionumber |
| 100 |
HAVING tot >0 |
| 101 |
ORDER BY tot DESC |
| 102 |
LIMIT $limit |
| 103 |
"; |
| 104 |
$template->param(itemtypesearch => 1); |
| 105 |
} |
| 81 |
|
106 |
|
| 82 |
my $sth = $dbh->prepare($query); |
107 |
my $sth = $dbh->prepare($query); |
| 83 |
$sth->execute(); |
108 |
$sth->execute(); |
|
Lines 100-119
$template->param(do_it => 1,
Link Here
|
| 100 |
|
125 |
|
| 101 |
$template->param( branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'})); |
126 |
$template->param( branchloop => GetBranchesLoop(C4::Context->userenv->{'branch'})); |
| 102 |
|
127 |
|
| 103 |
#doctype |
128 |
# the index parameter is different for item-level itemtypes |
|
|
129 |
my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':'itemtype'; |
| 104 |
$itemtypes = GetItemTypes; |
130 |
$itemtypes = GetItemTypes; |
| 105 |
my @itemtypeloop; |
131 |
my @itemtypesloop; |
| 106 |
foreach my $thisitemtype (sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'}} keys %$itemtypes) { |
132 |
my $selected=1; |
|
|
133 |
if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { |
| 134 |
foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { |
| 107 |
my $selected = 1 if $thisitemtype eq $itemtype; |
135 |
my $selected = 1 if $thisitemtype eq $itemtype; |
| 108 |
my %row =(value => $thisitemtype, |
136 |
my %row =( value => $thisitemtype, |
| 109 |
description => $itemtypes->{$thisitemtype}->{'description'}, |
137 |
description => $itemtypes->{$thisitemtype}->{'description'}, |
| 110 |
selected => $selected, |
138 |
selected => $selected, |
| 111 |
); |
139 |
); |
| 112 |
push @itemtypeloop, \%row; |
140 |
push @itemtypesloop, \%row; |
|
|
141 |
} |
| 142 |
} else { |
| 143 |
my $advsearchtypes = GetAuthorisedValues($advanced_search_types, '', 'opac'); |
| 144 |
for my $thisitemtype (@$advsearchtypes) { |
| 145 |
my $selected = 1 if $thisitemtype->{authorised_value} eq $itemtype; |
| 146 |
my %row =( value => $thisitemtype->{authorised_value}, |
| 147 |
selected => $selected, |
| 148 |
description => $thisitemtype->{'lib'}, |
| 149 |
); |
| 150 |
push @itemtypesloop, \%row; |
| 151 |
} |
| 113 |
} |
152 |
} |
| 114 |
|
153 |
|
| 115 |
$template->param( |
154 |
$template->param( |
| 116 |
itemtypeloop =>\@itemtypeloop, |
155 |
itemtypeloop =>\@itemtypesloop, |
| 117 |
dateformat => C4::Context->preference("dateformat"), |
156 |
dateformat => C4::Context->preference("dateformat"), |
| 118 |
); |
157 |
); |
| 119 |
output_html_with_http_headers $input, $cookie, $template->output; |
158 |
output_html_with_http_headers $input, $cookie, $template->output; |
| 120 |
- |
|
|