示例#1
0
 public function __invoke(Event $event, $dateStart = null, $dateEnd = null)
 {
     $view = $this->getView();
     $html = '';
     $html .= sprintf('<tr>');
     $html .= sprintf('<td>%s</td>', $event->need('eid'));
     /* Name col */
     $name = $event->getMeta('name', '?');
     if (strlen($name) > 48) {
         $name = substr($name, 0, 48) . '&hellip;';
     }
     $html .= sprintf('<td>%s</td>', $name);
     /* Date cols */
     $html .= sprintf('<td>%s</td>', $view->dateFormat($event->needExtra('datetime_start'), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT));
     $html .= sprintf('<td>%s</td>', $view->dateFormat($event->needExtra('datetime_end'), \IntlDateFormatter::MEDIUM, \IntlDateFormatter::SHORT));
     /* Capacity col */
     $capacity = $event->get('capacity');
     if ($capacity) {
         $capacityLabel = $capacity;
     } else {
         $capacityLabel = $view->t('None');
     }
     $html .= sprintf('<td>%s</td>', $capacityLabel);
     /* Square col */
     if ($event->get('sid')) {
         $squareLabel = $this->squareManager->get($event->need('sid'))->get('name');
     } else {
         $squareLabel = $view->t('All');
     }
     $html .= sprintf('<td>%s</td>', $squareLabel);
     /* Actions col */
     $html .= sprintf('<td class="actions-col no-print"><a href="%s" class="unlined gray symbolic symbolic-edit">%s</a></td>', $view->url('backend/event/edit', ['eid' => $event->need('eid')]), $view->t('Edit'));
     $html .= '</tr>';
     return $html;
 }
示例#2
0
 public function editAction()
 {
     $this->authorize('admin.event');
     $serviceManager = $this->getServiceLocator();
     $eventManager = $serviceManager->get('Event\\Manager\\EventManager');
     $formElementManager = $serviceManager->get('FormElementManager');
     $eid = $this->params()->fromRoute('eid');
     if ($eid) {
         $event = $eventManager->get($eid);
         $eventManager->getSecondsPerDay($event);
     } else {
         $event = null;
     }
     $editForm = $formElementManager->get('Backend\\Form\\Event\\EditForm');
     if ($this->getRequest()->isPost()) {
         $editForm->setData($this->params()->fromPost());
         if ($editForm->isValid()) {
             $data = $editForm->getData();
             if (!$event) {
                 $event = new Event();
             }
             $locale = $this->config('i18n.locale');
             $event->setMeta('name', $data['ef-name'], $locale);
             $event->setMeta('description', $data['ef-description'], $locale);
             $dateStart = new \DateTime($data['ef-date-start']);
             $timeStartParts = explode(':', $data['ef-time-start']);
             $dateStart->setTime($timeStartParts[0], $timeStartParts[1], 0);
             $dateEnd = new \DateTime($data['ef-date-end']);
             $timeEndParts = explode(':', $data['ef-time-end']);
             $dateEnd->setTime($timeEndParts[0], $timeEndParts[1], 0);
             $event->set('datetime_start', $dateStart->format('Y-m-d H:i:s'));
             $event->set('datetime_end', $dateEnd->format('Y-m-d H:i:s'));
             $sid = $data['ef-sid'];
             if ($sid == 'null') {
                 $sid = null;
             }
             $event->set('sid', $sid);
             $capacity = $data['ef-capacity'];
             if (!$capacity) {
                 $capacity = null;
             }
             $event->set('capacity', $capacity);
             $event->setMeta('notes', $data['ef-notes']);
             $eventManager->save($event);
             $this->flashMessenger()->addSuccessMessage('Event has been saved');
             return $this->redirectBack()->toOrigin();
         }
     } else {
         if ($event) {
             $editForm->setData(array('ef-name' => $event->getMeta('name'), 'ef-description' => $event->getMeta('description'), 'ef-date-start' => $this->dateFormat($event->needExtra('datetime_start'), \IntlDateFormatter::MEDIUM), 'ef-time-start' => $event->needExtra('datetime_start')->format('H:i'), 'ef-date-end' => $this->dateFormat($event->needExtra('datetime_end'), \IntlDateFormatter::MEDIUM), 'ef-time-end' => $event->needExtra('datetime_end')->format('H:i'), 'ef-sid' => $event->get('sid'), 'ef-capacity' => $event->get('capacity', 0), 'ef-notes' => $event->getMeta('notes')));
         } else {
             $params = $this->backendBookingDetermineParams();
             $editForm->setData(array('ef-date-start' => $this->dateFormat($params['dateTimeStart'], \IntlDateFormatter::MEDIUM), 'ef-time-start' => $params['dateTimeStart']->format('H:i'), 'ef-date-end' => $this->dateFormat($params['dateTimeEnd'], \IntlDateFormatter::MEDIUM), 'ef-time-end' => $params['dateTimeEnd']->format('H:i'), 'ef-sid' => $params['square']->get('sid'), 'ef-capacity' => 0));
         }
     }
     return array('event' => $event, 'editForm' => $editForm);
 }
 public function extractEvent(Event $event)
 {
     $headings = $this->exportHeadings;
     $output = [];
     $lead = false;
     $id = $event->getId();
     $em = $this->getEntityManager();
     $objRepository = $em->getRepository("Event\\Entity\\LeadEvent");
     $leadEvent = $objRepository->findOneBy(['event' => $id]);
     if ($leadEvent && $leadEvent instanceof LeadEvent) {
         $lead = $leadEvent->getLead();
     }
     foreach ($headings as $heading) {
         $words = explode(' ', $heading);
         $entity = strtolower(array_shift($words));
         $field = implode('', $words);
         switch ($entity) {
             case 'event':
                 $output[$heading] = "";
                 $method_name = 'get' . ucfirst(preg_replace('/^[^\\w]/i', '', $field));
                 $method = method_exists($event, $method_name) ? $method_name : false;
                 if ($method) {
                     switch ($field) {
                         case "Occurred":
                             $time = $event->getOccurred();
                             if ($time instanceof \DateTime) {
                                 $time = date_format($time, 'Y-m-d H:i:s');
                             }
                             $output[$heading] = $time;
                             break;
                         default:
                             $output[$heading] = $event->{$method}();
                             break;
                     }
                 }
                 break;
             case 'lead':
                 $output[$heading] = "";
                 if ($lead instanceof Lead) {
                     $method_name = 'get' . ucfirst(preg_replace('/^[^\\w]/i', '', $field));
                     $method = method_exists($lead, $method_name) ? $method_name : false;
                     if ($method) {
                         $output[$heading] = $lead->{$method}();
                     } else {
                         $output[$heading] = 'N/A';
                     }
                 }
                 break;
         }
     }
     return $output;
 }