call-comp.php

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

PHP
600
字号
<?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('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'));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";// 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("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.starttime, t1.sessiontime, t1.sessionbill-t1.buycost as profit, t1.sessionbill, t1.buycost';// 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=" - 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 ($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');  if ($_POST['before']) {    if (strpos($SQLcmd, 'WHERE') > 0) { 	$SQLcmd = "$SQLcmd AND ";    }else{     								$SQLcmd = "$SQLcmd WHERE "; }    $SQLcmd = "$SQLcmd starttime <'".$_POST['before']."'";  }  if ($_POST['after']) {    if (strpos($SQLcmd, 'WHERE') > 0) {      $SQLcmd = "$SQLcmd AND ";  } else {      $SQLcmd = "$SQLcmd WHERE ";    }    $SQLcmd = "$SQLcmd starttime >'".$_POST['after']."'";  }    }//echo "SQLcmd:$SQLcmd<br>";$date_clause='';// Period (Month-Day)if (!isset($fromstatsday_sday)){		$fromstatsday_sday = date("d");	$fromstatsmonth_sday = date("Y-m");	}if (!isset($days_compare)){			$days_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 ($FG_DEBUG == 3) echo "<br> date_clause $date_clause<br>";if (isset($customer)  &&  ($customer>0)){	if (strlen($SQLcmd)>0) $SQLcmd.=" AND ";	else $SQLcmd.=" WHERE ";	$SQLcmd.=" username='$customer' ";}else{	if (isset($entercustomer)  &&  ($entercustomer>0)){		if (strlen($SQLcmd)>0) $SQLcmd.=" AND ";		else $SQLcmd.=" WHERE ";		$SQLcmd.=" username='$entercustomer' ";	}}if ($_SESSION["is_admin"] == 1){        if (isset($enterprovider) && $enterprovider > 0) {		if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE ";		$SQLcmd .= " t3.id_provider = '$enterprovider' ";        }        if (isset($entertrunk) && $entertrunk > 0) {		if (strlen($SQLcmd) > 0) $SQLcmd .= " AND "; else $SQLcmd .= " WHERE ";		$SQLcmd .= " t3.id_trunk = '$entertrunk' ";        }}  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 ($_POST['posted']==1){	$list = $instance_table -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, $order, $sens, null, null, $FG_LIMITE_DISPLAY, $current_page*$FG_LIMITE_DISPLAY);		$list_total = $instance_table_graph -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, null, null, null, null, null, null);}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');?><script language="JavaScript" type="text/JavaScript"><!--function MM_openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);}//--></script><!-- ** ** ** ** ** Part for the research ** ** ** ** ** -->	<center>	<FORM METHOD=POST name="myForm" ACTION="<?php echo $PHP_SELF?>?s=<?php echo $s?>&t=<?php echo $t?>&order=<?php echo $order?>&sens=<?php echo $sens?>&current_page=<?php echo $current_page?>">	<INPUT TYPE="hidden" NAME="posted" value=1>		<table class="bar-status" width="80%" border="0" cellspacing="1" cellpadding="2" align="center">			<tbody>			<tr>				<td align="left" valign="top"  class="bgcolor_004">										<font  class="fontstyle_003">&nbsp;&nbsp;<?php echo gettext("CUSTOMERS");?></font>				</td>				<td align="left" class="bgcolor_005">

⌨️ 快捷键说明

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