/** * check if any events of categories below are present and free for booking * * @param Tx_WoehrlSeminare_Domain_Model_Category $category * @return boolean * @api */ public function render(Tx_WoehrlSeminare_Domain_Model_Category $category) { $events = $this->eventRepository->findAllGbByCategory($category); $categories = $this->categoryRepository->findCurrentBranch($category); $showLink = FALSE; if (count($categories) == 0 || count($events) == 0) { foreach ($events as $event) { $showLink = TRUE; if ($this->subscriberRepository->countAllByEvent($event) >= $event->getMaxSubscriber()) { $showLink = FALSE; } // event is cancelled if ($event->getCancelled()) { $showLink = FALSE; } // deadline reached.... if (is_object($event->getSubEndDateTime())) { if ($event->getSubEndDateTime()->getTimestamp() < time()) { $showLink = FALSE; } } // if any event exists and is valid, break here and return TRUE if ($showLink) { break; } } } //~ else //~ return TRUE; return $showLink; }
/** * makeStatisticsReportsCommand * * @param int stroagePid * @param string senderEmailAddress * @param string receiverEmailAddress list of receiver email addresses separated by comma * @return void */ public function makeStatisticsReportsCommand($storagePid, $senderEmailAddress = '', $receiverEmailAddress = '') { // do some init work... $this->initializeAction(); // abort if no storagePid is found if (!t3lib_utility_Math::canBeInterpretedAsInteger($storagePid)) { echo 'NO storagePid given. Please enter the storagePid in the scheduler task.'; exit(1); } // abort if no senderEmailAddress is found if (empty($senderEmailAddress)) { echo 'NO senderEmailAddress given. Please enter the senderEmailAddress in the scheduler task.'; exit(1); } // abort if no senderEmailAddress is found if (empty($receiverEmailAddress)) { echo 'NO receiverEmailAddress given. Please enter the receiverEmailAddress in the scheduler task.'; exit(1); } else { $receiverEmailAddress = explode(', ', $receiverEmailAddress); } // set storagePid to point extbase to the right repositories $configurationArray = array('persistence' => array('storagePid' => $storagePid)); $this->configurationManager->setConfiguration($configurationArray); // start the work... // 1. get the categories $categories = $this->categoryRepository->findAll(); foreach ($categories as $uid => $category) { $searchParameter['category'][$uid] = $uid; } // 2. get events of last month $startDateTime = strtotime('first day of last month 00:00:00'); $endDateTime = strtotime('last day of last month 23:59:59'); $allevents = $this->eventRepository->findAllByCategoriesAndDateInterval($searchParameter['category'], $startDateTime, $endDateTime); // used to name the csv file... $helper['nameto'] = strftime('%Y%m', $startDateTime); // email to all receivers... $out = $this->sendTemplateEmail($receiverEmailAddress, array($senderEmailAddress => 'WÖHRL Akademie - noreply'), 'Statistik Report Veranstaltungen: ' . ': ' . strftime('%x', $startDateTime) . ' - ' . strftime('%x', $endDateTime), 'Statistics', array('events' => $allevents, 'categories' => $categories, 'helper' => $helper, 'attachCsv' => TRUE, 'attachIcs' => FALSE)); return; }
public function checkEvent($params, $obj) { $this->initializeAction(); $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'woehrlSeminare', 'Eventlist'); //~ t3lib_utility_Debug::debug($params, 'addInformation: params: '); $gp = t3lib_div::_GP('tx_powermail_pi1'); $formUid = $gp['form']; $form = $this->formsRepository->findByUid($formUid); if (!method_exists($form, 'getPages')) { return $this->isValid = FALSE; } foreach ($form->getPages() as $page) { // every page in current form foreach ($page->getFields() as $field) { // every field in current page switch ($field->getMarker()) { case 'action': $action = $params[$field->getUid()]; break; case 'editcode': $editcode = $params[$field->getUid()]; break; case 'event': $formIdEvent = $field->getUid(); $eventId = $params[$formIdEvent]; break; case 'eventtitle': $formIdEventtitle = $field->getUid(); break; } } } //~ t3lib_utility_Debug::debug($editcode, 'checkEvent: editcode... '); switch ($action) { case 'delete': //~ $subscriber = $this->subscriberRepository->findAllByFeuser($frameworkConfiguration['persistence']['storagePid'])->getFirst(); $subscriber = $this->subscriberRepository->findAllByEditcode($editcode, $frameworkConfiguration['persistence']['storagePid'])->getFirst(); if (empty($subscriber)) { t3lib_utility_Debug::debug($subscriber, 'checkEvent: NO subscriber found... '); $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); break; } //~ t3lib_utility_Debug::debug($subscriber, 'saveSubscription: delete... '); $event = $this->eventRepository->findByUid($eventId); if (empty($event)) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); break; } $event->removeSubscriber($subscriber); break; case 'new': if ($eventId > 0) { $event = $this->eventRepository->findByUid($eventId); // limit reached already --> overbooked if (count($event->getSubscribers()) >= $event->getMaxSubscriber()) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); } } break; default: return; } return; //~ t3lib_utility_Debug::debug($eventId , 'checkEvent: eventId'); if ($eventId > 0) { $event = $this->eventRepository->findByUid($eventId); // limit reached already --> overbooked if (count($event->getSubscribers()) >= $event->getMaxSubscriber()) { $obj->isValid = FALSE; // we have to use the language labels of powermail :-( // --> for validationerror_validation: $obj->setError('validation', $idEventTitle); } } return; }