|
Lines 32-38
use C4::Debug;
Link Here
|
| 32 |
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/; |
32 |
use C4::Biblio qw/GetMarcBiblio GetRecordValue GetFrameworkCode/; |
| 33 |
|
33 |
|
| 34 |
my $input = new CGI; |
34 |
my $input = new CGI; |
| 35 |
my $order = $input->param('order') || ''; |
|
|
| 36 |
my $startdate = $input->param('from'); |
35 |
my $startdate = $input->param('from'); |
| 37 |
my $enddate = $input->param('to'); |
36 |
my $enddate = $input->param('to'); |
| 38 |
my $ratio = $input->param('ratio'); |
37 |
my $ratio = $input->param('ratio'); |
|
Lines 72-78
if ($ratio <= 0) {
Link Here
|
| 72 |
} |
71 |
} |
| 73 |
|
72 |
|
| 74 |
my $dbh = C4::Context->dbh; |
73 |
my $dbh = C4::Context->dbh; |
| 75 |
my ($sqlorderby, $sqldatewhere) = ("",""); |
74 |
my $sqldatewhere = ""; |
| 76 |
$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); |
75 |
$debug and warn format_date_in_iso($startdate) . "\n" . format_date_in_iso($enddate); |
| 77 |
my @query_params = (); |
76 |
my @query_params = (); |
| 78 |
if ($startdate) { |
77 |
if ($startdate) { |
|
Lines 84-106
if ($enddate) {
Link Here
|
| 84 |
push @query_params, format_date_in_iso($enddate); |
83 |
push @query_params, format_date_in_iso($enddate); |
| 85 |
} |
84 |
} |
| 86 |
|
85 |
|
| 87 |
if ($order eq "biblio") { |
|
|
| 88 |
$sqlorderby = " ORDER BY biblio.title, holdingbranch, listcall, l_location "; |
| 89 |
} elsif ($order eq "callnumber") { |
| 90 |
$sqlorderby = " ORDER BY listcall, holdingbranch, l_location "; |
| 91 |
} elsif ($order eq "itemcount") { |
| 92 |
$sqlorderby = " ORDER BY itemcount, reservecount "; |
| 93 |
} elsif ($order eq "itype") { |
| 94 |
$sqlorderby = " ORDER BY l_itype, holdingbranch, listcall "; |
| 95 |
} elsif ($order eq "location") { |
| 96 |
$sqlorderby = " ORDER BY l_location, holdingbranch, listcall "; |
| 97 |
} elsif ($order eq "reservecount") { |
| 98 |
$sqlorderby = " ORDER BY reservecount DESC "; |
| 99 |
} elsif ($order eq "branch") { |
| 100 |
$sqlorderby = " ORDER BY holdingbranch, l_location, listcall "; |
| 101 |
} else { |
| 102 |
$sqlorderby = " ORDER BY reservecount DESC "; |
| 103 |
} |
| 104 |
my $strsth = |
86 |
my $strsth = |
| 105 |
"SELECT reservedate, |
87 |
"SELECT reservedate, |
| 106 |
reserves.borrowernumber as borrowernumber, |
88 |
reserves.borrowernumber as borrowernumber, |
|
Lines 126-142
my $strsth =
Link Here
|
| 126 |
FROM reserves |
108 |
FROM reserves |
| 127 |
LEFT JOIN items ON items.biblionumber=reserves.biblionumber |
109 |
LEFT JOIN items ON items.biblionumber=reserves.biblionumber |
| 128 |
LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber |
110 |
LEFT JOIN biblio ON reserves.biblionumber=biblio.biblionumber |
| 129 |
WHERE |
111 |
WHERE |
| 130 |
notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0 |
112 |
notforloan = 0 AND damaged = 0 AND itemlost = 0 AND wthdrawn = 0 |
| 131 |
$sqldatewhere |
113 |
$sqldatewhere |
| 132 |
"; |
114 |
"; |
| 133 |
|
115 |
|
| 134 |
if (C4::Context->preference('IndependantBranches')){ |
116 |
if (C4::Context->preference('IndependantBranches')){ |
| 135 |
$strsth .= " AND items.holdingbranch=? "; |
117 |
$strsth .= " AND items.holdingbranch=? "; |
| 136 |
push @query_params, C4::Context->userenv->{'branch'}; |
118 |
push @query_params, C4::Context->userenv->{'branch'}; |
| 137 |
} |
119 |
} |
| 138 |
|
120 |
|
| 139 |
$strsth .= " GROUP BY reserves.biblionumber " . $sqlorderby; |
121 |
$strsth .= " GROUP BY reserves.biblionumber ORDER BY reservecount DESC"; |
| 140 |
|
122 |
|
| 141 |
$template->param(sql => $strsth); |
123 |
$template->param(sql => $strsth); |
| 142 |
my $sth = $dbh->prepare($strsth); |
124 |
my $sth = $dbh->prepare($strsth); |