Location: PHPKode > projects > TVEz - Media Library > tvez-0.2.1/html/movies/stats/added_stat.php
<?php

# ------------------------------------------------------------------------------
#
# The plot of when movies were added
#
# ------------------------------------------------------------------------------
#
# Copyright (C) 2003 Christian Eheim and Alex Pachikov
#                                                                               
# This file is part of TVEz (tvez.sourceforge.net).
#                                                                               
# TVEz is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#                                                                               
# TVEz is distributed in the hope that it will be useful,
# but WITHOUT ANY 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 TVEz; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#                                                                               
# ------------------------------------------------------------------------------
#
# Created on 12/12/2003 by Christian Eheim (hide@address.com)
#
# LAST MODIFIED:
# $Date: 2004/02/03 23:21:29 $
# $Revision: 1.1 $
# $Author: eheim $
#
# ------------------------------------------------------------------------------

$shortMonths = array (
	localize_string("Jan"),
	localize_string("Feb"),
	localize_string("Mar"),
	localize_string("Apr"),
	localize_string("May"),
	localize_string("Jun"),
	localize_string("Jul"),
	localize_string("Aug"),
	localize_string("Sep"),
	localize_string("Oct"),
	localize_string("Nov"),
	localize_string("Dec"),
);

    $query = "SELECT extract(year from date) year,extract(month from date) month,count(extract(year from date)) num from movies group by year,month order by year,month";
    list($anum,$add_movies) = query_db($query);
	if ($anum) {
		$cc=0;

		$firstY = $add_movies[0]['year'];
		$firstM = $add_movies[0]['month'];
		$lastY = $add_movies[$anum-1]['year'];
		$lastM = $add_movies[$anum-1]['month'];

		$year = $firstY;
		$month = $firstM;
		$m = array();
		while ($year < $lastY || ($year <= $lastY && $month <= $lastM)) {
				$m{$shortMonths[$month-1]."%20".$year} = 0;
				$month++;
				if ($month>12) {
					$month = 1;
					$year++;
				}
		}

		$ymax = 0;
		$ymin = 0;
		foreach ($add_movies as $movie) {
			$m{$shortMonths[$movie['month']-1]."%20".$movie['year']} = $movie['num'];
			if ($movie['num'] > $ymax) $ymax = $movie['num'];
		}
		$ymax = (floor($ymax/10)+1)*10;
	
		$data = "";
		foreach ($m as $key => $value)
			$data .= "$key^$value^^";

		$query = "width=500&height=260&xTitle=Month%20Added&yTitle=Number%20of%20Movies&yMin=$ymin&yMax=$ymax&xLabelUp=true&marker=diamond&markerSize=4&markerColor=blue&lineColor=blue&connected=true&data=";
		$query .= $data;

		portlet(localize_string("Date Added"),'<img src="shared/Graph/plot_graph.php?'.$query.'">',"x");
	}
	else
		portlet(localize_string("Date Added"),"No movies have been added","x");

?>
Return current item: TVEz - Media Library