/**
  * @param CalendarService $calendarService
  *
  * @return CalendarPdf
  */
 public function render(CalendarService $calendarService)
 {
     $pdf = new CalendarPdf();
     $pdf->setTemplate($this->getModuleOptions()->getCalendarContactTemplate());
     $pdf->addPage();
     $pdf->SetFontSize(9);
     $twig = $this->getServiceLocator()->get('ZfcTwigRenderer');
     $calendarContacts = $calendarService->findCalendarContactsByCalendar($calendarService->getCalendar());
     //Create chunks of arrays per 13, as that amount fits on the screen
     $paginatedContacts = array_chunk($calendarContacts, 13);
     $minAmountOfPages = max(sizeof($paginatedContacts), 2);
     for ($i = 0; $i < $minAmountOfPages; $i++) {
         /*
          * Use the NDA object to render the filename
          */
         $contactListContent = $twig->render('calendar/pdf/calendar-contact', ['calendarService' => $calendarService, 'calendarContacts' => isset($paginatedContacts[$i]) ? $paginatedContacts[$i] : []]);
         $pdf->writeHTMLCell(0, 0, 14, 42, $contactListContent);
         /*
          * Don't add a new page on the last iteration
          */
         if ($i < $minAmountOfPages - 1) {
             $pdf->addPage();
         }
     }
     return $pdf;
 }
Exemplo n.º 2
0
 /**
  * @param array $calendarItems
  *
  * @return CalendarPdf
  */
 public function render(array $calendarItems)
 {
     $pdf = new CalendarPdf();
     $pdf->setTemplate($this->getModuleOptions()->getReviewCalendarTemplate());
     $pdf->setPageOrientation('L');
     $pdf->addPage();
     $pdf->SetFontSize(8);
     $twig = $this->getServiceLocator()->get('ZfcTwigRenderer');
     /*
      * Use the NDA object to render the filename
      */
     $contactListContent = $twig->render('calendar/pdf/review-calendar', ['calendarItems' => $calendarItems]);
     $pdf->writeHTMLCell(0, 0, 12, 35, $contactListContent, 0, 0, 0, false);
     return $pdf;
 }