📄 call-log.php
字号:
<?php /* $Id: call-log.php 926 2006-02-17 13:31:58Z qldrob $ */include_once(dirname(__FILE__) . "/lib/defines.php");include_once(dirname(__FILE__) . "/lib/Class.Table.php");// correct 31 +1 = 32 for the date//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', 'userfieldtype', 'userfield', 'accountcodetype', 'accountcode', 'duration1', 'duration1type', 'duration2', 'duration2type'));//echo "'posted=$posted', 'Period=$Period', 'frommonth=$frommonth', 'fromstatsmonth=$fromstatsmonth', 'tomonth=$tomonth', 'tostatsmonth=$tostatsmonth', 'fromday=$fromday', 'fromstatsday_sday=$fromstatsday_sday', 'fromstatsmonth_sday=$fromstatsmonth_sday', 'today=$today', 'tostatsday_sday=$tostatsday_sday', 'tostatsmonth_sday=$tostatsmonth_sday', 'dsttype=$dsttype', 'sourcetype=$sourcetype', 'clidtype=$clidtype', 'channel=$channel', 'resulttype=$resulttype', 'stitle=$stitle', 'atmenu=$atmenu', 'current_page=$current_page', 'order=$order', 'sens=$sens', 'dst=$dst', 'src=$src', 'clid=$clid', 'userfieldtype=$userfieldtype', 'userfield=$userfield', 'accountcodetype=$accountcodetype', 'accountcode=$accountcode', 'duration1=$duration1', 'duration1type=$duration1type', 'duration2=$duration2', 'duration2type=$duration2type'"; 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=DB_TABLENAME;// 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*******//* --original--$FG_TABLE_COL[]=array ("Calldate", "calldate", "18%", "center", "SORT", "19");$FG_TABLE_COL[]=array ("Channel", "channel", "13%", "center", "", "30", "", "", "", "", "", "display_acronym");$FG_TABLE_COL[]=array ("Source", "src", "10%", "center", "", "30");$FG_TABLE_COL[]=array ("Clid", "clid", "12%", "center", "", "30");$FG_TABLE_COL[]=array ("Lastapp", "lastapp", "8%", "center", "", "30");$FG_TABLE_COL[]=array ("Lastdata", "lastdata", "12%", "center", "", "30");$FG_TABLE_COL[]=array ("Dst", "dst", "9%", "center", "SORT", "30");$FG_TABLE_COL[]=array ("APP", "dst", "9%", "center", "", "30","list", $appli_list);//$FG_TABLE_COL[]=array ("Serverid", "serverid", "7%", "center", "", "30");$FG_TABLE_COL[]=array ("Disposition", "disposition", "9%", "center", "", "30");if ((!isset($resulttype)) || ($resulttype=="min")) $minute_function= "display_minute";$FG_TABLE_COL[]=array ("Duration", "duration", "6%", "center", "SORT", "30", "", "", "", "", "", "$minute_function");$FG_TABLE_COL[]=array ("Userfield", "userfield", "8%", "center", "", "20");$FG_TABLE_COL[]=array ("Accountcode", "accountcode", "8%", "center", "", "20");$FG_TABLE_DEFAULT_ORDER = "calldate";$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';*//* --AMP Begin-- */$FG_TABLE_COL[]=array ("Calldate", "calldate", "18%", "center", "SORT", "19");$FG_TABLE_COL[]=array ("Channel", "channel", "13%", "center", "", "30", "", "", "", "", "", "display_acronym");$FG_TABLE_COL[]=array ("Source", "src", "14%", "center", "", "30");$FG_TABLE_COL[]=array ("Clid", "clid", "26%", "center", "", "30");$FG_TABLE_COL[]=array ("Dst", "dst", "14%", "center", "SORT", "30");$FG_TABLE_COL[]=array ("Disposition", "disposition", "9%", "center", "", "30");if ((!isset($resulttype)) || ($resulttype=="min")) $minute_function= "display_minute";$FG_TABLE_COL[]=array ("Duration", "duration", "6%", "center", "SORT", "30", "", "", "", "", "", "$minute_function");$FG_TABLE_DEFAULT_ORDER = "calldate";$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, dst, disposition, duration';/* --AMP End -- */$FG_COL_QUERY_GRAPH='calldate, 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=" - Call Logs - ";//This variable define the width of the HTML table$FG_HTML_TABLE_WIDTH="100%";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_duration($sql,$fld, $fldsql){ $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 $fldsql"; if (isset ($$fldtype)){ switch ($$fldtype) { case 1: $sql = "$sql ='".$$fld."'"; break; case 2: $sql = "$sql <= '".$$fld."'"; break; case 3: $sql = "$sql < '".$$fld."'"; break; case 4: $sql = "$sql > '".$$fld."'"; break; case 5: $sql = "$sql >= '".$$fld."'"; break; } }else{ $sql = "$sql = '".$$fld."'"; } } return $sql; } 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 = ''; $SQLcmd = do_field($SQLcmd, 'clid'); $SQLcmd = do_field($SQLcmd, 'src'); $SQLcmd = do_field($SQLcmd, 'dst'); $SQLcmd = do_field($SQLcmd, 'userfield'); $SQLcmd = do_field($SQLcmd, 'accountcode'); $SQLcmd = do_field($SQLcmd, 'channel'); $SQLcmd = do_field_duration($SQLcmd, 'duration1', 'duration'); $SQLcmd = do_field_duration($SQLcmd, 'duration2', 'duration'); }$date_clause='';// Period (Month-Day)if (DB_TYPE == "postgres"){ $UNIX_TIMESTAMP = "";}else{ $UNIX_TIMESTAMP = "UNIX_TIMESTAMP";}if ($Period=="Month"){ if ($frommonth && isset($fromstatsmonth)) $date_clause.=" AND $UNIX_TIMESTAMP(calldate) >= $UNIX_TIMESTAMP('$fromstatsmonth-01')"; if ($tomonth && isset($tostatsmonth)) $date_clause.=" AND $UNIX_TIMESTAMP(calldate) <= $UNIX_TIMESTAMP('$tostatsmonth-31 23:59:59')";}else{ if ($fromday && isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND $UNIX_TIMESTAMP(calldate) >= $UNIX_TIMESTAMP('$fromstatsmonth_sday-$fromstatsday_sday')"; if ($today && isset($tostatsday_sday) && isset($tostatsmonth_sday)) $date_clause.=" AND $UNIX_TIMESTAMP(calldate) <= $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",date("Y"),date("n")); $FG_TABLE_CLAUSE=" $UNIX_TIMESTAMP(calldate) >= $UNIX_TIMESTAMP('$cc_yearmonth-01')";}//--$list_total = $instance_table_graph -> Get_list ($FG_TABLE_CLAUSE, null, null, null, null, null, null);if ($posted==1){ /* --AMP BEGIN-- */ //enforce restrictions for this AMP User $FG_TABLE_CLAUSE .= $AMP_CLAUSE; /* --AMP END-- */ //> 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 ($FG_TABLE_CLAUSE, $order, $sens, null, null, $FG_LIMITE_DISPLAY, $current_page*$FG_LIMITE_DISPLAY); $_SESSION["pr_sql_export"]="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) //echo "$QUERY"; $res = $DBHandle -> query($QUERY); $num = $DBHandle -> num_rows(); for($i=0;$i<$num;$i++) { $DBHandle -> next_record(); $list_total_day [] =$DBHandle -> Record; } 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{ if ($nb_record % $FG_LIMITE_DISPLAY == 0){ $nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)); }else{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -