printTimeSheetForm.php 1.8 KB

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