LICENSE: AGPLv2 # # Report for QC activity within VICIdial # # changes: # 210306-1556 - First Build # 210827-1818 - Fix for security issue # 220302-0927 - Added allow_web_debug system setting # 240801-1130 - Code updates for PHP8 compatibility # $admin_version = '2.14-3'; $build = '220302-0927'; $startMS = microtime(); require("dbconnect_mysqli.php"); require("functions.php"); $PHP_AUTH_USER=$_SERVER['PHP_AUTH_USER']; $PHP_AUTH_PW=$_SERVER['PHP_AUTH_PW']; $PHP_SELF=$_SERVER['PHP_SELF']; $PHP_SELF = preg_replace('/\.php.*/i','.php',$PHP_SELF); if (isset($_GET["query_date"])) {$query_date=$_GET["query_date"];} elseif (isset($_POST["query_date"])) {$query_date=$_POST["query_date"];} if (isset($_GET["end_date"])) {$end_date=$_GET["end_date"];} elseif (isset($_POST["end_date"])) {$end_date=$_POST["end_date"];} if (isset($_GET["query_time"])) {$query_time=$_GET["query_time"];} elseif (isset($_POST["query_time"])) {$query_time=$_POST["query_time"];} if (isset($_GET["end_time"])) {$end_time=$_GET["end_time"];} elseif (isset($_POST["end_time"])) {$end_time=$_POST["end_time"];} if (isset($_GET["qc_finish_start_date"])) {$qc_finish_start_date=$_GET["qc_finish_start_date"];} elseif (isset($_POST["qc_finish_start_date"])) {$qc_finish_start_date=$_POST["qc_finish_start_date"];} if (isset($_GET["qc_finish_end_date"])) {$qc_finish_end_date=$_GET["qc_finish_end_date"];} elseif (isset($_POST["qc_finish_end_date"])) {$qc_finish_end_date=$_POST["qc_finish_end_date"];} if (isset($_GET["qc_finish_start_time"])) {$qc_finish_start_time=$_GET["qc_finish_start_time"];} elseif (isset($_POST["qc_finish_start_time"])) {$qc_finish_start_time=$_POST["qc_finish_start_time"];} if (isset($_GET["qc_finish_end_time"])) {$qc_finish_end_time=$_GET["qc_finish_end_time"];} elseif (isset($_POST["qc_finish_end_time"])) {$qc_finish_end_time=$_POST["qc_finish_end_time"];} if (isset($_GET["group"])) {$group=$_GET["group"];} elseif (isset($_POST["group"])) {$group=$_POST["group"];} if (isset($_GET["users"])) {$users=$_GET["users"];} elseif (isset($_POST["users"])) {$users=$_POST["users"];} if (isset($_GET["user_groups"])) {$user_groups=$_GET["user_groups"];} elseif (isset($_POST["user_groups"])) {$user_groups=$_POST["user_groups"];} if (isset($_GET["QCusers"])) {$QCusers=$_GET["QCusers"];} elseif (isset($_POST["QCusers"])) {$QCusers=$_POST["QCusers"];} if (isset($_GET["QCuser_groups"])) {$QCuser_groups=$_GET["QCuser_groups"];} elseif (isset($_POST["QCuser_groups"])) {$QCuser_groups=$_POST["QCuser_groups"];} if (isset($_GET["QCstatuses"])) {$QCstatuses=$_GET["QCstatuses"];} elseif (isset($_POST["QCstatuses"])) {$QCstatuses=$_POST["QCstatuses"];} if (isset($_GET["DB"])) {$DB=$_GET["DB"];} elseif (isset($_POST["DB"])) {$DB=$_POST["DB"];} if (isset($_GET["SUBMIT"])) {$SUBMIT=$_GET["SUBMIT"];} elseif (isset($_POST["SUBMIT"])) {$SUBMIT=$_POST["SUBMIT"];} if (isset($_GET["show_percentages"])) {$show_percentages=$_GET["show_percentages"];} elseif (isset($_POST["show_percentages"])) {$show_percentages=$_POST["show_percentages"];} if (isset($_GET["search_archived_data"])) {$search_archived_data=$_GET["search_archived_data"];} elseif (isset($_POST["search_archived_data"])) {$search_archived_data=$_POST["search_archived_data"];} if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];} elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];} $DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); $MT[0]=''; $NOW_DATE = date("Y-m-d"); $NOW_TIME = date("Y-m-d H:i:s"); $STARTtime = date("U"); if (!is_array($group)) {$group = array();} if (!is_array($users)) {$users = array();} if (!is_array($user_groups)) {$user_groups = array();} if (!is_array($QCusers)) {$QCusers = array();} if (!is_array($QCstatuses)) {$QCstatuses = array();} if (!is_array($QCuser_groups)) {$QCuser_groups = array();} if (!isset($query_date)) {$query_date = $NOW_DATE;} if (!isset($end_date)) {$end_date = $NOW_DATE;} if (!isset($query_time)) {$query_time = "00:00:00";} if (!isset($end_time)) {$end_time = "23:59:59";} #if (!isset($qc_finish_start_date)) {$qc_finish_start_date = $NOW_DATE;} #if (!isset($qc_finish_end_date)) {$qc_finish_end_date = $NOW_DATE;} #if (!isset($qc_finish_start_time)) {$qc_finish_start_time = "00:00:00";} #if (!isset($qc_finish_end_time)) {$qc_finish_end_time = "23:59:59";} $all_QC_statuses=array("CLAIMED", "FINISHED"); $QC_statuses_to_print=count($all_QC_statuses); $report_name = 'Quality Control Report'; $db_source = 'M'; $report_display_type="HTML"; ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### $stmt = "SELECT use_non_latin,outbound_autodial_active,slave_db_server,reports_use_slave_db,enable_languages,language_method,report_default_format,qc_features_active,log_recording_access,allow_web_debug FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); #if ($DB) {$HTML_text.="$stmt\n";} $qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) { $row=mysqli_fetch_row($rslt); $non_latin = $row[0]; $outbound_autodial_active = $row[1]; $slave_db_server = $row[2]; $reports_use_slave_db = $row[3]; $SSenable_languages = $row[4]; $SSlanguage_method = $row[5]; $SSreport_default_format = $row[6]; $SSqc_features_active = $row[7]; $log_recording_access = $row[8]; $SSallow_web_debug = $row[9]; } if ($SSallow_web_debug < 1) {$DB=0;} if (strlen($report_display_type)<2) {$report_display_type = $SSreport_default_format;} ##### END SETTINGS LOOKUP ##### ########################################### $query_date = preg_replace('/[^-0-9]/','',$query_date); $end_date = preg_replace('/[^-0-9]/','',$end_date); $query_time=preg_replace("/[^0-9\:]/", "", $query_time); $end_time=preg_replace("/[^0-9\:]/", "", $end_time); $qc_finish_start_date = preg_replace('/[^-0-9]/','',$qc_finish_start_date); $qc_finish_end_date = preg_replace('/[^-0-9]/','',$qc_finish_end_date); $qc_finish_start_time=preg_replace("/[^0-9\:]/", "", $qc_finish_start_time); $qc_finish_end_time=preg_replace("/[^0-9\:]/", "", $qc_finish_end_time); $DB = preg_replace('/[^0-9]/','',$DB); $SUBMIT=preg_replace('/[^-_0-9\p{L}]/u','',$SUBMIT); $show_percentages=preg_replace('/[^-_0-9\p{L}]/u','',$show_percentages); $file_download = preg_replace('/[^0-9]/','',$file_download); $search_archived_data=preg_replace('/[^-_0-9\p{L}]/u','',$search_archived_data); # Variables filtered further down in the code # $group # $users # $user_groups # $QCusers # $QCstatuses # $QCuser_groups if ($non_latin < 1) { $PHP_AUTH_USER = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_USER); $PHP_AUTH_PW = preg_replace('/[^-_0-9a-zA-Z]/', '', $PHP_AUTH_PW); } else { $PHP_AUTH_USER = preg_replace('/[^-_0-9\p{L}]/u', '', $PHP_AUTH_USER); $PHP_AUTH_PW = preg_replace('/[^-_0-9\p{L}]/u', '', $PHP_AUTH_PW); } ### ARCHIVED DATA CHECK CONFIGURATION $archives_available="N"; $log_tables_array=array("quality_control_queue", "quality_control_checkpoint_log"); for ($t=0; $t 0) { $row=mysqli_fetch_row($rslt); $VUselected_language = $row[0]; $qc_auth = $row[1]; } $auth=0; $reports_auth=0; $admin_auth=0; $auth_message = user_authorization($PHP_AUTH_USER,$PHP_AUTH_PW,'REPORTS',1,0); if ($auth_message == 'GOOD') {$auth=1;} if ($auth > 0) { $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 7 and view_reports='1';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $admin_auth=$row[0]; $stmt="SELECT count(*) from vicidial_users where user='$PHP_AUTH_USER' and user_level > 6 and view_reports='1';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $reports_auth=$row[0]; if ($reports_auth < 1) { $VDdisplayMESSAGE = _QXZ("You are not allowed to view reports"); Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } if ( ($reports_auth > 0) and ($admin_auth < 1) ) { $ADD=999999; $reports_only_user=1; } } else { $VDdisplayMESSAGE = _QXZ("Login incorrect, please try again"); if ($auth_message == 'LOCK') { $VDdisplayMESSAGE = _QXZ("Too many login attempts, try again in 15 minutes"); Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } if ($auth_message == 'IPBLOCK') { $VDdisplayMESSAGE = _QXZ("Your IP Address is not allowed") . ": $ip"; Header ("Content-type: text/html; charset=utf-8"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$auth_message|\n"; exit; } Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); Header("HTTP/1.0 401 Unauthorized"); echo "$VDdisplayMESSAGE: |$PHP_AUTH_USER|$PHP_AUTH_PW|$auth_message|\n"; exit; } ##### BEGIN log visit to the vicidial_report_log table ##### $LOGip = getenv("REMOTE_ADDR"); $LOGbrowser = getenv("HTTP_USER_AGENT"); $LOGscript_name = getenv("SCRIPT_NAME"); $LOGserver_name = getenv("SERVER_NAME"); $LOGserver_port = getenv("SERVER_PORT"); $LOGrequest_uri = getenv("REQUEST_URI"); $LOGhttp_referer = getenv("HTTP_REFERER"); $LOGbrowser=preg_replace("/<|>|\'|\"|\\\\/","",$LOGbrowser); $LOGrequest_uri=preg_replace("/<|>|\'|\"|\\\\/","",$LOGrequest_uri); $LOGhttp_referer=preg_replace("/<|>|\'|\"|\\\\/","",$LOGhttp_referer); if (preg_match("/443/i",$LOGserver_port)) {$HTTPprotocol = 'https://';} else {$HTTPprotocol = 'http://';} if (($LOGserver_port == '80') or ($LOGserver_port == '443') ) {$LOGserver_port='';} else {$LOGserver_port = ":$LOGserver_port";} $LOGfull_url = "$HTTPprotocol$LOGserver_name$LOGserver_port$LOGrequest_uri"; $LOGhostname = php_uname('n'); if (strlen($LOGhostname)<1) {$LOGhostname='X';} if (strlen($LOGserver_name)<1) {$LOGserver_name='X';} $stmt="SELECT webserver_id FROM vicidial_webservers where webserver='$LOGserver_name' and hostname='$LOGhostname' LIMIT 1;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $webserver_id_ct = mysqli_num_rows($rslt); if ($webserver_id_ct > 0) { $row=mysqli_fetch_row($rslt); $webserver_id = $row[0]; } else { ##### insert webserver entry $stmt="INSERT INTO vicidial_webservers (webserver,hostname) values('$LOGserver_name','$LOGhostname');"; if ($DB) {echo "$stmt\n";} $rslt=mysql_to_mysqli($stmt, $link); $affected_rows = mysqli_affected_rows($link); $webserver_id = mysqli_insert_id($link); } $stmt="INSERT INTO vicidial_report_log set event_date=NOW(), user='$PHP_AUTH_USER', ip_address='$LOGip', report_name='$report_name', browser='$LOGbrowser', referer='$LOGhttp_referer', notes='$LOGserver_name:$LOGserver_port $LOGscript_name |$query_date, $end_date, $shift, $file_download, $report_display_type|', url='$LOGfull_url', webserver='$webserver_id';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $report_log_id = mysqli_insert_id($link); ##### END log visit to the vicidial_report_log table ##### if ( (strlen($slave_db_server)>5) and (preg_match("/$report_name/",$reports_use_slave_db)) ) { mysqli_close($link); $use_slave_server=1; $db_source = 'S'; require("dbconnect_mysqli.php"); $HTML_text.="\n"; } $stmt="SELECT user_group from vicidial_users where user='$PHP_AUTH_USER';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGuser_group = $row[0]; $stmt="SELECT allowed_campaigns,allowed_reports,admin_viewable_groups,admin_viewable_call_times from vicidial_user_groups where user_group='$LOGuser_group';"; if ($DB) {$HTML_text.="|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $LOGallowed_campaigns = $row[0]; $LOGallowed_reports = $row[1]; $LOGadmin_viewable_groups = $row[2]; $LOGadmin_viewable_call_times = $row[3]; if ( (!preg_match("/$report_name/",$LOGallowed_reports)) and (!preg_match("/ALL REPORTS/",$LOGallowed_reports)) ) { Header("WWW-Authenticate: Basic realm=\"CONTACT-CENTER-ADMIN\""); Header("HTTP/1.0 401 Unauthorized"); echo _QXZ("You are not allowed to view this report").": |$PHP_AUTH_USER|$report_name|\n"; exit; } $LOGallowed_campaignsSQL=''; $whereLOGallowed_campaignsSQL=''; if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) ) { $rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns); $rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL); $LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')"; $whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')"; } $regexLOGallowed_campaigns = " $LOGallowed_campaigns "; $LOGadmin_viewable_groupsSQL=''; $whereLOGadmin_viewable_groupsSQL=''; if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) ) { $rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups); $rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL); $LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; $whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')"; } $i=0; $campaign_string='|'; $campaigns_ct = count($group); while($i < $campaigns_ct) { $group[$i] = preg_replace('/[^-_0-9\p{L}]/u', '', $group[$i]); $campaign_string .= "$group[$i]|"; $i++; } $i=0; $users_string='|'; $users_ct = count($users); while($i < $users_ct) { $users[$i] = preg_replace('/[^-_0-9\p{L}]/u', '', $users[$i]); $users_string .= "$users[$i]|"; $i++; } $i=0; $QCusers_string='|'; $QCusers_ct = count($QCusers); while($i < $QCusers_ct) { $QCusers[$i] = preg_replace('/[^-_0-9\p{L}]/u', '', $QCusers[$i]); $QCusers_string .= "$QCusers[$i]|"; $i++; } $i=0; $QCstatuses_string='|'; $QCstatuses_ct = count($QCstatuses); while($i < $QCstatuses_ct) { $QCstatuses[$i] = preg_replace('/[^-_0-9\p{L}]/u', '', $QCstatuses[$i]); $QCstatuses_string .= "$QCstatuses[$i]|"; $i++; } $stmt="SELECT campaign_id from vicidial_campaigns $whereLOGallowed_campaignsSQL order by campaign_id;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {$HTML_text.="$stmt\n";} $campaigns_to_print = mysqli_num_rows($rslt); $i=0; $groups=array(); while ($i < $campaigns_to_print) { $row=mysqli_fetch_row($rslt); $groups[$i] =$row[0]; if (preg_match('/\-ALL/',$group_string) ) {$group[$i] = $groups[$i];} $i++; } #for ($i=0; $i\"HELP\""; $NWB = "\"HELP\""; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_text.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.="\n"; $HTML_head.=""._QXZ("$report_name")."\n"; $HTML_head.=""; $short_header=1; # require("admin_header.php"); $HTML_text.="
"; $HTML_text.=""._QXZ("$report_name")." ".$NWB."quality_control_report".$NWE."\n"; $HTML_text.="
\n"; $HTML_text.=""; $HTML_text.=""; /* $HTML_text.=""; */ $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.="\n"; /* $HTML_text.=""; */ $HTML_text.=""; $HTML_text.=""; $HTML_text.="
"._QXZ("Call dates").":
"; $HTML_text.="\n"; $HTML_text.=""; $HTML_text.="\n"; $HTML_text.="  "; $HTML_text.="
"._QXZ("to")."
"; $HTML_text.="\n"; $HTML_text.="  "; $HTML_text.="
"._QXZ("Campaigns").":
"; $HTML_text.="\n"; $HTML_text.="
"._QXZ("User Groups").":
"; $HTML_text.="\n"; $HTML_text.="
"._QXZ("Users").":
"; $HTML_text.="\n"; $HTML_text.="
        "; $HTML_text.="          \n"; $HTML_text.=" "._QXZ("REPORTS")."

\n"; $HTML_text.=""._QXZ("Show %s")."
\n"; $HTML_text.=""._QXZ("Search archived data")."
\n"; $HTML_text.="

\n"; $HTML_text.="       \n"; $HTML_text.="
"._QXZ("Finish date").":
"; $HTML_text.=""; $HTML_text.="\n"; $HTML_text.="  "; $HTML_text.="
"._QXZ("to")."
"; $HTML_text.="\n"; $HTML_text.="  "; $HTML_text.="
"._QXZ("QC Status").":
"; $HTML_text.="\n"; $HTML_text.="
"._QXZ("QC User Groups").":
"; $HTML_text.="\n"; $HTML_text.="
"._QXZ("QC Users").":
"; $HTML_text.="\n"; $HTML_text.="
"; $HTML_text.="
\n\n"; if ($SUBMIT && ($QCuser_ct>0 || $user_ct>0 || $group_ct>0 || $QCstatus_ct>0 || ($qc_finish_start_date && $qc_finish_end_date)) ) { if ($qc_finish_start_date && $qc_finish_end_date) { if (!$qc_finish_start_time) {$qc_finish_start_time = "00:00:00";} if (!$qc_finish_end_time) {$qc_finish_end_time = "23:59:59";} $finish_date_clause=" and date_completed>='$qc_finish_start_date $qc_finish_start_time' and date_completed<='$qc_finish_end_date $qc_finish_end_time'"; } $qc_stmt="select * from ".$quality_control_queue_table." where call_date>='$query_date $query_time' and call_date<='$end_date $end_time' $finish_date_clause $group_SQL $QCstatus_QC_log_SQL $user_QC_log_SQL $QCuser_QC_log_SQL"; if ($DB) {$HTML_text.=$qc_stmt."

";} $qc_rslt=mysql_to_mysqli($qc_stmt, $link); if(mysqli_num_rows($qc_rslt)>0) { $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $CSV_header="\"Call date\",\"Call agent\",\"Lead ID\",\"Campaign ID\",\"Status\",\"Scorecard\",\"QC agent\",\"Claim date\",\"Finish date\",\"Score\",\"Instant fail\",\"Result\",\"QC status\""; $CSV_text=""; $x=0; $max_questions=0; while ($qc_row=mysqli_fetch_array($qc_rslt)) { $qc_recording_id=$qc_row["recording_id"]; if ($x%2==0) {$bgcolor=$SSstd_row2_background;} else {$bgcolor=$SSstd_row1_background;} $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $instant_fail=GetFail($qc_row["qc_log_id"]); $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $CSV_text.="\"".$qc_row["call_date"]."\",\"".GetFullName($qc_row["user"])."\",\"".$qc_row["lead_id"]."\",\"".$qc_row["campaign_id"]."\",\"".$qc_row["status"]."\",\"".$qc_row["qc_scorecard_id"]."\",\"".GetFullName($qc_row["qc_agent"])."\",\"".$qc_row["date_claimed"]."\",\"".$qc_row["date_completed"]."\",\"".GetScore($qc_row["qc_log_id"], "")."\",\"".$instant_fail."\",\"".($instant_fail=="Y" ? "FAILED" : GetResult($qc_row["qc_log_id"]))."\",\"".$qc_row["qc_status"]."\""; $checkpoint_stmt="select * from ".$quality_control_checkpoint_log_table." where qc_log_id='".$qc_row["qc_log_id"]."' order by checkpoint_rank asc"; if ($DB) {$HTML_text.=$checkpoint_stmt."
";} $checkpoint_rslt=mysql_to_mysqli($checkpoint_stmt, $link); $question_count=mysqli_num_rows($checkpoint_rslt); if ($question_count>$max_questions) {$max_questions=$question_count;} while($crow=mysqli_fetch_array($checkpoint_rslt)) { $checkpoint_comment=preg_replace("/((\d{1,2})?\:?\d?\d\:\d{2})/", "$1", $crow["checkpoint_comment_agent"]); $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $CSV_text.=",\"".$crow["checkpoint_rank"].") ".$crow["checkpoint_text"]."\",\"".$crow["checkpoint_comment_agent"]."\",\"".GetScore($qc_row["qc_log_id"], $crow["qc_checkpoint_log_id"])."\",\"".$crow["instant_fail_value"]."\""; } # RECORDING $rec_stmt="select location from recording_log where recording_id='" . mysqli_real_escape_string($link, $qc_recording_id) . "' order by recording_id desc limit 500;"; $rec_rslt=mysql_to_mysqli($rec_stmt, $link); $rec_row=mysqli_fetch_row($rec_rslt); $location = $rec_row[0]; if (strlen($location)>2) { $URLserver_ip = $location; $URLserver_ip = preg_replace('/http:\/\//i', '',$URLserver_ip); $URLserver_ip = preg_replace('/https:\/\//i', '',$URLserver_ip); $URLserver_ip = preg_replace('/\/.*/i', '',$URLserver_ip); $stmt="select count(*) from servers where server_ip='$URLserver_ip';"; $rsltx=mysql_to_mysqli($stmt, $link); $rowx=mysqli_fetch_row($rsltx); if ($rowx[0] > 0) { $stmt="select recording_web_link,alt_server_ip,external_server_ip from servers where server_ip='$URLserver_ip';"; $rsltx=mysql_to_mysqli($stmt, $link); $rowx=mysqli_fetch_row($rsltx); if (preg_match("/ALT_IP/i",$rowx[0])) { $location = preg_replace("/$URLserver_ip/i", "$rowx[1]", $location); } if (preg_match("/EXTERNAL_IP/i",$rowx[0])) { $location = preg_replace("/$URLserver_ip/i", "$rowx[2]", $location); } } } if (strlen($location)>30) {$locat = substr($location,0,27); $locat = "$locat...";} else {$locat = $location;} $play_audio=''; if ( (preg_match('/ftp/i',$location)) or (preg_match('/http/i',$location)) ) { $play_audio = "     \n"; $location = "$locat"; } else {$location = $locat;} $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; $HTML_text.=""; ########### $CSV_text.="\n"; $x++; } for ($i=1; $i<=$max_questions; $i++) { $CSV_header.=",\"Checkpoint $i\",\"Comments $i\",\"Score $i\",\"Instant fail $i\""; } $CSV_header.="\n"; $HTML_text.="
[DOWNLOAD]
Call dateCall agentLead IDCampaign IDStatusScorecardQC agentClaim dateFinish dateScoreInstant failResultQC status
".$qc_row["call_date"]."".GetFullName($qc_row["user"])."".$qc_row["lead_id"]."".$qc_row["campaign_id"]."".$qc_row["status"]."".$qc_row["qc_scorecard_id"]."".GetFullName($qc_row["qc_agent"])."".$qc_row["date_claimed"]."".$qc_row["date_completed"]."".GetScore($qc_row["qc_log_id"], "")."".$instant_fail."".($instant_fail=="Y" ? "FAILED" : GetResult($qc_row["qc_log_id"]))."".$qc_row["qc_status"]."
    ".$crow["checkpoint_rank"].") ".$crow["checkpoint_text"]."".$checkpoint_comment."".GetScore($qc_row["qc_log_id"], $crow["qc_checkpoint_log_id"])."".$crow["instant_fail_value"]." 
"._QXZ("RECORDING").":$play_audio   $location
"; } else { $HTML_text.="*** NO RESULTS FOUND ***"; } } $HTML_text.="\n\n
"; $HTML_text.="
"; $HTML_text.=""; if ($file_download == 0 || !$file_download) { echo $HTML_head; require("admin_header.php"); echo $HTML_text; echo "\n"; } else { $FILE_TIME = date("Ymd-His"); $CSVfilename = "Quality_control_rpt_$US$FILE_TIME.csv"; $CSV_text="$CSV_header$CSV_text"; $CSV_text=preg_replace('/^\s+/', '', $CSV_text); $CSV_text=preg_replace('/ +\"/', '"', $CSV_text); $CSV_text=preg_replace('/\" +/', '"', $CSV_text); // We'll be outputting a TXT file header('Content-type: application/octet-stream'); // It will be called LIST_101_20090209-121212.txt header("Content-Disposition: attachment; filename=\"$CSVfilename\""); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); ob_clean(); flush(); echo "$CSV_text"; } if ($db_source == 'S') { mysqli_close($link); $use_slave_server=0; $db_source = 'M'; require("dbconnect_mysqli.php"); } $endMS = microtime(); $startMSary = explode(" ",$startMS); $endMSary = explode(" ",$endMS); $runS = ($endMSary[0] - $startMSary[0]); $runM = ($endMSary[1] - $startMSary[1]); $TOTALrun = ($runS + $runM); #$stmt="UPDATE vicidial_report_log set run_time='$TOTALrun' where report_log_id='$report_log_id';"; #if ($DB) {echo "|$stmt|\n";} #$rslt=mysql_to_mysqli($stmt, $link); function GetFullName($full_name) { global $link, $DB; $name_stmt="select full_name from vicidial_users where user='$full_name'"; $name_rslt=mysql_to_mysqli($name_stmt, $link); while ($name_row=mysqli_fetch_array($name_rslt)) { $full_name=$name_row["full_name"]; } return $full_name; } function GetFail($QCID) { global $link, $DB; $fail_stmt="select count(*) From quality_control_checkpoint_log where qc_log_id='$QCID' and instant_fail_value='Y'"; $fail_rslt=mysql_to_mysqli($fail_stmt, $link); while ($fail_row=mysqli_fetch_row($fail_rslt)) { $fail_count=$fail_row[0]; } if ($fail_count>0) {return "Y";} else {return "N";} } function GetResult($QCID) { global $link, $DB, $show_percentages; $passing_score=0; $total_score=0; $score_stmt="select qc_scorecard_id, sum(checkpoint_points_earned) from quality_control_checkpoint_log where qc_log_id='$QCID'"; if ($DB) {echo $score_stmt."
\n";} $score_rslt=mysql_to_mysqli($score_stmt, $link); while ($score_row=mysqli_fetch_array($score_rslt)) { $scorecard_id=$score_row[0]; $total_score=$score_row[1]; $result_stmt="select passing_score from quality_control_scorecards where qc_scorecard_id='$scorecard_id'"; $result_rslt=mysql_to_mysqli($result_stmt, $link); $result_row=mysqli_fetch_array($result_rslt); $passing_score=$result_row[0]; } return ($total_score>=$passing_score ? "PASSED" : "FAILED"); } function GetScore($QCID, $checkpointID) { global $link, $DB, $show_percentages; $score="--"; $checkpoint_clause=""; if ($checkpointID) {$checkpoint_clause=" and qc_checkpoint_log_id='$checkpointID'";} $score_stmt="select sum(checkpoint_points), sum(checkpoint_points_earned) from quality_control_checkpoint_log where qc_log_id='$QCID' $checkpoint_clause"; if ($DB) {echo $score_stmt."
\n";} $score_rslt=mysql_to_mysqli($score_stmt, $link); $new_lead_IDs=array(); while ($score_row=mysqli_fetch_array($score_rslt)) { if ($show_percentages) { $score=sprintf("%.2f", (100*($score_row[1]/$score_row[0])))." %"; } else { $score=$score_row[1]." / ".$score_row[0]; } } return $score; } exit; ?>