-$sqldatewhere .= " AND reservedate >= " . $dbh->quote(format_date_in_iso($startdate)) if ($startdate) ;
-$sqldatewhere .= " AND reservedate <= " . $dbh->quote(format_date_in_iso($enddate)) if ($enddate) ;
-
-if ($order eq "biblio") {
- $sqlorderby = " order by biblio.title, holdingbranch, listcall, l_location ";
-} elsif ($order eq "callnumber") {
- $sqlorderby = " order by listcall, holdingbranch, l_location ";
-} elsif ($order eq "itemcount") {
- $sqlorderby = " order by itemcount, reservecount ";
-} elsif ($order eq "itype") {
- $sqlorderby = " order by l_itype, holdingbranch, listcall ";
-} elsif ($order eq "location") {
- $sqlorderby = " order by l_location, holdingbranch, listcall ";
-} elsif ($order eq "reservecount") {
- $sqlorderby = " order by reservecount DESC ";
-} elsif ($order eq "branch") {
- $sqlorderby = " order by holdingbranch, l_location, listcall ";
-} else {
- $sqlorderby = " order by reservecount DESC ";
+my @query_params = ();
+if ($startdate) {
+ $sqldatewhere .= " AND reservedate >= ?";
+ push @query_params, format_date_in_iso($startdate);
+}
+if ($enddate) {
+ $sqldatewhere .= " AND reservedate <= ?";
+ push @query_params, format_date_in_iso($enddate);