config["webcustomerui"]['cdr']) exit(); //require (LANGUAGE_DIR.FILENAME_BALANCE); $QUERY = "SELECT username, credit, lastname, firstname, address, city, state, country, zipcode, phone, email, fax, lastuse, activated FROM cc_card WHERE username = '".$_SESSION["pr_login"]."' AND uipass = '".$_SESSION["pr_password"]."'"; $DBHandle_max = DbConnect(); $resmax = $DBHandle_max -> query($QUERY); $numrow = $resmax -> numRows(); if ($numrow == 0) exit(); $customer_info =$resmax -> fetchRow(); if( $customer_info [13] != "t" && $customer_info [13] != "1" ) { exit(); } $customer = $_SESSION["pr_login"]; 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', 'choose_currency', 'terminatecause')); 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"; // 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 ("Source", "source", "9%", "center", "SORT", "30"); $FG_TABLE_COL[]=array (gettext("CardNumber"), "calledstation", "15%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix"); $FG_TABLE_COL[]=array (gettext("Destination"), "destination", "15%", "center", "SORT", "30", "", "", "", "", "", "remove_prefix"); $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("terminate cause"), "terminatecause", "10%", "center", "SORT", "30"); $FG_TABLE_COL[]=array (gettext("Calltype"), "sipiax", "6%", "center", "SORT", "", "list", $list_calltype); //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("InitalRate"), "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'; $FG_COL_QUERY='t1.starttime, t1.src, 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="82%"; if ($FG_DEBUG == 3) echo "
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', 'source'); $SQLcmd = do_field($SQLcmd, 'dst', 'calledstation'); } $date_clause=''; // Period (Month-Day) if (DB_TYPE == "postgres"){ $UNIX_TIMESTAMP = ""; }else{ $UNIX_TIMESTAMP = "UNIX_TIMESTAMP"; } if ($Period=="Month"){ //list($ccyear, $ccmonth) = split ('-', $tostatsmonth); //$ccmonth++; //$tostatsmonth_plus1 = "$ccyear-$ccmonth"; 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."-31 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)."')"; } //echo "
$date_clause
"; /* Month fromday today frommonth tomonth (true) fromstatsmonth tostatsmonth fromstatsday_sday fromstatsmonth_sday tostatsday_sday tostatsmonth_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'"; } } //To select just terminatecause=ANSWER if (!isset($terminatecause)){ $terminatecause="ANSWER"; } if ($terminatecause=="ANSWER") { if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND "; $FG_TABLE_CLAUSE.="t1.terminatecause='$terminatecause'"; } //WORKS! if (!$nodisplay){ $list = $instance_table -> Get_list ($DBHandle, $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) $QUERY = "SELECT substring(t1.starttime,1,10) AS day, sum(t1.sessiontime) AS calltime, sum(t1.sessionbill) AS cost, count(*) as nbcall 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 -> query($QUERY); $num = $res -> numRows(); for($i=0;$i<$num;$i++) { $list_total_day [] =$res -> fetchRow(); } if ($FG_DEBUG == 3) echo "
Clause : $FG_TABLE_CLAUSE"; $nb_record = $instance_table -> Table_count ($DBHandle, $FG_TABLE_CLAUSE); if ($FG_DEBUG >= 1) var_dump ($list); }//end IF nodisplay 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{ $nb_record_max=(intval($nb_record/$FG_LIMITE_DISPLAY)+1); } } if ($FG_DEBUG == 3) echo "
Nb_record : $nb_record"; if ($FG_DEBUG == 3) echo "
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); } */ /*************************************************************/ ?>
'.$CC_help_balance_customer; ?>
checked="checked" >
checked> :    checked> :


: 0){ echo $nb_record; }else{echo "0";}?>
Back to Top
0){ for($i=0;$i<$FG_NB_TABLE_COL;$i++){ ?> Get_list ($DBHandle, $sub_clause, null, null, null, null, null, null); $field_list_sun = split(',',$FG_TABLE_COL[$i][8]); $record_display = $FG_TABLE_COL[$i][10]; for ($l=1;$l<=count($field_list_sun);$l++){ $record_display = str_replace("%$l", $select_list[0][$l-1], $record_display); } }elseif ($FG_TABLE_COL[$i][6]=="list"){ $select_list = $FG_TABLE_COL[$i][7]; $record_display = $select_list[$recordset[$i]][0]; }else{ $record_display = $recordset[$i]; } if ( is_numeric($FG_TABLE_COL[$i][5]) && (strlen($record_display) > $FG_TABLE_COL[$i][5]) ){ $record_display = substr($record_display, 0, $FG_TABLE_COL[$i][5]-3).""; } ?>
">    
height=1>
1){ call_user_func($FG_TABLE_COL[$i][11], $record_display); }else{ echo stripslashes($record_display); } ?>
   
>
>
0){?> "> - / - ">
0 && 3==4){ ?>




0){ $mmax=0; $totalcall==0; $totalminutes=0; foreach ($list_total_day as $data){ if ($mmax < $data[1]) $mmax=$data[1]; $totalcall+=$data[3]; $totalminutes+=$data[1]; $totalcost+=$data[2]; } ?>
0) $widthbar= intval(($data[1]/$mmax)*200); //bgcolor="#336699" ?>
ACT");?>

.