/** * @param Loi $loi * * @return AffiliationPdf */ public function renderProjectLoi(Loi $loi) { $pdf = new AffiliationPdf(); $pdf->setTemplate($this->getModuleOptions()->getDoaTemplate()); $pdf->addPage(); $pdf->SetFontSize(9); $twig = $this->getServiceLocator()->get('ZfcTwigRenderer'); /** * Write the contact details */ $contactService = $this->getContactService()->setContact($loi->getContact()); $pdf->SetXY(14, 55); $pdf->Write(0, $contactService->parseFullName()); $pdf->SetXY(14, 60); $pdf->Write(0, $contactService->parseOrganisation()); /** * Write the current date */ $pdf->SetXY(77, 55); $pdf->Write(0, date("Y-m-d")); /** * Write the Reference */ $pdf->SetXY(118, 55); /** * Use the NDA object to render the filename */ $pdf->Write(0, $loi->parseFileName()); $ndaContent = $twig->render('affiliation/pdf/loi-project', array('contact' => $loi->getContact(), 'project' => $loi->getAffiliation()->getProject(), 'organisation' => $loi->getAffiliation()->getOrganisation())); $pdf->writeHTMLCell(0, 0, 14, 70, $ndaContent); /** * Signage block */ $pdf->SetXY(14, 250); $pdf->Write(0, 'Undersigned'); $pdf->SetXY(14, 260); $pdf->Write(0, 'Name:'); $pdf->SetXY(100, 260); $pdf->Write(0, 'Date of Signature:'); $pdf->SetXY(14, 270); $pdf->Write(0, 'Function:'); $pdf->SetXY(100, 270); $pdf->Write(0, 'Signature:'); $pdf->Line(130, 275, 190, 275); $pdf->Line(30, 265, 90, 265); $pdf->Line(130, 265, 190, 265); $pdf->Line(30, 275, 90, 275); return $pdf; }
/** * @return bool */ public function isEmpty() { return is_null($this->loi) || is_null($this->loi->getId()); }
/** * @return \Zend\Stdlib\ResponseInterface */ public function renderAction() { $affiliationService = $this->getAffiliationService()->setAffiliationId($this->params('affiliation-id')); //Create an empty Loi object $programLoi = new Loi(); $programLoi->setContact($this->zfcUserAuthentication()->getIdentity()); $programLoi->setAffiliation($affiliationService->getAffiliation()); $renderProjectLoi = $this->renderLoi()->renderProjectLoi($programLoi); $response = $this->getResponse(); $response->getHeaders()->addHeaderLine('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 36000))->addHeaderLine("Cache-Control: max-age=36000, must-revalidate")->addHeaderLine("Pragma: public")->addHeaderLine('Content-Disposition', 'attachment; filename="' . $programLoi->parseFileName() . '.pdf"')->addHeaderLine('Content-Type: application/pdf')->addHeaderLine('Content-Length', strlen($renderProjectLoi->getPDFData())); $response->setContent($renderProjectLoi->getPDFData()); return $response; }