<?php
//Export to Excel Server Behavior
if (isset($_GET['Export'])&&($_GET['Export']=="Export Spreadsheet")){
$delim="";
$delim_replace="";
if($delim==""){
$lang=(strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'],",")===false)?$_SERVER['HTTP_ACCEPT_LANGUAGE']:substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'],","));
$semi_array=array("af","zh-hk","zh-mo","zh-cn","zh-sg","zh-tw","fr-ch","de-li","de-ch","it-ch","ja","ko","es-do","es-sv","es-gt","es-hn","es-mx","es-ni","es-pa","es-pe","es-pr","sw");
$delim=(in_array($lang,$semi_array) || substr_count($lang,"en")>0)?",":";";
}
$output="";
$output="1 = RecruitSavvy 2 = CareerSoft 3 = Warm Calling 4 = Unclaimed Property that 5 = Resume Search Only 6 = Career Changers 7 = Brokerage\n\n";
$include_hdr="1";
if($include_hdr=="1"){
$columns = array_keys($WADAcustomers->Results);
for ($x=0; $x<sizeof($columns); $x++) {
if($x!=0) $output.=","
$output.= (ereg_replace("_", " ",$columns[$x]));
}
$output = $output."\r\n";
}
for ($x=0; $x<sizeof($WADAcustomers->Results); $x++) {
$fixcomma=array();
foreach($WADAcustomers->Results[$x] as $r){array_push($fixcomma,ereg_replace($delim,$delim_replace,$r));}
$line = join($delim,$fixcomma);
$line=ereg_replace("\r\n", " ",$line);
$line = "$line\n";
$output=$output.$line;
}
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=client_report.csv");
header("Content-Type: application/force-download");
header("Cache-Control: post-check=0, pre-check=0", false);
echo $output;
die();
}
?>