示例#1
0
 /**
  * Ulozeni formulare
  * @param \Nette\ArrayHash $values
  * @param \App\Model\Entity\Client $clientEntity
  * @throws \Doctrine\DBAL\DBALException
  * @return \App\Model\Entity\Event
  */
 public function save(\Nette\ArrayHash $values, $event)
 {
     $addressValues = explode(',', $values['address']->getAddress());
     $location = new \Knp\DoctrineBehaviors\ORM\Geocodable\Type\Point($values['address']->getLat(), $values['address']->getLng());
     $hasSoldTickets = $this->eventService->hasSoldTickets($event);
     //@ToDo potřeba upravit po dodělání addressFieldu (toto je provizorní řešení)
     $address = $event->getAddress();
     if (empty($address)) {
         $address = new \App\Model\Entity\Address();
     }
     /** @var \Nette\Http\FileUpload $file */
     $file = $values['logo'];
     if ($file->isImage()) {
         if ($file->move($this->config['uploadPath'] . '/logo/' . $file->getSanitizedName())) {
             $logo = new \App\Model\Entity\File();
             $logo->setName($file->getName())->setType('image')->setFile($file->getSanitizedName())->setFileSize(0)->setExtension('');
             $event->setLogo($logo);
         }
     }
     $event->setCategory($values['eventCategory']);
     if (!$hasSoldTickets) {
         //@ToDo potřeba upravit po dodělání addressFieldu (toto je provizorní řešení)
         $address->setName($addressValues[0])->setStreet($addressValues[1])->setCrossStreet($addressValues[1])->setCity($addressValues[2])->setZip(preg_replace('/[^0-9]/is', '', $addressValues[3]))->setInfo($addressValues[4])->setCountry($addressValues[5])->setLocation($location);
         $event->setAddress($address);
         $event->setName($values['name']);
         $event->setDateStart($values['dateTimeRange']->getFrom());
         $event->setDateEnd($values['dateTimeRange']->getTo());
     }
     $event->setDescription($values['description']);
     $event->setOrganizerName($values['organizer']);
     $event->setOrganizerDesc($values['organizerDescription']);
     return $this->eventService->saveEvent($event);
 }
示例#2
0
 /**
  * New event
  * Vytvoření nové události
  */
 public function actionCreate()
 {
     try {
         $client = $this->userEntity->getClient();
         $event = $this->eventService->createBlankEvent($client);
         $this->redirect('Event:edit', $event->getId(), $step = 'description');
         \Tracy\Debugger::log('Uživatel #' . $this->getUser()->getId() . ' (klient #' . $this->event->getClient()->getId() . ') vytvořil novou událost.');
     } catch (\Nette\Application\ForbiddenRequestException $e) {
         $this->flashMessage($e->getMessage());
         $this->redirect('Dashboard:default');
         \Tracy\Debugger::log('Uživatel #' . $this->getUser()->getId() . ' (klient #' . $this->event->getClient()->getId() . ') se pokusil vytvořit novou událost, ačkoli k tomu nemá oprávnění.');
     } catch (\Nette\Application\BadRequestException $e) {
         $this->flashMessage($e->getMessage());
         $this->redirect('Dashboard:default');
     }
 }