public function updateAction($id = null) { $context = []; if ($this->employee->hasPermission('admin')) { $context['creator'] = array_merge([$this->employee->data()], $this->model()->getEmployeeList()); } else { $context['creator'] = $this->employee->data()->id; } if (Input::exists() && isset($id) && !empty($id)) { if (!Token::check(Input::get('token'))) { Redirect::to(); } $data = ['employee_id' => Input::get('employee_id'), 'date' => Input::get('date'), 'time_start' => Input::get('time_start'), 'time_end' => Input::get('time_end'), 'notes' => Input::get('notes'), 'all' => Input::get('all'), 'recurrences' => Input::get('recurrences'), 'parent' => Input::get('parent'), 'boardroom' => Input::get('boardroom')]; $success = $this->model()->updateAppointment($data, $id); if ($success) { Redirect::to(); } else { $data['date'] = $this->model()->pickadatePrepDate($data['date']); $data['time_start'] = $this->model()->pickadatePrepTime($data['time_start']); $data['time_end'] = $this->model()->pickadatePrepTime($data['time_end']); $context['errors'] = $this->model()->getErrors(); $context['values'] = $data; } } else { if (isset($id) && !empty($id)) { $context['values'] = $this->model()->getAppointment($id); if (!$context['values']) { http_response_code(404); exit("No appointment was found by specified id"); } } else { http_response_code(404); exit("Dude, I think you're lost"); } } $context['flash'] = Session::flash('home'); $context['clock'] = Config::get('calendar/clock'); $context['token'] = Token::generate(); echo $this->view('reservation/update', $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); }