public function buildCalendar($month, $year, $boardroom) { $offsetModifier = Config::get('calendar/first_weekday'); $dayCount = cal_days_in_month(CAL_GREGORIAN, $month, $year); $fillBefore = date('w', mktime(0, 0, 0, $month, 1, $year)) - $offsetModifier; $fillAfter = 6 - date('w', mktime(0, 0, 0, $month, $dayCount, $year)) + $offsetModifier; // a lazy fix for excessive number of filler blocks in some scenarios where $offsetModifier is set to 1 if ($offsetModifier == 1) { if ($dayCount + $fillAfter == 36 && $fillBefore <= 0 || $dayCount == 28 && $fillAfter == 1) { $fillAfter -= 1; } } $timestamp = $offsetModifier == 1 ? strtotime('next Monday') : strtotime('next Sunday'); $daysOfTheWeek = []; for ($i = 0; $i < 7; $i++) { $daysOfTheWeek[] = date('D', $timestamp); $timestamp = strtotime('+1 day', $timestamp); } $monthNames = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; $stmt = 'SELECT id, start_time, end_time FROM appointment WHERE MONTH(start_time) = ? AND boardroom = ?;'; $appointments = Database::getInstance()->query($stmt, [$month, $boardroom])->results(); $context = ['month' => $monthNames[$month], 'year' => $year, 'dayCount' => $dayCount, 'fillBefore' => $fillBefore, 'fillAfter' => $fillAfter, 'daysOfTheWeek' => $daysOfTheWeek, 'appointments' => $appointments, 'clock' => Config::get('calendar/clock')]; return $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; } }
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(); } }
public function getEmployeeList() { $stmt = 'SELECT id, email, first_name, middle_name, last_name '; $stmt .= 'FROM employee WHERE '; $stmt .= 'employee_group_id = 1 ORDER BY last_name;'; $query = Database::getInstance()->query($stmt); // $query = Database::getInstance()->get('employee', ['employee_group_id', '=', '1']); return $query->count() === 0 ? false : $query->results(); }