reportsController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. class reportsController extends Staple_Controller
  3. {
  4. private $authLevel;
  5. public function _start()
  6. {
  7. $auth = Staple_Auth::get();
  8. $this->authLevel = $auth->getAuthLevel();
  9. if($this->authLevel < 500)
  10. {
  11. header("location:".$this->_link(array('index','index'))."");
  12. }
  13. }
  14. public function index($year = null, $month = null)
  15. {
  16. if($year == null)
  17. {
  18. $year = date('Y');
  19. }
  20. if($month == null)
  21. {
  22. $month = date('m');
  23. }
  24. $report = new reportModel($year, $month);
  25. $this->view->report = $report->getTimesheets();
  26. }
  27. public function weekly()
  28. {
  29. //Weekly report form
  30. $form = new weeklyReportForm();
  31. if($form->wasSubmitted())
  32. {
  33. $form->addData($_POST);
  34. if($form->validate())
  35. {
  36. $data = $form->exportFormData();
  37. $report = new weeklyReportModel();
  38. $this->view->report = $report->timeWorked($data['account'],$data['year']);
  39. $account = new userModel();
  40. $this->view->account = $account->userInfo($data['account']);
  41. $this->view->year = $data['year'];
  42. }
  43. else
  44. {
  45. $this->view->form = $form;
  46. }
  47. }
  48. else
  49. {
  50. $this->view->form = $form;
  51. }
  52. }
  53. }