public function indexAction($boardroom = null) { $currentBoardroom = isset($boardroom) && !empty($boardroom) ? $boardroom : 1; $boardrooms = Config::get('calendar/boardrooms'); $context = ['currentBoardroom' => $currentBoardroom, 'boardrooms' => $boardrooms, 'flash' => Session::flash('home')]; $employee = new Employee(); if ($employee->hasPermission('admin')) { $context['admin'] = true; } echo $this->view('home/index', $context); }
public function sendMailToAllAction() { $context = []; $employee = new Employee(); if (!$employee->hasPermission('admin')) { Redirect::to('home'); } if (Input::exists()) { if (!Token::check(Input::get('token'))) { Redirect::to(); } $data = ['subject' => Input::get('subject'), 'body' => Input::get('body')]; $success = $this->model()->sendMailToAll($data); if ($success) { Redirect::to('employee'); } else { $context['errors'] = $this->model()->getErrors(); $context['values'] = $data; } } $context['flash'] = Session::flash('home'); $context['token'] = Token::generate(); echo $this->view('employee/sendmailtoall', $context); }
public function sendMailToAll($data) { $errorHandler = new ErrorHandler(); $validator = new Validate($errorHandler); $validator->check($data, ['subject' => ['required' => true], 'body' => ['required' => true]]); if ($errorHandler->hasErrors()) { $this->errors = $errorHandler->all(); return false; } else { $phpMailer = new PHPMailer(); $mailer = new Mail(null, $phpMailer); $database = Database::getInstance(); $massMailer = new MailAll($mailer, $database); $massMailer->mail($data['subject'], $data['body']); Session::flash('home', 'The job is done. Specified mail should have been sent to all employees.'); return true; } }
public function confirmationAction() { $context = ['flash' => Session::flash('home')]; echo $this->view('reservation/confirmation', $context); }
private function runUpdate($data, $id) { if ($data['recurrences'] === 'true' && $data['all']) { $appointments = Database::getInstance()->query('SELECT id, start_time, end_time FROM appointment WHERE id = ? OR parent = ? OR id = ?', [$id, $data['parent'], $data['parent']])->results(); foreach ($appointments as $instance) { if ($this->isTimeAvailable($instance->start_time, $instance->end_time, $data['boardroom'], $instance->id) === false) { return false; } } $stmt = "UPDATE appointment SET "; $stmt .= "start_time = concat_ws(' ', date(start_time), ?), "; $stmt .= "end_time = concat_ws(' ', date(end_time), ?), notes = ?, employee_id = ? "; $stmt .= "WHERE id = ? OR parent = ? OR id = ?;"; $count = Database::getInstance()->query($stmt, [$data['time_start'] . ':00', $data['time_end'] . ':00', $data['notes'], $data['employee_id'], $id, $data['parent'], $data['parent']])->count(); } else { $startTime = $data['date'] . ' ' . $data['time_start'] . ':00'; $endTime = $data['date'] . ' ' . $data['time_end'] . ':00'; if ($this->isTimeAvailable($startTime, $endTime, $data['boardroom'], $id) === false) { return false; } $count = Database::getInstance()->update('appointment', $id, ['start_time' => $startTime, 'end_time' => $endTime, 'notes' => $data['notes'], 'employee_id' => $data['employee_id']])->count(); } if ($count === 0) { Session::flash('home', 'Information regarding specified appointment was not changed'); } else { Session::flash('home', 'You\'ve successfully updated specified records'); } }