示例#1
0
if (isset($_SESSION['admin'])) {
    $club_id = $_SESSION['admin_club_id'];
    include "category_manager.php";
    //sets database and whereString based on club/category
    $message = "";
    if (isset($_REQUEST['gen'])) {
        $result = mysql_query("SELECT varname, vardesc, vartype, '' FROM {$database} WHERE {$whereString} ORDER BY orderId");
        if ($club_id != 0) {
            $whereString = "id = '" . $club_id . "'";
            $clubInfo = clubInfo($club_id);
            //array (club name, club description, open_time, close_time, num_recommendations)
            $sectionheader = "Supplement: " . $clubInfo[0];
        } else {
            $sectionheader = "General Application";
        }
        $createResult = generatePDFByResult($result, "../pdf/", $sectionheader);
        if (!$createResult[0]) {
            $error = "Error during PDF generation: " . $createResult[1];
        } else {
            $basePath = basePath();
            $style = getStyle();
            $stylePath = $basePath . "/astyle/{$style}";
            $message = "<a href=\"../pdf/" . $createResult[1] . ".pdf\"><img src=\"" . $stylePath . "/images/application_word.png\" width=\"64\"></a>";
            $success = "PDF made!";
        }
    }
    if (isset($error)) {
        get_page_advanced("gen_pdf", "admin", array('error' => $error, 'message' => $message, 'categories' => $categories));
    } else {
        if (isset($success)) {
            get_page_advanced("gen_pdf", "admin", array('success' => $success, 'message' => $message, 'categories' => $categories));
示例#2
0
文件: latex.php 项目: uakfdotb/oneapp
function createApplicationPDF($user_id, $application_id, $targetDirectory)
{
    $user_id = escape($user_id);
    $application_id = escape($application_id);
    //first verify that application belongs to user and has not been submitted yet
    $checkArray = checkApplication($user_id, $application_id, true);
    if ($checkArray[0] == -2 || $checkArray[0] == -1) {
        return array(FALSE, "verification failure");
    }
    $club_id = $checkArray[1];
    //get application fields
    if ($club_id == 0) {
        $result = mysql_query("SELECT baseapp.varname, baseapp.vardesc, baseapp.vartype, profiles.val, 0 AS sort_col, baseapp.orderId AS sort2_col FROM profiles, baseapp WHERE profiles.user_id = '{$user_id}' AND profiles.var_id = baseapp.id UNION ALL SELECT baseapp.varname, baseapp.vardesc, baseapp.vartype, answers.val, basecat.orderId AS sort_col, baseapp.orderId AS sort2_col FROM answers, baseapp, basecat WHERE answers.application_id = '{$application_id}' AND baseapp.id = answers.var_id AND basecat.id = baseapp.category ORDER BY sort_col, sort2_col");
        $sectionheader = "General Application";
    } else {
        $result = mysql_query("SELECT supplements.varname, supplements.vardesc, supplements.vartype, answers.val FROM answers, supplements WHERE answers.application_id = '{$application_id}' AND supplements.id = answers.var_id ORDER BY supplements.orderId");
        $clubInfo = clubInfo($club_id);
        //array (club name, club description, open_time, close_time, num_recommendations)
        $sectionheader = "Supplement: " . $clubInfo[0];
    }
    $userInfo = getUserInformation($user_id);
    //array(username, email, name)
    return generatePDFByResult($result, $targetDirectory, latexSpecialChars($sectionheader), "User ID: " . latexSpecialChars($user_id) . "\\\\" . latexSpecialChars($userInfo[2]));
}
示例#3
0
function customSubmit($instance_id, $sectionheader = "Custom", $extrainfo = "Custom")
{
    $instance_id = escape($instance_id);
    //make sure all fields have been filled completely
    $result = mysql_query("SELECT custom.vartype FROM custom_response LEFT JOIN custom ON custom_response.var_id = custom.id WHERE custom_response.instance_id='{$instance_id}' AND custom_response.val = ''");
    while ($row = mysql_fetch_array($result)) {
        $typeArray = getTypeArray($row[0]);
        if ($typeArray['status'] == "required") {
            return -2;
        }
    }
    //create the PDF
    $result = mysql_query("SELECT custom.varname, custom.vardesc, custom.vartype, custom_response.val FROM custom_response LEFT JOIN custom ON custom_response.var_id = custom.id WHERE custom_response.instance_id = '{$instance_id}' ORDER BY custom.orderId");
    $createResult = generatePDFByResult($result, "../submit/", $sectionheader, $extrainfo);
    if (!$createResult[0]) {
        //if error during PDF generation
        return -1;
    }
    $filename = $createResult[1];
    return $filename;
}