Location: PHPKode > projects > phpMyPrepaid > phpmyprepaid/www/include/reports/printReports.php
<?php
include ('../../config.inc.php');
Session::Start();
include_once ("../configuration/".$_SESSION['gatewayType'].".attr");
$oreon=$_SESSION['oreon'];
$dateFormat=$oreon->phpmyprepaid['display_date_format'];

if ($debug)	echo " DATE FORMAT ".$dateFormat;
echo'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Prepaid Internet Cards List</title>
</head>
<body>';
if (isset($_POST['locationReports'])) $loc=$_POST['locationReports'];


if ($loc!="")
	{
		$locstr=" AND LocationID='$loc'";
		$locstrwa=" WHERE LocationID='$loc'";
	}
	else 
		$locstr="";

if ($_POST['order']!='None') 
{
 if ($_POST['order']=="Username")
   $order="ORDER BY  userinfo.UserName";
 if ($_POST['order']=="Creation Date")
   $order=" ORDER BY CrDate";
 if ($_POST['order']=="Type")
   $order=" ORDER BY Type";
 if ($_POST['order']=="Billing Plan")
   $order="ORDER BY BillingPlan";
 if ($_POST['order']=="Activate Date")
   $order="ORDER BY activeDate";
}
else $order='';
if ($_POST['user']!='') $user=" AND userinfo.UserName='".$_POST['user']."' ";
else $user='';
if ($_POST['type']!='None') $type=" AND Type='".$_POST['type']."' ";
else $type='';
$bpid=get_plan_id($_POST['billing_plan']);
//echo $_POST['billing_plan'];
if ($_POST['billing_plan']!='None') $billing_plan=" AND BillingPlan='".$bpid."' ";
else $billing_plan='';

if ($_POST['billing_plan']!='None') $billing_plan=" AND BillingPlan='".$bpid."' ";


$after=date_to_attribute($_POST['after']." 00:00:00","mysql");
$before=date_to_attribute($_POST['before']."23:59:59","mysql");
$date_search=$_POST['date_search'];

if ($date_search=="Creation Date")
	$search_attribute="AND CrDate>='$after' AND CrDate<='$before'";
if ($date_search=="Accounting Date" or $date_search=='')
	$search_attribute="AND AcctStopTime>='$after' AND AcctStopTime<='$before'";
if ($date_search=="Login Date")
	$search_attribute="AND activeDate>='$after' AND activeDate<='$before'";
	 
if ($_POST['user_list']!='')
{
  $search="SELECT UserName,Type,BillingPlan,CrDate,activeDate from userinfo $locstrwa $type $billing_plan GROUP BY UserName ".$order;
  //echo $search; //DEBUG
  if ($debug) print $search;
  $result = $_SESSION["oreon"]->database->database->query($search);
  include('UsersList.php');
}

if ($_POST['bp_list']!='')
{
  
	$search="SELECT NameBp,TimeBp,PriceBp,TypeBp  from BillingPlan $locstrwa ORDER BY NameBp";
	$result = $_SESSION["oreon"]->database->database->query($search);
  include('BillingPlan.php');
}

if ($_POST['never_used']!='')
{
 $search = "SELECT userinfo.* FROM userinfo LEFT JOIN radacct ON userinfo.UserName=radacct.UserName WHERE radacct.Username IS NULL $locstr $type $billing_plan $user $order ";
  $result = $oreon->database->database->query($search) or die("Query database error !");
  include('NeverUsedAccount.php');
}

if ($_POST['activate_users']!='')
{
  if ($date_search=="Login Date" OR $date_search=="Creation Date")
    
    $search="SELECT userinfo.UserName,Type,BillingPlan,CrDate,activeDate from userinfo WHERE activated='1' $locstr  $user $billing_plan $type GROUP BY userinfo.UserName $order ;";
  else
    {
	  $search="SELECT userinfo.UserName,Type,BillingPlan,CrDate,activeDate AS val FROM userinfo,$sql_accounting_table WHERE $sql_accounting_table.UserName=userinfo.UserName AND activated='1' $locstr  $user $type $billing_plan $search_attribute GROUP BY userinfo.UserName";
    }
	$result = $_SESSION["oreon"]->database->database->query($search);
      include('ActivateUser.php');
}

if ($_POST['expired_users']!='')
{
  if ($date_search=="Login Date" OR $date_search=="Creation Date")
    $search = "SELECT userinfo.UserName,Value,Type from userinfo where $user $type $billing_plan $locstr $search_attribute";
  else
    $search = "SELECT userinfo.UserName,Type from userinfo,$sql_accounting_table  where $sql_accounting_table.UserName=userinfo.UserName  $type $billing_plan AND AcctStopTime>='$after' AND AcctStopTime<='$before' $locstr $user GROUP BY userinfo.UserName $order";
  $array=expiredUser("",$search);
  $eu=count($array['time'])+count($array['octet'])+count($array['expiration']);
  include('ExpiredUser.php');
}

if ($_POST['user_accounting']!='')
{
$search = "SELECT * from userinfo,$sql_accounting_table where  $sql_accounting_table.UserName=userinfo.UserName  $type $billing_plan AND AcctStopTime>='$after' AND AcctStopTime<='$before' $locstr   $user $order;";
	$result = $_SESSION["oreon"]->database->database->query($search);
  include('UserAccounting.php');
}

if ($_POST['used_account']!='')
{
$search = "SELECT * from userinfo,$sql_accounting_table where $sql_accounting_table.UserName=userinfo.UserName $type $billing_plan AND AcctStopTime>='$after' AND AcctStopTime<='$before' AND ((activeDate>='$after' AND activeDate<='$before') OR (AcctStartTime>='$after' AND AcctStartTime<='$before'))  $locstr $user $order;";
  $array=expiredUser("",$search);
  $eu=count($array['time'])+count($array['octet'])+count($array['expiration']);
  include('UsedAccount.php');
 
}

if ($_POST['activate_usersb']!='')
{
  $search="SELECT UserName,Type,BillingPlan,CrDate,activeDate,PriceBp from userinfo,BillingPlan,$sql_accounting_table WHERE BillingPlan.ID=userinfo.BillingPlan AND activated='1' $locstr GROUP BY UserName ".$order;
	$result = $_SESSION["oreon"]->database->database->query($search);
  include('ActivateUserb.php');
}

if ($_POST['expired_usersb']!='')
{
$search = "SELECT * from userinfo,$sql_accounting_table,BillingPlan where  BillingPlan.ID=userinfo.BillingPlan AND $sql_accounting_table.UserName=userinfo.UserName $type $billing_plan AND AcctStopTime>='$after' AND AcctStopTime<='$before' AND ((activeDate>='$after' AND activeDate<='$before') OR (AcctStartTime>='$after' AND AcctStartTime<='$before'))  $locstr $user $order;";
 $array=expiredUser("",$search);
$eu=count($array['time'])+count($array['octet'])+count($array['expiration']);
  include('ExpiredUserb.php');
}



echo (" </tbody></table><br><br></body></html>");
?>
Return current item: phpMyPrepaid