a2b_detail_package.php
来自「asterisk用 的voip记费软件」· PHP 代码 · 共 786 行 · 第 1/3 页
PHP
786 行
<?phpinclude ("../lib/defines.php");include ("../lib/module.access.php");include ("../lib/smarty.php");if (! has_rights (ACX_PACKAGEOFFER)){ Header ("HTTP/1.0 401 Unauthorized"); Header ("Location: PP_error.php?c=accessdenied"); die(); }getpost_ifset(array('customer', 'enter_cardid', 'enter_packageid', 'posted', 'Period', 'frommonth', 'fromstatsmonth', 'tomonth', 'tostatsmonth', 'fromday', 'fromstatsday_sday', 'fromstatsmonth_sday', 'today', 'tostatsday_sday', 'tostatsmonth_sday', 'stitle', 'atmenu', 'current_page', 'order', 'sens'));if (($_GET[download]=="file") && $_GET[file] ) { $value_de=base64_decode($_GET[file]); $dl_full = MONITOR_PATH."/".$value_de; $dl_name=$value_de; if (!file_exists($dl_full)) { echo gettext("ERROR: Cannot download file")." ".$dl_full.", ".gettext("it does not exist.")."<br>"; exit(); } header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$dl_name"); header("Content-Length: ".filesize($dl_full)); header("Accept-Ranges: bytes"); header("Pragma: no-cache"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-transfer-encoding: binary"); @readfile($dl_full); exit();}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_card_package_offer t1 ";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";$yesno = array(); $yesno["1"] = array( "Yes", "1"); $yesno["0"] = array( "No", "0");//$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("Date"), "date_consumption", "15%", "center", "SORT", "19", "", "", "", "", "", "display_dateformat");$FG_TABLE_COL[]=array (gettext("CARDID"), "id_cc_card", "15%", "center", "SORT", "30");$FG_TABLE_COL[]=array (gettext("CARDNUMBER"), "id_cc_card", "20%", "center", "sort", "15", "lie", "cc_card", "username", "id='%id'", "%1");$FG_TABLE_COL[]=array (gettext("PACKAGE"), "id_cc_package_offer", "20%", "center", "sort", "15", "lie", "cc_package_offer", "label", "id='%id'", "%1");$FG_TABLE_COL[]=array (gettext("USED MINUTES"), "used_secondes", "20%", "center", "SORT", "30", "", "", "", "", "", "display_minute");$FG_TABLE_COL[]=array (gettext("NB PERFORMED"), "nbperf", "15%", "center", "SORT", "30");// ??? cardID$FG_TABLE_DEFAULT_ORDER = "t1.date_consumption";$FG_TABLE_DEFAULT_SENS = "DESC"; // This Variable store the argument for the SQL query//$FG_COL_QUERY='t1.date_consumption, t1.id_cc_card, t1.id_cc_card, t1.id_cc_package_offer';$FG_COL_QUERY=' t1.id_cc_card, t1.id_cc_card, t1.id_cc_package_offer, sum(t1.used_secondes) AS used_secondes, count(*) as nbperf ';// 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(" - Package Infos - ");//This variable define the width of the HTML table$FG_HTML_TABLE_WIDTH="85%"; 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 = ''; }$date_clause='';// Period (Month-Day)if (DB_TYPE == "postgres"){ $UNIX_TIMESTAMP = "";}else{ $UNIX_TIMESTAMP = "UNIX_TIMESTAMP";}$lastdayofmonth = date("t", strtotime($tostatsmonth.'-01'));if ($Period=="Month"){ if ($frommonth && isset($fromstatsmonth)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.date_consumption) >= $UNIX_TIMESTAMP('$fromstatsmonth-01')"; if ($tomonth && isset($tostatsmonth)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.date_consumption) <= $UNIX_TIMESTAMP('".$tostatsmonth."-$lastdayofmonth 23:59:59')"; }else{ if ($fromday && isset($fromstatsday_sday) && isset($fromstatsmonth_sday)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.date_consumption) >= $UNIX_TIMESTAMP('$fromstatsmonth_sday-$fromstatsday_sday')"; if ($today && isset($tostatsday_sday) && isset($tostatsmonth_sday)) $date_clause.=" AND $UNIX_TIMESTAMP(t1.date_consumption) <= $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-%02d",date("Y"),date("n"),date("d")); $FG_TABLE_CLAUSE=" $UNIX_TIMESTAMP(t1.date_consumption) >= $UNIX_TIMESTAMP('$cc_yearmonth')";}if (isset($customer) && ($customer>0)){ if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND "; $FG_TABLE_CLAUSE.="t1.id_cc_card='$customer'";}else{ if (isset($enter_cardid) && ($enter_cardid>0)){ if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND "; $FG_TABLE_CLAUSE.="t1.id_cc_card='$enter_cardid'"; }}if (isset($enter_packageid) && ($enter_packageid>0)){ if (strlen($FG_TABLE_CLAUSE)>0) $FG_TABLE_CLAUSE.=" AND "; $FG_TABLE_CLAUSE.="t1.id_cc_package_offer='$enter_packageid'";}$FG_TABLE_CLAUSE_GROUP = $FG_TABLE_CLAUSE." GROUP BY t1.id_cc_card, t1.id_cc_package_offer ";//WORKS! if (!$nodisplay){ $list = $instance_table -> Get_list ($DBHandle, $FG_TABLE_CLAUSE_GROUP, null, null, 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_GROUP";/************************///$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.date_consumption,1,10) AS day, sum(t1.used_secondes) AS used_secondes, count(*) as nbperf FROM $FG_TABLE_NAME WHERE ".$FG_TABLE_CLAUSE." GROUP BY substring(t1.date_consumption,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){
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?