New file |
0,0 → 1,354 |
<?php |
|
// +------------------------------------------------------------------------------------------------------+ |
// | PHP version 4.1 | |
// +------------------------------------------------------------------------------------------------------+ |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) | |
// +------------------------------------------------------------------------------------------------------+ |
// | This library is free software; you can redistribute it and/or | |
// | modify it under the terms of the GNU Lesser General Public | |
// | License as published by the Free Software Foundation; either | |
// | version 2.1 of the License, or (at your option) any later version. | |
// | | |
// | This library is distributed in the hope that it will be useful, | |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
// | Lesser General Public License for more details. | |
// | | |
// | You should have received a copy of the GNU Lesser General Public | |
// | License along with this library; if not, write to the Free Software | |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
// +------------------------------------------------------------------------------------------------------+ |
// |@author ABDOOL RAHEEM shaheen shaheenar50@hotmail.com | |
// |@version 3 | |
/*@package gtt_general |
//Auteur original : |
*@author Dorian Bannier <dbannier@aol.com> |
//Autres auteurs : |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
*@copyright Copyright (C) 2003 Tela-Botanica |
@version $Date: 2004/07/06 |
*/ |
// +------------------------------------------------------------------------------------------------------+ |
// +------------------------------------------------------------------------------------------------------+ |
// | INCLUSION DE FICHIERS | |
// +------------------------------------------------------------------------------------------------------+ |
|
include_once CHEMIN_CLASSES_METIER.'gtt_statut.class.php'; |
include_once CHEMIN_CONTROLEUR.'gtt_controleur_admin_utilisateur.php'; |
|
//inclusion des paquets de la librairie pear |
include_once 'HTML/QuickForm.php'; |
|
|
/** |
*focntion affichant le menu aministration utilisateur |
*@$tabDef =tableau contenant les parametres par defaut |
*@$test =test si on est en insertion ou modification |
*@ $mode = 1 =>modification |
*@ $mode =0 =>insertion |
*/ |
|
|
function afficherMenuAjouterUser($tabDef,$mode) |
{ |
$id="MANIPULER_USER"; |
$size=30; |
|
|
$assoc1 =array('class'=>$id); |
|
$form=new HTML_QuickForm('gestion_utilisateur', 'post',$GLOBALS['urlBase'].GESTION_ADMIN_UTILISATEUR,'', $assoc1); |
|
//creation des templates pour la mise en forme |
$squelette =& $form->defaultRenderer(); |
$squelette->setFormTemplate("\n<form{attributes}>\n<ul>{content}\n</ul></form>"); |
$squelette->setElementTemplate('<li>'."\n".'{label}'."\n".'{element}'."\n". |
'<!-- BEGIN required --><span class="symbole_obligatoire">*</span><!-- END required -->'."\n". |
'<!-- BEGIN error --><span class="erreur">{error}</span><!-- END error -->'."\n". |
'</li>'."\n"); |
$squelette->setGroupElementTemplate('{label}{element}','groupe'); |
$squelette->setRequiredNoteTemplate("\n".'<li>'.'<p>'."\n".'<span class="symbole_obligatoire">*</span> {requiredNote}'."\n".'</p>'.'</li>'."\n"); |
$squelette->setHeaderTemplate("\n".'<li><h2>'."\n".'{header}'."\n".'</h2></li>'."\n"); |
|
//entete du formulaire |
|
$form->addElement('header', 'entete', GESTION_AJOUTER_UTILISATEUR_L); |
|
//creation des Messages d'erreur |
|
$form->setRequiredNote('='.GTT_CHAMPS_OBLIGATOIRE); |
$form->setJsWarnings(GTT_DONNEES_INCORRECTES, GTT_DONNEES_A_CORRIGER); |
|
|
//creation et ajouts des elements |
|
|
//element cache pour verifier si formulaire est en mode insertion ou modification |
|
$form->addElement('hidden', 'champ_verif', $mode); |
|
//definition du champ d'activation |
|
|
//premier ligne: nom |
$size=20; |
$assoc=array('class' =>$id, 'size'=>$size); |
|
//desactivation des champs si mode modification |
if ($mode==1) |
{ |
$temp_assoc=array('disabled'); |
$assoc=array_merge($assoc,$temp_assoc); |
|
} |
$ligneNom = &HTML_QuickForm::createElement('text', 'champ_nom',GESTION_NOM_L.': ',$assoc); |
$form->addElement($ligneNom); |
|
//ligne : prenom |
$assoc=array('class' =>$id, 'size'=>$size); |
//desactivation des champs si mode modification |
if ($mode==1) |
{ |
$temp_assoc=array('disabled'); |
$assoc=array_merge($assoc,$temp_assoc); |
|
} |
$lignePrenom = &HTML_QuickForm::createElement('text', 'champ_prenom',GESTION_PRENOM_L.': ',$assoc); |
$form->addElement($lignePrenom); |
|
// ligne : adresse |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneAdresse= &HTML_QuickForm::createElement('text', 'champ_adresse',GTT_L_FU_ADRESSE.': ',$assoc); |
$form->addElement($ligneAdresse); |
|
//ligne :ville |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneVille = &HTML_QuickForm::createElement('text', 'champ_ville',GTT_L_FU_VILLE.': ',$assoc); |
$form->addElement($ligneVille); |
|
// ligne : code postal |
$size=5; |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneCode = &HTML_QuickForm::createElement('text', 'champ_code_postal',GTT_L_FU_CODE_POSTAL.': ',$assoc); |
$form->addElement($ligneCode); |
|
// ligne :telephone |
|
$size=10; |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneTel=&HTML_QuickForm::createElement('text', 'champ_telephone',GTT_L_FU_TEL.': ',$assoc); |
$form->addElement($ligneTel); |
|
// ligne :email |
$size=25; |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneMail=&HTML_QuickForm::createElement('text', 'champ_email',GTT_L_FU_EMAIL.': ',$assoc); |
$form->addElement($ligneMail); |
|
// ligne : explication |
$cl="EXPLICATION"; |
$assoc=array('class' =>$cl, 'size'=>$size); |
|
if ($mode==1) |
{ |
$ligneExplication=&HTML_QuickForm::createElement('HTML',GTT_L_FU_MAJ_MDP); |
$form->addElement($ligneExplication); |
|
} |
// ligne : mot de passe |
$size=20; |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneMDP=&HTML_QuickForm::createElement('password', 'champ_password',GTT_L_FU_MDP.': ', $assoc); |
$form->addElement($ligneMDP); |
|
//ligne : confirmer mot de passe |
|
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneConfirmMDP=&HTML_QuickForm::createElement('password', 'champ_confirm_password',GTT_L_FU_CONFIRMATION_MDP.': ',$assoc); |
$form->addElement( $ligneConfirmMDP); |
|
|
//recuperation de la liste de statut |
|
$assoc=array('class' =>$id); |
$ligneStatut = &HTML_QuickForm::createElement('select', 'champ_statut',GESTION_STATUT_L.': ','',$assoc); |
|
$ligneStatut->load($result) ; |
$c="SELECT * FROM ".GEST_STATUT.""; |
$ligneStatut->loadQuery($GLOBALS['dsn'],$c,GEST_CHAMPS_LIBELLE_STATUT,GEST_CHAMPS_ID_STATUT); |
$form->addElement($ligneStatut); |
|
|
//conges payes initiaux |
$size=3; |
$assoc=array('class' =>$id, 'size'=>$size); |
//desactivation des champs si mode modification |
if ($mode==1) |
{ |
$temp_assoc=array('disabled'); |
$assoc=array_merge($assoc,$temp_assoc); |
|
} |
$ligneConges = &HTML_QuickForm::createElement('text', 'champ_nb_conge',GESTION_CONGES_INIT_L.': ',$assoc); |
$form->addElement($ligneConges); |
|
//temps journalier de travail |
$size=3; |
$assoc=array('class' =>$id, 'size'=>$size); |
$ligneTT = &HTML_QuickForm::createElement('text', 'champ_temps_travail',GTT_L_FU_TEMPS_TRAVAIL.': ',$assoc); |
$form->addElement($ligneTT); |
|
//heures supp |
//desactivation des champs si mode modification |
$size=3; |
$assoc=array('class' =>$id, 'size'=>$size); |
if ($mode==1) |
{ |
$temp_assoc=array('disabled'); |
$assoc=array_merge($assoc,$temp_assoc); |
|
} |
$ligneHeuresSup = &HTML_QuickForm::createElement('text', 'champ_heure_supp_init',GESTION_HEURESINIT_L.': ',$assoc); |
$form->addElement($ligneHeuresSup); |
|
//administrateur |
$size=1; |
$assoc=array('class' =>$id,'size'=>$size); |
$ligneAdmin = &HTML_QuickForm::createElement('checkbox', 'champ_administrateur',GTT_L_FU_ADMIN.': ','',$assoc); |
if ($mode==1 and $tabDef['champ_administrateur']==true) |
{ |
$ligneAdmin->setChecked(true); |
}else{ |
$ligneAdmin->setChecked(false); |
} |
$form->addElement($ligneAdmin); |
|
|
|
//ligne : admin2 |
$ligneAdmin2= &HTML_QuickForm::createElement('checkbox', 'champ_admin2',GTT_L_FU_ADMIN_2.': ','',$assoc); |
|
if ($mode==1 and $tabDef['champ_admin2']==true) |
{ |
$ligneAdmin2->setChecked(true); |
}else{ |
$ligneAdmin2->setChecked(false); |
} |
$form->addElement($ligneAdmin2); |
|
|
//element ok : valider le formulaire |
$bouton=&HTML_QuickForm::createElement('submit', 'champ_valider',GTT_L_G_VALIDER,$assoc); |
$form->addElement($bouton); |
|
|
//ajout des regles de saisie |
$form->applyFilter('champ_nom', 'trim'); |
$form->applyFilter('champ_prenom','trim'); |
$form->applyFilter('champ_email', 'trim'); |
|
|
//regles individuelles |
//regles applicables si on est en mode insertion |
|
if($mode==0) |
{ |
$form->addRule('champ_nom',GTT_ERREUR_NOM, 'required','','client'); |
$form->addRule('champ_nom',GTT_ERREUR_NOM, 'lettersonly','','client'); |
|
$form->addRule('champ_prenom',GTT_ERREUR_PRENOM, 'required','','client'); |
$form->addRule('champ_prenom',GTT_ERREUR_PRENOM, 'lettersonly','','client'); |
$form->addRule('champ_password',GTT_ERREUR_PASSWD, 'required','','client'); |
$form->addRule('champ_confirm_password','', 'required','','client'); |
$form->addRule('champ_nb_conge',GTT_ERREUR_NOMBRE, 'numeric','','client'); |
$form->addRule('champ_heure_supp_init',GTT_ERREUR_NOMBRE, 'numeric','','client'); |
} |
|
$form->addRule(array('champ_password','champ_confirm_password'),GESTION_ERREUR_PASSWORD_L, 'compare','','client'); |
|
|
$form->addRule('champ_temps_travail',GTT_ERREUR_NOMBRE, 'numeric','','client'); |
|
//nouvelles regles |
$form->registerRule('verifValeurTemps','function','verifValeurTemps'); |
$form->addRule('champ_temps_travail',GTT_ERREUR_NOMBRE, 'verifValeurTemps','','client'); |
|
$form->addRule('champ_code_postal',GTT_ERREUR_NOMBRE, 'numeric','','client'); |
$form->addRule('champ_telephone',GTT_ERREUR_TEL, 'numeric','','client'); |
$form->addRule('champ_email',GTT_ERREUR_MAIL, 'required','','client'); |
$form->addRule('champ_email',GTT_ERREUR_MAIL, 'email','','client'); |
|
//creation de valeurs par defaut |
$default=array("champ_nom"=> null, |
"champ_prenom"=>null, |
"champ_adresse" =>null, |
"champ_ville" =>null, |
"champ_code_postal" =>0, |
"champ_telephone" => 0, |
"champ_email" =>null, |
"champ_administrateur" =>false, |
"champ_statut"=>0, |
"champ_admin2"=> false, |
"champ_nb_conge"=>0, |
"champ_temps_travail"=>7, |
"champ_heure_supp_init"=>0); |
|
if ($mode==1) |
{ |
$form->setDefaults($tabDef); |
$form->addElement('hidden', 'nom_utilisateur',$tabDef["champ_nom"]); |
$form->addElement('hidden', 'prenom_utilisateur',$tabDef["champ_prenom"]); |
$form->addElement('hidden', 'conges_utilisateur',$tabDef["champ_nb_conge"]); |
$form->addElement('hidden', 'heure_supp_utilisateur',$tabDef["champ_heure_supp_init"]); |
|
}else { |
$form->setDefaults($default); |
} |
|
|
//ajout des regles de saisie |
$form->applyFilter('champ_nom', 'trim'); |
$form->applyFilter('champ_prenom','trim'); |
$form->applyFilter('champ_email', 'trim'); |
$form->applyFilter('champ_adresse','trim'); |
return $form; |
} |
|
/** |
*fonction creant le formulaire de suppression d'utilisateur |
*affiche la liste des utilisateurs |
*la supression se fera en fonction du choix de l'utilisateur |
*/ |
|
function afficherMenuEditerUser() |
{ |
$id="EDITER_USER"; |
$size=30; |
$assoc1 =array('class'=>$id); |
$form= new HTML_QuickForm('editer_utilisateur', 'post',$GLOBALS['urlBase'].GESTION_EDITER_UTILISATEUR,'',$assoc1); |
|
$form->addElement('header', 'entete', GESTION_EDITER_UTILISATEUR_L); |
|
//creation des elements |
$id="EDITER_USER"; |
$assoc=array('class' =>$id); |
$ligne[0]=&HTML_QuickForm::createElement('select', 'champ_utilisateur_supprimer',GESTION_UTILISATEUR_L." : ",'',$assoc); |
$ligne[0]->load($result) ; |
$c="SELECT * FROM ".GEST_UTILISATEUR.""; |
$ligne[0]->loadQuery($GLOBALS['dsn'],$c,GEST_CHAMPS_NOM,GEST_CHAMPS_ID_UTILISATEUR); |
// $ligne[1]=&HTML_QuickForm::createElement('html','<a href ="'.$GLOBALS['urlBase'].GESTION_EDITER_UTILISATEUR.'">'); |
$ligne[2]=&HTML_QuickForm::createElement('submit', 'btn_modifier',GTT_L_G_MODIFIER, $assoc); |
// $ligne[3]=&HTML_QuickForm::createElement('html','</a>'); |
|
//$ligne[4]=&HTML_QuickForm::createElement('html','<a href ="'.$GLOBALS['urlBase'].GESTION_ADMIN_UTILISATEUR.'">'); |
$ligne[5]=&HTML_QuickForm::createElement('submit', 'btn_supprimer',GTT_L_G_SUPPRIMER,$assoc); |
// $ligne[6]=&HTML_QuickForm::createElement('html','</a>'); |
$form->addElement('hidden','action',GESTION_EDITER_UTILISATEUR); |
//ajout |
$form->addGroup($ligne,'groupe',"",' ',false); |
//validation des donnees |
return $form; |
} |
|
?> |