gT("Export results")); $exportoutput .= "
' ."| ".$elang->gT('NEW RECORD')." | $ftitle | ";}
if ($type == "pdf"){ $pdf->intopdf($ftitle);}
switch ($ftype)
{
case "-": //SPECIAL Placeholder TYPE
$exportoutput .= $drow[$i];
if($type == "pdf"){$pdf->intopdf($drow[$i]);}
break;
case "R": //RANKING TYPE
$lq = "SELECT * FROM {$dbprefix}answers WHERE qid=$fqid AND language='$explang' AND code = ?";
$lr = db_execute_assoc($lq, array($drow[$i]));
while ($lrow = $lr->FetchRow())
{
$exportoutput .= strip_tags_full($lrow['answer']);
if($type == "pdf"){$pdf->intopdf(strip_tags_full($lrow['answer']));}
}
break;
case "1":
if (mb_substr($fieldinfo,-1) == 0)
{
//$lq = "select a.*, l.*, l.code as lcode, l.title as ltitle from {$dbprefix}answers as a, {$dbprefix}labels as l where qid=$fqid AND l.lid =$flid AND a.language='$explang' AND l.code = ? group by l.lid";
$lq = "select answer as ltitle from {$dbprefix}answers where qid=$fqid AND language='$explang' and scale_id=0 AND code = ?";
}
else
{
//$lq = "select a.*, l.*, l.code as lcode, l.title as ltitle from {$dbprefix}answers as a, {$dbprefix}labels as l where qid=$fqid AND l.lid =$flid1 AND a.language='$explang' AND l.code = ? group by l.lid";
$lq = "select answer as ltitle from {$dbprefix}answers where qid=$fqid AND language='$explang' and scale_id=1 AND code = ?";
}
$lr = db_execute_assoc($lq, array($drow[$i])) or safe_die($lq." ERROR: ".$connect->ErrorMsg()); while ($lrow = $lr->FetchRow()) { $exportoutput .= strip_tags_full($lrow['ltitle']); if($type == "pdf"){$pdf->intopdf(strip_tags_full($lrow['ltitle']));} } break; case "L": //DROPDOWN LIST case "!": if (mb_substr($fieldinfo, -5, 5) == "other") { $exportoutput .= strip_tags_full($drow[$i]); if($type == "pdf"){$pdf->intopdf($drow[$i]);} } else { if ($drow[$i] == "-oth-") { $exportoutput .= $elang->gT("Other"); if($type == "pdf"){$pdf->intopdf($elang->gT("Other"));} } else { $lq = "SELECT * FROM {$dbprefix}answers WHERE qid=$fqid AND language='$explang' AND code = ?"; $lr = db_execute_assoc($lq, array($drow[$i])) or safe_die($lq." ERROR: ".$connect->ErrorMsg()); while ($lrow = $lr->FetchRow()) { //if ($lrow['code'] == $drow[$i]) {$exportoutput .= $lrow['answer'];} if ($type == "csv") { $exportoutput .= str_replace("\"", "\"\"", strip_tags_full($lrow['answer'])); if($type == "pdf"){$pdf->intopdf(str_replace("\"", "\"\"", strip_tags_full($lrow['answer'])));} } else { $exportoutput .= strip_tags_full($lrow['answer']); if($type == "pdf"){$pdf->intopdf(strip_tags_full($lrow['answer']));} } } } } break; case "O": //DROPDOWN LIST WITH COMMENT $lq = "SELECT * FROM {$dbprefix}answers WHERE qid=$fqid AND language='$explang' ORDER BY answer"; $lr = db_execute_assoc($lq) or safe_die ("Could do it $lq ".$connect->ErrorMsg()); $found = ""; while ($lrow = $lr->FetchRow()) { if ($lrow['code'] == $drow[$i]) { $exportoutput .= strip_tags_full($lrow['answer']); $found = "Y"; if($type == "pdf"){$pdf->intopdf(strip_tags_full($lrow['answer']));} } } //This following section exports the comment field if ($found != "Y") { if ($type == "csv") {$exportoutput .= str_replace("\r\n", "\n", str_replace("\"", "\"\"", strip_tags_full($drow[$i])));} else if ($type == "pdf") {$pdf->intopdf(str_replace("\r\n", " ", strip_tags_full($drow[$i])));} else {$exportoutput .= str_replace("\r\n", " ", $drow[$i]);} } break; case "Y": //YES\NO switch($drow[$i]) { case "Y": $exportoutput .= $elang->gT("Yes"); if($type == "pdf"){$pdf->intopdf($elang->gT("Yes"));} break; case "N": $exportoutput .= $elang->gT("No"); if($type == "pdf"){$pdf->intopdf($elang->gT("No"));} break; default: $exportoutput .= $elang->gT("N/A"); if($type == "pdf"){$pdf->intopdf($elang->gT("N/A"));} break; } break; case "G": //GENDER switch($drow[$i]) { case "M": $exportoutput .= $elang->gT("Male"); if($type == "pdf"){$pdf->intopdf($elang->gT("Male"));} break; case "F": $exportoutput .= $elang->gT("Female"); if($type == "pdf"){$pdf->intopdf($elang->gT("Female"));} break; default: $exportoutput .= $elang->gT("N/A"); if($type == "pdf"){$pdf->intopdf($elang->gT("N/A"));} break; } break; case "M": //multioption case "P": if (mb_substr($fieldinfo, -5, 5) == "other") { $exportoutput .= strip_tags_full($drow[$i]); if($type == "pdf"){$pdf->intopdf($drow[$i]);} } elseif (mb_substr($fieldinfo, -7, 7) == "comment") { $exportoutput .= strip_tags_full($drow[$i]); if($type == "pdf"){$pdf->intopdf($drow[$i]);} } else { switch($drow[$i]) { case "Y": $exportoutput .= $elang->gT("Yes"); if($type == "pdf"){$pdf->intopdf($elang->gT("Yes"));} break; case "N": $exportoutput .= $elang->gT("No"); if($type == "pdf"){$pdf->intopdf($elang->gT("No"));} break; case "": $exportoutput .= $elang->gT("No"); if($type == "pdf"){$pdf->intopdf($elang->gT("No"));} break; default: $exportoutput .= $drow[$i]; if($type == "pdf"){$pdf->intopdf($drow[$i]);} break; } } break; case "C": switch($drow[$i]) { case "Y": $exportoutput .= $elang->gT("Yes"); if($type == "pdf"){$pdf->intopdf($elang->gT("Yes")); } break; case "N": $exportoutput .= $elang->gT("No"); if($type == "pdf"){$pdf->intopdf($elang->gT("No")); } break; case "U": $exportoutput .= $elang->gT("Uncertain"); if($type == "pdf"){$pdf->intopdf($elang->gT("Uncertain"));} break; } case "E": switch($drow[$i]) { case "I": $exportoutput .= $elang->gT("Increase"); if($type == "pdf"){$pdf->intopdf($elang->gT("Increase"));} break; case "S": $exportoutput .= $elang->gT("Same"); if($type == "pdf"){$pdf->intopdf($elang->gT("Same"));} break; case "D": $exportoutput .= $elang->gT("Decrease"); if($type == "pdf"){$pdf->intopdf($elang->gT("Decrease"));} break; } break; case "F": case "H": if (!isset($labelscache[$fqid.'|'.$explang.'|'.$drow[$i]])) { $fquery = "SELECT * FROM {$dbprefix}answers WHERE qid=$fqid AND language='$explang' AND scale_id=0 AND code='{$drow[$i]}'"; $fresult = db_execute_assoc($fquery) or safe_die("ERROR:".$fquery."\n".$qq."\n".$connect->ErrorMsg()); if ($fresult) { $frow=$fresult->FetchRow(); if($type == "pdf"){$pdf->intopdf(strip_tags_full($frow['answer']));} $exportoutput .= strip_tags_full($frow['answer']); $labelscache[$fqid.'|'.$explang.'|'.$drow[$i]]=strip_tags_full($frow['answer']); } } else { $exportoutput .=$labelscache[$fqid.'|'.$explang.'|'.$drow[$i]]; if($type == "pdf"){$pdf->intopdf($labelscache[$fqid.'|'.$explang.'|'.$drow[$i]]);} } break; case "1": //dual scale if (mb_substr($fieldinfo,-1) == '0') { $strlabel = "1"; $lq = "select title from {$dbprefix}labels as l where l.lid = $flid AND l.language='$surveybaselang'"; } else { $strlabel = "2"; $lq = "select title from {$dbprefix}labels as l where l.lid = $flid1 AND l.language='$surveybaselang'"; } $lr = db_execute_assoc($lq); while ($lrow=$lr->FetchRow()) { $fquest .= " [".strip_tags_full($lrow['title'])."][".strip_tags_full($strlabel).". label]"; } break; default: $tempresult=$dresult->FetchField($i); if ($tempresult->name == "token") { $tokenquery = "SELECT firstname, lastname FROM {$dbprefix}tokens_$surveyid WHERE token='$drow[$i]'"; if ($tokenresult = db_execute_assoc($tokenquery)) //or safe_die ("Couldn't get token info $tokenquery ".$connect->ErrorMsg()); while ($tokenrow=$tokenresult->FetchRow()) { $exportoutput .= "{$tokenrow['lastname']}, {$tokenrow['firstname']}"; if($type == "pdf"){$pdf->intopdf($tokenrow['lastname']." , ".$tokenrow['firstname']);} } else { $exportoutput .= $elang->gT("Tokens problem - token table missing"); if($type == "pdf"){$pdf->intopdf($elang->gT("Tokens problem - token table missing"));} } } else { if ($type == "csv") {$exportoutput .= str_replace("\r\n", "\n", str_replace("\"", "\"\"", strip_tags_full($drow[$i])));} else if ($type == "pdf") {$pdf->intopdf(trim(strip_tags($drow[$i])));} else if ($type == "doc") {$exportoutput .= trim(strip_tags($drow[$i]));} else {$exportoutput .= str_replace("\r\n", " ", $drow[$i]);} } } if ($type == "doc") { $exportoutput .= " | ";
}
if ($type == "csv") {$exportoutput .= "\"";}
$exportoutput .= "$separator";
$ftype = "";
}
$exportoutput=mb_substr($exportoutput,0,-(strlen($separator)));
if ($type == "doc")
{
$exportoutput .= "
|---|