Esempio n. 1
0
 public function detailAction()
 {
     $id = $this->_params('id');
     $calendar = $this->getServiceLocator()->get('rdvMapper')->getById($id);
     $form = new Contact(['dates' => [], 'times' => []]);
     $data = $calendar->toArray();
     $data['full-date'] = $calendar->getDate()->format('d/m/Y H:i');
     $date = Date::translate($calendar->getDate()->format('l d M Y \\à H\\h'));
     $form->setData($data);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formValidator = new AdminContactValidator();
         $form->setInputFilter($formValidator->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             try {
                 $googleApi = $this->getServiceLocator()->get('calendar');
                 $requestDate = \DateTime::createFromFormat('d/m/Y H:i', $data['full-date'], new \DateTimeZone('Europe/Paris'));
                 $event = new \Google_Service_Calendar_Event(array('summary' => $data['firstname'] . ' ' . $data['lastname'] . ' - ' . $data['phone'], 'description' => $data['comment'], 'start' => array('dateTime' => $requestDate->format(\Datetime::ATOM), 'timeZone' => 'Europe/Paris'), 'end' => array('dateTime' => $requestDate->modify('+ 1 hour')->format(\Datetime::ATOM), 'timeZone' => 'Europe/Paris')));
                 $calendarId = '*****@*****.**';
                 $event = $googleApi->events->insert($calendarId, $event);
                 if (isset($data['email'])) {
                     // Emailing
                     $mail = new Mail($this->getServiceLocator()->get('mail'));
                     $mail->addFrom('*****@*****.**');
                     $mail->addBcc($data['email']);
                     $mail->setSubject('[osteo-defour.fr] Rendez-vous du  - ' . \App\Services\Date::translate($requestDate->format('l d F Y \\à H:i')) . ' confirmé');
                     $mail->setTemplate(Mail::TEMPLATE_CONFIRMATION, ['firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'phone' => $data['phone'], 'email' => $data['email'], 'comment' => $data['comment'], 'date' => \App\Services\Date::translate($requestDate->format('l d F Y \\à H:i')), 'baseUrl' => '']);
                     $mail->send();
                     $message = '<i class="fa fa-envelope"></i> Un email de confirmation a été envoyé au patient';
                     $this->getServiceLocator()->get('rdvMapper')->delete($id);
                 } else {
                     $message = '<i class="fa fa-exclamation-triangle"></i> Une confirmation téléphonique s\'impose';
                     $this->getServiceLocator()->get('rdvMapper')->fromArray(['id' => $calendar->id, 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'phone' => $data['phone'], 'email' => $data['email'], 'comment' => $data['comment'], 'date' => $requestDate->format('Y-m-d H:i:s'), 'status' => Rdv::STATUS_NEED_CONFIRM])->save();
                 }
                 $this->flashMessenger()->addMessage('<p>Rendez-vous ajouté au calendrier !</p> 
                      <p>' . $message . '</p>
                 ');
             } catch (Exception $e) {
                 $this->flashMessenger()->addErrorMessage('<p>Un problème est survenu lors de l\'ajout au calendrier</p>
                 ');
             }
             $this->redirect()->toRoute('App/admin');
         }
     }
     return new ViewModel(array('date' => $date, 'form' => $form, 'calendar' => $calendar));
 }
Esempio n. 2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'province_id' => $data['province_id'], 'mobile' => $data['mobile'], 'confirmation_code' => \Hash::make(str_random(20))]);
     \Mail::queue('emails.confirmation', ['user' => $user], function ($m) use($user) {
         $m->to($user->email, $user->name)->subject(trans('confirmation.subject'));
     });
     return $user;
 }
Esempio n. 3
0
	public function sendRegistrationEmail($user)
	{
		$queue = Mail::queue('emails.register', array('key' => 'value'), function($message) 
        {
            $message->to('*****@*****.**', 'Test user')->subject('Welcome!');

        });

		return $queue;
	}
Esempio n. 4
0
 public function sendMailPost($request, $response, $args)
 {
     $to = $request->getParam('email');
     try {
         Mail::send($to, "Test", 'test.tpl', ['time' => Tools::toDateTime(time())], [BASE_PATH . '/LICENSE']);
         $res = ["ret" => 1, "msg" => "ok"];
     } catch (\Exception $e) {
         $res = ["ret" => 0, "msg" => $e->getMessage()];
     }
     return $this->echoJson($response, $res);
 }
Esempio n. 5
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $key = csrf_token();
     $key = md5($key);
     $token = "?inf=" . $key;
     //$key='3D'.$key;
     \Mail::send('emails.confirmation', compact('token', 'data'), function ($message) use($data) {
         $message->from('*****@*****.**', 'ED Exoplanets');
         $message->to($data['email'], $data['name'])->subject('ED Exoplanets registration confirmation');
     });
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'confirmed' => $key]);
 }
Esempio n. 6
0
 public static function sendDailyMail()
 {
     $users = User::all();
     foreach ($users as $user) {
         echo "Send daily mail to user: "******"-每日流量报告";
         $to = $user->email;
         try {
             Mail::send($to, $subject, 'news/daily-traffic-report.tpl', ["user" => $user], []);
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
 }
Esempio n. 7
0
 /**
  * @param $email string
  * @return bool
  */
 public static function sendResetEmail($email)
 {
     $pwdRst = new PasswordReset();
     $pwdRst->email = $email;
     $pwdRst->init_time = time();
     $pwdRst->expire_time = time() + 3600 * 24;
     // @todo
     $pwdRst->token = Tools::genRandomChar(64);
     if (!$pwdRst->save()) {
         return false;
     }
     $subject = Config::get('appName') . "重置密码";
     $resetUrl = Config::get('baseUrl') . "/password/token/" . $pwdRst->token;
     try {
         Mail::send($email, $subject, 'password/reset.tpl', ["resetUrl" => $resetUrl], []);
     } catch (Exception $e) {
         return false;
     }
     return true;
 }
Esempio n. 8
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     error_log("Data " . json_encode($data));
     $confirmation_code = str_random(30);
     $user = User::create(['email' => $data['email'], 'password' => bcrypt($data['password']), 'first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'name' => $data['first_name'] . ' ' . $data['last_name'], 'phone' => $data['phone'], 'company_name' => $data['company_name'], 'company_address' => $data['company_address'], 'company_city' => $data['company_city'], 'company_zip' => $data['company_zip'], 'company_country' => $data['company_country'], 'company_website' => $data['company_website'], 'confirmed' => 0, 'confirmation_code' => $confirmation_code]);
     // photo file input
     $photo_posted = array_key_exists('photo', $data) && !empty($data['photo']) || \Request::has('photo');
     $photo_path = 'images/icons/default_user.png';
     if ($photo_posted) {
         $photo_path = 'images/uploads/users/' . $data['photo'];
         // user image
         \Image::make(\Input::file('photo'))->fit(100)->save($photo_path);
     }
     $user->update(['photo' => $photo_path]);
     // send verification email
     \Mail::queue('emails.verify', array('data' => $data, 'user' => $user), function ($message) use($data, $user) {
         $message->to($data['email'], null)->subject('Crovv - Please Verify your account');
     });
     return $user;
 }
Esempio n. 9
0
 public function indexAction()
 {
     $calendar = $this->getServiceLocator()->get('calendar');
     $config = $this->getServiceLocator()->get('config');
     // build Dates
     $dates = [0 => 'Date'];
     $date = new \DateTime('now');
     for ($i = 1; $i < 10; $i++) {
         $date = $date->modify('next monday');
         $dates[$date->format('Ymd')] = \App\Services\Date::translate($date->format('l d F Y'));
         $date = $date->modify('next tuesday');
         $dates[$date->format('Ymd')] = \App\Services\Date::translate($date->format('l d F Y'));
     }
     // build time
     $formData = ['dates' => $dates, 'times' => [0 => 'Heure', 9 => '9h00', 10 => '10h00', 11 => '11h00', 12 => '12h00', 13 => '13h00', 14 => '14h00', 15 => '15h00', 16 => '16h00', 17 => '17h00', 18 => '18h00', 19 => '19h00', 20 => '20h00']];
     $form = new Contact($formData);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formValidator = new ContactValidator($request->getPost()->toArray());
         $form->setInputFilter($formValidator->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $date = \Datetime::createFromFormat('Ymd H', $data['date'] . ' ' . $data['time']);
             // save RDV in DB
             $rdvMapper = $this->getServiceLocator()->get('rdvMapper');
             $rdv = $rdvMapper->fromArray(['email' => $data['email'], 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'status' => 0, 'date' => $date->format('Y-m-d H:i:s'), 'phone' => $data['phone'], 'comment' => $data['comment']])->save();
             // Emailing
             $mail = new Mail($this->getServiceLocator()->get('mail'));
             $mail->addFrom($config['mail']['address']);
             $mail->addBcc($config['mail']['bcc']);
             $mail->setSubject('[osteo-defour.fr] Demande de RDV - ' . $data['firstname'] . ' ' . $data['lastname']);
             $mail->setTemplate(Mail::TEMPLATE_RDV, ['id' => $rdv->id, 'firstname' => $data['firstname'], 'lastname' => $data['lastname'], 'phone' => $data['phone'], 'email' => $data['email'], 'comment' => $data['comment'], 'date' => \App\Services\Date::translate($date->format('l d F Y \\à H:i')), 'baseUrl' => $config['baseUrl']]);
             $mail->send();
             $this->flashMessenger()->addMessage('<p>Demande de rendez-vous prise en compte.</p> 
                  <p>Nous vous confirmerons ce rendez-vous dans les plus brefs délais.</p>
             ');
             $this->redirect()->toRoute('App/default');
         } else {
             $inputErrors = array_keys($form->getMessages());
             foreach ($inputErrors as $input) {
                 $form->get($input)->setAttribute('class', 'form-control has-error');
             }
         }
     }
     return new ViewModel(['form' => $form]);
 }
Esempio n. 10
0
 /**
  * @param $email string
  * @return bool
  */
 public static function sendVerification($email)
 {
     $ttl = Config::get('emailVerifyTTL');
     $verification = EmailVerifyModel::where('email', '=', $email)->first();
     if ($verification == null) {
         $verification = new EmailVerifyModel();
         $verification->email = $email;
     }
     $verification->token = Tools::genRandomChar(Config::get('emailVerifyCodeLength'));
     $verification->expire_at = time() + $ttl * 60;
     if (!$verification->save()) {
         return false;
     }
     $appName = Config::get('appName');
     $subject = $appName . ' 邮箱验证';
     try {
         Mail::send($email, $subject, 'auth/verify.tpl', ['verification' => $verification, 'ttl' => $ttl], []);
     } catch (Exception $e) {
         return false;
     }
     return true;
 }