newAccountForm.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. class newAccountForm extends Staple_Form
  3. {
  4. public function _start()
  5. {
  6. $this->setLayout('newAccountFormLayout');
  7. $this->setName('newAccount')
  8. ->setAction($this->link(array('accounts','index')));
  9. $pin = new Staple_Form_FoundationPasswordElement('pin','User PIN');
  10. $pin->setRequired()
  11. ->addAttrib("readonly","true")
  12. ->addValidator(new Staple_Form_Validate_Length(1,4))
  13. ->addValidator(new Staple_Form_Validate_Numeric());
  14. $firstName = new Staple_Form_FoundationTextElement('firstName','First Name');
  15. $firstName->setRequired()
  16. ->addValidator(new Staple_Form_Validate_Length(1,40));
  17. $lastName = new Staple_Form_FoundationTextElement('lastName','Last Name');
  18. $lastName->setRequired()
  19. ->addValidator(new Staple_Form_Validate_Length(1,40));
  20. $supervisor = new Staple_Form_FoundationSelectElement('supervisor','Select a Supervisor');
  21. $supervisor->setRequired()
  22. ->addOption("0","Select an account")
  23. ->addOptionsArray($this->accounts())
  24. ->addValidator(new Staple_Form_Validate_InArray($this->accounts(1)));
  25. $type = new Staple_Form_FoundationSelectElement('type','Set Account Type');
  26. $type->setRequired()
  27. ->addOption("","Select an account")
  28. ->addOptionsArray(array("part"=>"Part Time","full"=>"Full Time"))
  29. ->addValidator(new Staple_Form_Validate_InArray(array("part","full")));
  30. $level = new Staple_Form_FoundationSelectElement('level','Set Account Level');
  31. $level->setRequired()
  32. ->addOption("","Select a level")
  33. ->addOptionsArray(array("100"=>"Standard User","500"=>"Supervisor","900"=>"Administrator"))
  34. ->addValidator(new Staple_Form_Validate_InArray(array("100","500","900")));
  35. $pin = new Staple_Form_FoundationTextElement('pinNum','4 Digit PIN');
  36. $pin->setRequired()
  37. ->addValidator(new Staple_Form_Validate_Length(4,4))
  38. ->addValidator(new Staple_Form_Validate_Numeric())
  39. ->addAttrib("maxlength","4");
  40. $pin2 = new Staple_Form_FoundationTextElement('pinNum2','Confirm 4 Digit PIN');
  41. $pin2->setRequired()
  42. ->addValidator(new Staple_Form_Validate_Length(4,4))
  43. ->addValidator(new Staple_Form_Validate_Numeric())
  44. ->addAttrib("maxlength","4");
  45. $submit = new Staple_Form_FoundationSubmitElement('submit','Submit');
  46. $submit->addClass('button expand radius');
  47. $this->addField($firstName, $lastName, $supervisor, $type, $level, $pin, $pin2, $submit);
  48. }
  49. public function accounts($ids = null)
  50. {
  51. $accounts = new userModel();
  52. $users = $accounts->listAll();
  53. $data = array();
  54. foreach($users as $user)
  55. {
  56. if($user['authLevel'] >= 500)
  57. {
  58. if($ids == 1)
  59. {
  60. $data[] = $user['id'];
  61. }
  62. else
  63. {
  64. $data[$user['id']] = $user['lastName'].", ".$user['firstName']."";
  65. }
  66. }
  67. }
  68. return $data;
  69. }
  70. }
  71. ?>