Subversion Repositories Applications.gtt

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1 → Rev 2

/trunk/menu/gtt_menu_travail.php
New file
0,0 → 1,321
<?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_travail.class.php';
include_once CHEMIN_CLASSES_METIER.'gtt_projet.class.php';
include_once CHEMIN_CLASSES_METIER.'gtt_absence.class.php';
include_once CHEMIN_CALENDRIER.'gtt_calendrier.class.php';
include_once CHEMIN_CONTROLEUR.'gtt_controleur_travail.php';
//fichier langues
include_once CHEMIN_LANGUES.'gtt_langue_fr.inc.php';
//inclusion des paquets de la librairie pear
include_once 'HTML/QuickForm.php';
 
/**
*fonction affichant le tableau des jours
*et le menu travail
*@param : $utilisateur : identifiant de l'utilisateur
*@param : semaine : numero de semaine
*/
function afficherTableauJour($url,$utilisateur,$semaine,$annee)
{
$id10="TABLEAU_JOUR_TRAVAIL";
$assoc10=array('class'=>$id10);
$form=new HTML_QuickForm('tableau_travail','post',$GLOBALS['urlBase'].GESTION_TRAVAIL,'',$assoc10);
//templates
$squelette =& $form->defaultRenderer();
$squelette->setGroupElementTemplate('<td>{label}{element}</td>','groupe');
//construction d'une preference
$pref=new Preference($utilisateur,0);
//recuperation du tableau de preferences regroupes par categorie
$tabPref=$pref->recupererTableauPreferences();
 
//creation des Messages d'erreur
$form->setRequiredNote('='.GTT_CHAMPS_OBLIGATOIRE);
$form->setJsWarnings(GTT_DONNEES_INCORRECTES, GTT_DONNEES_A_CORRIGER);
//affichage du nom, conges et heure supp de la personn
$user=&Utilisateur::recupererUtilisateur($utilisateur);
if($user!=-1)
{
$z=$form->addElement('html','<tr><td>'.GTT_L_TR_BIENVENUE."\t".$user->getPrenom()."\t".
$user->getNom().'</td></tr>');
$z=$form->addElement('html','<tr><td>'.'</td></tr>');
if($user->getConges()==1 or $user->getConges()==0 or $user->getConges()==-1)
{
$jour=GESTION_RTTJOUR_L;
}else $jour =GESTION_RTTJOURS_L;
$z=$form->addElement('html','<tr><td>'.GTT_L_TR_JOURS_CONGES." : ".$user->getConges().$jour.'</td></tr>');
$z=$form->addElement('html','<tr><td>'.'</td></tr>');
$quota=$user->getQuota();
$jour1=intval($quota / 24);
$heure= ($quota %24);
if($heure==0 or $heure==1 or $heure==-1)
{
$h=GTT_L_TR_HEURE_L;
}else $h=GTT_L_TR_HEURES_L;
if($jour1==0 or $jour1==1 or $jour1==-1)
{
$jour2=GESTION_RTTJOUR_L;
}else $jour2=GESTION_RTTJOURS_L;
$temps =$jour1.'&nbsp'.$jour2.'&nbsp'.$heure.'&nbsp'.$h;
$z=$form->addElement('html','<tr><td>'.GTT_L_TR_JOURS_RECUPERATION." : ".'</td></tr>');
$z=$form->addElement('html','<tr><td>'." ".$jour1.$jour2."\t".$heure.$h.'</td></tr>');
$z=$form->addElement('html','<tr><td>'.'</td></tr>');
}
//insertion du calendrier
$calendrier=new Calendrier($url,$semaine,$annee);
//affichage de la ligne mois
$z=$form->addElement('html','<tr><td>'.GTT_L_TR_MOIS." : ".
$calendrier->nom_mois[$calendrier->mois]."\t".$calendrier->annee.'</td></tr>');
$aff=$calendrier->afficherCalendrier($annee);
$form->addElement('html','<tr><td>'.$aff.'</td></tr>');
$z=$form->addElement('html','<tr><td>'.'</td></tr>');
//memoriser le nombre de projets inclus dans les preferences
$form->addElement('hidden','champ_nb_projet',count($tabPref));
//creation du tableau
$cat='';
$ok=0;
$form->addElement('html','<tr><td>'.GESTION_PROJETS_L.'</td><td></td><td>'.GESTION_LUN_L.'</td><td>'.
GESTION_MAR_L.'</td><td>'.GESTION_MER_L.'</td><td>'.GESTION_JEU_L.
'</td><td>'.GESTION_VEN_L.'</td><td>'.GESTION_SAM_L.'</td><td>'.GESTION_DIM_L.
'</td><td>'.GESTION_TACHES_L.'</td></tr>');
for ($i=0; $i<count($tabPref) ;$i++)
{
//ligne categorie si categorie pas deja inseree
$tabLigne=$tabPref[$i];
if ($cat!=$tabLigne['libelle_cat'])
{
$size1=25;
$id1="nom_categorie";
$assoc1=array('class' =>$id1, 'size'=>$size1);
$ligneNomCat=&HTML_QuickForm::createElement('html', '<tr><td>'.$tabLigne['libelle_cat'].' : '.'</td></tr>');
$form->addElement($ligneNomCat);
$cat =$tabLigne['libelle_cat'];
}
//creation de l'element hidden pour memoriser l'identifiant du projet
$ligneIdProjet=&HTML_QuickForm::createElement('hidden', 'champ_id_projet'.$i,$tabLigne['id_proj']);
$form->addElement($ligneIdProjet);
//nom des jours
$id2="nom_jours";
$size2=5;
$assoc2=array('class' =>$id2, 'size'=>$size2);
$ligne2[0]=&HTML_QuickForm::createElement('text','champ_lundi'.$i,'',$assoc2);
$ligne2[1]=&HTML_QuickForm::createElement('text','champ_mardi'.$i,'',$assoc2);
$ligne2[2]=&HTML_QuickForm::createElement('text','champ_mercredi'.$i,'',$assoc2);
$ligne2[3]=&HTML_QuickForm::createElement('text','champ_jeudi'.$i,'',$assoc2);
$ligne2[4]=&HTML_QuickForm::createElement('text','champ_vendredi'.$i,'',$assoc2);
$ligne2[5]=&HTML_QuickForm::createElement('text','champ_samedi'.$i,'',$assoc2);
$ligne2[6]=&HTML_QuickForm::createElement('text','champ_dimanche'.$i,'',$assoc2);
//creation des taches
$id3="nom_taches";
$assoc3=array('class' =>$id3);
$ligne2[7]=&HTML_QuickForm::createElement('select','champ_tache'.$i,'','',$assoc3);
//verification si le projet contient une tache
$verification=&Projet::contientTache($tabLigne['id_proj']);
//enregistrement de la tache par defaut
if ($verification!=1)
{
$tache=new Tache(0);
$tache->construireDefaultTache($tabLigne['id_proj'],GESTION_NOM_TACHE_DEFAUT_L);
$tache->enregistrerNewDefaultTache();
}
$ligne2[7]->load($result) ;
$c="SELECT * FROM ".GEST_TACHES." WHERE ".GEST_CHAMPS_ID_PROJET." = $tabLigne[id_proj]";
$ligne2[7]->loadQuery($GLOBALS['dsn'],$c,GEST_CHAMPS_NOM_TACHE,GEST_CHAMPS_ID_TACHE);
//recuperation de l'identifiant de la tache par defaut
$idDefTache=&Tache::recupererIdentifiantDefaultTache();
$ligne2[7]->setSelected(GESTION_NOM_TACHE_DEFAUT_L,$idDefTache);
$form->addGroup($ligne2,'groupe',$tabLigne['nom_proj'].' : ','&nbsp',false);
//filtres
$form->applyFilter('champ_lundi'.$i,'trim');
$form->applyFilter('champ_mardi'.$i,'trim');
$form->applyFilter('champ_mercredi'.$i,'trim');
$form->applyFilter('champ_jeudi'.$i,'trim');
$form->applyFilter('champ_vendredi'.$i,'trim');
$form->applyFilter('champ_samedi'.$i,'trim');
$form->applyFilter('champ_dimanche'.$i,'trim');
//creation de regles
$regle['champ_lundi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$regle['champ_mardi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$regle['champ_mercredi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$regle['champ_jeudi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$regle['champ_vendredi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$regle['champ_samedi'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$regle['champ_dimanche'.$i][]=array(GTT_ERREUR_NOMBRE,'numeric','','client');
$form->addGroupRule('groupe', $regle);
}
//enregistrement de regles
$form->registerRule('verifTempsTravail','function','verifTempsTravail');
$regle2['champ_tache0'][]=array(GESTION_ERREUR_L,'verifTempsTravail','','client');
$form->addGroupRule('groupe', $regle2);
//ligne type de jour
$id4="type_jour";
$size4=3;
$assoc4=array('classe'=>$id4,'cols'=>10);
$tabMotif=&Motif::recupererTableauMotif();
$tabTypeJour1=array();
for ($h=0;$h<count($tabMotif);$h++)
{
array_push($tabTypeJour1,trim($tabMotif[$h][GEST_CHAMPS_LIBELLE_MOTIF]));
//champ cache pour recuperer le type de jour si des modifications
//sont faites eventuellement dans la base de donnees
//et le rang des motifs d'absence se b=voit altéré
$y=& $form->addElement('hidden',"champ_libelle_type_jour".$h,trim($tabMotif[$h][GEST_CHAMPS_LIBELLE_MOTIF]) );
$z=& $form->addElement('hidden',"champ_rtt_type_jour".$h,($tabMotif[$h][GEST_CHAMPS_TYPE_RTT]) );
}
$y=& $form->addElement('hidden',"champ_libelle_type_jour".count($tabMotif),GTT_NOM_TRAVAIL);
$z=& $form->addElement('hidden',"champ_rtt_type_jour".count($tabMotif),1);
array_push($tabTypeJour1,GTT_NOM_TRAVAIL);
$z=& $form->addElement('hidden',"champ_rtt_type_jour".(count($tabMotif)+1),1);
$y=& $form->addElement('hidden',"champ_libelle_type_jour".(count($tabMotif)+1),GTT_NOM_WEEK_END);
//CHAMP POUR AVOIR LE NOMBRE DE TYPE DE JOUR
$y=& $form->addElement('hidden',"champ_nb_type_jour",(count($tabMotif)+1+1));
//determination des indices des valeurs dans la table
$ferie=array_search('Ferié',$tabTypeJour1);
$trav=array_search('travail',$tabTypeJour1);
//calcul de la date du premier jour de la semaine choisie
$tabJour=$calendrier->lundiEtDimancheSemaine($calendrier->semaine,$calendrier->annee);
$d=date('d',mktime(0,0,0,1,$tabJour[0],$calendrier->annee));
$m=date('m',mktime(0,0,0,1,$tabJour[0],$calendrier->annee));
$Y=date('Y',mktime(0,0,0,1,$tabJour[0],$calendrier->annee));
//recuperation de la liste des absences de l'utilisateur
$listeAbsence=&Absence::recupAbsence( $GLOBALS['idCurrentUser'],date('Y-m-d',mktime(0,0,0,1,$tabJour[0],$calendrier->annee)),
date('Y-m-d',mktime(0,0,0,1,$tabJour[1],$calendrier->annee)));
//creation du tableau pour les week ends
$tabTypeJour2=array(array_search(GTT_NOM_TRAVAIL,$tabTypeJour1) => GTT_NOM_TRAVAIL,
(array_search(GTT_NOM_TRAVAIL,$tabTypeJour1)+1) =>GTT_NOM_WEEK_END);
//parcours de la liste de jours
for ($g=0;$g<7;$g++)
{
//creation des dates de la semaine
$date=mktime(0,0,0,$m,$d+(1*$g),$Y);
//ajout d'un element cache pour recuperer les dates
$form->addElement('hidden','champ_date_j'.$g,$date);
//proposition de l'option week end que si on est en we
if($g==5 or $g==6)
{
$tabTypeJour=$tabTypeJour2;
}else
{
$tabTypeJour=$tabTypeJour1;
}
$ligneType[$g]=&HTML_QuickForm::createElement('select','champ_type_jour'.$g,'',$tabTypeJour,$assoc4);
//determination du type de jour
//weekend
if (($g==5)or ($g==6))
{
$ligneType[$g]->setSelected(array_search(GTT_NOM_WEEK_END,$tabTypeJour));
}
//jours feries
elseif (in_array($date,$calendrier->liste_feries)==1 and ($g!=5 and $g!=6))
{
$ligneType[$g]->setSelected(array_search(GTT_NOM_FERIE,$tabTypeJour));
}else
{
$ligneType[$g]->setSelected(array_search(GTT_NOM_TRAVAIL,$tabTypeJour));
}
//parcours de liste des absences
if(count($listeAbsence)!=0)
{
for($t=0;$t<count($listeAbsence);$t++)
{
$h=$listeAbsence[$t];
$debAbs=explode('-',$h[GEST_CHAMPS_DATE_DEBUT_ABSENCE]);
$dateDebAbs=mktime(0,0,0,$debAbs[1],$debAbs[2],$debAbs[0]);
//date fin absence
if($h[GEST_CHAMPS_DATE_FIN_ABSENCE]!='0000-00-00')
{
$finAbs=explode('-',$h[GEST_CHAMPS_DATE_FIN_ABSENCE]);
$dateFinAbs=mktime(0,0,0,$finAbs[1],$finAbs[2],$finAbs[0]);
if (($dateDebAbs<=$date)and ($date<=$dateFinAbs))
{
$ligneType[$g]->setSelected($h[GEST_CHAMPS_ID_MOTIF]);
}
}else{
//cas ou la date de fin n'est pas rentre
if($dateDebAbs==$date)
{
$ligneType[$g]->setSelected($h[GEST_CHAMPS_ID_MOTIF]);
}
}
}
}
}
$form->addGroup($ligneType,'groupe','Type de Jour : ','&nbsp',false);
//ligne bouton validation
$size4=5;
$id4='bouton_valider_travail';
$assoc4=array('class' =>$id4, 'size'=>$size4);
$boutonSubmit= &HTML_QuickForm::createElement('submit', 'champ_valider_travail',GTT_L_G_VALIDER,$assoc4);
$form->addElement($boutonSubmit);
$form->addElement('html',afficherOptionAplication($utilisateur));
return $form;
}
 
?>
Property changes:
Added: svn:executable