\n";
$printablesurveyoutput .="\t\t\n";
if ($deqrow['help'])
{
$hh = $deqrow['help'];
$printablesurveyoutput .="\t\t\t\n";
if(isset($_POST['printableexport'])){$pdf->helptextintopdf($hh);}
}
$printablesurveyoutput .="\t\t \n";
$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=" \n ";
$upto=0;
$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=" \n ";
$upto=0;
$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=" \n ";
$upto=0;
$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 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";
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->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->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->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->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";
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\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";
$printablesurveyoutput .="\t\t\t\t \n";
$a++;
}
$printablesurveyoutput .="\t\t\t
\n";
if(isset($_POST['printableexport'])){$pdf->tableintopdf($pdfoutput);}
break;
}
$printablesurveyoutput .="\t\t \n";
$printablesurveyoutput .="\t \n";
$printablesurveyoutput .="\t