Calendar.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('Config');
  4. Lib::loadClass('UI');
  5. Lib::loadClass('Request');
  6. Lib::loadClass('ProcesHelper');
  7. class Route_UrlAction_Calendar extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
  8. public function handleAuth() {
  9. if (!User::logged()) {
  10. //throw new HttpException('Unauthorized', 401);
  11. User::authByRequest();
  12. }
  13. }
  14. public function defaultAction() {
  15. UI::gora();
  16. UI::menu();
  17. try {
  18. $userLogin = V::get('USER_ID', '', $_REQUEST, 'string');
  19. if (empty($userLogin)) {
  20. $userLogin = User::getLogin();
  21. }
  22. $this->showCalendar($userLogin);
  23. } catch (Exception $e) {
  24. UI::alert('danger', "Error: " . $e->getMessage());
  25. }
  26. UI::dol();
  27. }
  28. public function showCalendar($userLogin) {
  29. echo '<div class="container-fluid">';
  30. echo '<div class="row">';
  31. echo '<div class="col-md-12">';
  32. echo '<div id="calendar" style="margin-top:15px"></div>';
  33. echo "</div>";
  34. echo "</div>";
  35. // echo "<script>var BASE_URL = '".Request::getPathUri()."';var USER='".$userLogin."';var TableId=".ProcesHelper::getZasobTableID('GRAFIK_PRACY').";</script>";
  36. echo '<script src="static/sweetalert2.min.js"></script>';
  37. echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
  38. echo '<script src="static/fullcalendar.min.js"></script>';
  39. echo '<link rel="stylesheet" href="static/fullcalendar.min.css" type="text/css" />';
  40. // echo '<script src="static/calendar.js?11.1"></script>';
  41. UI::inlineJS(APP_PATH_WWW . '/static/calendar.js', [
  42. 'BASE_URL' => Request::getPathUri(),
  43. 'USER' => $userLogin,
  44. 'TableId' => ProcesHelper::getZasobTableID('GRAFIK_PRACY'),
  45. 'CALENDAR_NODE_ID' => 'calendar',
  46. 'DBG' => (V::get('DBG', '', $_GET)) ? 1 : 0
  47. ]);
  48. $this->showCss();
  49. //echo '<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.9.0/fullcalendar.print.css">';
  50. }
  51. public function showCss(){
  52. ?>
  53. <style>
  54. .workingHours{
  55. padding:10px;
  56. text-align:center;
  57. font-size:1.3em;
  58. }
  59. .empty{
  60. padding:10px;
  61. text-align:center;
  62. color:black;
  63. opacity:0.8;
  64. font-size:1.3em;
  65. background-color:#ededed;
  66. }
  67. .empty:hover{
  68. opacity:1;
  69. color:black;
  70. }
  71. </style>
  72. <?php
  73. }
  74. }