/** * Construcutor takes the application we want to display * @param \Jazzee\Entity\Application $application */ public function __construct(\Jazzee\Entity\Application $application) { $applicantElements = array('firstName' => 'First Name', 'lastName' => 'Last Name', 'email' => 'Email', 'createdAt' => 'Created At', 'updatedAt' => 'Updated At', 'lastLogin' => 'Last Login', 'percentComplete' => 'Progress', 'isLocked' => 'Locked', 'lockedAt' => 'Last Locked', 'hasPaid' => 'Paid', 'externalId' => 'External ID', 'attachments' => 'Attachments', 'status_declined' => 'Declined', 'status_admitted' => 'Admitted', 'status_denied' => 'Denied', 'status_accepted' => 'Accepted', 'status_nominate_admit' => 'Nominate Admit', 'status_nominate_deny' => 'Nominate Deny'); foreach ($application->getApplicants() as $applicant) { foreach ($applicant->getTags() as $tag) { $applicantElements[$tag->getId()] = $tag->getTitle(); } } $weight = 0; foreach ($applicantElements as $name => $title) { $this->_elements[] = new \Jazzee\Display\Element('applicant', $title, $weight++, $name, null); } $pages = array(); foreach ($application->getApplicationPages() as $applicationPage) { if (is_subclass_of($applicationPage->getPage()->getType()->getClass(), 'Jazzee\\Interfaces\\DataPage')) { foreach ($applicationPage->getJazzeePage()->listDisplayElements() as $displayElement) { $this->_elements[] = $displayElement; if ($displayElement->getType() == 'page') { $this->_pageIds[] = $displayElement->getPageId(); } else { if ($displayElement->getType() == 'element') { $this->_elementIds[] = $displayElement->getName(); $this->_pageIds[] = $application->getElementById($displayElement->getName())->getPage()->getId(); } } } } } }
/** * Check credentials and intialize members */ public function beforeAction() { parent::beforeAction(); $this->_store = $this->_session->getStore('apply', $this->_config->getApplicantSessionLifetime()); $this->_application = $this->_em->getRepository('Jazzee\\Entity\\Application')->findEasy($this->actionParams['programShortName'], $this->actionParams['cycleName']); if (!$this->_application) { throw new \Jazzee\Exception("Unable to load {$this->actionParams['programShortName']} {$this->actionParams['cycleName']} application", E_USER_NOTICE, 'That is not a valid application'); } if (!$this->_application->isPublished() or $this->_application->getOpen() > new \DateTime('now')) { $this->addMessage('error', $this->_application->getCycle()->getName() . ' ' . $this->_application->getProgram()->getName() . ' is not open for applicants'); $this->redirectPath('apply/' . $this->_application->getProgram()->getShortName()); } foreach ($this->_application->getApplicationPages(\Jazzee\Entity\ApplicationPage::APPLICATION) as $applicationPage) { $this->_pages[$applicationPage->getId()] = $applicationPage; $applicationPage->getJazzeePage()->setController($this); } $this->setLayoutVar('layoutTitle', $this->_application->getCycle()->getName() . ' ' . $this->_application->getProgram()->getName() . ' Application'); $this->addCss($this->path('resource/styles/apply.css')); $this->setVar('application', $this->_application); }
/** * 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(); }