Lines 151-162
$template->param(sql => $strsth);
Link Here
|
151 |
my $sth = $dbh->prepare($strsth); |
151 |
my $sth = $dbh->prepare($strsth); |
152 |
$sth->execute(@query_params); |
152 |
$sth->execute(@query_params); |
153 |
|
153 |
|
154 |
my $ratio_atleast1 = ($ratio >= 1) ? 1 : 0; |
|
|
155 |
my @reservedata; |
154 |
my @reservedata; |
156 |
while ( my $data = $sth->fetchrow_hashref ) { |
155 |
while ( my $data = $sth->fetchrow_hashref ) { |
157 |
my $thisratio = $data->{reservecount} / $data->{itemcount}; |
156 |
my $thisratio = $data->{reservecount} / $data->{itemcount}; |
158 |
my $ratiocalc = ($thisratio / $ratio); |
157 |
my $ratiocalc = $data->{reservecount}/$ratio - $data->{itemcount}; |
159 |
($thisratio / $ratio) >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause |
158 |
$ratiocalc >= 1 or next; # TODO: tighter targeting -- get ratio limit into SQL using HAVING clause |
160 |
push( |
159 |
push( |
161 |
@reservedata, |
160 |
@reservedata, |
162 |
{ |
161 |
{ |
Lines 180-186
while ( my $data = $sth->fetchrow_hashref ) {
Link Here
|
180 |
itype => [split('\|', $data->{l_itype})], |
179 |
itype => [split('\|', $data->{l_itype})], |
181 |
reservecount => $data->{reservecount}, |
180 |
reservecount => $data->{reservecount}, |
182 |
itemcount => $data->{itemcount}, |
181 |
itemcount => $data->{itemcount}, |
183 |
ratiocalc => sprintf( "%.0d", $ratio_atleast1 ? ( $thisratio / $ratio ) : $thisratio ), |
182 |
ratiocalc => sprintf( "%.0d", $ratiocalc ), |
184 |
thisratio => sprintf( "%.2f", $thisratio ), |
183 |
thisratio => sprintf( "%.2f", $thisratio ), |
185 |
thisratio_atleast1 => ( $thisratio >= 1 ) ? 1 : 0, |
184 |
thisratio_atleast1 => ( $thisratio >= 1 ) ? 1 : 0, |
186 |
listcall => [split('\|', $data->{listcall})] |
185 |
listcall => [split('\|', $data->{listcall})] |
Lines 194-200
for my $rd ( @reservedata ) {
Link Here
|
194 |
} |
193 |
} |
195 |
|
194 |
|
196 |
$template->param( |
195 |
$template->param( |
197 |
ratio_atleast1 => $ratio_atleast1, |
|
|
198 |
todaysdate => $todaysdate, |
196 |
todaysdate => $todaysdate, |
199 |
from => $startdate, |
197 |
from => $startdate, |
200 |
to => $enddate, |
198 |
to => $enddate, |
201 |
- |
|
|