Beispiel #1
0
 /**
  * @return Nda
  */
 public function getNda()
 {
     if (is_null($this->nda)) {
         $this->nda = new Nda();
         if (!is_null($this->getCall())) {
             $arrayCollection = new ArrayCollection([$this->getCall()]);
             $this->nda->setCall($arrayCollection);
         }
     }
     return $this->nda;
 }
Beispiel #2
0
 public function testCanRenderCallNda()
 {
     $renderNda = new RenderNda();
     $renderNda->setServiceLocator($this->serviceManager);
     $contact = new Contact();
     $contact->setFirstName('Johan');
     $contact->setLastName('van der Heide');
     $nda = new Nda();
     $nda->setContact($contact);
     $pdf = $renderNda->renderForCall($nda);
     $this->assertInstanceOf("Program\\Controller\\Plugin\\ProgramPdf", $pdf);
     $this->assertTrue(strlen($pdf->getPDFData()) > 0);
 }
Beispiel #3
0
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->serviceManager = Bootstrap::getServiceManager();
     $this->nda = new Nda();
     $this->nda->setId(1);
     $contact = new Contact();
     $contact->setId(1234);
     $this->nda->setContact($contact);
     $program = new Program();
     $program->setId(1);
     $program->setProgram('Program');
     $call = new Call();
     $call->setId(1);
     $call->setCall("Call");
     $call->setProgram($program);
     $this->nda->setCall(new ArrayCollection([$call]));
     $this->ndaLink = $this->serviceManager->get('viewhelpermanager')->get('ndaLink');
     /**
      * Bootstrap the application to have the other information available
      */
     $application = $this->serviceManager->get('application');
     $application->bootstrap();
 }
Beispiel #4
0
 /**
  * Upload a NDA to the system and store it for the user
  *
  * @param array   $file
  * @param Contact $contact
  * @param Call    $call
  *
  * @return NdaObject
  */
 public function uploadNda(array $file, Contact $contact, Call $call = null)
 {
     $ndaObject = new NdaObject();
     $ndaObject->setObject(file_get_contents($file['tmp_name']));
     $nda = new Nda();
     $nda->setContact($contact);
     if (!is_null($call)) {
         $nda->setCall([$call]);
     }
     $nda->setSize($file['size']);
     $contentType = $this->getGeneralService()->findContentTypeByContentTypeName($file['type']);
     if (is_null($contentType)) {
         $contentType = $this->getGeneralService()->findEntityById('ContentType', 0);
     }
     $nda->setContentType($contentType);
     $ndaObject->setNda($nda);
     $this->newEntity($ndaObject);
     return $ndaObject->getNda();
 }
Beispiel #5
0
 /**
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function renderAction()
 {
     //Create an empty NDA object
     $nda = new Nda();
     $nda->setContact($this->zfcUserAuthentication()->getIdentity());
     /*
      * Add the call when a id is given
      */
     if (!is_null($this->params('callId'))) {
         $call = $this->getCallService()->setCallId($this->params('callId'))->getCall();
         if ($this->getCallService()->isEmpty()) {
             return $this->notFoundAction();
         }
         $arrayCollection = new ArrayCollection([$call]);
         $nda->setCall($arrayCollection);
         $renderNda = $this->renderNda()->renderForCall($nda);
     } else {
         $renderNda = $this->renderNda()->render($nda);
     }
     $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="' . $nda->parseFileName() . '.pdf"')->addHeaderLine('Content-Type: application/pdf')->addHeaderLine('Content-Length', strlen($renderNda->getPDFData()));
     $response->setContent($renderNda->getPDFData());
     return $response;
 }
Beispiel #6
0
 /**
  * Render a NDA not bound to a call
  *
  * @param Nda $nda
  *
  * @return ProgramPdf
  */
 public function render(Nda $nda)
 {
     $pdf = new ProgramPdf();
     $pdf->setTemplate($this->getModuleOptions()->getNdaTemplate());
     $pdf->addPage();
     $pdf->SetFontSize(10);
     $twig = $this->getServiceLocator()->get('ZfcTwigRenderer');
     /**
      * Write the contact details
      */
     $contactService = $this->getContactService()->setContact($nda->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);
     $pdf->Write(0, $nda->parseFileName());
     $ndaContent = $twig->render('program/pdf/nda-general', ['contact' => $nda->getContact()]);
     $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;
 }