/** * {@inheritDoc} */ public function setUp() { $this->serviceManager = Bootstrap::getServiceManager(); $this->doa = new Doa(); $this->doa->setId(1); $program = new Program(); $program->setId(1); $program->setProgram('Program'); $this->doa->setProgram($program); $organisation = new Organisation(); $organisation->setId(1); $organisation->setOrganisation("Organisation"); $this->doa->setOrganisation($organisation); $this->authorizeService = $this->serviceManager->get('BjyAuthorize\\Service\\Authorize'); if (!$this->authorizeService->getAcl()->hasResource($this->doa)) { $this->authorizeService->getAcl()->addResource($this->doa); $this->authorizeService->getAcl()->allow([], $this->doa, []); } /** * Add the resource on the fly */ if (!$this->authorizeService->getAcl()->hasResource(new Doa())) { $this->authorizeService->getAcl()->addResource(new Doa()); } $this->authorizeService->getAcl()->allow([], new Doa(), []); $this->doaLink = $this->serviceManager->get('viewhelpermanager')->get('programDoaLink'); /** * Bootstrap the application to have the other information available */ $application = $this->serviceManager->get('application'); $application->bootstrap(); }
/** * @param Doa $doa * * @return ProgramPdf */ public function renderForDoa(Doa $doa) { $pdf = new ProgramPdf(); $pdf->setTemplate($this->getModuleOptions()->getDoaTemplate()); $pdf->addPage(); $pdf->SetFontSize(9); $twig = $this->getServiceLocator()->get('ZfcTwigRenderer'); /* * Write the contact details */ $contactService = $this->getContactService()->setContact($doa->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, $doa->parseFileName()); $ndaContent = $twig->render('program/pdf/doa-program', ['contact' => $doa->getContact(), 'program' => $doa->getProgram()]); $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; }
public function testCanRenderDoa() { /** * Bootstrap the application to have the other information available */ $renderDoa = new RenderDoa(); $renderDoa->setServiceLocator($this->serviceManager); $contact = new Contact(); $contact->setFirstName('Johan'); $contact->setLastName('van der Heide'); $program = new Program(); $program->setProgram('testProgram'); $doa = new Doa(); $doa->setContact($contact); $doa->setProgram($program); $pdf = $renderDoa->renderForDoa($doa); $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf); $this->assertTrue(strlen($pdf->getPDFData()) > 0); }
/** * @return \Zend\Stdlib\ResponseInterface */ public function renderAction() { $organisationService = $this->getOrganisationService()->setOrganisationId($this->getEvent()->getRouteMatch()->getParam('organisation-id')); $program = $this->getProgramService()->findEntityById('Program', $this->getEvent()->getRouteMatch()->getParam('program-id')); //Create an empty Doa object $programDoa = new Doa(); $programDoa->setContact($this->zfcUserAuthentication()->getIdentity()); $programDoa->setOrganisation($organisationService->getOrganisation()); $programDoa->setProgram($program); $renderProjectDoa = $this->renderProgramDoa()->renderForDoa($programDoa); $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="' . $programDoa->parseFileName() . '.pdf"')->addHeaderLine('Content-Type: application/pdf')->addHeaderLine('Content-Length', strlen($renderProjectDoa->getPDFData())); $response->setContent($renderProjectDoa->getPDFData()); return $response; }