Example #1
0
namespace Ventus\Student;

//============================================================================================
// Session, config
//============================================================================================
require '../includes/php/bootstrap.php';
$SESSION = new \Zend_Session_Namespace('student', true);
if (!isset($SESSION->logged_in)) {
    header('location: index.php?next=' . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']);
    die;
}
//============================================================================================
// Load the Model and L10N
//============================================================================================
$model = new LettersIssued($dbo);
$dashboard = new Dashboard($dbo);
if (\Ventus\Utilities\I18n\Translate::isAllowedLanguage($SESSION->corr_lang)) {
    $l10n->setLanguage($SESSION->corr_lang);
    \Locale::setDefault($SESSION->corr_lang);
}
$l10n->addResource(FS_L10N . '/header-external.json');
//============================================================================================
// Load the page requested by the user
//============================================================================================
$this_page = "letters";
if (!isset($_GET['page'])) {
    $count_pending_follow_ups = $dashboard->fetchCountPendingFollowUps($SESSION->student_num);
    $all_student_letters = $model->fetchAllLetters($SESSION->student_num);
    $l10n->addResource(__DIR__ . '/l10n/header.json');
    $l10n->addResource(__DIR__ . '/l10n/letters-issued.json');
<?php

namespace Ventus\Student;

require '../includes/php/bootstrap.php';
// Load the Model
$letter_model = new LettersIssued($dbo);
$letter = $letter_model->fetchLetter($_GET['serial']);
if (!$letter) {
    echo '<div style="text-align:center; font-size:1.5em; font-family: Segoe UI, Arial; margin-top: 2em;">Cette lettre n\'existe pas. No such letter exists :(</div>';
} else {
    $format = 'html';
    if (isset($_GET['format']) && $_GET['format'] === 'pdf') {
        $format = 'pdf';
    }
    if (isset($_GET['format']) && $_GET['format'] === 'pdf-email-attachment') {
        $format = 'pdf-email-attachment';
    }
    //Generate QR code based on letter serial
    ob_start();
    \PHPQRCode\QRcode::png("https://" . URL_STUDENT . "/letters-issued-fetch-as-pdf.php?serial={$letter['letter_serial']}", null);
    $qr = 'data:image/png;base64,' . base64_encode(ob_get_contents());
    ob_end_clean();
    //Generate PDF with QR code
    $html = '<!DOCTYPE html>
                <div style="width: 25%; padding: 10px; margin-right: 10px; float: left; text-align: center;">
                    <img src="//' . URL_IMAGES . '/uottawa_logo.png" style="width: 130px; margin-top: 2em;">
                    <address style="font-style: normal; font-weight: bold; font-family: Segoe UI, Arial; margin-top: 5em; text-align: left; padding-left: 20px;">
                        <h5 style="color: #800000; margin-bottom: 0.2em;">Université d\'Ottawa</h5>
                        <h6 style="color: #6a584a; margin-top: 0.2em;">
                            Service d\'appui au succ&#232;s scolaire (SASS)<br>