indexController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. class indexController extends Staple_Controller
  3. {
  4. private $authLevel;
  5. private $userId;
  6. public function _start()
  7. {
  8. $user = new userModel();
  9. $this->authLevel = $user->getAuthLevel();
  10. $this->userId = $user->getId();
  11. }
  12. public function index()
  13. {
  14. $this->view->authLevel = $this->authLevel;
  15. $messages = new messagesModel();
  16. $this->view->messages = $messages;
  17. if(count($messages->getPrivateMessages()) > 0)
  18. {
  19. $this->layout->addScriptBlock('$(document).ready(function() { $("#privateMessages").foundation("reveal", "open"); }); ');
  20. }
  21. $date = new DateTime();
  22. $date->setTime(0,0,0);
  23. if($date->format('d') >= 26)
  24. {
  25. $date->modify('+1 month');
  26. }
  27. $date->setDate($date->format('Y'),$date->format('m'),1);
  28. $timesheet = new timesheetModel($date->format('Y'),$date->format('m'));
  29. $this->view->timesheet = $timesheet;
  30. $this->view->year = $date->format('Y');
  31. $this->view->month = $date->format('F');
  32. $date = new DateTime();
  33. $week = $date->format('W');
  34. $year = $date->format('Y');
  35. $report = new weeklyReportModel();
  36. $this->view->week = $report->getWeekWorked($this->userId, $week, $year);
  37. }
  38. public function read($id = null)
  39. {
  40. if($id != null)
  41. {
  42. $message = new privateMessageModel();
  43. $message->markRead($id);
  44. header("location: ".$this->_link(array("index"))."");
  45. }
  46. else
  47. {
  48. header("location: ".$this->_link(array("index"))."");
  49. }
  50. }
  51. }
  52. ?>