realtime-call-log.php

来自「asterisk用 的voip记费软件」· PHP 代码 · 共 708 行 · 第 1/2 页

PHP
708
字号
<?php include ("../lib/defines.php");include ("../lib/module.access.php");//include ("../lib/Class.Table.php");exit();session_start();getpost_ifset(array('posted', 'Period', 'frommonth', 'fromstatsmonth', 'tomonth', 'tostatsmonth', 'fromday', 'fromstatsday_sday', 'fromstatsmonth_sday', 'today', 'tostatsday_sday', 'tostatsmonth_sday', 'dsttype', 'sourcetype', 'clidtype', 'channel', 'resulttype', 'stitle', 'atmenu', 'current_page', 'order', 'sens', 'dst', 'src', 'clid'));if (!isset ($current_page) || ($current_page == "")){			$current_page=0; 	}// this variable specifie the debug type (0 => nothing, 1 => sql result, 2 => boucle checking, 3 other value checking)$FG_DEBUG = 0;// The variable FG_TABLE_NAME define the table name to use$FG_TABLE_NAME="log t1";if ($_SESSION["is_admin"]==0){ 	$FG_TABLE_NAME.=", Customer t2";}// THIS VARIABLE DEFINE THE COLOR OF THE HEAD TABLE$FG_TABLE_HEAD_COLOR = "#D1D9E7";$FG_TABLE_EXTERN_COLOR = "#7F99CC"; //#CC0033 (Rouge)$FG_TABLE_INTERN_COLOR = "#EDF3FF"; //#FFEAFF (Rose)// THIS VARIABLE DEFINE THE COLOR OF THE HEAD TABLE$FG_TABLE_ALTERNATE_ROW_COLOR[] = "#FFFFFF";$FG_TABLE_ALTERNATE_ROW_COLOR[] = "#F2F8FF";//$link = DbConnect();$DBHandle  = DbConnect();// The variable Var_col would define the col that we want show in your table// First Name of the column in the html page, second name of the field$FG_TABLE_COL = array();/*******Calldate Clid Src Dst Dcontext Channel Dstchannel Lastapp Lastdata Duration Billsec Disposition Amaflags Accountcode Uniqueid Serverid*******/$FG_TABLE_COL[]=array (gettext("Nb Call"), "count(*)", "12%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("Customer"), "cardID", "20%", "center", "SORT", "30", "lie", "Customer", "AnaCust", "IDCust ='%id'", "%1");/*if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Buycosts", "buycosts", "12%", "center", "SORT", "30");if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Rate", "rate", "12%", "center", "SORT", "30");*/$FG_TABLE_COL[]=array (gettext("Incoming"), "costs", "12%", "center", "SORT", "30");if ($_SESSION["is_admin"]==1){	$FG_TABLE_COL[]=array (gettext("RealDuration"), "realduration", "12%", "center", "SORT", "30");}else{	$FG_TABLE_COL[]=array (gettext("Duration"), "duration", "12%", "center", "SORT", "30");}// ??? cardID$FG_TABLE_DEFAULT_ORDER = "t1.callstart";$FG_TABLE_DEFAULT_SENS = "DESC";// This Variable store the argument for the SQL query//$FG_COL_QUERY='calldate, channel, src, clid, lastapp, lastdata, dst, dst, serverid, disposition, duration';//$FG_COL_QUERY='calldate, channel, src, clid, lastapp, lastdata, dst, dst, disposition, duration';if ($_SESSION["is_admin"]==1) {	$FG_COL_QUERY='count(*), t1.cardID,  sum(t1.costs), sum(t1.realduration), sum(t1.buycosts)';}else{	$FG_COL_QUERY='count(*), t1.cardID, sum(t1.costs), sum(t1.duration), sum(t1.buycosts)';	}$FG_COL_QUERY_GRAPH='t1.callstart, t1.duration';// The variable LIMITE_DISPLAY define the limit of record to display by page$FG_LIMITE_DISPLAY=8;// Number of column in the html table$FG_NB_TABLE_COL=count($FG_TABLE_COL);// The variable $FG_EDITION define if you want process to the edition of the database record$FG_EDITION=true;//This variable will store the total number of column$FG_TOTAL_TABLE_COL = $FG_NB_TABLE_COL;if ($FG_DELETION || $FG_EDITION) $FG_TOTAL_TABLE_COL++;//This variable define the Title of the HTML table$FG_HTML_TABLE_TITLE=" - Call Logs - ";//This variable define the width of the HTML table$FG_HTML_TABLE_WIDTH="96%";if ($FG_DEBUG == 3) echo "<br>Table : $FG_TABLE_NAME  	- 	Col_query : $FG_COL_QUERY";$instance_table = new Table($FG_TABLE_NAME, $FG_COL_QUERY);$instance_table_graph = new Table($FG_TABLE_NAME, $FG_COL_QUERY_GRAPH);if ( is_null ($order) || is_null($sens) ){	$order = $FG_TABLE_DEFAULT_ORDER;	$sens  = $FG_TABLE_DEFAULT_SENS;}$date_clause='';// Period (Month-Day)if (DB_TYPE == "postgres"){			 	$UNIX_TIMESTAMP = "";}else{		$UNIX_TIMESTAMP = "UNIX_TIMESTAMP";}  if (!isset ($FG_TABLE_CLAUSE) || strlen($FG_TABLE_CLAUSE)==0){				$cc_yearmonth = sprintf("%04d-%02d-%02d",date("Y"),date("n")-1,date("d")); 			$FG_TABLE_CLAUSE=" $UNIX_TIMESTAMP(t1.callstart) >= $UNIX_TIMESTAMP('$cc_yearmonth')";}//--$list_total = $instance_table_graph -> Get_list ($FG_TABLE_CLAUSE, null, null, null, null, null, null);if (isset($customer)  &&  ($customer>0)){	if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND ";	$FG_TABLE_CLAUSE.="t1.cardID='$customer'";}if ($_SESSION["is_admin"]==0){ 		if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND ";	$FG_TABLE_CLAUSE.="t1.cardID=t2.IDCust AND t2.IDmanager='".$_SESSION["pr_reseller_ID"]."'";	}//> function Get_list ($clause=null, $order=null, $sens=null, $field_order_letter=null, $letters = null, $limite=null, $current_record = NULL)//$list = $instance_table -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, $order, $sens, null, null, $FG_LIMITE_DISPLAY, $current_page*$FG_LIMITE_DISPLAY);$list = $instance_table -> Get_list ($DBHandle, $FG_TABLE_CLAUSE." GROUP BY t1.cardID", $order, $sens, null, null, null, null);//echo "<br>--<br>".$FG_TABLE_CLAUSE."<br><br>";$_SESSION["pr_sql_export"]="SELECT $FG_COL_QUERY FROM $FG_TABLE_NAME WHERE $FG_TABLE_CLAUSE";//echo "SELECT $FG_COL_QUERY FROM $FG_TABLE_NAME WHERE $FG_TABLE_CLAUSE";	/************************///$QUERY = "SELECT substring(calldate,1,10) AS day, sum(duration) AS calltime, count(*) as nbcall FROM cdr WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(calldate,1,10)"; //extract(DAY from calldate) $QUERY = "SELECT substring(t1.callstart,1,10) AS day, sum(t1.duration) AS calltime, count(*) as nbcall FROM $FG_TABLE_NAME WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(t1.callstart,1,10)"; //extract(DAY from calldate) //echo "$QUERY";		$res = $DBHandle -> Execute($QUERY);		if ($res){			$num = $res -> RecordCount( );			for($i=0;$i<$num;$i++)			{								$list_total_day [] =$res -> fetchRow();				 			}		}if ($FG_DEBUG == 3) echo "<br>Clause : $FG_TABLE_CLAUSE";$nb_record = $instance_table -> Table_count ($DBHandle, $FG_TABLE_CLAUSE);//$nb_record = count($list_total);if ($FG_DEBUG >= 1) var_dump ($list);if ($nb_record<=$FG_LIMITE_DISPLAY){ 	$nb_record_max=1;}else{ 	$nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)+1);}if ($FG_DEBUG == 3) echo "<br>Nb_record : $nb_record";if ($FG_DEBUG == 3) echo "<br>Nb_record_max : $nb_record_max";/*******************   TOTAL COSTS  *****************************************/if ($_SESSION["is_admin"]==1){ 				$fields_costs="sum(t1.costs), sum(t1.buycosts),  sum(realduration)";}else{				$fields_costs="sum(t1.costs), sum(t1.buycosts),  sum(duration)";}$instance_table_cost = new Table($FG_TABLE_NAME, $fields_costs);		$total_cost = $instance_table_cost -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, null, null, null, null, null, null);//echo "<br/>".$total_cost[0][0]."-".$total_cost[0][1];/*************************************************************//*******************   REFILL  *****************************************/		//**** GET REFILL BY CUSTOMERS		$QUERY = "SELECT  sum(credit)  from Customer";				if ($_SESSION["is_admin"]==0){ 							$QUERY.=" WHERE IDmanager='".$_SESSION["pr_reseller_ID"]."'";		}elseif (isset($IDmanager)){			$QUERY.=" WHERE IDmanager='".$IDmanager."'";					}				//echo $QUERY ;		$res = $DBHandle -> Execute($QUERY);		if ($res){			$num = $res -> RecordCount( );							for($i=0;$i<$num;$i++)			{						$list_credit [] =$res -> fetchRow();						}		}	   //print_r($list_refill);	    $total_credit=$list_credit[0][0];/*******************   REFILL  *****************************************/		//**** GET REFILL BY CUSTOMERS		$QUERY = "SELECT  t1.IDCust, sum(t3.credit)  from Customer as t1, cc_logrefill as t3  WHERE  t1.IDCust=t3.IDCust AND t3.opt='0' ";		//echo $QUERY ;		if ($_SESSION["is_admin"]==0){ 							$QUERY.=" AND t1.IDmanager='".$_SESSION["pr_reseller_ID"]."'";		}elseif (isset($IDmanager)){			$QUERY.=" AND t1.IDmanager='".$IDmanager."'";					}		$QUERY.=" GROUP BY t1.IDCust";				$res = $DBHandle -> Execute($QUERY);		if ($res){			$num = $res -> RecordCount( );							for($i=0;$i<$num;$i++)			{						$list_refill [] =$res -> fetchRow();						}		}	   //print_r($list_refill);	   $total_refill=0;	   if (is_array($list_refill)){	   		foreach ($list_refill as $refill_records){ 	   			$total_refill+=$refill_records[1];	   		}	   }	   	      	   	   function findkey($refill, $keytofind){	   		if (is_array($refill)){				foreach ($refill as $refill_records){ 					//print_r ($refill_records);					//echo $refill_records[0];					if ($refill_records[0] == $keytofind) return $refill_records[1];													}			}			return 0;				   }/*******************   DISCOUNT  *****************************************/		//**** GET DISCOUNT BY CUSTOMERS				$QUERY = "SELECT  t1.IDCust, sum(t3.credit)  from Customer as t1, cc_logrefill as t3  WHERE  t1.IDCust=t3.IDCust AND t3.opt='1' ";		if ($_SESSION["is_admin"]==0){ 							$QUERY.=" AND t1.IDmanager='".$_SESSION["pr_reseller_ID"]."'";		}elseif (isset($IDmanager)){			$QUERY.=" AND t1.IDmanager='".$IDmanager."'";					}		$QUERY.=" GROUP BY t1.IDCust";				$res = $DBHandle -> Execute($QUERY);		if ($res){			$num = $res -> RecordCount( );							for($i=0;$i<$num;$i++)			{						$list_discount[] =$res -> fetchRow();						}		}	   //print_r($list_discount);	   $total_discount=0;	   if (is_array($list_discount)){	   		foreach ($list_discount as $refill_records){ 	   			$total_discount+=$refill_records[1];	   		}	   }	   	   	   /*******************   SALDO  *****************************************/		//**** GET SALDO BY CUSTOMERS		// select t1.IDCust, t1.AnaCust, t1.credit, SUM(t2.saldo)  from Customer as t1, saldorefill as t2 WHERE t1.IDCust=t2.IDCust GROUP BY t1.IDCust;		$QUERY = "SELECT t1.IDCust, SUM(t2.saldo)  from Customer as t1, saldorefill as t2 WHERE t1.IDCust=t2.IDCust";		if ($_SESSION["is_admin"]==0){ 							$QUERY.=" AND t1.IDmanager='".$_SESSION["pr_reseller_ID"]."'";		}elseif (isset($IDmanager)){			$QUERY.=" AND t1.IDmanager='".$IDmanager."'";					}		$QUERY.=" GROUP BY t1.IDCust";				$res = $DBHandle -> Execute($QUERY);		if ($res){			$num = $res -> RecordCount( );							for($i=0;$i<$num;$i++)			{						$list_saldo [] =$res -> fetchRow();						}		}				$total_saldo=0;	    if (is_array($list_saldo)){	   		foreach ($list_saldo as $refill_records){ 	   			$total_saldo+=$refill_records[1];	   		}	   }/******************* *******************/?><script language="JavaScript" type="text/JavaScript"><!--function MM_openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);}//--></script><?php	include("PP_header.php");?><!-- ** ** ** ** ** Part to display the CDR ** ** ** ** ** --><?php  if (is_array($list) && count($list)>0){  ?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?