call-log-customers.php

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

PHP
1,042
字号
		$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 ($_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"]."'";	}$FG_ASR_CIC_CLAUSE = $FG_TABLE_CLAUSE;//To select just terminatecause=ANSWERif (!isset($terminatecause)){	$terminatecause="ANSWER";}if ($terminatecause=="ANSWER") {	if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND ";	$FG_TABLE_CLAUSE .= " t1.terminatecause='ANSWER' OR t1.terminatecause='ANSWERED' ";}//WORKS! if (!$nodisplay){	$list = $instance_table -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, $order, $sens, null, null, $FG_LIMITE_DISPLAY, $current_page*$FG_LIMITE_DISPLAY);}//echo "<br>--<br>".$FG_TABLE_CLAUSE."<br><br>";$_SESSION["pr_sql_export"]="SELECT $FG_COL_QUERY FROM $FG_TABLE_NAME WHERE $FG_TABLE_CLAUSE";//************************************************************/// calculate nbr of success calls,nbr fail calls, max nbr of fail calls successfally ///************************************************************/$QUERY="CREATE TEMPORARY TABLE ASR_CIC_TEMP AS (SELECT substring(t1.starttime,1,10) AS day,case when t1.terminatecause='ANSWER' then 1 else 0 end as success,case when t1.terminatecause ='ANSWER'  OR t1.terminatecause='ANSWERED' then 0 else 1 end as fail,0 as maxfail FROM $FG_TABLE_NAME WHERE ".$FG_TABLE_CLAUSE." ORDER BY day)";$max_fail=0;$max=0;$total_fail_succ=0;$total_max_succ=0;$update=array();if (!$nodisplay){		$num = 0;		$res = $DBHandle -> Execute($QUERY);		$QUERY="SELECT * FROM ASR_CIC_TEMP order by day";		$res = $DBHandle -> Execute($QUERY);		if ($res)			$num = $res -> RecordCount();		$pos=0;		for($i=0;$i<$num;$i++)		{				$asr_cic_list [] =$res -> fetchRow();			if ($i>0)			{					if ($asr_cic_list[$i][0] == $asr_cic_list[$i-1][0] && $i<$num-1 && $asr_cic_list[$i][2]==1) {					$max++;				}else {					if (($i==$num-1) && ($asr_cic_list[$i][2]==1)) $max++;					if ($max > $max_fail) {						$max_fail=$max;						$asr_cic_list1[$pos][3]=$max_fail;						$max=0;					}					if($asr_cic_list[$i][0] != $asr_cic_list[$i-1][0]){						$pos++;						$success=0; 						$fail=0;						$max_fail=0;					}				}							}elseif($asr_cic_list[$i][2]==1){				$max++;			}			$success+=$asr_cic_list[$i][1]; 			$fail+=$asr_cic_list[$i][2];			$asr_cic_list1[$pos][0] = $asr_cic_list[$i][0];			$asr_cic_list1[$pos][1] = $success; 			$asr_cic_list1[$pos][2] = $fail;			if ($asr_cic_list[$i][2]==1){				$total_fail_succ++;				}elseif($total_fail_succ > $total_max_succ){				$total_max_succ=$total_fail_succ;				$total_fail_succ=0;			}		}}/************************///$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.starttime,1,10) AS day, sum(t1.sessiontime) AS calltime, sum(t1.sessionbill) AS cost, count(*) as nbcall, sum(t1.buycost) AS buy FROM $FG_TABLE_NAME WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(t1.starttime,1,10) ORDER BY day"; //extract(DAY from calldate) if (!$nodisplay){		$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);if ($FG_DEBUG >= 1) var_dump ($list);}//end IF nodisplayif ($nb_record<=$FG_LIMITE_DISPLAY){ 	$nb_record_max=1;}else{ 	if ($nb_record % $FG_LIMITE_DISPLAY == 0){		$nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY));	}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  *****************************************$instance_table_cost = new Table($FG_TABLE_NAME, "sum(t1.costs), sum(t1.buycosts)");		if (!$nodisplay){		$total_cost = $instance_table_cost -> Get_list ($DBHandle, $FG_TABLE_CLAUSE, null, null, null, null, null, null);}*//*************************************************************/$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=1&t=0&order=<?php echo $order?>&sens=<?php echo $sens?>&current_page=<?php echo $current_page?>">	<INPUT TYPE="hidden" NAME="posted" value=1>	<INPUT TYPE="hidden" NAME="current_page" value=0>			<table class="bar-status" width="85%" border="0" cellspacing="1" cellpadding="2" align="center">			<tbody>			<?php  if ($_SESSION["pr_groupID"]==2 && is_numeric($_SESSION["pr_IDCust"])){ ?>			<?php  }else{ ?>			<tr>				<td align="left" valign="top" class="bgcolor_004">										<font class="fontstyle_003">&nbsp;&nbsp;<?php echo gettext("CUSTOMERS");?></font>				</td>								<td class="bgcolor_005" align="left">				<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>					<td class="fontstyle_searchoptions">						<?php echo gettext("Enter the cardnumber");?>: <INPUT TYPE="text" NAME="entercustomer" value="<?php echo $entercustomer?>" class="form_input_text">						<a href="#" onclick="window.open('A2B_entity_card.php?popup_select=2&popup_formname=myForm&popup_fieldname=entercustomer' , 'CardNumberSelection','scrollbars=1,width=550,height=330,top=20,left=100,scrollbars=1');"><img src="<?php echo Images_Path;?>/icon_arrow_orange.gif"></a>					</td>					<td align="right" class="fontstyle_searchoptions">						<?php echo gettext("Provider");?>: <INPUT TYPE="text" NAME="enterprovider" value="<?php echo $enterprovider?>" size="4" class="form_input_text">						<a href="#" onclick="window.open('A2B_entity_provider.php?popup_select=2&popup_formname=myForm&popup_fieldname=enterprovider' , 'ProviderSelection','scrollbars=1,width=550,height=330,top=20,left=100,scrollbars=1');"><img src="<?php echo Images_Path;?>/icon_arrow_orange.gif"></a>						<?php echo gettext("Trunk");?>: <INPUT TYPE="text" NAME="entertrunk" value="<?php echo $entertrunk?>" size="4" class="form_input_text">						<a href="#" onclick="window.open('A2B_entity_trunk.php?popup_select=2&popup_formname=myForm&popup_fieldname=entertrunk' , 'TrunkSelection','scrollbars=1,width=550,height=330,top=20,left=100');"><img src="<?php echo Images_Path;?>/icon_arrow_orange.gif"></a>					</td>				</tr></table></td>			</tr>						<?php  }?>			<tr>        		<td class="bgcolor_002" align="left">					<input type="radio" name="Period" value="Month" <?php  if (($Period=="Month") || !isset($Period)){ ?>checked="checked" <?php  } ?>> 					<font class="fontstyle_003"><?php echo gettext("SELECT MONTH");?></font>				</td>      			<td class="bgcolor_003" align="left">					<table width="100%" border="0" cellspacing="0" cellpadding="0">					<tr><td class="fontstyle_searchoptions">	  				<input type="checkbox" name="frommonth" value="true" <?php  if ($frommonth){ ?>checked<?php }?>>					<?php echo gettext("From");?> : <select name="fromstatsmonth" class="form_input_select">					<?php						$monthname = array( gettext("January"), gettext("February"),gettext("March"), gettext("April"), gettext("May"), gettext("June"), gettext("July"), gettext("August"), gettext("September"), gettext("October"), gettext("November"), gettext("December"));						$year_actual = date("Y");  							for ($i=$year_actual;$i >= $year_actual-1;$i--)						{		   						   if ($year_actual==$i){							$monthnumber = date("n")-1; // Month number without lead 0.						   }else{							$monthnumber=11;						   }		   						   for ($j=$monthnumber;$j>=0;$j--){								$month_formated = sprintf("%02d",$j+1);				   			if ($fromstatsmonth=="$i-$month_formated")	$selected="selected";							else $selected="";							echo "<OPTION value=\"$i-$month_formated\" $selected> $monthname[$j]-$i </option>";										   }						}					?>							</select>					</td><td  class="fontstyle_searchoptions">&nbsp;&nbsp;					<input type="checkbox" name="tomonth" value="true" <?php  if ($tomonth){ ?>checked<?php }?>> 					<?php echo gettext("To");?> : <select name="tostatsmonth" class="form_input_select">					<?php 	$year_actual = date("Y");  							for ($i=$year_actual;$i >= $year_actual-1;$i--)						{		   						   if ($year_actual==$i){							$monthnumber = date("n")-1; // Month number without lead 0.						   }else{							$monthnumber=11;						   }		   						   for ($j=$monthnumber;$j>=0;$j--){								$month_formated = sprintf("%02d",$j+1);				   			if ($tostatsmonth=="$i-$month_formated") $selected="selected";							else $selected="";							echo "<OPTION value=\"$i-$month_formated\" $selected> $monthname[$j]-$i </option>";										   }						}					?>					</select>					</td></tr></table>	  			</td>    		</tr>						<tr>        		<td align="left" class="bgcolor_004">					<input type="radio" name="Period" value="Day" <?php  if ($Period=="Day"){ ?>checked="checked" <?php  } ?>> 					<font class="fontstyle_003"><?php echo gettext("SELECT DAY");?></font>				</td>      			<td align="left" class="bgcolor_005">					<table width="100%" border="0" cellspacing="0" cellpadding="0">

⌨️ 快捷键说明

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