コード例 #1
0
ファイル: ApplicantPDF.php プロジェクト: Jazzee/Jazzee
 /**
  * PDF a full single applicant using the display array
  * @param \Jazzee\Entity\Application $application
  * @param array $applicant
  * @return string the PDF buffer suitable for display
  */
 public function pdfFromApplicantArray(\Jazzee\Entity\Application $application, array $applicant)
 {
     $this->pdf->set_info("Title", $this->pdf->convert_to_unicode('utf8', $applicant["fullName"], '') . ' Application');
     $this->addText($applicant["fullName"] . "\n", 'h1');
     $this->addText('Email Address: ' . $applicant["email"] . "\n", 'p');
     if ($applicant["isLocked"]) {
         switch ($applicant["decision"]["status"]) {
             case 'finalDeny':
                 $status = 'Denied';
                 break;
             case 'finalAdmit':
                 $status = 'Admited';
                 break;
             case 'acceptOffer':
                 $status = 'Accepted';
                 break;
             case 'declineOffer':
                 $status = 'Declined';
                 break;
             default:
                 $status = 'No Decision';
         }
     } else {
         $status = 'Not Locked';
     }
     $this->addText("Admission Status: {$status}\n", 'p');
     $this->write();
     $pages = array();
     foreach ($applicant['pages'] as $pageArray) {
         $pages[$pageArray['id']] = $pageArray['answers'];
     }
     foreach ($application->getApplicationPages(\Jazzee\Entity\ApplicationPage::APPLICATION) as $applicationPath) {
         if ($applicationPath->getJazzeePage() instanceof \Jazzee\Interfaces\PdfPage) {
             $applicationPath->getJazzeePage()->setController($this->_controller);
             $pageData = array_key_exists($applicationPath->getPage()->getId(), $pages) ? $pages[$applicationPath->getPage()->getId()] : array();
             $applicationPath->getJazzeePage()->renderPdfSectionFromArray($pageData, $this);
         }
     }
     $this->write();
     $this->pdf->end_page_ext("");
     foreach ($applicant["attachments"] as $attachment) {
         $blob = \Jazzee\Globals::getFileStore()->getFileContents($attachment["attachmentHash"]);
         $this->addPdf($blob);
         $blob = null;
     }
     $this->attachPdfs();
     $this->pdf->end_document("");
     return $this->pdf->get_buffer();
 }