\n" ."\n\n" . "\n" . "$sitename\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n\n"; $surveyid = $_GET['sid']; // PRESENT SURVEY DATAENTRY SCREEN if(isset($_POST['printableexport'])) { $pdf = new PDF ('L','mm','A4'); $pdf->SetFont($pdfdefaultfont,'',$pdffontsize); $pdf->AddPage(); } // Set the language of the survey, either from GET parameter of session var if (isset($_GET['lang'])) { $_GET['lang'] = preg_replace("/[^a-zA-Z0-9-]/", "", $_GET['lang']); if ($_GET['lang']) $surveyprintlang = $_GET['lang']; } else { $surveyprintlang=GetbaseLanguageFromSurveyid($surveyid); } // Setting the selected language for printout $clang = new limesurvey_lang($surveyprintlang); $desquery = "SELECT * FROM ".db_table_name('surveys')." inner join ".db_table_name('surveys_languagesettings')." on (surveyls_survey_id=sid) WHERE sid=$surveyid and surveyls_language=".$connect->qstr($surveyprintlang); //Getting data for this survey $desresult = db_execute_assoc($desquery); while ($desrow = $desresult->FetchRow()) { $surveyname = $desrow['surveyls_title']; $surveydesc = $desrow['surveyls_description']; $surveyactive = $desrow['active']; $surveytable = db_table_name("survey_".$desrow['sid']); $surveyuseexpiry = $desrow['useexpiry']; $surveyexpirydate = $desrow['expires']; $surveyfaxto = $desrow['faxto']; } if (!isset($surveyfaxto) || !$surveyfaxto and isset($surveyfaxnumber)) { $surveyfaxto=$surveyfaxnumber; //Use system fax number if none is set in survey. } $printablesurveyoutput .="\n"; if(isset($usepdfexport) && $usepdfexport == 1 && !in_array($surveyprintlang,$notsupportlanguages)) { $printablesurveyoutput .="\n"; $printablesurveyoutput .="\n"; $printablesurveyoutput .="\t\t\n"; $printablesurveyoutput .="\t\n"; // SURVEY NAME AND DESCRIPTION TO GO HERE $fieldmap=createFieldMap($surveyid); $degquery = "SELECT * FROM ".db_table_name("groups")." WHERE sid='{$surveyid}' AND language='{$surveyprintlang}' ORDER BY ".db_table_name("groups").".group_order"; $degresult = db_execute_assoc($degquery); // GROUP NAME while ($degrow = $degresult->FetchRow()) { $deqquery = "SELECT * FROM ".db_table_name("questions")." WHERE sid=$surveyid AND gid={$degrow['gid']} AND language='{$surveyprintlang}' AND TYPE<>'I' ORDER BY question_order"; $deqresult = db_execute_assoc($deqquery); $deqrows = array(); //Create an empty array in case FetchRow does not return any rows while ($deqrow = $deqresult->FetchRow()) {$deqrows[] = $deqrow;} // Get table output into array // Perform a case insensitive natural sort on group name then question title of a multidimensional array usort($deqrows, 'CompareGroupThenTitle'); $printablesurveyoutput .="\t\n"; $printablesurveyoutput .="\t\t\n"; $printablesurveyoutput .="\t\n"; $gid = $degrow['gid']; //Alternate bgcolor for different groups if (!isset($bgc) || $bgc == "#EEEEEE") {$bgc = "#DDDDDD";} else {$bgc = "#EEEEEE";} foreach ($deqrows as $deqrow) { //GET ANY CONDITIONS THAT APPLY TO THIS QUESTION $explanation = ""; //reset conditions explanation $x=0; $distinctquery="SELECT DISTINCT cqid, method, ".db_table_name("questions").".title FROM ".db_table_name("conditions").", ".db_table_name("questions")." WHERE ".db_table_name("conditions").".cqid=".db_table_name("questions").".qid AND ".db_table_name("conditions").".qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY cqid"; $distinctresult=db_execute_assoc($distinctquery); while ($distinctrow=$distinctresult->FetchRow()) { if ($x > 0) {$explanation .= " ".$clang->gT("and")." ";} if (trim($distinctrow['method'])=='') {$distinctrow['method']='==';} if ($distinctrow['method']=='==') {$explanation .= $clang->gT("if you answered")." ";} elseif ($distinctrow['method']='!=') {$explanation .= $clang->gT("if you have NOT answered")." ";} else {$explanation .= $clang->gT("if you answered")." ";} $conquery="SELECT cid, cqid, ".db_table_name("questions").".title,\n" ."".db_table_name("questions").".question, value, ".db_table_name("questions").".type,\n" ."".db_table_name("questions").".lid, cfieldname\n" ."FROM ".db_table_name("conditions").", ".db_table_name("questions")."\n" ."WHERE ".db_table_name("conditions").".cqid=".db_table_name("questions").".qid\n" ."AND ".db_table_name("conditions").".cqid={$distinctrow['cqid']}\n" ."AND ".db_table_name("conditions").".qid={$deqrow['qid']} AND language='{$surveyprintlang}'"; $conresult=db_execute_assoc($conquery) or safe_die("$conquery
".htmlspecialchars($connect->ErrorMsg())); $conditions=array(); while ($conrow=$conresult->FetchRow()) { $postans=""; $value=$conrow['value']; switch($conrow['type']) { case "Y": switch ($conrow['value']) { case "Y": $conditions[]=$clang->gT("Yes"); break; case "N": $conditions[]=$clang->gT("No"); break; } break; case "G": switch($conrow['value']) { case "M": $conditions[]=$clang->gT("Male"); break; case "F": $conditions[]=$clang->gT("Female"); break; } // switch break; case "A": case "B": $conditions[]=$conrow['value']; break; case "C": switch($conrow['value']) { case "Y": $conditions[]=$clang->gT("Yes"); break; case "U": $conditions[]=$clang->gT("Uncertain"); break; case "N": $conditions[]=$clang->gT("No"); break; } // switch break; case "E": switch($conrow['value']) { case "I": $conditions[]=$clang->gT("Increase"); break; case "D": $conditions[]=$clang->gT("Decrease"); break; case "S": $conditions[]=$clang->gT("Same"); break; } case "F": case "1": case "H": case "W": case "L": default: $value=substr($conrow['cfieldname'], strpos($conrow['cfieldname'], "X".$conrow['cqid'])+strlen("X".$conrow['cqid']), strlen($conrow['cfieldname'])); $fquery = "SELECT * FROM ".db_table_name("labels")."\n" . "WHERE lid='{$conrow['lid']}'\n" . "AND code='{$conrow['value']}' AND language='{$surveyprintlang}'"; $fresult=db_execute_assoc($fquery) or safe_die("$fquery
".htmlspecialchars($connect->ErrorMsg())); while($frow=$fresult->FetchRow()) { $postans=$frow['title']; $conditions[]=$frow['title']; } // while break; } // switch $answer_section=""; switch($conrow['type']) { case "A": case "B": case "C": case "E": $thiscquestion=arraySearchByKey($conrow['cfieldname'], $fieldmap, "fieldname"); $ansquery="SELECT answer FROM ".db_table_name("answers")." WHERE qid='{$conrow['cqid']}' AND code='{$thiscquestion[0]['aid']}' AND language='{$surveyprintlang}'"; $ansresult=db_execute_assoc($ansquery); while ($ansrow=$ansresult->FetchRow()) { $answer_section=" (".$ansrow['answer'].")"; } break; default: $ansquery="SELECT answer FROM ".db_table_name("answers")." WHERE qid='{$conrow['cqid']}' AND code='{$conrow['value']}' AND language='{$surveyprintlang}'"; $ansresult=db_execute_assoc($ansquery); while ($ansrow=$ansresult->FetchRow()) { $conditions[]=$ansrow['answer']; } $conditions = array_unique($conditions); break; } } if (count($conditions) > 1) { $explanation .= "'".implode("' ".$clang->gT("or")." '", $conditions)."'"; } elseif (count($conditions) == 1) { $explanation .= "'".$conditions[0]."'"; } unset($conditions); $explanation .= " ".$clang->gT("to question")." '".$distinctrow['title']." $answer_section'"; $x++; } if ($explanation) { $explanation = "[".$clang->gT("Only answer this question")." ".$explanation."]"; $printablesurveyoutput .="\n"; } //END OF GETTING CONDITIONS $qid = $deqrow['qid']; $fieldname = "$surveyid"."X"."$gid"."X"."$qid"; $printablesurveyoutput .="\t\n"; $printablesurveyoutput .="\t\t\n"; $printablesurveyoutput .="\t\n"; //DIFFERENT TYPES OF DATA FIELD HERE if(isset($_POST['printableexport'])){$pdf->intopdf($deqrow['title']." ".$deqrow['question']);} $printablesurveyoutput .="\t\n"; $printablesurveyoutput .="\t\t\n"; $printablesurveyoutput .="\t\t\n \n \n \n"; $printablesurveyoutput .="\t\n"; $printablesurveyoutput .="\t\n"; if(isset($_POST['printableexport'])){$pdf->ln(5);} } } $printablesurveyoutput .="\t\n"; $printablesurveyoutput .="\t\t\n"; $printablesurveyoutput .="\t\n"; $printablesurveyoutput .="
"; $printablesurveyoutput .=""; $printablesurveyoutput .=""; $printablesurveyoutput .=""; } if(isset($_POST['printableexport'])){$pdf->titleintopdf($surveyname,$surveydesc);} $printablesurveyoutput .="\t
\n"; $printablesurveyoutput .="\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t
\n"; $printablesurveyoutput .="\t\t\t\t\t$surveyname\n"; $printablesurveyoutput .="\t\t\t\t\t
$surveydesc\n"; $printablesurveyoutput .="\t\t\t\t
\n"; $printablesurveyoutput .="\t\t
\n"; $printablesurveyoutput .="\t\t\t{$degrow['group_name']}\n"; if ($degrow['description']) { $printablesurveyoutput .="\t\t\t
{$degrow['description']}\n"; } if(isset($_POST['printableexport'])){$pdf->titleintopdf($degrow['group_name'],$degrow['description']);} $printablesurveyoutput .="\t\t
$explanation
\n"; $pdfoutput =''; if ($deqrow['mandatory'] == "Y") { $printablesurveyoutput .=$clang->gT("*"); $pdfoutput .= $clang->gT("*"); } $printablesurveyoutput .="\t\t\t{$deqrow['title']}: {$deqrow['question']}\n"; $printablesurveyoutput .="\t\t
\n"; if ($deqrow['help']) { $hh = $deqrow['help']; $printablesurveyoutput .="\t\t\t
$hh
\n"; if(isset($_POST['printableexport'])){$pdf->helptextintopdf($hh);} } $printablesurveyoutput .="\t\t
\n"; switch($deqrow['type']) { case "5": //5 POINT CHOICE $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"),"U");} $pdfoutput =''; for ($i=1; $i<=5; $i++) { $pdfoutput .=" o ".$i." "; $printablesurveyoutput .="\t\t\t$i \n"; } if(isset($_POST['printableexport'])){$pdf->intopdf($pdfoutput);} break; case "D": //DATE $printablesurveyoutput .="\t\t\t".$clang->gT("Please enter a date:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please enter a date:")." ___________");} break; case "G": //GENDER $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; $printablesurveyoutput .="\t\t\t".$clang->gT("Female")."
\n"; $printablesurveyoutput .="\t\t\t".$clang->gT("Male")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"));} if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$clang->gT("Female")." | o ".$clang->gT("Male"));} break; case "W": //Flexible List case "Z": $qidattributes=getQuestionAttributes($deqrow['qid']); if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"),"U");} $deaquery = "SELECT * FROM ".db_table_name("labels")." WHERE lid={$deqrow['lid']} AND language='{$surveyprintlang}' ORDER BY sortorder"; $dearesult = db_execute_assoc($deaquery) or safe_die("ERROR: $deaquery
\n".$connect->ErrorMsg()); $deacount=$dearesult->RecordCount(); if ($deqrow['other'] == "Y") {$deacount++;} if ($dcols > 0 && $deacount >= $dcols) { $width=sprintf("%0d", 100/$dcols); $maxrows=ceil(100*($deacount/$dcols)/100); //Always rounds up to nearest whole number $divider="
"; $upto=0; $printablesurveyoutput .="\n
"; while ($dearow = $dearesult->FetchRow()) { if ($upto == $maxrows) { $printablesurveyoutput .=$divider; $upto=0; } $printablesurveyoutput .="\t\t\t{$dearow['title']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$dearow['title']);} $upto++; } if ($deqrow['other'] == "Y") { $printablesurveyoutput .="\t\t\t".$clang->gT("Other")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Other").": ________");} } $printablesurveyoutput .="
\n"; //Let's break the presentation into columns. } else { while ($dearow = $dearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t{$dearow['title']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$dearow['title']);} } if ($deqrow['other'] == "Y") { $printablesurveyoutput .="\t\t\t".$clang->gT("Other")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Other").": ________");} } } break; case "L": //LIST case "!": $qidattributes=getQuestionAttributes($deqrow['qid']); if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"));} $deaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $dearesult = db_execute_assoc($deaquery); $deacount=$dearesult->RecordCount(); if ($deqrow['other'] == "Y") {$deacount++;} if ($dcols > 0 && $deacount >= $dcols) { $width=sprintf("%0d", 100/$dcols); $maxrows=ceil(100*($deacount/$dcols)/100); //Always rounds up to nearest whole number $divider="
"; $upto=0; $printablesurveyoutput .="\n
"; while ($dearow = $dearesult->FetchRow()) { if ($upto == $maxrows) { $printablesurveyoutput .=$divider; $upto=0; } $printablesurveyoutput .="\t\t\t{$dearow['answer']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$dearow['answer']);} $upto++; } if ($deqrow['other'] == "Y") { $printablesurveyoutput .="\t\t\t".$clang->gT("Other")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$clang->gT("Other").": ________");} } $printablesurveyoutput .="
\n"; //Let's break the presentation into columns. } else { while ($dearow = $dearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t{$dearow['answer']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$dearow['answer']);} } if ($deqrow['other'] == "Y") { $printablesurveyoutput .="\t\t\t".$clang->gT("Other")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$clang->gT("Other").": ________");} } } break; case "O": //LIST WITH COMMENT $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"),"U");} $deaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer "; $dearesult = db_execute_assoc($deaquery); while ($dearow = $dearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t{$dearow['answer']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($dearow['answer']);} } $printablesurveyoutput .="\t\t\t".$clang->gT("Make a comment on your choice here:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf("Make a comment on your choice here:");} $printablesurveyoutput .="\t\t\t\n"; for($i=0;$i<9;$i++) { if(isset($_POST['printableexport'])){$pdf->intopdf("____________________");} } break; case "R": //RANKING Type Question $reaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $rearesult = db_execute_assoc($reaquery) or safe_die ("Couldn't get ranked answers
".$connect->ErrorMsg()); $reacount = $rearesult->RecordCount(); $printablesurveyoutput .="\t\t\t".$clang->gT("Please number each box in order of preference from 1 to")." $reacount
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please number each box in order of preference from 1 to ").$reacount,"U");} while ($rearow = $rearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\n"; $printablesurveyoutput .="\t\t\t
 {$rearow['answer']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf("__ ".$rearow['answer']);} } break; case "M": //MULTIPLE OPTIONS (Quite tricky really!) $qidattributes=getQuestionAttributes($deqrow['qid']); if ($displaycols=arraySearchByKey("display_columns", $qidattributes, "attribute", 1)) { $dcols=$displaycols['value']; } else { $dcols=0; } if (!$maxansw=arraySearchByKey("max_answers", $qidattributes, "attribute", 1)) { $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *all* that apply:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *all* that apply:"),"U");} } else { $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *at most* ").$maxansw['value']." ".$clang->gT("answers:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *at most* ").$maxansw['value'].$clang->gT("answers:"),"U");} } $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $meacount = $mearesult->RecordCount(); if ($deqrow['other'] == "Y") {$meacount++;} if ($dcols > 0 && $meacount >= $dcols) { $width=sprintf("%0d", 100/$dcols); $maxrows=ceil(100*($meacount/$dcols)/100); //Always rounds up to nearest whole number $divider="
"; $upto=0; $printablesurveyoutput .="\n
"; while ($mearow = $mearesult->FetchRow()) { if ($upto == $maxrows) { $printablesurveyoutput .=$divider; $upto=0; } $printablesurveyoutput .="\t\t\t{$mearow['answer']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$mearow['answer']);} $upto++; } if ($deqrow['other'] == "Y") { $printablesurveyoutput .="\t\t\t".$clang->gT("Other").": \n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$clang->gT("Other").": ________");} } $printablesurveyoutput .="
\n"; } else { while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t{$mearow['answer']}
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$mearow['answer']);} } if ($deqrow['other'] == "Y") { $printablesurveyoutput .="\t\t\t".$clang->gT("Other").": \n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Other").": ________");} } } break; /*case "I": //Language Switch in a printable survey does not make sense $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; $answerlangs = GetAdditionalLanguagesFromSurveyID($surveyid); $answerlangs [] = GetBaseLanguageFromSurveyID($surveyid); foreach ($answerlangs as $ansrow) { $printablesurveyoutput .="\t\t\t".getLanguageNameFromCode($ansrow, true)."
\n"; } break; */ case "P": //MULTIPLE OPTIONS WITH COMMENTS $qidattributes=getQuestionAttributes($deqrow['qid']); if (!$maxansw=arraySearchByKey("max_answers", $qidattributes, "attribute", 1)) { $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose all that apply and provide a comment:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose all that apply and provide a comment:"),"U");} } else { $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *at most* ").$maxansw['value']." ".$clang->gT("answers and provide a comment:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *at most* ").$maxansw['value'].$clang->gT("answers and provide a comment:"),"U");} } $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); // $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose all that apply and provide a comment:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; $pdfoutput=array(); $j=0; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $a++; } $printablesurveyoutput .="\t\t\t
tableintopdf($pdfoutput);} break; case "Q": //MULTIPLE SHORT TEXT $width=60; case "K": //MULTIPLE NUMERICAL $width=(!isset($width)) ? 30 : $width; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please write your answer(s) here:"),"U");} $printablesurveyoutput .="\t\t\t".$clang->gT("Please write your answer(s) here:")."
\n"; $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t\n"; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t
{$mearow['answer']}:intopdf($mearow['answer'].": ____________________");} } $printablesurveyoutput .="\t\t\t
\n"; break; case "S": //SHORT TEXT $printablesurveyoutput .="\t\t\t".$clang->gT("Please write your answer here:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please write your answer here:"),"U");} if(isset($_POST['printableexport'])){$pdf->intopdf("____________________");} break; case "T": //LONG TEXT $printablesurveyoutput .="\t\t\t".$clang->gT("Please write your answer here:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please write your answer here:"),"U");} for($i=0;$i<9;$i++) { if(isset($_POST['printableexport'])){$pdf->intopdf("____________________");} } break; case "U": //HUGE TEXT $printablesurveyoutput .="\t\t\t".$clang->gT("Please write your answer here:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please write your answer here:"),"U");} for($i=0;$i<20;$i++) { if(isset($_POST['printableexport'])){$pdf->intopdf("____________________");} } break; case "N": //NUMERICAL $printablesurveyoutput .="\t\t\t".$clang->gT("Please write your answer here:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please write your answer here:"),"U");} if(isset($_POST['printableexport'])){$pdf->intopdf("____________________");} break; case "Y": //YES/NO $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose *only one* of the following:")."
\n"; $printablesurveyoutput .="\t\t\t".$clang->gT("Yes")."
\n"; $printablesurveyoutput .="\t\t\t".$clang->gT("No")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose *only one* of the following:"),"U");} if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$clang->gT("Yes"));} if(isset($_POST['printableexport'])){$pdf->intopdf(" o ".$clang->gT("No"));} break; case "A": //ARRAY (5 POINT CHOICE) $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} $pdfoutput = array(); $j=0; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $answertext=$mearow['answer']; if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));} $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $answertext=$mearow['answer']; if (strpos($answertext,'|')) { $answertext=substr($answertext,strpos($answertext,'|')+1); $printablesurveyoutput .= "\t\t\t\t\n"; } $printablesurveyoutput .="\t\t\t\t\n"; $j++; } $printablesurveyoutput .="\t\t\t
$answertext"; $pdfoutput[$j][0]=$answertext; for ($i=1; $i<=5; $i++) { $printablesurveyoutput .="\t\t\t\t\t\t$i \n"; $pdfoutput[$j][$i]=" o ".$i; } $printablesurveyoutput .="\t\t\t\t\t$answertext
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; case "B": //ARRAY (10 POINT CHOICE) $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} $pdfoutput=array(); $j=0; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $j++; } $printablesurveyoutput .="\t\t\t
{$mearow['answer']}\n"; $pdfoutput[$j][0]=$mearow['answer']; for ($i=1; $i<=10; $i++) { $printablesurveyoutput .="\t\t\t\t\t\t$i \n"; $pdfoutput[$j][$i]=" o ".$i; } $printablesurveyoutput .="\t\t\t\t\t
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; case "C": //ARRAY (YES/UNCERTAIN/NO) $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} $pdfoutput = array(); $j=0; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $pdfoutput[$j]=array($mearow['answer']," o ".$clang->gT("Yes")," o ".$clang->gT("Uncertain")," o ".$clang->gT("No")); $j++; } $printablesurveyoutput .="\t\t\t
{$mearow['answer']}\n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Yes")." \n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Uncertain")." \n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("No")." \n"; $printablesurveyoutput .="\t\t\t\t\t
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; case "E": //ARRAY (Increase/Same/Decrease) $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} $pdfoutput = array(); $j=0; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $pdfoutput[$j]=array($mearow['answer'].":"," o ".$clang->gT("Increase")," o ".$clang->gT("Same")," o ".$clang->gT("Decrease")); $j++; } $printablesurveyoutput .="\t\t\t
{$mearow['answer']}\n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Increase")." \n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Same")." \n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Decrease")." \n"; $printablesurveyoutput .="\t\t\t\t\t
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; case "F": //ARRAY (Flexible Labels) //$headstyle="style='border-left-style: solid; border-left-width: 1px; border-left-color: #AAAAAA'"; $headstyle="style='padding-left: 20px; padding-right: 7px'"; $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
\n"; $printablesurveyoutput .="\t\t\t\n"; $fquery = "SELECT * FROM ".db_table_name("labels")." WHERE lid='{$deqrow['lid']}' AND language='{$surveyprintlang}' ORDER BY sortorder, code"; $fresult = db_execute_assoc($fquery); $fcount = $fresult->RecordCount(); $fwidth = "120"; $i=1; $pdfoutput = array(); $pdfoutput[0][0]=''; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} while ($frow = $fresult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\t\t\n"; $pdfoutput[0][$i] = $frow['title']; $i++; } $printablesurveyoutput .="\t\t\t\t\t\t\n"; $counter = 1; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $answertext=$mearow['answer']; if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));} $printablesurveyoutput .="\t\t\t\t\t\n"; //$printablesurveyoutput .="\t\t\t\t\t\n"; $pdfoutput[$counter][$i] = "o"; } $counter++; $answertext=$mearow['answer']; if (strpos($answertext,'|')) { $answertext=substr($answertext,strpos($answertext,'|')+1); $printablesurveyoutput .= "\t\t\t\t\n"; } $printablesurveyoutput .="\t\t\t\t\n"; } $printablesurveyoutput .="\t\t\t
{$frow['title']}
$answertext"; $pdfoutput[$counter][0]=$answertext; for ($i=1; $i<=$fcount; $i++) { $printablesurveyoutput .="\t\t\t\t\t 1) {$printablesurveyoutput .=" $headstyle";} $printablesurveyoutput .=">\n"; $printablesurveyoutput .="\t\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t$answertext
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; case "1": //ARRAY (Flexible Labels) multi scale $qidattributes=getQuestionAttributes($deqrow['qid']); if ($dsheaderA=arraySearchByKey("dualscale_headerA", $qidattributes, "attribute", 1)) { $leftheader= $dsheaderA['value']; } else { $leftheader =''; } if ($dsheaderB=arraySearchByKey("dualscale_headerB", $qidattributes, "attribute", 1)) { $rightheader= $dsheaderB['value']; } else { $rightheader =''; } //$headstyle="style='border-left-style: solid; border-left-width: 1px; border-left-color: #AAAAAA'"; $headstyle="style='padding-left: 20px; padding-right: 7px'"; $meaquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $mearesult = db_execute_assoc($meaquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} $printablesurveyoutput .="\t\t\t"; $fquery = "SELECT * FROM ".db_table_name("labels")." WHERE lid='{$deqrow['lid']}' AND language='{$surveyprintlang}' ORDER BY sortorder, code"; $fresult = db_execute_assoc($fquery); $fcount = $fresult->RecordCount(); $fwidth = "120"; $l1=0; $printablesurveyoutput2 = ''; $myheader2 = ''; $pdfoutput = array(); $pdfoutput[0][0]=''; while ($frow = $fresult->FetchRow()) { $printablesurveyoutput2 .="\t\t\t\t\t\t\n"; $myheader2 .= ""; $pdfoutput[0][$ll+1]=$frow['title']; $l1++; } // second scale $printablesurveyoutput2 .="\t\t\t\t\t\t\n"; $fquery1 = "SELECT * FROM ".db_table_name("labels")." WHERE lid='{$deqrow['lid1']}' AND language='{$surveyprintlang}' ORDER BY sortorder, code"; $fresult1 = db_execute_assoc($fquery1); $fcount1 = $fresult1->RecordCount(); $fwidth = "120"; $l2=0; while ($frow1 = $fresult1->FetchRow()) { $printablesurveyoutput2 .="\t\t\t\t\t\t\n"; $pdfoutput[1][$l2]=$frow['title']; $l2++; } // build header if needed if ($leftheader != '' || $rightheader !='') { $myheader = "\t\t\t\t\t"; $myheader .= "\t\t\t\t\t\n"; if ($rightheader !='') { // $myheader .= "\t\t\t\t\t" .$myheader2; $myheader .= "\t\t\t\t\t"; $myheader .= "\t\t\t\t\t\n"; } $myheader .= "\t\t\t\t\n"; } else { $myheader = ''; } $printablesurveyoutput .= $myheader; $printablesurveyoutput .= $printablesurveyoutput2; $printablesurveyoutput .="\t\t\t\t\t\t\n"; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $answertext=$mearow['answer']; if (strpos($answertext,'|')) {$answertext=substr($answertext,0, strpos($answertext,'|'));} $printablesurveyoutput .="\t\t\t\t\t\n"; for ($i=1; $i<=$fcount; $i++) { $printablesurveyoutput .="\t\t\t\t\t\n"; } $printablesurveyoutput .="\t\t\t\t\t\t\n"; for ($i=1; $i<=$fcount1; $i++) { $printablesurveyoutput .="\t\t\t\t\t\n"; } $answertext=$mearow['answer']; if (strpos($answertext,'|')) { $answertext=substr($answertext,strpos($answertext,'|')+1); $printablesurveyoutput .= "\t\t\t\t\n"; } $printablesurveyoutput .="\t\t\t\t\n"; } $printablesurveyoutput .="\t\t\t
{$frow['title']}{$frow1['title']}$leftheader$rightheader
$answertext 1) {$printablesurveyoutput .=" $headstyle";} $printablesurveyoutput .=">\n"; $printablesurveyoutput .="\t\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t 1) {$printablesurveyoutput .=" $headstyle";} $printablesurveyoutput .=">\n"; $printablesurveyoutput .="\t\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t$answertext
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; case "H": //ARRAY (Flexible Labels) by Column //$headstyle="style='border-left-style: solid; border-left-width: 1px; border-left-color: #AAAAAA'"; $headstyle="style='padding-left: 20px; padding-right: 7px'"; $fquery = "SELECT * FROM ".db_table_name("answers")." WHERE qid={$deqrow['qid']} AND language='{$surveyprintlang}' ORDER BY sortorder, answer"; $fresult = db_execute_assoc($fquery); $printablesurveyoutput .="\t\t\t".$clang->gT("Please choose the appropriate response for each item:")."
\n"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please choose the appropriate response for each item:"),"U");} $printablesurveyoutput .="\t\t\t\n"; $meaquery = "SELECT * FROM ".db_table_name("labels")." WHERE lid='{$deqrow['lid']}' AND language='{$surveyprintlang}' ORDER BY sortorder, code"; $mearesult = db_execute_assoc($meaquery); $fcount = $fresult->RecordCount(); $fwidth = "120"; $i=0; $pdfoutput = array(); $pdfoutput[0][0]=''; while ($frow = $fresult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\t\n"; $i++; $pdfoutput[0][$i]=$frow['answer']; } $printablesurveyoutput .="\t\t\t\t\t\t\n"; $a=1; while ($mearow = $mearesult->FetchRow()) { $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\t\n"; //$printablesurveyoutput .="\t\t\t\t\t\n"; $pdfoutput[$a][$i]="o"; } //$printablesurveyoutput .="\t\t\t\t\t
{$frow['answer']}
{$mearow['title']}"; $pdfoutput[$a][0]=$mearow['title']; for ($i=1; $i<=$fcount; $i++) { $printablesurveyoutput .="\t\t\t\t\t 1) {$printablesurveyoutput .=" $headstyle";} $printablesurveyoutput .=">\n"; $printablesurveyoutput .="\t\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t
\n"; if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);} break; } $printablesurveyoutput .="\t\t

\n"; $printablesurveyoutput .="\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t\t\n"; $printablesurveyoutput .="\t\t\t
\n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Submit Your Survey.")."
\n"; $printablesurveyoutput .="\t\t\t\t\t\t".$clang->gT("Thank you for completing this survey."); if(isset($_POST['printableexport'])){$pdf->titleintopdf($clang->gT("Submit Your Survey."),$clang->gT("Thank you for completing this survey."));} if(!empty($surveyfaxto)) //If no fax number exists, don't display faxing information! { $printablesurveyoutput .= $clang->gT("Please fax your completed survey to:")." $surveyfaxto"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please fax your completed survey to:")."$surveyfaxto",'B');} } if ($surveyuseexpiry=="Y") { $printablesurveyoutput .=$clang->gT("Please submit by")." $surveyexpirydate"; if(isset($_POST['printableexport'])){$pdf->intopdf($clang->gT("Please submit by")." $surveyexpirydate");} } $printablesurveyoutput .=".\n"; $printablesurveyoutput .="\t\t\t\t\t
\n"; $printablesurveyoutput .="\t\t
\n"; $printablesurveyoutput .="\n"; if(isset($_POST['printableexport'])) { $pdf->write_out($clang->gT($surveyname)." ".$surveyid.".pdf"); } echo $printablesurveyoutput ; exit; ?>