1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
| class Application_Form_AjoutStage extends Zend_Form
{
public function init()
{
$validator = new Zend_Validate_Alpha(array ('allowWhiteSpace' => true));
if ($validator->isValid('Abcd and efg'))
{
// value ne contient que des caractères autorisés
} else {
// false
}
$this->setMethod('post');
$id_stage = new Zend_Form_Element_Hidden('id_stage');
$db=new Zend_Db_Adapter_Pdo_Mysql(array('host'=>'localhost',
'username'=>'root','password'=>'','dbname'=>'Stages'));
$etd = new Zend_Form_Element_Select('code_etd');
$etd->setLabel("Etudiant : <font color='red'>*</font>")
->setRequired(TRUE)
->setErrorMessages(array("<font color='red'>Veuillez sélectionner un étudiant</font>"));
$sql="select * from etudiant order by prenom_etd ASC";
$db->setFetchMode(Zend_Db::FETCH_OBJ);
$enreg=$db->fetchAll($sql);
$tot=count($enreg);
$etd->addMultiOption('','--Etudiant--');
$i=0;
while($i<$tot)
{
$text=$enreg[$i]->prenom_etd." ".$enreg[$i]->nom_etd;
$val=$enreg[$i]->code_etudiant;
$etd->addMultiOption($val,$text);
$i++;
}
$nom_superviseur = new Zend_Form_Element_Select('nom_superviseur');
$nom_superviseur->setLabel("Superviseur : <font color='red'>*</font>")
->setRequired(TRUE)
->setErrorMessages(array("<font color='red'>Veuillez sélectionner un superviseur</font>"));
$sql="select * from superviseur order by prenom_superviseur ASC";
$db->setFetchMode(Zend_Db::FETCH_OBJ);
$enreg=$db->fetchAll($sql);
$tot=count($enreg);
$nom_superviseur->addMultiOption('','--Superviseur--');
$i=0;
while($i<$tot)
{
$text=$enreg[$i]->prenom_superviseur." ".$enreg[$i]->nom_superviseur;
$val=$enreg[$i]->id_superviseur;
$nom_superviseur->addMultiOption($val,$text);
$i++;
}
$encadreur=new Zend_Form_Element_Select('id_encadreur');
$encadreur->setLabel("Encadreur : <font color='red'>*</font>")
->setRequired(TRUE)
->setErrorMessages(array("<font color='red'>Veuillez sélectionner un encadreur</font>"));
$sql="select * from encadreur order by prenom_encadreur ASC";
$db->setFetchMode(Zend_Db::FETCH_OBJ);
$enreg=$db->fetchAll($sql);
$tot=count($enreg);
$encadreur->addMultiOption('','--Encadreur--');
$i=0;
while($i<$tot)
{
$text=$enreg[$i]->prenom_encadreur." ".$enreg[$i]->nom_encadreur;
$val=$enreg[$i]->id_encadreur;
$encadreur->addMultiOption($val,$text);
$i++;
}
$nature_stage = new Zend_Form_Element_Text('nature_stage');
$nature_stage->setLabel("Nature de stage : <font color='red'>*</font>")
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addFilter('StringToUpper')
->addValidator($validator)
->setErrorMessages(array("<font color='red'>Nature de stage non valide</font>"));
$date_debut = new Zend_Form_Element_Text('date_debut');
$date_debut->setLabel("Date de début : <font color='red'>*</font>")
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->setErrorMessages(array("<font color='red'>Date non valide , Format YYYY-MM-DD</font>"));
$date_fin = new Zend_Form_Element_Text('date_fin');
$date_fin->setLabel("Date de fin : <font color='red'>*</font>")
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->setErrorMessages(array("<font color='red'>Date non valide , Format YYYY-MM-DD</font>"));
$heur_debut = new Zend_Form_Element_Text('heur_debut');
$heur_debut->setLabel("Heure de début : <font color='red'>*</font>")
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->setErrorMessages(array("<font color='red'>Heure de début non valide , Format HH:MM:SC</font>"));
$heur_fin = new Zend_Form_Element_Text('heur_fin');
$heur_fin->setLabel("Heure de fin : <font color='red'>*</font>")
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->setErrorMessages(array("<font color='red'>Heure de fin non valide , Format HH:MM:SC</font>"));
$submit = new Zend_Form_Element_Submit('Ajouter');
$submit1 = new Zend_Form_Element_Reset('Annuler');
$this->addElements(array($etd,$nom_superviseur,$encadreur,$nature_stage,$date_debut,$date_fin,$heur_debut,$heur_fin,$submit,$submit1));
$elementDecorators = array(array('ViewHelper'),
array('Errors'),
array('decorator'=>array('1er'=>'HtmlTag'),'options'=>array('tag'=>'td')),
array('label',array('tag' => 'td','style'=>'font-weight:bold;font-size:10pt;color:#565656;')),
array('decorator'=>array('2eme'=>'HtmlTag'),'options'=>array('tag'=>'tr')));
$etd->setDecorators($elementDecorators);
$nom_superviseur->setDecorators($elementDecorators);
$encadreur->setDecorators($elementDecorators);
$nature_stage->setDecorators($elementDecorators);
$date_debut->setDecorators($elementDecorators);
$date_fin->setDecorators($elementDecorators);
$heur_debut->setDecorators($elementDecorators);
$heur_fin->setDecorators($elementDecorators);
$elementDecorators1 = array(array('ViewHelper'),
array('decorator'=>array('1er'=>'HtmlTag'),'options'=>array('tag'=>'td','align'=>'right')));
$formDecorators = array('FormElements',
'Form',
array('decorator'=>array('1er'=>'HtmlTag'),'options'=>array('tag'=>'table','align'=>'center','width'=>'590','bgcolor'=>'white')),
);
$elementDecorators2 = array(array('ViewHelper'),
array('decorator'=>array('1er'=>'HtmlTag'),'options'=>array('tag'=>'td','align'=>'left')));
$formDecorators = array('FormElements',
'Form',
array('decorator'=>array('1er'=>'HtmlTag'),'options'=>array('tag'=>'table','align'=>'center','width'=>'590','bgcolor'=>'white')),
);
$this->setDecorators($formDecorators);
$submit->setDecorators($elementDecorators1);
$submit1->setDecorators($elementDecorators2);
}
} |
Partager