weeklyReportForm.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. class weeklyReportForm extends Staple_Form
  3. {
  4. public function _start()
  5. {
  6. $this->setLayout('weeklyReportFormLayout');
  7. $this->setName('weeklyReportForm')
  8. ->setAction($this->link(array('reports','weekly')));
  9. $account = new Staple_Form_FoundationSelectElement('account','Account');
  10. $account->setRequired()
  11. ->addOption('','Select an account')
  12. ->addOptionsArray($this->accounts())
  13. ->addValidator(new Staple_Form_Validate_InArray($this->accounts(1)));
  14. $year = new Staple_Form_FoundationTextElement('year','Year');
  15. $year->setRequired()
  16. ->setValue(date('Y'))
  17. ->addValidator(new Staple_Form_Validate_Length(4,4))
  18. ->addValidator(new Staple_Form_Validate_Numeric());
  19. $submit = new Staple_Form_FoundationSubmitElement('submit','Submit');
  20. $submit->addClass('button expand radius');
  21. $this->addField($account, $year, $submit);
  22. }
  23. public function accounts($ids = null)
  24. {
  25. $user = new userModel();
  26. $id = $user->getId();
  27. $authLevel = $user->getAuthLevel();
  28. $accounts = new userModel();
  29. $users = $accounts->listAll();
  30. $data = array();
  31. if($ids == null)
  32. {
  33. foreach($users as $user)
  34. {
  35. if($user['supervisorId'] == $id)
  36. {
  37. $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
  38. }
  39. elseif($authLevel >= 900)
  40. {
  41. $data[$user['id']] = $user['lastName'].", ".$user['firstName'];
  42. }
  43. }
  44. }
  45. else
  46. {
  47. foreach($users as $user)
  48. {
  49. $data[] = $user['id'];
  50. }
  51. }
  52. return $data;
  53. }
  54. }
  55. ?>