X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=C4%2FSuggestions.pm;h=ccc0c8e6ac4a9dbba14ae3f2e293ae52169ee304;hb=9d80ca27750c60471ef0902c6f7bda345341dd7c;hp=779cc7cb08122825fb583994f71db3ab482159d8;hpb=88b3711ca918877796d8577c54efe3f0aba96673;p=koha.git diff --git a/C4/Suggestions.pm b/C4/Suggestions.pm index 779cc7cb08..ccc0c8e6ac 100644 --- a/C4/Suggestions.pm +++ b/C4/Suggestions.pm @@ -25,7 +25,7 @@ use CGI; use C4::Context; use C4::Output; -use C4::Dates qw(format_date); +use C4::Dates qw(format_date format_date_in_iso); use C4::SQLHelper qw(:all); use C4::Debug; use C4::Letters; @@ -113,7 +113,7 @@ sub SearchSuggestion { LEFT JOIN borrowers AS U2 ON managedby=U2.borrowernumber LEFT JOIN branches AS B2 ON B2.branchcode=U2.branchcode LEFT JOIN categories AS C2 ON C2.categorycode = U2.categorycode - WHERE STATUS NOT IN ('CLAIMED') + WHERE 1=1 } , map { if ( my $s = $suggestion->{$_} ) { push @sql_params,'%'.$s.'%'; @@ -147,6 +147,17 @@ sub SearchSuggestion { } } + my $today = C4::Dates->today('iso'); + + foreach ( qw( suggesteddate manageddate accepteddate ) ) { + my $from = $_ . "_from"; + my $to = $_ . "_to"; + if ($$suggestion{$from} || $$suggestion{$to}) { + push @query, " AND suggestions.suggesteddate BETWEEN '" + . (format_date_in_iso($$suggestion{$from}) || 0000-00-00) . "' AND '" . (format_date_in_iso($$suggestion{$to}) || $today) . "'"; + } + } + $debug && warn "@query"; my $sth=$dbh->prepare("@query"); $sth->execute(@sql_params);