/**
  * @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;
 }
Beispiel #2
0
 /**
  * @param CalendarService $calendarService
  * @param ContactService  $contactService
  */
 public function __construct(CalendarService $calendarService, ContactService $contactService)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'form-horizontal');
     $this->setAttribute('action', '');
     $contacts = [];
     foreach ($contactService->findPossibleContactByCalendar($calendarService->getCalendar()) as $contact) {
         $contacts[$contact->getId()] = $contact->getDisplayName();
     }
     $this->add(['type' => 'Zend\\Form\\Element\\MultiCheckbox', 'name' => 'contact', 'options' => ['value_options' => $contacts, 'label' => _("txt-contact-name")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update")]]);
     $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]);
 }
 /**
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return CalendarService
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $calendarService = new CalendarService();
     $calendarService->setServiceLocator($serviceLocator);
     /** @var EntityManager $entityManager */
     $entityManager = $serviceLocator->get(EntityManager::class);
     $calendarService->setEntityManager($entityManager);
     /** @var Authorize $authorizeService */
     $authorizeService = $serviceLocator->get(Authorize::class);
     $calendarService->setAuthorizeService($authorizeService);
     /** @var ContactService $contactService */
     $contactService = $serviceLocator->get(ContactService::class);
     $calendarService->setContactService($contactService);
     /** @var AdminService $adminService */
     $adminService = $serviceLocator->get(AdminService::class);
     $calendarService->setAdminService($adminService);
     /** @var ModuleOptions $moduleOptions */
     $moduleOptions = $serviceLocator->get(ModuleOptions::class);
     $calendarService->setModuleOptions($moduleOptions);
     return $calendarService;
 }