call-log-customers.php

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

PHP
1,042
字号
<?phpinclude ("../lib/defines.php");include ("../lib/module.access.php");include ("../lib/smarty.php");if (! has_rights (ACX_CALL_REPORT)){ 	Header ("HTTP/1.0 401 Unauthorized");	Header ("Location: PP_error.php?c=accessdenied");	   	die();}getpost_ifset(array('customer', 'entercustomer', 'enterprovider', 'entertrunk', 'posted', 'Period', 'frommonth', 'fromstatsmonth', 'tomonth', 'tostatsmonth', 'fromday', 'fromstatsday_sday', 'fromstatsmonth_sday', 'today', 'tostatsday_sday', 'tostatsmonth_sday', 'dsttype', 'srctype', 'clidtype', 'channel', 'resulttype', 'stitle', 'atmenu', 'current_page', 'order', 'sens', 'dst', 'src', 'clid', 'choose_currency', 'terminatecause'));if (($_GET[download]=="file") && $_GET[file] ) {		$value_de=base64_decode($_GET[file]);	$dl_full = MONITOR_PATH."/".$value_de;	$dl_name=$value_de;	if (!file_exists($dl_full))	{ 		echo gettext("ERROR: Cannot download file ".$dl_full.", it does not exist.<br>");		exit();	} 		header("Content-Type: application/octet-stream");	header("Content-Disposition: attachment; filename=$dl_name");	header("Content-Length: ".filesize($dl_full));	header("Accept-Ranges: bytes");	header("Pragma: no-cache");	header("Expires: 0");	header("Cache-Control: must-revalidate, post-check=0, pre-check=0");	header("Content-transfer-encoding: binary");				@readfile($dl_full);	exit();}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="cc_call t1 LEFT OUTER JOIN cc_trunk t3 ON t1.id_trunk = t3.id_trunk";if ($_SESSION["is_admin"]==0){ 	$FG_TABLE_NAME.=", cc_card 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";$yesno = array(); 	$yesno["1"]  = array( "Yes", "1");	 $yesno["0"]  = array( "No", "0");// 0 = NORMAL CALL ; 1 = VOIP CALL (SIP/IAX) ; 2= DIDCALL + TRUNK ; 3 = VOIP CALL DID ; 4 = CALLBACK call$list_calltype = array(); 	$list_calltype["0"]  = array( "STANDARD", "0");	 $list_calltype["1"]  = array( "SIP/IAX", "1");$list_calltype["2"]  = array( "DIDCALL", "2"); $list_calltype["3"]  = array( "DID_VOIP", "3"); $list_calltype["4"]  = array( "CALLBACK", "4");$list_calltype["5"]  = array( "PREDICT", "5");//$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("Calldate"), "starttime", "15%", "center", "SORT", "19", "", "", "", "", "", "display_dateformat");//$FG_TABLE_COL[]=array ("Callend", "stoptime", "15%", "center", "SORT", "19");$FG_TABLE_COL[]=array (gettext("Source"), "src", "7%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("CalledNumber"), "calledstation", "10%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix");$FG_TABLE_COL[]=array (gettext("Destination"), "destination", "10%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix");//$FG_TABLE_COL[]=array ("Country",  "calledcountry", "10%", "center", "SORT", "30", "lie", "country", "countryname", "countrycode='%id'", "%1");//$FG_TABLE_COL[]=array ("Site", "site_id", "7%", "center", "sort", "15", "lie", "site", "name", "id='%id'", "%1");$FG_TABLE_COL[]=array (gettext("Duration"), "sessiontime", "6%", "center", "SORT", "30", "", "", "", "", "", "display_minute");$FG_TABLE_COL[]=array (gettext("CardUsed"), "username", "6%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("Trunk"), "trunkcode", "6%", "center", "SORT", "30");$FG_TABLE_COL[]=array ('<acronym title="'.gettext("Terminate Cause").'">'.gettext("TC").'</acronym>', "terminatecause", "7%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("Calltype"), "sipiax", "6%", "center", "SORT",  "", "list", $list_calltype);//$FG_TABLE_COL[]=array ("DestID", "destID", "12%", "center", "SORT", "30");//if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Con_charg", "connectcharge", "12%", "center", "SORT", "30");//if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Dis_charg", "disconnectcharge", "12%", "center", "SORT", "30");//if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Sec/mn", "secpermin", "12%", "center", "SORT", "30");//if ($_SESSION["is_admin"]==1) $FG_TABLE_COL[]=array ("Buycosts", "buycosts", "12%", "center", "SORT", "30");//$FG_TABLE_COL[]=array (gettext("InitialRate"), "calledrate", "7%", "center", "SORT", "30", "", "", "", "", "", "display_2dec");$FG_TABLE_COL[]=array (gettext("Buy"), "buycost", "8%", "center", "SORT", "30", "", "", "", "", "", "display_2bill");$FG_TABLE_COL[]=array (gettext("Sell"), "sessionbill", "8%", "center", "SORT", "30", "", "", "", "", "", "display_2bill");$FG_TABLE_COL[]=array (gettext("Margin"), "margin", "7%", "center", "SORT", "30", "", "", "", "", "", "display_2dec_percentage");$FG_TABLE_COL[]=array (gettext("Markup"), "markup", "7%", "center", "SORT", "30", "", "", "", "", "", "display_2dec_percentage");if (LINK_AUDIO_FILE)	$FG_TABLE_COL[]=array ("", "uniqueid", "1%", "center", "", "30", "", "", "", "", "", "linkonmonitorfile");// ??? cardID$FG_TABLE_DEFAULT_ORDER = "t1.starttime";$FG_TABLE_DEFAULT_SENS = "DESC";	// This Variable store the argument for the SQL query// t1.calledrate,$FG_COL_QUERY='t1.starttime, t1.src, t1.calledstation, t1.destination, t1.sessiontime, t1.username, t3.trunkcode, t1.terminatecause, t1.sipiax, t1.buycost, t1.sessionbill, case when t1.sessionbill!=0 then ((t1.sessionbill-t1.buycost)/t1.sessionbill)*100 else NULL end as margin,case when t1.buycost!=0 then ((t1.sessionbill-t1.buycost)/t1.buycost)*100 else NULL end as markup';// t1.stoptime,if (LINK_AUDIO_FILE) 	$FG_COL_QUERY .= ', t1.uniqueid';$FG_COL_QUERY_GRAPH='t1.callstart, t1.duration';// The variable LIMITE_DISPLAY define the limit of record to display by page$FG_LIMITE_DISPLAY=25;// 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=gettext(" - Call Logs - ");//This variable define the width of the HTML table$FG_HTML_TABLE_WIDTH="98%";	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;}if ($posted==1){    function do_field($sql,$fld,$dbfld){  		$fldtype = $fld.'type';		global $$fld;		global $$fldtype;		        if ($$fld){                if (strpos($sql,'WHERE') > 0){                        $sql = "$sql AND ";                }else{                        $sql = "$sql WHERE ";                }				$sql = "$sql t1.$dbfld";				if (isset ($$fldtype)){                                        switch ($$fldtype) {							case 1:	$sql = "$sql='".$$fld."'";  break;							case 2: $sql = "$sql LIKE '".$$fld."%'";  break;							case 3: $sql = "$sql LIKE '%".$$fld."%'";  break;							case 4: $sql = "$sql LIKE '%".$$fld."'";						}                }else{ $sql = "$sql LIKE '%".$$fld."%'"; }		}        return $sql;  }    $SQLcmd = '';  $SQLcmd = do_field($SQLcmd, 'src', 'src');  $SQLcmd = do_field($SQLcmd, 'dst', 'calledstation');	  }$date_clause='';// Period (Month-Day)if (DB_TYPE == "postgres"){			 	$UNIX_TIMESTAMP = "";}else{		$UNIX_TIMESTAMP = "UNIX_TIMESTAMP";}$lastdayofmonth = date("t", strtotime($tostatsmonth.'-01'));if ($Period=="Month"){	if ($frommonth && isset($fromstatsmonth)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.starttime) >= $UNIX_TIMESTAMP('$fromstatsmonth-01')";	if ($tomonth && isset($tostatsmonth)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.starttime) <= $UNIX_TIMESTAMP('".$tostatsmonth."-$lastdayofmonth 23:59:59')"; }else{	if ($fromday && isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.starttime) >= $UNIX_TIMESTAMP('$fromstatsmonth_sday-$fromstatsday_sday')";	if ($today && isset($tostatsday_sday) && isset($tostatsmonth_sday)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.starttime) <= $UNIX_TIMESTAMP('$tostatsmonth_sday-".sprintf("%02d",intval($tostatsday_sday)/*+1*/)." 23:59:59')";}//echo "<br>$date_clause<br>";/*Monthfromday todayfrommonth tomonth (true)fromstatsmonth tostatsmonthfromstatsday_sdayfromstatsmonth_sdaytostatsday_sdaytostatsmonth_sday*/  if (strpos($SQLcmd, 'WHERE') > 0) { 	$FG_TABLE_CLAUSE = substr($SQLcmd,6).$date_clause; }elseif (strpos($date_clause, 'AND') > 0){	$FG_TABLE_CLAUSE = substr($date_clause,5); }if (!isset ($FG_TABLE_CLAUSE) || strlen($FG_TABLE_CLAUSE)==0){				$cc_yearmonth = sprintf("%04d-%02d-%02d",date("Y"),date("n"),date("d"));		$FG_TABLE_CLAUSE=" $UNIX_TIMESTAMP(t1.starttime) >= $UNIX_TIMESTAMP('$cc_yearmonth')";}if (isset($customer)  &&  ($customer>0)){	if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND ";	$FG_TABLE_CLAUSE.="t1.username='$customer'";}else{	if (isset($entercustomer)  &&  ($entercustomer>0)){		if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND ";		$FG_TABLE_CLAUSE.="t1.username='$entercustomer'";	}}if ($_SESSION["is_admin"] == 1){	if (isset($enterprovider) && $enterprovider > 0) {		if (strlen($FG_TABLE_CLAUSE) > 0) $FG_TABLE_CLAUSE .= " AND ";

⌨️ 快捷键说明

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