X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=circ%2Fstats.pl;h=558a985c962fcabcfcad1d5cd5ffd46289ac9469;hb=ded520afdc1b3191d3ec204e3ad10443e7c0925e;hp=5c1248b2af430628cbe5a3a35c14d3cbd42cef77;hpb=606ecb532aa42562687bf0d05b4d6df6697300d7;p=koha_fer diff --git a/circ/stats.pl b/circ/stats.pl index 5c1248b2af..558a985c96 100755 --- a/circ/stats.pl +++ b/circ/stats.pl @@ -17,20 +17,24 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. use strict; +#use warnings; FIXME - Bug 2505 use CGI; use C4::Context; use C4::Output; use C4::Auth; use Date::Manip; use C4::Stats; +use C4::Debug; + +use vars qw($debug); my $input = new CGI; -my $time = $input->param('time'); +my $time = $input->param('time') || ''; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -45,51 +49,51 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my $date; my $date2; -if ( $time eq '' ) { - $template->param(notime => '1'); - output_html_with_http_headers $input, $cookie, $template->output; - exit; -} if ( $time eq 'yesterday' ) { $date = ParseDate('yesterday'); $date2 = ParseDate('today'); } -if ( $time eq 'today' ) { +elsif ( $time eq 'today' ) { $date = ParseDate('today'); $date2 = ParseDate('tomorrow'); } -if ( $time eq 'daybefore' ) { +elsif ( $time eq 'daybefore' ) { $date = ParseDate('2 days ago'); $date2 = ParseDate('yesterday'); } -if ( $time eq 'month' ) { +elsif ( $time eq 'month' ) { $date = ParseDate('1 month ago'); $date2 = ParseDate('today'); - warn "d : $date // d2 : $date2"; } -if ( $time =~ /\// ) { +elsif ( $time =~ /\// ) { $date = ParseDate($time); $date2 = ParseDateDelta('+ 1 day'); $date2 = DateCalc( $date, $date2 ); +} else { + $template->param(notime => '1'); # TODO: add error feedback if time sent, but unrecognized + output_html_with_http_headers $input, $cookie, $template->output; + exit; } + +$debug and warn "d : $date // d2 : $date2"; $date = UnixDate( $date, '%Y-%m-%d' ); $date2 = UnixDate( $date2, '%Y-%m-%d' ); -warn "d : $date // d2 : $date2"; +$debug and warn "d : $date // d2 : $date2"; my @payments = TotalPaid( $date, $date2 ); my $count = @payments; my $total = 0; +my $totalw = 0; my $oldtime; -my $totalw = 0; my @loop; my %row; my $i = 0; while ( $i < $count ) { - warn " pay : " . $payments[$i]{'timestamp'}; + $debug and warn " pay : " . $payments[$i]{'timestamp'}; my $time = $payments[$i]{'datetime'}; my $payments = $payments[$i]{'value'}; my $charge = 0; - my @temp = split( / /, $payments[$i]{'datetime'} ); + my @temp = split(/ /, $payments[$i]{'datetime'}); my $date = $temp[0]; my @charges = getcharges( $payments[$i]{'borrowernumber'}, $payments[$i]{'timestamp'} ); @@ -100,6 +104,7 @@ while ( $i < $count ) { my $temptotalren = 0; my $temptotalw = 0; + # FIXME: way too much logic to live only here in a report script for ( my $i2 = 0 ; $i2 < $count ; $i2++ ) { $charge += $charges[$i2]->{'amount'}; %row = ( @@ -136,11 +141,7 @@ while ( $i < $count ) { } } } - my $hour = substr( $payments[$i]{'timestamp'}, 8, 2 ); - my $min = substr( $payments[$i]{'timestamp'}, 10, 2 ); - my $sec = substr( $payments[$i]{'timestamp'}, 12, 2 ); - my $time = "$hour:$min:$sec"; - my $time2 = "$payments[$i]{'date'}"; + my $time2 = $payments[$i]{'date'}; my $branch = Getpaidbranch( $time2, $payments[$i]{'borrowernumber'} ); my $borrowernumber = $payments[$i]{'borrowernumber'}; my $oldtime = $payments[$i]{'timestamp'}; @@ -150,12 +151,8 @@ while ( $i < $count ) { && $oldtype == $payments[$i]{'accounttype'} && $oldtime eq $payments[$i]{'timestamp'} ) { - my $hour = substr( $payments[$i]{'timestamp'}, 8, 2 ); - my $min = substr( $payments[$i]{'timestamp'}, 10, 2 ); - my $sec = substr( $payments[$i]{'timestamp'}, 12, 2 ); - my $time = "$hour:$min:$sec"; - my $time2 = "$payments[$i]{'date'}"; - my $branch = Getpaidbranch( $time2, $payments[$i]{'borrowernumber'} ); + my $xtime2 = $payments[$i]{'date'}; + my $branch = Getpaidbranch( $xtime2, $payments[$i]{'borrowernumber'} ); if ( $payments[$i]{'accounttype'} eq 'W' ) { $totalw += $payments[$i]{'amount'}; } @@ -164,6 +161,7 @@ while ( $i < $count ) { $total += $payments[$i]{'amount'}; } + #FIXME: display layer HTML %row = ( name => "" . $payments[$i]{'firstname'}