Permalink
Browse files

Confirmation e-mail

  • Loading branch information...
vojtasvoboda committed Aug 17, 2014
1 parent 46070b4 commit 7b03818a372dad6a5019f2a8b844d226472d4a45
Showing with 28 additions and 1 deletion.
  1. +26 −1 models/Reservations.php
  2. +2 −0 sql/reservations.sql
View
@@ -77,12 +77,19 @@ public function isFree($date, $time) {
* Create new reservation
*
* @param $data
*
* @return DibiResult|int result set object (if any)
*/
public function create($data) {
$data['created%sql'] = 'NOW()';
$data['ip'] = $_SERVER['REMOTE_ADDR'];
unset($data['terms']);
$this->db->query('INSERT INTO ' . $this->table, $data);
$result = $this->db->query('INSERT INTO ' . $this->table, $data);
// if everything is ok, send e-mail
if ($result) {
$this->sendConfirmationEmail($data['email'], $data['date'], $data['time']);
}
return $result;
}
/**
@@ -161,4 +168,22 @@ private function getMaxTimesCombination() {
return count($this->dates) * self::MAX_PERSON_PER_TERM;
}
/**
* Send confirmation e-mail
*
* @param $email
* @param $date
* @param $time
*/
public function sendConfirmationEmail($email, $date, $time) {
$title = 'Potvrzení o rezervaci LG G3 na KVIFF';
$text = "Text potvrzení. Instrukce pro vyzvednutí telefonu $date v $time." . "\n";
$headers = "MIME-Versin: 1.0\r\n" .
"Content-type: text/plain; charset=utf-8; format=flowed\r\n" .
"Content-Transfer-Encoding: 8bit\r\n" .
"From: no-reply@lg.cz";
$subject = "=?utf-8?B?".base64_encode($title)."?=";
mail($email, $subject, $text, $headers);
}
}
View
@@ -8,3 +8,5 @@ CREATE TABLE IF NOT EXISTS `reservations` (
`ip` varchar(255) COLLATE utf8_czech_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=1 ;
ALTER TABLE `reservations` ADD UNIQUE(`email`);

0 comments on commit 7b03818

Please sign in to comment.