Пример #1
0
 public function eventRegistrationFormSucceeded(Nette\Application\UI\Form $form, $values)
 {
     $event = $this->event->get($values['event_id']);
     $duplicite = $this->registration->where('event_id = ? AND email = ?', [$values['event_id'], $values['email']]);
     if (count($duplicite) >= $event['max_ticket_per_email']) {
         $this->flashMessage('Byla nalezena starší registrace, nebyly provedeny žádné změny. Změny konzultujte s pořadatelkou.', 'warning');
         $this->redirect('this');
     }
     try {
         $res = $this->registration->insert($values);
     } catch (\Exception $e) {
         $res = false;
     }
     if ($res) {
         $this->mailNotify('SOS - nova registrace', 'Probehla registrace ' . $values['name'] . ' ' . $values['surname'] . ' k akci ' . $event->name . '.', $values);
         $this->flashMessage('Registrace proběhla v pořádku.', 'success');
     } else {
         $this->flashMessage('Je nám líto, ale došlo k chybě. S registrací se obraťte se pořadatelku akce.', 'danger');
     }
     $this->redirect('this');
 }
 public function actionDelete($id)
 {
     $this->registration->get($id)->delete();
     $this->flashMessage('Registrace odstraněna.', 'success');
     $this->redirect('default');
 }
Пример #3
0
    public function newsletterFormSucceeded(UI\Form $form, $values)
    {
        if (!$values['event_id']) {
            $values['event_id'] = null;
        }
        $this->saveFormValues($values);
        $contacts = array();
        if (!$values['event_id'] && $values['notTest']) {
            foreach ($this->registration as $registration) {
                $contacts[] = $registration->email;
            }
            foreach ($this->ticket as $ticket) {
                $contacts[] = $ticket->email;
            }
            $contacts = array_unique($contacts);
        } elseif ($values['notTest']) {
            foreach ($this->registration->where('event_id = ?', $values['event_id']) as $registration) {
                $contacts[] = $registration->email;
            }
            foreach ($this->ticket->where('event_id = ?', $values['event_id']) as $ticket) {
                $contacts[] = $ticket->email;
            }
            $contacts = array_unique($contacts);
        } else {
            $contacts = [0 => self::EMAIL_OPERATOR];
        }
        $mail = new Nette\Mail\Message();
        $mail->setFrom('Hudební S.O.S. <*****@*****.**>')->setSubject($values['subject'])->setHtmlBody('
				<html><head><title>' . $values['subject'] . '</title></head>
				<body>
				<div style="background-color: rgb(197, 230, 235);color: rgb(0, 117, 117);letter-spacing: 0.3px; margin: auto auto; padding:1em 1em">
				' . $values['text'] . '
				<br /><br />
				</div>
				<hr style="border:0;border-top: 1px solid #DDD;" />
				<center>
				<small>
				<font style="color:silver;font-family:\'Helvetica Neue\', sans-sherif">Pro odhlášení odpovězte na tento email slovy "Prosím odhlásit".</font>
				</small>
				</center>
				</body></html>');
        /** @var Nette\Http\FileUpload $attach */
        foreach ($values['files'] as $attach) {
            $mail->addAttachment($attach->getSanitizedName(), $attach->getContents());
        }
        $counter = 0;
        foreach ($contacts as $contact) {
            $counter++;
            $mail->addBcc($contact);
        }
        $mailer = new Nette\Mail\SendmailMailer();
        try {
            $mailer->send($mail);
            if (!$values['notTest']) {
                $this->flashMessage("Byl odeslán testovací email.", 'success');
            } else {
                $this->flashMessage("Bylo odesláno {$counter} emailů.", 'success');
            }
        } catch (\Exception $e) {
            $this->flashMessage('Při odesílání došlo k chybě. :: ' . $e->getMessage());
        }
        $this->redirect('this');
    }