call-last-month.php

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

PHP
539
字号
<?phpinclude_once(dirname(__FILE__) . "/../lib/defines.php");include_once(dirname(__FILE__) . "/../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('months_compare', 'current_page', 'fromstatsday_sday', 'fromstatsmonth_sday', 'days_compare', 'min_call', 'posted',  'dsttype', 'srctype', 'clidtype', 'channel', 'resulttype', 'stitle', 'atmenu', 'current_page', 'order', 'sens', 'dst', 'src', 'clid', 'userfieldtype', 'userfield', 'accountcodetype', 'accountcode', 'customer', 'entercustomer', 'enterprovider', 'entertrunk', 'graphtype'));// graphtype = 1, 2, 3  // 1 : traffic// 2 : Profit// 3 : Sells// 4 : Buysif (!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";$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 ("Source", "source", "20%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("CalledNumber"), "calledstation", "15%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix");$FG_TABLE_COL[]=array (gettext("Destination"), "destination", "15%", "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", "7%", "center", "SORT", "30", "", "", "", "", "", "display_minute");$FG_TABLE_COL[]=array (gettext("CardUsed"), "username", "11%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("terminatecause"), "terminatecause", "10%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("IAX/SIP"), "sipiax", "6%", "center", "SORT",  "", "list", $yesno);//$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", "10%", "center", "SORT", "30", "", "", "", "", "", "display_2dec");$FG_TABLE_COL[]=array (gettext("Cost"), "sessionbill", "10%", "center", "SORT", "30", "", "", "", "", "", "display_2bill");// ??? cardID$FG_TABLE_DEFAULT_ORDER = "t1.starttime";$FG_TABLE_DEFAULT_SENS = "DESC";	// This Variable store the argument for the SQL query$FG_COL_QUERY='t1.starttime, t1.calledstation, t1.destination, t1.sessiontime, t1.username, t1.terminatecause, t1.sipiax, t1.calledrate, t1.sessionbill';// t1.stoptime,$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="90%";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 ($_POST['posted']==1){	  function do_field($sql,$fld){  		$fldtype = $fld.'type';		global $$fld;		global $$fldtype;        if (isset($$fld) && ($$fld!='')){                if (strpos($sql,'WHERE') > 0){                        $sql = "$sql AND ";                }else{                        $sql = "$sql WHERE ";                }				$sql = "$sql $fld";				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 = '';  if ($_POST['before']) {    if (strpos($SQLcmd, 'WHERE') > 0) { 	$SQLcmd = "$SQLcmd AND ";    }else{     								$SQLcmd = "$SQLcmd WHERE "; }    $SQLcmd = "$SQLcmd calldate<'".$_POST['before']."'";  }  if ($_POST['after']) {    if (strpos($SQLcmd, 'WHERE') > 0) {      $SQLcmd = "$SQLcmd AND ";  } else {      $SQLcmd = "$SQLcmd WHERE ";    }    $SQLcmd = "$SQLcmd calldate>'".$_POST['after']."'";  }  $SQLcmd = do_field($SQLcmd, 'dst');    }$date_clause='';// Period (Month-Day)if (!isset($months_compare)){			$months_compare=2;}//if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND calldate <= '$fromstatsmonth_sday-$fromstatsday_sday+23' AND calldate >= SUBDATE('$fromstatsmonth_sday-$fromstatsday_sday',INTERVAL $days_compare DAY)";if (DB_TYPE == "postgres"){		if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND t1.starttime < date'$fromstatsmonth_sday-$fromstatsday_sday'+ INTERVAL '1 DAY' AND t1.starttime >= date'$fromstatsmonth_sday-$fromstatsday_sday' - INTERVAL '$days_compare DAY'";}else{	if (isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND t1.starttime < ADDDATE('$fromstatsmonth_sday-$fromstatsday_sday',INTERVAL 1 DAY) AND t1.starttime >= SUBDATE('$fromstatsmonth_sday-$fromstatsday_sday',INTERVAL $days_compare DAY)";  }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 ";		$FG_TABLE_CLAUSE .= "t3.id_provider = '$enterprovider'";	}	if (isset($entertrunk) && $entertrunk > 0) {		if (strlen($FG_TABLE_CLAUSE) > 0) $FG_TABLE_CLAUSE .= " AND ";		$FG_TABLE_CLAUSE .= "t3.id_trunk = '$entertrunk'";	}}if ($FG_DEBUG == 3) echo "<br>$date_clause<br>";  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 ($FG_DEBUG == 3) echo "<br>Clause : $FG_TABLE_CLAUSE";//$nb_record = $instance_table -> Table_count ($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";/*************************************************************/$instance_table_customer = new Table("cc_card", "id,  username, lastname");$FG_TABLE_CLAUSE = "";/*if ($_SESSION["is_admin"]==0){ 		$FG_TABLE_CLAUSE =" IDmanager='".$_SESSION["pr_reseller_ID"]."'";	}*/$list_customer = $instance_table_customer -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, "id", "ASC", null, null, null, null);$nb_customer = count($list_customer);?><?php$smarty->display('main.tpl');?>

⌨️ 快捷键说明

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