Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 4 → Rev 5

/trunk/controleur/gtt_controleur_travail.php
34,7 → 34,6
*/
// +------------------------------------------------------------------------------------------------------+
include_once CHEMIN_FN_GENERIQUE_AFFICHAGE;
include_once 'gtt_config.inc.php';
include_once CHEMIN_MENU.'gtt_menu_travail.php';
include_once CHEMIN_CLASSES_METIER.'gtt_travail.class.php';
include_once CHEMIN_CLASSES_METIER.'gtt_taches.class.php';
48,91 → 47,82
 
function verifTempsTravail()
{
$nb=$_POST["champ_nb_projet"];
$nb = $_POST['champ_nb_projet'];
$res = true;
// Iniatilisation des variables
$somme1 = $somme2 = $somme3 = $somme4 = $somme5 = $somme6 = $somme7 = 0;
$verif_a_faire = false;
// Tableau jour
$tabJour = array(0 => "champ_lundi", 1 => "champ_mardi", "champ_mercredi", "champ_jeudi", "champ_vendredi", "champ_samedi", "champ_dimanche");
$res = true;
//iniatilisation des variables
$somme1=$somme2=$somme3=$somme4=$somme5=$somme6=$somme7=0;
$verif_a_faire=false;
//tableau jour
$tabJour=array(0=>"champ_lundi",1=>"champ_mardi","champ_mercredi","champ_jeudi","champ_vendredi","champ_samedi","champ_dimanche");
for ($i=0;$i<$nb;$i++)
{
for ($j=0;$j<count($tabJour);$j++)
{
//on ne fait les tests que si des jours de travail ou de recuperation partielle
if ((isset($_POST[$tabJour[$j].$i]))and (($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL) or
($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]=="Récup part:1/2j")))
{
$verif_a_faire=true;
//attribution de la limite selon le type de jour
if ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL)
{
$limite = 24;
for ($i = 0; $i < $nb; $i++) {
for ($j = 0; $j < count($tabJour); $j++) {
// On ne fait les tests que si des jours de travail ou de recuperation partielle
if ((isset($_POST[$tabJour[$j].$i]))and (($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL) or
($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]=="Récup part:1/2j"))) {
$verif_a_faire = true;
//attribution de la limite selon le type de jour
if ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL) {
$limite = 24;
} elseif ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]=="Récup part:1/2j") {
$limite = 12;
}
if ((!(($_POST[$tabJour[$j].$i]<$limite)and ($_POST[$tabJour[$j].$i]>=0))) or
(empty($_POST[$tabJour[$j].$i])!=1 and is_numeric($_POST[$tabJour[$j].$i]) != 1)) {
$res = false;
} else {
switch ($j) {
//cas lundi
case 1:
$somme1 += $_POST[$tabJour[$j].$i];
break;
//cas mardi
case 2 :
$somme2 += $_POST[$tabJour[$j].$i];
break;
//cas mercredi
case 3 :
$somme3 += $_POST[$tabJour[$j].$i];
break;
//cas jeudi
case 4 :
$somme4 += $_POST[$tabJour[$j].$i];
break;
//cas vendredi
case 5 :
$somme5 += $_POST[$tabJour[$j].$i];
break;
//cas samedi
case 6 :
$somme6 += $_POST[$tabJour[$j].$i];
break;
//cas dimanche
case 7 :
$somme7 += $_POST[$tabJour[$j].$i];
break;
}
}
}
}
elseif($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]=="Récup part:1/2j")
{
$limite = 12;
}
if ((!(($_POST[$tabJour[$j].$i]<$limite)and ($_POST[$tabJour[$j].$i]>=0)))or
(empty($_POST[$tabJour[$j].$i])!=1 and is_numeric($_POST[$tabJour[$j].$i])!=1))
{
$res=false;
}else{
switch ($j)
{
//cas lundi
case 1:
$somme1 += $_POST[$tabJour[$j].$i];
break;
//cas mardi
case 2 :
$somme2 += $_POST[$tabJour[$j].$i];
break;
//cas mercredi
case 3 :
$somme3 += $_POST[$tabJour[$j].$i];
break;
//cas jeudi
case 4 :
$somme4 += $_POST[$tabJour[$j].$i];
break;
//cas vendredi
case 5 :
$somme5 += $_POST[$tabJour[$j].$i];
break;
//cas samedi
case 6 :
$somme6 += $_POST[$tabJour[$j].$i];
break;
//cas dimanche
case 7 :
$somme7 += $_POST[$tabJour[$j].$i];
break;
}
}
}
}
}
//test si une des valeurs >24
if( $verif_a_faire==true)
{
$resultat=(($somme1<$limite)and ($somme2<$limite)and ($somme3<$limite)and ($somme4<$limite)and ($somme5<$limite)
and ($somme6<$limite)and ($somme7<$limite)and ($res==true));
}else $resultat=true;
return $resultat;
if( $verif_a_faire == true) {
$resultat=(($somme1<$limite)and ($somme2<$limite)and ($somme3<$limite)and ($somme4<$limite)and ($somme5<$limite)
and ($somme6<$limite)and ($somme7<$limite)and ($res==true));
} else {
$resultat = true;
}
return $resultat;
}
 
/**
*fonction traitant l'ajout d'un champ travail dans la base
*@param : utilisateur
139,185 → 129,163
*/
function traiterSemaine($utilisateur)
{
if (isset($_POST["champ_valider_travail"]))
{
//recuperation de l'utilisateur
$user1=&Utilisateur::recupererUtilisateur($utilisateur);
//parcours du tableau de jours
$tabListeJour=array(0 =>'champ_lundi',1 =>'champ_mardi','champ_mercredi','champ_jeudi','champ_vendredi','champ_samedi','champ_dimanche');
//parcourt du tableau de jour
for ($nb=0;$nb<$_POST["champ_nb_projet"];$nb++)
{
for($j=0; $j<count($tabListeJour);$j++)
{
//test du type de jour
if (isset($_POST["champ_type_jour".$j]))
{
//cas jour de travail ou recuperation partielle(recuperation partielle ne reduit pas le temps de travail
if (($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL)
or (($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_RECUP_PART)
and ($_POST["champ_rtt_type_jour".$_POST["champ_type_jour".$j]]==0)))
{
//test si aucun conges prealablement rentre ne chevauche la date voulue
//construction d'un objet absence equivalent a la date de travail
$testAbs= new Absence($utilisateur,0,date('Y-m-d',$_POST["champ_date_j".$j]));
$testAbs->setDateFin(date('Y-m-d',$_POST["champ_date_j".$j]));
$tabAbsence=$testAbs->existeAbsence();
//booleen pour indiquer si on peut ajouter
$possibleAjout=true;
//si chevauchement: verification si tous validee
if(count($tabAbsence)>0)
{
if($testAbs->existeAbsenceValidee()==true)
{
$possibleAjout=false;
$_POST[$tabListeJour[$j].$nb]='';
$codeErreur=2;
}else{
//supression des absences non validees
for($p=0;$p<count($tabAbsence);$p++)
{
$l=$tabAbsence[$p];
$absTemp2=$testAbs;
$absTemp2->construireAbsence($l);
$nbJour2=$absTemp2->getDureeAbsence();
//mise a jour des quota heures sup et des conges payes de l'utilisateur
if($_POST["champ_libelle_type_jour".$l[GEST_CHAMPS_ID_MOTIF]]==GTT_NOM_RECUPERATION)
{
$quotaTemp=$user1->getQuota();
$user1->setQuota($quotaTemp+(($user1->getTempsTravail())*$nbJour2));
if (isset($_POST['champ_valider_travail'])) {
// Récuperation de l'utilisateur
$user1 = Utilisateur::recupererUtilisateur($utilisateur);
// Parcours du tableau de jours
$tabListeJour = array(0 =>'champ_lundi',1 =>'champ_mardi','champ_mercredi','champ_jeudi','champ_vendredi','champ_samedi','champ_dimanche');
// Parcourt du tableau de jour
for ($nb = 0; $nb < $_POST["champ_nb_projet"]; $nb++) {
for($j = 0; $j < count($tabListeJour); $j++) {
// Test du type de jour
if (isset($_POST["champ_type_jour".$j])) {
//cas jour de travail ou recuperation partielle(recuperation partielle ne reduit pas le temps de travail
if (($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]] == GTT_NOM_TRAVAIL)
or (($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]] == GTT_NOM_RECUP_PART)
and ($_POST["champ_rtt_type_jour".$_POST["champ_type_jour".$j]] == 0))) {
//test si aucun conges prealablement rentre ne chevauche la date voulue
//construction d'un objet absence equivalent a la date de travail
$testAbs = new Absence($utilisateur,0,date('Y-m-d', $_POST["champ_date_j".$j]));
$testAbs->setDateFin(date('Y-m-d', $_POST["champ_date_j".$j]));
$tabAbsence = $testAbs->existeAbsence();
// Booleen pour indiquer si on peut ajouter
$possibleAjout = true;
// Si chevauchement: verification si tous validee
if (count($tabAbsence) > 0) {
if ($testAbs->existeAbsenceValidee() == true) {
$possibleAjout = false;
$_POST[$tabListeJour[$j].$nb] = '';
$codeErreur = 2;
} else {
//supression des absences non validees
for ($p = 0; $p < count($tabAbsence); $p++) {
$l = $tabAbsence[$p];
$absTemp2 = $testAbs;
$absTemp2->construireAbsence($l);
$nbJour2 = $absTemp2->getDureeAbsence();
// Mise a jour des quota heures sup et des conges payes de l'utilisateur
if ($_POST["champ_libelle_type_jour".$l[GEST_CHAMPS_ID_MOTIF]]==GTT_NOM_RECUPERATION) {
$quotaTemp=$user1->getQuota();
$user1->setQuota($quotaTemp+(($user1->getTempsTravail())*$nbJour2));
} elseif ($_POST["champ_libelle_type_jour".$l[GEST_CHAMPS_ID_MOTIF]]==GTT_NOM_RECUP_PART) {
$quotaTemp=$user1->getQuota();
$user1->setQuota($quotaTemp+((($user1->getTempsTravail())/2)*$nbJour2));
} else {
if ($_POST["champ_libelle_type_jour".$l[GEST_CHAMPS_ID_MOTIF]]==GTT_NOM_CONGES_PAYES) {
$congesTemp=$user1->getConges();
$user1->setConges($congesTemp+($nbJour2*1));
}
}
$f = $testAbs->supprimerAbsence($utilisateur,$l[GEST_CHAMPS_DATE_DEBUT_ABSENCE]);
if ($f != 1) {
$codeErreur = 3;
}
}
}
}
}elseif($_POST["champ_libelle_type_jour".$l[GEST_CHAMPS_ID_MOTIF]]==GTT_NOM_RECUP_PART)
{
$quotaTemp=$user1->getQuota();
$user1->setQuota($quotaTemp+((($user1->getTempsTravail())/2)*$nbJour2));
}else
{
if ($_POST["champ_libelle_type_jour".$l[GEST_CHAMPS_ID_MOTIF]]==GTT_NOM_CONGES_PAYES)
//determination des limites de travail en fonction du type de jour
if ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL) {
$limiteHeureTravail = $GLOBALS['limiteJourTravail'];
} else {
$limiteHeureTravail=$GLOBALS['limiteJourRecupPart'];
//construction de l'absence
$absenceRecupPart=new Absence($utilisateur,$_POST["champ_type_jour".$j],date('Y-m-d',$_POST["champ_date_j".$j]));
$absenceRecupPart->setDateFin(date('Y-m-d',$_POST["champ_date_j".$j]));
//traitement de l'enregistrement de la recuperation partielle
if ($possibleAjout == true) {
$q = $absenceRecupPart->enregistrerNewAbsence();
//mise a jour des quotas
$val=$user1->getQuota();
$duree=$user1->getTempsTravail();
$user1->setQuota($val-(($user1->getTempsTravail())/2));
if ($q != 1 ) {
//attribution d'un code erreur
$codeErreur=1;
}
}
}
//test si le champ n'est pas vide et le champ est different de 0
if (empty($_POST[$tabListeJour[$j].$nb])!=1 and ($_POST[$tabListeJour[$j].$nb])!=0)
{
$congesTemp=$user1->getConges();
$user1->setConges($congesTemp+($nbJour2*1));
}
}
$f=$testAbs->supprimerAbsence($utilisateur,$l[GEST_CHAMPS_DATE_DEBUT_ABSENCE]);
if ($f!=1)$codeErreur=3;
}
}
}
//determination des limites de travail en fonction du type de jour
if ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_TRAVAIL)
{
$limiteHeureTravail=$GLOBALS['limiteJourTravail'];
}else
{
$limiteHeureTravail=$GLOBALS['limiteJourRecupPart'];
//construction de l'absence
$absenceRecupPart=new Absence($utilisateur,$_POST["champ_type_jour".$j],date('Y-m-d',$_POST["champ_date_j".$j]));
$absenceRecupPart->setDateFin(date('Y-m-d',$_POST["champ_date_j".$j]));
//traitement de l'enregistrement de la recuperation partielle
if($possibleAjout==true)
{
$q = $absenceRecupPart->enregistrerNewAbsence();
//mise a jour des quotas
$val=$user1->getQuota();
$duree=$user1->getTempsTravail();
$user1->setQuota($val-(($user1->getTempsTravail())/2));
if ($q!=1 )
{
//attribution d'un code erreur
$codeErreur=1;
}
}
}
//test si le champ n'est pas vide et le champ est different de 0
if (empty($_POST[$tabListeJour[$j].$nb])!=1 and ($_POST[$tabListeJour[$j].$nb])!=0)
{
//test si date <=date d'aujourd'hui
if ($_POST["champ_date_j".$j]<=time() and ($possibleAjout==true))
{
//impossible de modifier des donnees une fosi que l'absence
//est enregistree
//construction de l'objet travail
$travail= new Travail($utilisateur,$_POST["champ_tache".$nb]);
$travail->setDateTravail(date('Y-m-d',$_POST["champ_date_j".$j]));
$travail->setDureeTravail($_POST[$tabListeJour[$j].$nb]);
//traitement de l'objet travail
$t=traiterTravail($travail,$limiteHeureTravail);
$_POST[$tabListeJour[$j].$nb]='';
if($t!=1)$codeErreur=$t;
//test si date <=date d'aujourd'hui
if ($_POST["champ_date_j".$j]<=time() and ($possibleAjout==true))
{
//impossible de modifier des donnees une fosi que l'absence
//est enregistree
//construction de l'objet travail
$travail= new Travail($utilisateur,$_POST["champ_tache".$nb]);
$travail->setDateTravail(date('Y-m-d',$_POST["champ_date_j".$j]));
$travail->setDureeTravail($_POST[$tabListeJour[$j].$nb]);
//traitement de l'objet travail
$t=traiterTravail($travail,$limiteHeureTravail);
$_POST[$tabListeJour[$j].$nb]='';
if($t!=1)$codeErreur=$t;
}else{
if($possibleAjout==true)
{
//cas ou la date est superieure a la date d'aujourd'hui
//construction de l'objet prevision
$prevision=new Prevision(1000,1000);
$tableau=array(GEST_CHAMPS_ID_UTILISATEUR=>$utilisateur,
GEST_CHAMPS_ID_TACHE=>$_POST["champ_tache".$nb],
GEST_CHAMPS_DATE_PREVISION=>date('Y-m-d',$_POST["champ_date_j".$j]),
GEST_CHAMPS_DUREE_PREVISION=> $_POST["$tabListeJour[$j]".$nb]);
$prevision->construirePrevision($tableau);
$o=traiterPrevision($prevision, $limiteHeureTravail);
$_POST[$tabListeJour[$j].$nb]='';
if($o!=1)$codeErreur=$o;
}
}
}//fin traitement travail et prevision
}else{
if($possibleAjout==true)
//cas des conges
//cas : conges paye,recup,maladie,greve,ferie
if(($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_CONGES_PAYES)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_RECUPERATION)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_MALADIE)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_GREVE)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_WEEK_END)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_FERIE))
{
//cas ou la date est superieure a la date d'aujourd'hui
//construction de l'objet prevision
$prevision=new Prevision(1000,1000);
$tableau=array(GEST_CHAMPS_ID_UTILISATEUR=>$utilisateur,
GEST_CHAMPS_ID_TACHE=>$_POST["champ_tache".$nb],
GEST_CHAMPS_DATE_PREVISION=>date('Y-m-d',$_POST["champ_date_j".$j]),
GEST_CHAMPS_DUREE_PREVISION=> $_POST["$tabListeJour[$j]".$nb]);
//construction du nouvel objet absence
$objetAbsence=new Absence($utilisateur,$_POST["champ_type_jour".$j],date('Y-m-d',$_POST["champ_date_j".$j]));
$objetAbsence->setDateFin(date('Y-m-d',$_POST["champ_date_j".$j]));
//traitement de l'objet absence
$g=traiterAbsence($objetAbsence,$user1,$_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]);
if ($g[0]!=1){
$codeErreur=$g[0];
}else {
$user1=$g[1];
}
$prevision->construirePrevision($tableau);
$o=traiterPrevision($prevision, $limiteHeureTravail);
$_POST[$tabListeJour[$j].$nb]='';
if($o!=1)$codeErreur=$o;
}
}
}//fin traitement travail et prevision
}else{
//cas des conges
//cas : conges paye,recup,maladie,greve,ferie
if(($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_CONGES_PAYES)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_RECUPERATION)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_MALADIE)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_GREVE)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_WEEK_END)
or ($_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]==GTT_NOM_FERIE))
{
//construction du nouvel objet absence
$objetAbsence=new Absence($utilisateur,$_POST["champ_type_jour".$j],date('Y-m-d',$_POST["champ_date_j".$j]));
$objetAbsence->setDateFin(date('Y-m-d',$_POST["champ_date_j".$j]));
//traitement de l'objet absence
$g=traiterAbsence($objetAbsence,$user1,$_POST["champ_libelle_type_jour".$_POST["champ_type_jour".$j]]);
if ($g[0]!=1){
$codeErreur=$g[0];
}else {
$user1=$g[1];
}
}
}//fin traitement type jour
}//typr jour
}
// }
}
$h=$user1->mettreAJourUtilisateur();
if ($h!=1)
{
$codeErreur=25;
}
}//fin traitement type jour
}//typr jour
}
// }
}
$h=$user1->mettreAJourUtilisateur();
if ($h!=1) {
$codeErreur = 25;
}
}
$_POST["champ_valider_travail"]='dejaValider';
$_POST['champ_valider_travail'] = 'dejaValider';
}
 
/**
746,26 → 714,22
}
 
 
/**
*fonction traitant le menu travail
*/
function traiterAdminTravail($url,$semaine,$annee,$utilisateur)
function traiterAdminTravail($url, $semaine, $annee, $utilisateur)
{
$text=creerEntetePage(GESTION_GESTIONDEPOSTE_L);
$form=afficherTableauJour($url,$utilisateur,$semaine,$annee);
if (isset($_POST["champ_valider_travail"])and $_POST["champ_valider_travail"]!='dejaValider'and $form->validate())
{
$text = creerEntetePage(GESTION_GESTIONDEPOSTE_L);
$form = afficherTableauJour($url, $utilisateur, $semaine, $annee);
$form->process(traiterSemaine($utilisateur));
$t=afficherTableauJour($url,$utilisateur,$semaine,$annee);
$text.=$t->ToHTml();
}else{
$text.=$form->ToHtml();
}
return $text;
if (isset($_POST['champ_valider_travail']) and $_POST['champ_valider_travail'] != 'dejaValider' and $form->validate()) {
$form->process(traiterSemaine($utilisateur));
$t = afficherTableauJour($url, $utilisateur, $semaine, $annee);
$text .= $t->ToHTml();
} else {
$text .= $form->ToHtml();
}
return $text;
}
 
 
?>
/trunk/controleur/gtt_controleur_editer_preferences.php
42,19 → 42,18
*/
function traiterEditerPreferences($user)
{
$text=creerEntetePage(GESTION_EDITER_PREFERENCES_L);
$form= afficherMenuEditerPref($user);
if (isset($_POST["btn_valider_editer"])and $_POST["btn_valider_editer"]!='dejaValider'and $form->validate())
{
$form->process(editerPref($user));
$t=afficherMenuEditerPref($user);
$text.=$t->ToHTml();
}else{
$text.=$form->ToHtml();
}
//affichage des options disponibles pour l'utilisateur courant
$text.=afficherOptionAplication($user);
return $text;
$text = creerEntetePage(GESTION_EDITER_PREFERENCES_L);
$form = afficherMenuEditerPref($user);
if (isset($_POST["btn_valider_editer"]) and $_POST["btn_valider_editer"] != 'dejaValider' and $form->validate()) {
$form->process(editerPref($user));
$t = afficherMenuEditerPref($user);
$text .= $t->ToHTml();
} else {
$text .= $form->ToHtml();
}
// Affichage des options disponibles pour l'utilisateur courant
$text .= afficherOptionAplication($user);
return $text;
}
 
/**
62,16 → 61,15
*/
function editerPref($user)
{
$r=&Preference::supprimerPreferences($user);
$nb=$_POST["champ_nb_total_proj"]; //NB TOTAL DE PROJET
for($u=0;$u<$nb;$u++)
{
if(isset($_POST["champ_check".$u]))
{
$preference1=new Preference($user,$_POST["champ_id_pr".$u]);
$ret= $preference1->enregistrerPreference();
if($ret!=1)echo "erreur preferences";
}
}
$r =& Preference::supprimerPreferences($user);
$nb = $_POST['champ_nb_total_proj']; //NB TOTAL DE PROJET
for($i = 0; $i < $nb; $i++) {
if (isset($_POST['champ_check'.$i])) {
$Preference = new Preference($user, $_POST['champ_id_pr'.$i]);
if (!$Preference->ajouter()) {
echo "Erreur preferences";
}
}
}
}
?>