示例#1
0
 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);
 }
示例#2
0
 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 confirmationAction()
 {
     $context = ['flash' => Session::flash('home')];
     echo $this->view('reservation/confirmation', $context);
 }
示例#4
0
if (Config::get('general/environment') == 'development') {
    /**
     *
     * Nice looking and informative error reporting
     *
     **/
    $whoops = new Run();
    $whoops->pushHandler(new PrettyPageHandler());
    $whoops->register();
} else {
    ini_set("display_errors", 0);
}
$loader = new Twig_Loader_Filesystem(APP . 'view');
$options = ['cache' => APP . 'storage/twig', 'auto_reload' => true];
$twig = new Twig_Environment($loader, $options);
header('Content-Type: text/html; charset=UTF-8');
/**
*
* "Remember me" functionality for login system
*
**/
$rememberCookieExists = Cookie::exists(Config::get('cookie_to_remember_employee_session/name'));
$employeeSessionExists = Session::exists(Config::get('session/name'));
if ($rememberCookieExists === true && $employeeSessionExists === false) {
    $hash = Cookie::get(Config::get('cookie_to_remember_employee_session/name'));
    $hashCheck = Database::getInstance()->get('employee_session', ['hash', '=', $hash]);
    if ($hashCheck->count()) {
        $employee = new Employee($hashCheck->first()->employee_id);
        $employee->login();
    }
}
示例#5
0
 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;
     }
 }
示例#6
0
 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');
     }
 }