Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/statistiques/Statistiques.php
<?php
 /*     This file is used to display all cards that have been created
	It is expected that in production, this feature will be rather
	useless because of the number of accounts that will build up
	over time.  Some sort of method for clearing old accounts will
	need to be implemented.  For now, AllCards is the first step
	in building a reporting system.

	This file C. Carl H. Peterson 2004 and released under the GPL.
	If you didn't get a copy of the GPL with this, do a search for
	GPL and find it your self.  Remember, I copyrighted this so if
	you are using it you better have a license to use it.  GPl 
	works for me.
*/

	//////////////////////////////////////////////////////////
	//	THIS SCRIPT DISPLAYS ACCOUNTS FOR A LOCATION	//
	//	First we pull the session location ID and then	//
	//	use it to pull the correct cards.  		//
	//	we use the button ID to figure out which type	//
	//	of cards we want to pull			//
	//////////////////////////////////////////////////////////
$loc='';
if  (isset($_POST['lsid'])) 
	{
		$loc=getLocationID($_POST['lsid']);
		$loctmp=$loc;
		$LocName=$_POST['lsid'];
	}
else
{
	$LocName = $_SESSION['LocName'];
	$loc="";
}

if (isset($_GET['lsid']) AND ($_GET['lsid']=="All"))
		$locstr="";
else
{ 
	if (isset($loc) AND ($loc!='')) {
		$locstr=" AND userinfo.LocationID='$loc'";
		$locstrwa=" WHERE LocationID='$loc'";
	}
	else $locstr="";
}
if(!isset($buttonID)) {
		$msg= "$msg <p class=\"error\">No button ID was sent</p>"; // this shouldn't happen
		}
	
	if(!isset($msg)){  // no errors? ...  hit it.  Need to reset button id
	

		
	echo "General Statistics for location ".$LocName;
	if (isset($_POST['fromdate'])) $fromdate=$_POST['fromdate'];
	if (isset($_POST['todate'])) $todate=$_POST['todate'];
	if (isset($_POST['date_search'])) $date_search=$_POST['date_search'];
	$user_status=$oreon->user->get_status();
	if (isset($_POST['check_graphic'])) $check_graphic=$_POST['check_graphic'];
	if (isset($_POST['plot_graphic'])) $plot_graphic=$_POST['plot_graphic'];
	else $plot_graphic="Bars";

	if (isset($_POST['vw_graphic'])) $vw_graphic=$_POST['vw_graphic'];
	else $vw_graphic="ausers";

	$y=date('Y');
	$m=date('m');
	
        if ($fromdate=='') {
	 $start=$y."-".$m."-01 00:00:00";
	$startf=date($dateFormat,strtotime($start));
	}
	 else
	{ 
	 $start=date_to_attribute($fromdate,"mysql");
	$startf=$fromdate;
	}

	if ($todate=='') 
	{
	 $stop=date("Y-m-d")." 23:59:59";
	 $stopf=date($dateFormat,strtotime($stop));
	}
	else
	{
	 $stop=date_to_attribute($todate,"mysql");
	 $stopf=$todate; 
	} 


	if ($date_search=="Creation Date")
		$search_attribute="AND CrDate>='$start' AND CrDate<='$stop'";
	if ($date_search=="Accounting Date" or $date_search=='')
		$search_attribute="AND AcctStopTime>='$start' AND AcctStopTime<='$stop'";
	if ($date_search=="Login Date")
		$search_attribute="AND activeDate>='$start' AND activeDate<='$stop'";
	 

	$nbaccount=0;
	$nbexpiredaccount=0;
	$nbactivateaccount=0;
	$datenow=date("d-m-Y",time());
	$qnbaccount="SELECT ID FROM userinfo $locstrwa GROUP BY UserName " ;
	$qnbactivateaccount="SELECT COUNT(*) AS val FROM userinfo WHERE activated='1' $locstr GROUP BY UserName";

	$rnbactivateaccount= $oreon->database->database->query($qnbactivateaccount) or die("Query database error !");
	$rnbactivateaccount=$oreon->database->database->result_num_rows($rnbactivateaccount);
	$rnbaccounti=$oreon->database->database->query($qnbaccount) or die("Query database error !");
	$rnbaccount=$oreon->database->database->result_num_rows($rnbaccounti);
	
		$search="SELECT BillingPlan.Id,NameBp From BillingPlan,userinfo WHERE userinfo.BillingPlan=BillingPlan.ID $locstr GROUP BY NameBp";
	
	$search2="SELECT Type,COUNT(Username) AS cuser From userinfo $locstrwa GROUP BY Type";

	$result = $oreon->database->database->query($search) or die("Query database error !");
	$result2 = $oreon->database->database->query($search2) or die("Query database error !");	


	$expu=0;
	$query3 = "SELECT UserName,Type from userinfo where (Type='Hourly' OR Type='Subscription Time') $locstr";
        $array=expiredUser("",$query3);
	$expu+=count($array['time']);
	//COUNT EXPIRED OCTET
	$query4 = "SELECT UserName,Type from userinfo where (Type='Octets' OR Type='Subscription Octets') $locstr";
	$array=expiredUser("",$query4);
	$expu+=count($array['octet']);
	//COUNT EXPIRED EXPIRATION 
	$query5 = "SELECT UserName,Type from userinfo WHERE Type='Subscription Expiration'  $locstr";
        $array=expiredUser("",$query5);
	$expu+=count($array['expiration']);
	include('Statistiques_html.php');
	}else{
		echo($msg);
}

?>		

Return current item: phpMyPrepaid