<?php

require_once __DIR__ . "/../../../Backend/Certs/ConfirmationCertificate.php";
SessionManager::validateUserInPage('confirmationLook.php');
if (isset($_GET) && $_GET["idConfirmation"] !== NULL && isset($_SESSION) && $_SESSION["user_id"] !== NULL) {
    $user = SessionManager::getCurrentUser();
    $pdf = new ConfirmationCertificate($user->getId(), $_GET["idConfirmation"], $_GET["full"]);
    $pdf->AliasNbPages();
    $pdf->AddPage();
    $pdf->displayData();
    $pdf->Output();
} else {
    echo "<script>\n                url = String(window.location);\n                url = url.substr(0, url.indexOf('cert'));\n                window.location.href = url + 'main.php';\n              </script>";
}
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return ConfirmationCertificate the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = ConfirmationCertificate::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }