コード例 #1
0
ファイル: printanswers.php プロジェクト: himanshu12k/ce-www
}
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$printoutput = '';
if (isset($usepdfexport) && $usepdfexport == 1) {
    $printoutput .= "<form action='printanswers.php?printableexport=pdf&sid={$surveyid}' method='post'>\n<center><input type='submit' value='" . $clang->gT("PDF Export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
}
if (isset($_POST['printableexport'])) {
    $pdf = new PDF($pdforientation);
    $pdf->SetFont($pdfdefaultfont, '', $pdffontsize);
    $pdf->AddPage();
    $pdf->titleintopdf($clang->gT("Survey name (ID)", 'unescaped') . ": {$surveyname} ({$surveyid})");
}
$printoutput .= "\t<div class='printouttitle'><strong>" . $clang->gT("Survey name (ID):") . "</strong> {$surveyname} ({$surveyid})</div><p>&nbsp;\n";
$bHonorConditions = $printanswershonorsconditions == 1;
$aFullResponseTable = aGetFullResponseTable($surveyid, $id, $language, $bHonorConditions);
//Get the fieldmap @TODO: do we need to filter out some fields?
unset($aFullResponseTable['id']);
unset($aFullResponseTable['token']);
unset($aFullResponseTable['lastpage']);
unset($aFullResponseTable['startlanguage']);
unset($aFullResponseTable['datestamp']);
unset($aFullResponseTable['startdate']);
$printoutput .= "<table class='printouttable' >\n";
if (isset($_POST['printableexport'])) {
    $pdf->intopdf($clang->gT("Question", 'unescaped') . ": " . $clang->gT("Your answer", 'unescaped'));
}
$oldgid = 0;
$oldqid = 0;
foreach ($aFullResponseTable as $sFieldname => $fname) {
    if (substr($sFieldname, 0, 4) == 'gid_') {
コード例 #2
0
    }
}
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$printoutput = '';
if (isset($usepdfexport) && $usepdfexport == 1) {
    $printoutput .= "<form action='printanswers.php?printableexport=pdf&sid={$surveyid}' method='post'>\n<center><input type='submit' value='" . $clang->gT("PDF Export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
}
if (isset($_POST['printableexport'])) {
    $pdf = new PDF($pdforientation);
    $pdf->SetFont($pdfdefaultfont, '', $pdffontsize);
    $pdf->AddPage();
    $pdf->titleintopdf($clang->gT("Survey name (ID)", 'unescaped') . ": {$surveyname} ({$surveyid})");
}
$printoutput .= "\t<div class='printouttitle'><strong>" . $clang->gT("Survey name (ID):") . "</strong> {$surveyname} ({$surveyid})</div><p>&nbsp;\n";
$aFullResponseTable = aGetFullResponseTable($surveyid, $id, $language);
//Get the fieldmap @TODO: do we need to filter out some fields?
unset($aFullResponseTable['id']);
unset($aFullResponseTable['token']);
unset($aFullResponseTable['lastpage']);
unset($aFullResponseTable['startlanguage']);
unset($aFullResponseTable['datestamp']);
unset($aFullResponseTable['startdate']);
$printoutput .= "<table class='printouttable' >\n";
if (isset($_POST['printableexport'])) {
    $pdf->intopdf($clang->gT("Question", 'unescaped') . ": " . $clang->gT("Your answer", 'unescaped'));
}
$oldgid = 0;
$oldqid = 0;
foreach ($aFullResponseTable as $sFieldname => $fname) {
    if (substr($sFieldname, 0, 4) == 'gid_') {
コード例 #3
0
/**
* Send a submit notification to the email address specified in the notifications tab in the survey settings
*/
function SendSubmitNotifications()
{
    global $thissurvey, $debug;
    global $dbprefix, $clang, $emailcharset;
    global $sitename, $homeurl, $surveyid, $publicurl, $maildebug, $tokensexist;
    $bIsHTML = $thissurvey['htmlemail'] == 'Y';
    $aReplacementVars = array();
    if ($thissurvey['allowsave'] == "Y" && isset($_SESSION['scid'])) {
        $aReplacementVars['RELOADURL'] = "{$publicurl}/index.php?sid={$surveyid}&loadall=reload&scid=" . $_SESSION['scid'] . "&loadname=" . urlencode($_SESSION['holdname']) . "&loadpass="******"<a href='{$aReplacementVars['RELOADURL']}'>{$aReplacementVars['RELOADURL']}</a>";
        }
    } else {
        $aReplacementVars['RELOADURL'] = '';
    }
    $aReplacementVars['ADMINNAME'] = $thissurvey['adminname'];
    $aReplacementVars['ADMINEMAIL'] = $thissurvey['adminemail'];
    $aReplacementVars['VIEWRESPONSEURL'] = "{$homeurl}/admin.php?action=browse&sid={$surveyid}&subaction=id&id={$_SESSION['srid']}";
    $aReplacementVars['EDITRESPONSEURL'] = "{$homeurl}/admin.php?action=dataentry&sid={$surveyid}&subaction=edit&surveytable=survey_{$surveyid}&id=" . $_SESSION['srid'];
    $aReplacementVars['STATISTICSURL'] = "{$homeurl}/admin.php?action=statistics&sid={$surveyid}";
    if ($bIsHTML) {
        $aReplacementVars['VIEWRESPONSEURL'] = "<a href='{$aReplacementVars['VIEWRESPONSEURL']}'>{$aReplacementVars['VIEWRESPONSEURL']}</a>";
        $aReplacementVars['EDITRESPONSEURL'] = "<a href='{$aReplacementVars['EDITRESPONSEURL']}'>{$aReplacementVars['EDITRESPONSEURL']}</a>";
        $aReplacementVars['STATISTICSURL'] = "<a href='{$aReplacementVars['STATISTICSURL']}'>{$aReplacementVars['STATISTICSURL']}</a>";
    }
    $aReplacementVars['ANSWERTABLE'] = '';
    $aEmailResponseTo = array();
    $aEmailNotificationTo = array();
    $sResponseData = "";
    if (!empty($thissurvey['emailnotificationto'])) {
        $aRecipient = explode(";", $thissurvey['emailnotificationto']);
        foreach ($aRecipient as $sRecipient) {
            $sRecipient = dTexts::run($sRecipient);
            if (validate_email($sRecipient)) {
                $aEmailNotificationTo[] = $sRecipient;
            }
        }
    }
    if (!empty($thissurvey['emailresponseto'])) {
        if (isset($_SESSION['token']) && $_SESSION['token'] != '' && db_tables_exist($dbprefix . 'tokens_' . $surveyid)) {
            //Gather token data for tokenised surveys
            $_SESSION['thistoken'] = getTokenData($surveyid, $_SESSION['token']);
        } elseif ($_SESSION['insertarray'][0] == 'token') {
            unset($_SESSION['insertarray'][0]);
        }
        //Make an array of email addresses to send to
        $aRecipient = explode(";", $thissurvey['emailresponseto']);
        foreach ($aRecipient as $sRecipient) {
            $sRecipient = dTexts::run($sRecipient);
            if (validate_email($sRecipient)) {
                $aEmailResponseTo[] = $sRecipient;
            }
        }
        $aFullResponseTable = aGetFullResponseTable($surveyid, $_SESSION['srid'], $_SESSION['s_lang']);
        $ResultTableHTML = "<table class='printouttable' >\n";
        $ResultTableText = "\n\n";
        $oldgid = 0;
        $oldqid = 0;
        foreach ($aFullResponseTable as $sFieldname => $fname) {
            if (substr($sFieldname, 0, 4) == 'gid_') {
                $ResultTableHTML .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
                $ResultTableText .= "\n{$fname[0]}\n\n";
            } elseif (substr($sFieldname, 0, 4) == 'qid_') {
                $ResultTableHTML .= "\t<tr class='printanswersquestionhead'><td  colspan='2'>{$fname[0]}</td></tr>\n";
                $ResultTableText .= "\n{$fname[0]}\n";
            } else {
                $ResultTableHTML .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
                $ResultTableText .= "     {$fname[0]} {$fname[1]}: {$fname[2]}\n";
            }
        }
        $ResultTableHTML .= "</table>\n";
        $ResultTableText .= "\n\n";
        if ($bIsHTML) {
            $aReplacementVars['ANSWERTABLE'] = $ResultTableHTML;
        } else {
            $aReplacementVars['ANSWERTABLE'] = $ResultTableText;
        }
    }
    $sFrom = $thissurvey['adminname'] . ' <' . $thissurvey['adminemail'] . '>';
    if (count($aEmailNotificationTo) > 0) {
        $sMessage = templatereplace($thissurvey['email_admin_notification'], $aReplacementVars, $thissurvey['anonymized'] == "Y");
        $sSubject = templatereplace($thissurvey['email_admin_notification_subj'], $aReplacementVars, $thissurvey['anonymized'] == "Y");
        $oMail = new PHPMailer();
        foreach ($aEmailNotificationTo as $sRecipient) {
            if (!SendEmailMessage($oMail, $sMessage, $sSubject, $sRecipient, $sFrom, $sitename, $bIsHTML, getBounceEmail($surveyid))) {
                if ($debug > 0) {
                    echo '<br />Email could not be sent. Reason: ' . $maildebug . '<br/>';
                }
            }
        }
        $oMail->SmtpClose();
    }
    if (count($aEmailResponseTo) > 0) {
        $sMessage = templatereplace($thissurvey['email_admin_responses'], $aReplacementVars);
        $sSubject = templatereplace($thissurvey['email_admin_responses_subj'], $aReplacementVars);
        $mail = new PHPMailer();
        foreach ($aEmailResponseTo as $sRecipient) {
            if (!SendEmailMessage($mail, $sMessage, $sSubject, $sRecipient, $sFrom, $sitename, $bIsHTML, getBounceEmail($surveyid))) {
                if ($debug > 0) {
                    echo '<br />Email could not be sent. Reason: ' . $maildebug . '<br/>';
                }
            }
        }
        $mail->SmtpClose();
    }
}