0; $i --) { $tmp[$i] = $time % $fixStep[$i]; $time = intval($time / $fixStep[$i]); if($tmp[$i] < 10) $tmp[$i] = "0".$tmp[$i]; } $tmp[0] = $time; if($tmp[0] < 10) $tmp[0] = "0".$tmp[0]; $flag = false; for($i = 0; $i <= $num; $i ++) { if($tmp[$i] || $flag) { $putStr .= $tmp[$i].$fixStr[$i]; $flag = true; } } return ( $putStr ) ? $putStr : "00"; } if( !is_array( $_POST ) ) $_POST = array(); if( !is_array( $_GET ) ) $_GET = array(); $_POST = array_merge( $_POST, $_GET ); $db = new PostgreSQL(); $db->DBconnect(); $xml = getXML(sprintf("../../lang/%s/report.xml", $_SESSION['Lang'] ? $_SESSION['Lang'] : 'en' )); $FRC_TelState = $xml->data[0]->list[0]->FRC_TelState[0]["Stitle"]; $FRC_MonthlyState = $xml->data[0]->list[0]->FRC_MonthlyState[0]["Stitle"]; $FRC_Sec = $xml->data[0]->list[0]->FRC_Sec[0]["Stitle"]; $FRC_Jan = $xml->data[0]->list[0]->FRC_Jan[0]["Stitle"]; $FRC_Feb = $xml->data[0]->list[0]->FRC_Feb[0]["Stitle"]; $FRC_Mar = $xml->data[0]->list[0]->FRC_Mar[0]["Stitle"]; $FRC_Apr = $xml->data[0]->list[0]->FRC_Apr[0]["Stitle"]; $FRC_May = $xml->data[0]->list[0]->FRC_May[0]["Stitle"]; $FRC_Jun = $xml->data[0]->list[0]->FRC_Jun[0]["Stitle"]; $FRC_Jul = $xml->data[0]->list[0]->FRC_Jul[0]["Stitle"]; $FRC_Aug = $xml->data[0]->list[0]->FRC_Aug[0]["Stitle"]; $FRC_Sep = $xml->data[0]->list[0]->FRC_Sep[0]["Stitle"]; $FRC_Oct = $xml->data[0]->list[0]->FRC_Oct[0]["Stitle"]; $FRC_Nov = $xml->data[0]->list[0]->FRC_Nov[0]["Stitle"]; $FRC_Dec = $xml->data[0]->list[0]->FRC_Dec[0]["Stitle"]; $FRC_InOutState = $xml->data[0]->list[0]->FRC_InOutState[0]["Stitle"]; $FRC_ExtState = $xml->data[0]->list[0]->FRC_ExtState[0]["Stitle"]; $FRC_AverageState = $xml->data[0]->list[0]->FRC_AverageState[0]["Stitle"]; $FRC_Sec_Scale = $xml->data[0]->list[0]->FRC_Sec_Scale[0]["Stitle"]; if ( !isset( $_POST['txt_sdate'] ) ) $_POST['txt_sdate'] = ""; if ( !isset( $_POST['txt_edate'] ) ) $_POST['txt_edate'] = ""; if ( !isset( $_POST['sel_type'] ) ) $_POST['sel_type'] = ""; if ( !isset( $_POST['sel_price'] ) ) $_POST['sel_price'] = ""; if ( !isset( $_POST['hd_sort'] ) ) $_POST['hd_sort'] = ""; if ( !isset( $_POST['iPage'] ) ) $_POST['iPage'] = ""; if ( !isset( $_GET['iPage'] ) ) $_GET['iPage'] = ""; if ( !isset( $_POST['txt_sys_code'] ) ) $_POST['txt_sys_code'] = ""; if ( !isset( $_POST['hid_mode'] ) ) $_POST['hid_mode'] = ""; $txt_sys_code = $_POST['txt_sys_code']; $txt_sdate = $_POST['txt_sdate']; $txt_edate = $_POST['txt_edate']; $sel_type = $_POST['sel_type']; $sel_price = $_POST['sel_price']; $hd_sort = $_POST['hd_sort']; //echo($txt_sdate." ".$txt_edate." ".$sel_type." ".$sel_price." ||| hd_sort : ".$hd_sort); if( empty( $_POST['iPage'] ) ) $_POST['iPage'] = 1; if( $_GET['iPage'] ) $_POST['iPage'] = $_GET['iPage']; //print_r( array( $_GET, $_POST ) ); //************************************************************ where ********************************* $arWhere = array(); if($_POST['txt_sys_code'] != '') { //array_push( $arWhere, sprintf( " R_BUFFER2 = '%s' ", $_POST['txt_sys_code'] ) ); array_push( $arWhere, sprintf( " r_v_sys_code = '%s' ", $_POST['txt_sys_code'] ) ); } if($_POST['txt_sdate'] == '') { $_POST['txt_sdate'] = $sdate = date( "Y-m-d", time() - 86400 * 15 ); } $sdate = str_replace("-", "", $_POST['txt_sdate']); array_push( $arWhere, sprintf( " R_REC_DATE >= '%s' ", $sdate ) ); if($_POST['txt_edate'] == '') { $_POST['txt_edate'] = $edate = date('Y-m-d'); } $edate = str_replace("-", "", $_POST['txt_edate']); array_push( $arWhere, sprintf( " R_REC_DATE <= '%s' ", $edate ) ); if( sizeof( $arWhere ) > 0 ) { $szWhere = "WHERE " . implode( " AND ", $arWhere ); } if ( !isset( $_POST['sel_type'] ) ) $_POST['sel_type'] = "day"; //************************************************************ group by // group type ********************************* $szAddTitle = sprintf( " ( %s ~ %s )", $_POST['txt_sdate'], $_POST['txt_edate'] ); $szRotateLable = 0; if($_POST['sel_type'] == "year") { $group_type = "SUBSTRING( R_REC_DATE, 1,4 )"; $caption = sprintf( "%s%s", "년별 콜수 현황", $szAddTitle ); } else if($_POST['sel_type'] == "month") { $group_type = "SUBSTRING( R_REC_DATE, 1,6 )"; $caption = sprintf( "%s%s", "월별 콜수 현황", $szAddTitle ); } else if($_POST['sel_type'] == "day") { $group_type = "SUBSTRING( R_REC_DATE, 1,8 )"; $caption = sprintf( "%s%s", "일별 콜수 현황", $szAddTitle ); $szRotateLable = 1; } else if($_POST['sel_type'] == "time") { $group_type = "R_REC_RTIME"; $caption = sprintf( "%s%s", "시간별 콜수 현황", $szAddTitle ); } else if($_POST['sel_type'] == "ext") { $group_type = "R_EXT_NUM"; $caption = sprintf( "%s%s", "내선별 콜수 현황", $szAddTitle ); } else if($_POST['sel_type'] == "co") { $group_type = "R_CO_NUM"; $caption = sprintf( "%s%s", "국선별 콜수 현황", $szAddTitle ); } else if($_POST['sel_type'] == "did") { $group_type = "R_DID_NUM"; $caption = sprintf( "%s%s", "DID별 콜수 현황", $szAddTitle ); } //************************************************************ order by ********************************* $_POST['hd_sort'] = strtoupper( $_POST['hd_sort'] ); if( $_POST['hd_sort'] ) { //$sort_type = $hd_sort; $szOrderBy = sprintf( " ORDER BY %s ", $_POST['hd_sort'] ); } else{ //$sort_type = "r_rec_date"; $szOrderBy = " ORDER BY R_REC_DATE ASC"; } //************************************************************ paging ********************************* $from_query = " SUM(CASE WHEN r_call_kind1 != '' THEN 1 ELSE 0 END) AS ALL_CALL, SUM(CAST(r_call_ttime AS INT)) AS ALL_TIME, SUM(CASE WHEN r_call_kind1 = 'I' THEN 1 ELSE 0 END) AS INBOUND, SUM(CASE WHEN r_call_kind1 = 'I' THEN CAST(r_call_ttime AS INT) ELSE 0 END) AS INBOUND_TIME, SUM(CASE WHEN r_call_kind1 = 'O' THEN 1 ELSE 0 END) AS OUTBOUND, SUM(CASE WHEN r_call_kind1 = 'O' THEN CAST(r_call_ttime AS INT) ELSE 0 END) AS OUTBOUND_TIME, SUM(CASE WHEN r_call_kind1 = 'Z' THEN 1 ELSE 0 END) AS EXTENSION, SUM(CASE WHEN r_call_kind1 = 'Z' THEN CAST(r_call_ttime AS INT) ELSE 0 END) AS EXTENSION_TIME, SUM(CASE WHEN r_call_kind1 = 'T' THEN 1 ELSE 0 END) AS TRANSFER, SUM(CASE WHEN r_call_kind1 = 'T' THEN CAST(r_call_ttime AS INT) ELSE 0 END) AS TRANSFER_TIME FROM RS_RECFILE "; if($_POST['hid_mode'] == 'search') { $query = sprintf( "SELECT %s AS R_REC_DATE, %s %s GROUP BY %s ORDER BY R_REC_DATE ASC" // %s" , $group_type, $from_query, $szWhere, $group_type ); //, $szOrderBy ); } else { $query = sprintf(" SELECT R_REC_DATE, %s %s GROUP BY R_REC_DATE ORDER BY R_REC_DATE ASC" // %s " , $from_query, $szWhere ); //, $szOrderBy ); } //print_r( $query ); $Return= ""; $Return.= sprintf( "" , $FRC_Sec, $FRC_Sec_Scale ); $db->ExecSql( $query, "S" ); $arTmpData = array(); $arData = array(); if ( $db->Num > 0 ) { //print_r( $db->Num ); while( $row = $db->Fetch() ) { $arTmpData[ $row['r_rec_date'] ] = $row; } $db->ResultFree(); } //print_r( $arTmpData ); /* * 년, 월, 일, 시 출력 시 * 데이타가 없는 경우 0 처리 * 내선 번호도 해야하는지??? */ if ( $_POST['sel_type'] != 'time' && $_POST['sel_type'] != 'ext' && $_POST['sel_type'] != 'co' && $_POST['sel_type'] != 'did' ) { for( $nowYear = (int)substr( $sdate, 0, 4 ); $nowYear <= (int)substr( $edate, 0, 4 ); $nowYear++ ) { if ( $_POST['sel_type'] == "year" ) { $arData[ $nowYear ] = $arTmpData[ $nowYear ]; continue; } else { if ( $nowYear == substr( $sdate, 0, 4 ) ) $startMonth = substr( $sdate, 4, 2 ); else $startMonth = 1; if ( $nowYear == substr( $edate, 0, 4 ) ) $lastMonth = substr( $edate, 4, 2 ); else $lastMonth = 12; } for( $nowMonth = $startMonth; $nowMonth <= $lastMonth; $nowMonth++ ) { if ( $_POST['sel_type'] == "month" ) { $nowDate = sprintf( "%04d%02d", $nowYear, $nowMonth ); $arData[ $nowDate ] = $arTmpData[ $nowDate ]; continue; } else { if ( $nowMonth == substr( $sdate, 4, 2 ) ) $startDay = substr( $sdate, 6, 2 ); else $startDay = 1; if ( $nowMonth == substr( $edate, 4, 2 ) ) $lastDay = substr( $edate, 6, 2 ); else $lastDay = date( 't', strtotime( str_to_date( sprintf( "%04d%02d01", $nowYear, $nowMonth ) ) ) ); //$lastDay = date( 't', strtotime( str_to_date( sprintf( "%04d-%02d-01", substr( $edate, 0, 4 ), substr( $edate, 4, 2 ) ) ) ) ); } for( $nowDay = $startDay; $nowDay <= $lastDay; $nowDay++ ) { $nowDate = sprintf( "%04d%02d%02d", $nowYear, $nowMonth, $nowDay ); if ( !isset( $arTmpData[ $nowDate ] ) ) $arTmpData[ $nowDate ] = ""; $arData[ $nowDate ] = $arTmpData[ $nowDate ]; } } } } else if ( $_POST['sel_type'] == 'time' ) { for( $nowTime = 0; $nowTime <= 23; $nowTime++ ) { $arData[ $nowTime ] = $arTmpData[ sprintf( "%02d", $nowTime ) ]; } } else if ( $_POST['sel_type'] == 'co' ) { $nCoNo = 1; foreach( $arTmpData AS $key => $val ) { $arData[ $nCoNo ] = $val; $nCoNo++; } } else { foreach( $arTmpData AS $key => $val ) $arData[ $key ] = $val; } $Return.= ""; $szData = ""; foreach( $arData AS $key => $arSubData ) { if($_POST['sel_type'] == "year") { $szData = substr( $key, 0, 4 ); } else if($_POST['sel_type'] == "month") { $szData = substr( $key, 0, 6 ); } else if($_POST['sel_type'] == "day") { $szData = substr( $key, 4, 4 ); } else if($_POST['sel_type'] == "time") { $szData = $key; } else if($_POST['sel_type'] == "ext") { $szData = $key; } else if($_POST['sel_type'] == "co") { $szData = $key; } else if($_POST['sel_type'] == "did") { $szData = $key; } $Return .= sprintf( "\r\n", $szData); } //var_dump( $arData ); $Return.= "\r\n"; $Return.= "\r\n"; reset( $arData ); foreach( $arData AS $key => $arSubData ) { if ( !is_array( $arSubData ) ) $Return.= sprintf( "\r\n", 0 ); else $Return.= sprintf( "\r\n", $arSubData['all_call'] ); } $Return.= "\r\n"; $Return.= "\r\n"; reset( $arData ); foreach( $arData AS $key => $arSubData ) { if ( !is_array( $arSubData ) ) $Return.= sprintf( "\r\n", 0 ); else $Return.= sprintf( "\r\n", $arSubData['extension'] ); } $Return.= "\r\n"; $Return.= "\r\n"; reset( $arData ); foreach( $arData AS $key => $arSubData ) { if ( !is_array( $arSubData ) ) { $nAvg = 0; } else { if ( $arSubData['all_call'] == 0 ) { $nAvg = 0; } else { $nAvg = round( $arSubData['all_time'] / $arSubData['all_call'] ); } } $Return.= sprintf( "\r\n", $nAvg ); } $Return.= "\r\n"; $Return.= "\r\n"; //$Return.= "\r\n"; $Return.= "\r\n"; $Return.= "\r\n"; $Return.= "\r\n"; $Return.= "