*SUBROUTINE AffichePlanning(RETURNVAL,PARAMETRES,W_Sortie)

EXECUTE 'DATE.FORMAT'
EXECUTE 'SET-DEC ,'
EXECUTE 'SET-THOUS .'
*************************************************************************************************************
*					PR D'dition / affichage des plannings							*
*																		*
* NB : 1 On notifie quand mme en affichage les interventions ayant lieu 						*
*         pendant une absence de l'aidant, mais pas en dition...								*
*	    Par contre, on notifie mme en dition les interventions pendant une indispo...				*
*      2 Pour dterminer sur une intervention cyclique non hebdomadaire (bihebdo, ttes les 3 semaines,	*
*         si elle est active dans l'intervfalle, il faut savoir que l'intervention commence 			*
*         entre le lundi et le dimanche encadrant sa date de dbut, et ce mme si la date de dbut 		*
*         est postrieure a ce dbut d'intervention calcule... 								*
*         Ex : Intervention le mardi ttes les 3 semaines, date de dbut le mercredi 6				*
*         On considre que l'intervention a commenc le mardi 5, et donc la premire vraie intervention 	*
*         aura lieu le mardi 26.													*
*	 3 MOD(Date,7) = 1 => Date est un lundi, MOD(Date,7) = 2 => Date est un mardi, etc....			*
*	    Alors que ds cl DETAILINTERV, on a 0 = lundi, 1 = mardi,...							*
*      4 Convention utilise : les variables dont la valeur est fixe (qui ne doivent pas changer) 		*
*         sont nommes sans "W_"... (Parametres d'appel du PR, NbJours a afficher...)				*
*      5 Si l'on veut utiliser le fichier gnr pour traiter les paies, modifier en procdure 10		*
*	    les informations crites, de manire  y ajouter les informations 						*
*	    relatives  la saisie (rubrique, activits, base), plus faire suivre en procdure 200,300,400...	*
*	 6 Cas des congs dbutant l'a.-m. ou finissant le matin :								*
*	    Penser a renseigner le paramtre ci dessous : 									*
MidiConges = "1300"
*																		*
*Modification JC 17/03/2008, en vue d'une optimisation du temps d'affichage du planning en visualisation, il a t cr la procdure 410*
*La visualisation du planning faisait 2 fois appel  ce PR. Le traitement du 2eme appel a donc t trait en mme temps que le 1er appel.
*La procdure 410 est un couper d'une partie de la procdure 400 trait au 2eme appel. Les modifications apportes  ce code ne s'xcute que lors de 
* la visualisation, pour ne pas interfrer avec les autres appels du AFFICHEPLANNING.
*Un argument 14 a t rajout pour ne traiter que ce cas.
*************************************************************************************************************

DepartTraitement = TIME()

*OPEN "", "TPSTAMPON" TO F.TAMPON ELSE RETURN

OPEN "", "TEMPO" TO F.TEMPO ELSE STOP
OPEN "", "TABLES" TO F.TABLES ELSE STOP
OPEN "", "TPSEXCEPTIONS" TO F.TPSEXCEPTIONS ELSE STOP
OPEN "", "TPSMOI" TO F.TPSMOI ELSE STOP
OPEN "", "RUBSAISIE" TO F.RUBSAISIE ELSE STOP
OPEN "","TPSDETAILSINTERV" TO F.TPSDETAILSINTERV ELSE STOP;* en lecture
OPEN "","TPSAIDANTDISPO" TO F.TPSAIDANTDISPO ELSE STOP
OPEN "","CIVILAIDE" TO F.CIVILAIDE ELSE STOP;* en lecture
OPEN "","CIVILAIDANT" TO F.CIVILAIDANT ELSE STOP;* en lecture
OPEN "","CONTRAT" TO F.CONTRAT ELSE STOP;* en lecture
OPEN "","ABSENCESAIDANT" TO F.ABSENCESAIDANT ELSE STOP;* en lecture
OPEN "","ABSENCESAIDE" TO F.ABSENCESAIDE ELSE STOP;* en lecture
OPEN "","ACTIVITESAIDE" TO F.ACTIVITESAIDE ELSE STOP;* en lecture
OPEN "","ACTIVITES" TO F.ACTIVITES ELSE STOP;* en lecture
OPEN "", "BESOINSAIDE" TO F.BESOINSAIDE ELSE STOP
OPEN "", "SECTEUR" TO F.SECTEUR ELSE STOP
OPEN "", "RESPONSABLE" TO F.RESPONSABLE ELSE STOP
OPEN "", "PAQUES" TO F.PAQUES ELSE STOP
OPEN "", "TPSPARAMBASCUL" TO F.TPSPARAMBASCUL ELSE STOP
OPEN "", "TPSOBS" TO F.TPSOBS ELSE STOP
OPEN "", "TPSPARAM" TO F.TPSPARAM ELSE STOP
OPEN "", "TPSTEMPO" TO F.TPSTEMPO ELSE STOP
OPEN "","PERIODESPAIE" TO F.PERIODESPAIE ELSE STOP
OPEN "","TPSDETAILSINTERVARCH" TO F.TPSDETAILSINTERVARCH ELSE STOP
OPEN "","TPSEXCEPTIONSARCH" TO F.TPSEXCEPTIONSARCH ELSE STOP


*********************************************************
* Recuperation des arguments					  *
*********************************************************

PROCREAD PARAMETRES ELSE STOP

* Nom utilisateur
User = FIELD(PARAMETRES,"|",2)

* Code asso ou [Vide]
Asso = FIELD(PARAMETRES,"|",3)
* Intgration spcifique Caen :
OPEN "", "ASSOCIATION" TO F.ASSOCIATION ELSE STOP
READ ENR_ASSOCIATION FROM F.ASSOCIATION, Asso ELSE ENR_ASSOCIATION = ""

* Type d'activit
* Nb : chaine de caractre contenant une ou plusieurs des lettres P, M, I et S
TypesAct = FIELD(PARAMETRES,"|",4)

* Dates  diter
DateDeb = FIELD(PARAMETRES,"|",5)
DateFin = FIELD(PARAMETRES,"|",6)

* Critres de tri : (S)ecteur, (C)ommune ou (A)id...
Tri = FIELD(PARAMETRES,"|",7)
* Code dans la slection
Sel = FIELD(PARAMETRES,"|",8)

* Edition individuelle : Code aidant
CodeAidant = FIELD(PARAMETRES,"|",9)

* Type Demand : (A)ffichage / (E)dition / (P)aie (pas encore dfini, juste prvu)
TraitementRecapMens = ""
VraimentRecapMens = ""
TraitementPaie = ""
TraitementRempl = ""
TraitementExtract = ""
Affichage = FIELD(PARAMETRES,"|",10)
IF Affichage = "AA" THEN
	ParAide = "1"
	Affichage = "A"
END ELSE
	IF Affichage = "EA" THEN
		Affichage = "E"
		ParAide= "1"
	END ELSE
		IF Affichage = "ESA" THEN
			Affichage = "ES"
			ParAide= "1"
		END ELSE
			IF Affichage = "Recap" THEN
				TraitementRecapMens = "1"
				VraimentRecapMens = "1"
				Affichage = "E"
				ParAide = ""
			END ELSE
				IF Affichage[1,9] = "FeuilPres" THEN
					IF Affichage[10,1] = "A" THEN
						ParAide= "1"
					END ELSE
						ParAide= ""
					END
					TraitementRecapMens = "1"
					Affichage = "E"
				END ELSE
					IF Affichage = "BASCULPAIE" THEN
						Affichage = "ES"
						TraitementPaie = "1"
						ParAide= ""

					END ELSE
						IF Affichage = "REMPLACEMENT" THEN
							Affichage = "A"
							TraitementRempl = "1"
							ParAide= ""

						END ELSE
							IF Affichage = "EXTRACT" THEN
								Affichage = "A"
								TraitementExtract = "1"
								ParAide= ""

							END
							
							IF Affichage = "EXTRACTA" THEN
							
								Affichage = "A"
								ParAide= "1"
								TraitementExtract = "1"
							
							END ELSE
								ParAide= ""
							END
						END	
					END
					

				END
			END
		END
	END
END
* Nb : dans tout le programme, si traitement par aid, alors ParAide # ""

CodeAide = FIELD(PARAMETRES,"|",11)
CodeAbsRempl = FIELD(PARAMETRES,"|",12)

* Spcifique feuilles prsence : bornage par le nom aidant / aid...
BorneInf = FIELD(PARAMETRES,"|",12)
BorneSup = FIELD(PARAMETRES,"|",13)

QuiAppel = FIELD(PARAMETRES,"|",14)


READ ENR_TABLESMOTIFSORTIE FROM F.TABLES, "MOTIFSORTIE" ELSE ENR_TABLESMOTIFSORTIE = ""
READ ENR_TABLESABSENCES FROM F.TABLES, "ABSENCES" ELSE ENR_TABLESABSENCES = ""
READ ENR_TPSPARAM FROM F.TPSPARAM, "1" ELSE ENR_TPSPARAM = ""
READ ENR_PERIODESPAIE FROM F.PERIODESPAIE, "1" ELSE 
	ENR_PERIODESPAIE<1> = OCONV(DATE(),"D4/")
	ENR_PERIODESPAIE<1> = ENR_PERIODESPAIE<1>[7,4]:ENR_PERIODESPAIE<1>[4,2]
END
W_DateArchive = ENR_PERIODESPAIE<1> - 2
IF W_DateArchive[5,2] = "00" THEN
	W_DateArchive = W_DateArchive[1,4]
	W_DateArchive = W_DateArchive:"12"
END ELSE
  IF W_DateArchive[5,2] = "99" THEN
	W_DateArchive = W_DateArchive[1,4]
	W_DateArchive = W_DateArchive:"11"
  END ELSE
	
  END
END
W_NomReqIntervArch = ""
W_NomReqExceptArch = ""
W_SauveCumul=""
W_DateArchive = ICONV("01/":W_DateArchive[5,2]:"/":W_DateArchive[1,4],"D4/")
IF DateDeb < W_DateArchive THEN
	ENRTEMPO = ""
	W_ReqTemp = ""
	W_NomReqIntervArch = "ReqIntervArch":User:TIME()
	W_NomReqExceptArch = "ReqExceptArch":User:TIME()
	W_Temp = 'SELECT TPSDETAILSINTERVARCH AVEC DateFinDetailsInterv >= "':DateDeb:'"'
	IF CodeAidant # "" THEN
		W_Temp = W_Temp:' AND AVEC CodeAidant = "':CodeAidant:'"'
	END
	IF CodeAide # "" THEN
		W_Temp = W_Temp:' AND AVEC CodeAide = "':CodeAide:'"'
	END
	EXECUTE W_Temp
	ENRTEMPO<-1> = W_Temp
	EXECUTE 'SAUVE-LISTE ':W_NomReqIntervArch
	EXECUTE 'LISTE ':W_NomReqIntervArch RETURNING MSGCODE
	IF MSGCODE<1> # "209" THEN
		ENRTEMPO<-1> = "# 209"
		SELECT F.TPSDETAILSINTERVARCH TO W_ReqTemp
		W_Fin = "F"
		LOOP
			READNEXT W_CleTemp FROM W_ReqTemp ELSE W_Fin = "V"
		WHILE W_Fin = "F"
			READ ENRTEMP FROM F.TPSDETAILSINTERVARCH, W_CleTemp THEN
				WRITE ENRTEMP ON F.TPSDETAILSINTERV, W_CleTemp
				ENRTEMPO<-1> = W_CleTemp:" ecrite"
			END
		REPEAT
	END
	W_Temp = 'SELECT TPSEXCEPTIONSARCH AVEC DateDebExcep >= "':DateDeb:'"'
	IF CodeAidant # "" THEN
		W_Temp = W_Temp:' AND AVEC CodeAidantExcep = "':CodeAidant:'"'
	END
	IF CodeAide # "" THEN
		W_Temp = W_Temp:' AND AVEC CodeAideExcep = "':CodeAide:'"'
	END
	EXECUTE W_Temp
	ENRTEMPO<-1> = W_Temp
	EXECUTE 'SAUVE-LISTE ':W_NomReqExceptArch
	EXECUTE 'LISTE ':W_NomReqExceptArch RETURNING MSGCODE
	IF MSGCODE<1> # "209" THEN
		SELECT F.TPSEXCEPTIONSARCH TO W_ReqTemp
		W_Fin = "F"
		LOOP
			READNEXT W_CleTemp FROM W_ReqTemp ELSE W_Fin = "V"
		WHILE W_Fin = "F"
			READ ENRTEMP FROM F.TPSEXCEPTIONSARCH, W_CleTemp THEN
				WRITE ENRTEMP ON F.TPSEXCEPTIONS, W_CleTemp
			END
		REPEAT
	END
	WRITE ENRTEMPO ON F.TEMPO, "Debug**"
END
*********************************************************
* En dur : longueur du libelle absence pour l'dition	  *
LongueurLibAbsence = 23

*********************************************************
* PROGRAMME PRINCIPAL
*********************************************************

*********************************************************
   
   W_Temp='SELECT TPSDETAILSINTERV AVEC DateDebInterv <= "':DateFin:'" AND AVEC DateFinDetailsInterv >= "':DateDeb:'" OR = ""'
   IF ParAide # "" THEN

	W_NomReqMOITps=""

	IF CodeAide # "" THEN
		W_Temp = W_Temp:' AND AVEC CodeAide = "':CodeAide:'"'
	END
   END
      
   IF CodeAidant # "" THEN
	   W_Temp = W_Temp: ' AND AVEC CodeAidant = "':CodeAidant:'"'
   END
   IF Asso # "" THEN
		W_Temp = W_Temp: ' AND AVEC CodeActInterv = "':Asso:']"'
   END 
   W_Temp = W_Temp:' AND AVEC TypeActDetailInterv = "':TypesAct[1,1]:'"'	
   FOR i = 2 TO LEN(TypesAct)
   	   W_Temp = W_Temp:' OR = "':TypesAct[i,1]:'"'
   NEXT i
   IF ParAide = "" THEN
     IF BorneInf # "" THEN
		W_Temp = W_Temp:' AND AVEC NomPrenomAidantDetailInterv >= "':BorneInf:'"'
     END
     IF BorneSup # "" THEN
		W_Temp = W_Temp:' AND AVEC NomPrenomAidantDetailInterv <= "':BorneSup:'"'
     END
     BEGIN CASE
       CASE Tri = "S"
	   IF Sel # "" THEN 
            W_Temp=W_Temp:' AND AVEC CodeSecteurAidant = "':Sel:'"'
         END ELSE
            W_Temp=W_Temp:' PAR NomSecteurAidant'
         END
       CASE Tri = "C"
	   IF Sel # "" THEN 
            W_Temp=W_Temp:' AND AVEC CommuneAidant = "':Sel:'"'
         END ELSE
            W_Temp=W_Temp:' PAR CommuneAidant'
         END
       CASE Tri = "A"
         W_Temp=W_Temp:' AND AVEC CodeAide = "':Sel:'"'
      END CASE
   END ELSE
     IF BorneInf # "" THEN
		W_Temp = W_Temp:' AND AVEC NomPrenomAideDetailInterv >= "':BorneInf:'"'
     END
     IF BorneSup # "" THEN
		W_Temp = W_Temp:' AND AVEC NomPrenomAideDetailInterv <= "':BorneSup:'"'
     END
     BEGIN CASE
       CASE Tri = "S"
	   IF Sel # "" THEN 
            W_Temp=W_Temp:' AND AVEC CodeSectAideDetailInterv = "':Sel:'"'
         END ELSE
            W_Temp=W_Temp:' PAR NomSectAideDetailInterv'
         END
       CASE Tri = "C"
	   IF Sel # "" THEN 
            W_Temp=W_Temp:' AND AVEC CommuneAideDetailInterv = "':Sel:'"'
         END ELSE
            W_Temp=W_Temp:' PAR CommuneAideDetailInterv'
         END
       CASE Tri = "R"
	   IF Sel # "" THEN
            W_Temp=W_Temp:' AND AVEC CodeRespAideDetailInterv = "':Sel:'"'
	   END ELSE
		W_Temp=W_Temp:' PAR NomRespAideDetailInterv'
	   END
      END CASE

   END
   IF ParAide # "" THEN
	W_Temp=W_Temp:' PAR NomPrenomAideDetailInterv PAR CodeAide PAR CodeAidant PAR DateDebInterv PAR HeureInterv'
   END ELSE   
	IF TraitementPaie = "1" THEN
		* Spcifique trt paie : on trie par code afin de parcourir le rsultat simultanment avec une requte sur contrat (et dtection des ruptures aidant)
	   W_Temp=W_Temp:' PAR CodeAidant PAR DateDebInterv PAR HeureInterv'
	END ELSE
         W_Temp=W_Temp:' PAR NomPrenomAidantDetailInterv PAR CodeAidant PAR DateDebInterv PAR HeureInterv'
	END
   END

   W_RequeteIntervAffPl = ""
   W_DerniereAnneeFerieProsp = ""

   EXECUTE W_Temp
   W_NomRequeteIntervAffPl = "RequeteIntervAffPl":User:Affichage:TIME()
   EXECUTE 'SAUVE-LISTE ':W_NomRequeteIntervAffPl
   EXECUTE "LISTE ":W_NomRequeteIntervAffPl RETURNING MSGCODE

   IF MSGCODE<1> # 209 THEN
	ENR_RAPPORT = ""

	W_ReqMOITps = ""
	W_ReqAbsAidantTps = ""

	W_NomReqAbsAidantTps = ""
	W_NomReqMOITps = ""

	SELECT F.TPSDETAILSINTERV TO W_RequeteIntervAffPl
	
	ENR_TEMPO = ""
      W_IndTempo = 0
	
	W_TabTypeAct = ""
	* Remplissage du tableau des types d'activit
	GOSUB 1000

	W_TabLibRub = ""
	* Remplissage du tableau des libelles rubriques de saisie utilisables en MOI
	GOSUB 1200	

	NbJours = DateFin - DateDeb + 1
	
	READ ENR_TABLES FROM F.TABLES, "ABSENCES" ELSE ENR_TABLES = ""


	W_Ind1TPSPARAMBASCUL = 1
	W_Ind2TPSPARAMBASCUL = 1
	W_Ind3TPSPARAMBASCUL = 1
	W_Ind4TPSPARAMBASCUL = 1
	READ ENR_TPSPARAMBASCUL FROM F.TPSPARAMBASCUL, Asso THEN
		i = 0
		W_Trouve = "F"
		LOOP
		i = i + 1
		WHILE ENR_TPSPARAMBASCUL<5,i> # "" AND W_Trouve = "F"
			IF ENR_TPSPARAMBASCUL<5,i> = ENR_TPSPARAMBASCUL<10,1> THEN
				W_Ind1TPSPARAMBASCUL = i
				W_Trouve = "V"
				IF ENR_TPSPARAMBASCUL<9,i> = "" THEN
					ENR_RAPPORT<-1> = "la"
					ENR_TPSPARAMBASCUL<9,i> = "999"
				END

			END
		REPEAT
		i = 0
		W_Trouve = "F"
		LOOP
		i = i + 1
		WHILE ENR_TPSPARAMBASCUL<5,i> # "" AND W_Trouve = "F"
			IF ENR_TPSPARAMBASCUL<5,i> = ENR_TPSPARAMBASCUL<10,2> THEN
				W_Ind2TPSPARAMBASCUL = i
				W_Trouve = "V"
				IF ENR_TPSPARAMBASCUL<9,i> = "" THEN
					ENR_TPSPARAMBASCUL<9,i> = "999"
				END

			END
		REPEAT
		i = 0
		W_Trouve = "F"
		LOOP
		i = i + 1
		WHILE ENR_TPSPARAMBASCUL<5,i> # "" AND W_Trouve = "F"
			IF ENR_TPSPARAMBASCUL<5,i> = ENR_TPSPARAMBASCUL<10,3> THEN
				W_Ind3TPSPARAMBASCUL = i
				W_Trouve = "V"
				IF ENR_TPSPARAMBASCUL<9,i> = "" THEN
					ENR_TPSPARAMBASCUL<9,i> = "999"
				END

			END
		REPEAT
		i = 0
		W_Trouve = "F"
		LOOP
		i = i + 1
		WHILE ENR_TPSPARAMBASCUL<5,i> # "" AND W_Trouve = "F"
			IF ENR_TPSPARAMBASCUL<5,i> = ENR_TPSPARAMBASCUL<10,4> THEN
				W_Ind4TPSPARAMBASCUL = i
				W_Trouve = "V"
				IF ENR_TPSPARAMBASCUL<9,i> = "" THEN
					ENR_TPSPARAMBASCUL<9,i> = "999"
				END

			END
		REPEAT
		
	END ELSE
		ENR_RAPPORT<-1> = "ici"
		ENR_TPSPARAMBASCUL = ""
		* Rub Prest
		ENR_TPSPARAMBASCUL<9,1> = "999"
*		* Rub Mand
*		ENR_TPSPARAMBASCUL<9,2> = "999"
*		* Rub Inter
*		ENR_TPSPARAMBASCUL<9,3> = "999"
*		* Rub SSIAD
*		ENR_TPSPARAMBASCUL<9,4> = "999"
	END
	ENR_RAPPORT<-1> = "**-** : Indices : ":W_Ind1TPSPARAMBASCUL:W_Ind2TPSPARAMBASCUL:W_Ind3TPSPARAMBASCUL:W_Ind4TPSPARAMBASCUL
	ENR_RAPPORT<-1> = ENR_TPSPARAMBASCUL
	W_TamponAidant = ""
	W_TamponAide = ""
	W_FinTrt = "F"
	LOOP
		READNEXT W_CleTrt FROM W_RequeteIntervAffPl ELSE W_FinTrt = "V"
		IF ParAide = "" THEN
		   IF W_CleTrt[1,5] # W_TamponAidant THEN
			IF W_TamponAidant # "" THEN

			   GOSUB 100

			   
			END
			W_TamponAidant = W_CleTrt[1,5]
			W_TabInterv = ""
			W_ListeAidesAidants = ""
		   END
		END ELSE
		   IF W_CleTrt[6,5] # W_TamponAide THEN
			IF W_TamponAide # "" THEN
				GOSUB 100
			END
			W_TamponAide = W_CleTrt[6,5]
			W_TabInterv = ""
			W_ListeAidants = ""
		   END
		   IF W_CleTrt[1,5] # W_TamponAidant AND W_FinTrt = "F" THEN
			W_TamponAidant = W_CleTrt[1,5]
			GOSUB 1600
		   END
		END
	WHILE W_FinTrt = "F"
		READ ENR_TPSDETAILSINTERV FROM F.TPSDETAILSINTERV, W_CleTrt THEN
			GOSUB 10
		END
	REPEAT
   END ELSE
	IF (CodeAidant = "" AND ParAide = "") OR (ParAide # "" AND CodeAide = "") THEN
	   IF ParAide = "" THEN
		ENR_TEMPO<1> = "Erreur - Pas d'aidants ayant au moins une intervention sur cette slection."
	   END ELSE
		ENR_TEMPO<1> = "Erreur - Pas d'aids ayant au moins une intervention sur cette slection."
	   END
	END ELSE
		*On prvoie que l'utilisateur demande l'dition (affichage ?) en individuel alors qu'aucune intervention n'est saisie...
		ENR_TEMPO = ""
      	W_IndTempo = 0
	
		W_TabTypeAct = ""
		* Remplissage du tableau des types d'activit
		GOSUB 1000

		IF ParAide = "" THEN
			W_TabLibRub = ""
			* Remplissage du tableau des libelles rubriques de saisie utilisables en MOI
			GOSUB 1200	
		END

		NbJours = DateFin - DateDeb + 1

		READ ENR_TABLES FROM F.TABLES, "ABSENCES" ELSE ENR_TABLES = ""
		IF ParAide = "" THEN
			W_TamponAidant = CodeAidant
		END ELSE
			W_TamponAide = CodeAide
		END
		W_TabInterv = ""
		GOSUB 100
		
	END
   END

   EXECUTE 'EFFACER-LISTE ':W_NomRequeteIntervAffPl
   IF W_NomReqAbsAidantTps # "" THEN
	EXECUTE 'EFFACER-LISTE ':W_NomReqAbsAidantTps
   END
   
   IF ParAide # "" THEN
      IF W_NomReqMOITps # "" THEN
	   EXECUTE 'EFFACER-LISTE ':W_NomReqMOITps
      END
   END

W_IndTempo = W_IndTempo + 1

ENR_TEMPO<W_IndTempo,1> = "#FIN"
IF Affichage # "E" THEN
	FOR i = 1 TO W_NbMois
		ENR_TEMPO<W_IndTempo,i+1,1> = W_Cumul<i,5>
		ENR_TEMPO<W_IndTempo,i+1,2> = W_Cumul<i,1>
		ENR_TEMPO<W_IndTempo,i+1,3> = W_Cumul<i,2>
		ENR_TEMPO<W_IndTempo,i+1,4> = W_Cumul<i,3>
		ENR_TEMPO<W_IndTempo,i+1,5> = W_Cumul<i,4>
		* Restriction MOD : on a cumul la MOI, MOD = Nb hres totales - MOI...
		ENR_TEMPO<W_IndTempo,i+1,6> = W_Cumul<i,1> - W_Cumul<i,6>
		ENR_TEMPO<W_IndTempo,i+1,7> = W_Cumul<i,2> - W_Cumul<i,7>
		ENR_TEMPO<W_IndTempo,i+1,8> = W_Cumul<i,3> - W_Cumul<i,8>
		ENR_TEMPO<W_IndTempo,i+1,9> = W_Cumul<i,4> - W_Cumul<i,9>
	NEXT i
END


CONVERT CHAR(208) TO "" IN ENR_TEMPO
*WRITE ENR_TEMPO ON F.TEMPO, "EDITPLANNING":User
W_Sortie = ENR_TEMPO

IF TraitementRempl = "1" THEN
	GOSUB 2200
END

IF W_NomReqIntervArch # "" THEN
	EXECUTE 'LISTE ':W_NomReqIntervArch RETURNING MSGCODE
	IF MSGCODE<1> # "209" THEN
		SELECT F.TPSDETAILSINTERVARCH TO W_ReqTemp
		W_Fin = "F"
		LOOP
			READNEXT W_CleTemp FROM W_ReqTemp ELSE W_Fin = "V"
		WHILE W_Fin = "F"
			
				DELETE F.TPSDETAILSINTERV, W_CleTemp
			
		REPEAT
	END
	
	EXECUTE 'LISTE ':W_NomReqExceptArch RETURNING MSGCODE
	IF MSGCODE<1> # "209" THEN
		SELECT F.TPSEXCEPTIONSARCH TO W_ReqTemp
		W_Fin = "F"
		LOOP
			READNEXT W_CleTemp FROM W_ReqTemp ELSE W_Fin = "V"
		WHILE W_Fin = "F"
		
				DELETE F.TPSEXCEPTIONS, W_CleTemp
		
		REPEAT
	END

END

ENR_RAPPORT<-1> = INT(((TIME() - DepartTraitement)/60)/60):" heure ":MOD((TIME() - DepartTraitement)/60,60):" minutes"
*WRITE ENR_RAPPORT ON F.TEMPO, "Rapport"
WRITE W_Sortie ON F.TPSTEMPO, "AFFICHEPLANNING":User
*WRITE W_Sortie ON F.TPSTEMPO,"DEBUG"

STOP


10 ****************************************************************************************
*    					Gestion d'un DETAILINTERV						*
*******************************************************************************************
W_Freq = ENR_TPSDETAILSINTERV<3>
W_DateDebInterv = W_CleTrt[11,5]
W_CodeAide = W_CleTrt[6,5]
W_HreDebInterv = W_CleTrt[23,4]
W_HreFinInterv = ENR_TPSDETAILSINTERV<2>
W_ValeurInterv = ENR_TPSDETAILSINTERV<5>"R%4"
W_DateFinInterv = INT(ENR_TPSDETAILSINTERV<1>)
IF W_DateFinInterv = 0 THEN
	W_DateFinInterv = 99999
END
IF Affichage = "A" THEN
   IF ParAide = "" THEN
	* Va mettre nom prenom aid dans W_CleTrt
	GOSUB 600
   END ELSE
	* Va mettre nom prenom aidant dans W_CleTrt
	GOSUB 610
   END
END ELSE
	IF Affichage = "E" THEN
		IF ENR_TPSDETAILSINTERV<6># "" THEN
			W_CleTrt = W_CleTrt:"|" 
		END
	END
END

W_ActiviteInterv = W_CleTrt[16,6]
W_RubSaiInterv = ENR_TPSDETAILSINTERV<4>
IF W_RubSaiInterv = "" THEN
W_RubSaiInterv = CHAR(208)
END

* 1 On dtermine le lundi de la semaine dans laquelle est situe la date de dbut d'intervention :
IF MOD(W_DateDebInterv,7)=0 THEN
	* Date de dbut = dimanche 
	W_LundiDeb = W_DateDebInterv - 6
END ELSE
	W_LundiDeb = W_DateDebInterv - MOD(W_DateDebInterv,7) + 1
END

* 2 On dtermine une date de rfrence correspondant au 1 jour o il y a eu intervention effective...
W_JourInterv = W_CleTrt[22,1]
W_DateIntervRef = W_LundiDeb + W_JourInterv
IF INT(W_DateIntervRef) < INT(W_DateDebInterv) THEN
	W_DateIntervRef = W_DateIntervRef + W_Freq*7
END

* 3 On a la date de la premiere intervention (effective)
* => pour dterminer si il y a intervention a une date D, on doit avoir 
* D - [DatePremiereIntervention] = [(W_Freq) * 7 = intervalle en jours entre 2 interventions(7,14 ,21 ou 28)] * nbre entier = nbre d'interventions effectues

W_Step = 1
FOR i = 1 TO NbJours STEP W_Step

	W_JourEnCours = DateDeb + i - 1
	IF W_JourEnCours >= W_DateIntervRef THEN
	
	   IF MOD(W_JourEnCours-W_DateIntervRef, W_Freq*7) = 0 THEN
		W_Step = 7
		IF W_JourEnCours <= W_DateFinInterv THEN		
		
		*************************************************************
		*  			Grer ici les exceptions !!!			*
		* On change le libelle si il y a exception			*
		* W_LibInterv = "EXCEPT"						*
		*************************************************************
		  W_CleExcept = W_CleTrt[1,10]:W_JourEnCours:W_CleTrt[16,11]
		  READ ENR_EXCEPTION FROM F.TPSEXCEPTIONS, W_CleExcept THEN
			IF ENR_EXCEPTION<1> = W_CleTrt[1,26] THEN
				W_LibInterv = "EXCEPTInterv":W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]>
			END ELSE
				* cas prvu : interv. hebdo de 16  20h, on la "rduit" de 16 a 18 en mettant une exception sur l'hebdo,
				* et en crant une interv. de 16 a 18 : la cl d'exception calcule est la mme pour les 2 interventions => se mfier !
			  	W_LibInterv = "Interv":W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]>
			END
		  END ELSE
		  	W_LibInterv = "Interv":W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]>
		  END
		  
		  W_HreDebInterv = W_CleTrt[23,4]
		  W_HreFinInterv = ENR_TPSDETAILSINTERV<2>
		  W_ValeurInterv = ENR_TPSDETAILSINTERV<5>"R%4"

		  W_DescripAbs = ""

		  IF ParAide = "" THEN
		    READ ENR_ABSENCESAIDE FROM F.ABSENCESAIDE, W_CodeAide THEN
			W_NbAbsAide = DCOUNT(ENR_ABSENCESAIDE<1>, CHAR(253))
			FOR k = 1 TO W_NbAbsAide
			IF ENR_ABSENCESAIDE<1,k> <= W_JourEnCours AND ENR_ABSENCESAIDE<2,k> >= W_JourEnCours THEN
			   * Attention : on concatene car si exception, il faut l'indiquer en affichage en plus de l'absence aid...
			   * Sauf si spcifique Caen : on intgre mme les hres effectues pdt une abs aid...
			   * DIDIER le 04/02/2008 --> remplacer test code postal association sur 14017 par 140 (suite pb cedex en dads)
			   IF NOT (TraitementPaie = "1" AND ENR_ASSOCIATION<8>[1,3] = "140" AND W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]> = "M") THEN
				
				   IF ENR_ABSENCESAIDE<4,k> # "" THEN
					W_iDescrAbs = 0
					LOOP
						W_iDescrAbs = W_iDescrAbs + 1
					WHILE ENR_ABSENCESAIDE<4,k> # ENR_TABLESMOTIFSORTIE<2,W_iDescrAbs> AND ENR_TABLESMOTIFSORTIE<2,W_iDescrAbs> # ""
					REPEAT
					IF ENR_TABLESMOTIFSORTIE<2,W_iDescrAbs> # "" THEN
						W_DescripAbs = "Absence aid - ":ENR_TABLESMOTIFSORTIE<3,W_iDescrAbs>
					END
				   END
				   IF W_DescripAbs = "" THEN
					W_DescripAbs = "Absence aid - ":ENR_ABSENCESAIDE<3,k>
				   END
				   W_DescripAbs = W_DescripAbs:" du ":OCONV(ENR_ABSENCESAIDE<1,k>,"D4/"):" au ":OCONV(ENR_ABSENCESAIDE<2,k>,"D4/")	

			   	   W_LibInterv = W_LibInterv:"AbsAide"
			   END
			END
			NEXT k
		    END
		  END ELSE
			* Trt Absences aidant
			W_SauveLibInterv = W_LibInterv
			GOSUB 1700
			IF W_SauveLibInterv = W_LibInterv THEN
				W_DescripAbs = ""
			END
			* Trt MOI !!! En effet, en affichage par aid, la MOI a le mme effet que les absences aidant :
			* elle annule ou rduit l'intervention...
			GOSUB 2100
		  END
		  
		  IF (Affichage = "A" ) OR LEN(W_LibInterv) = 7 THEN
			
		*************************************************************
		* Nb : On est certain ici qu'a part absence de l'aidant, 	*
		* l'intervention doit avoir lieu.					*
		* On notifie donc l'aid sur l'dition, et c'est l 		*
		* qu'il faudra "construire" le DETAILPREST (DETAILMANDAT...)*
		* en cas d'intgration des paies...					*
		* Attention : si l'on ajoute des SV 5 => 7, 			*
		* il faudra penser a les mettre a vide en remplissant les	*
		* autres plages en procdures 200,300,...				*
		*************************************************************
				IF W_DescripAbs # "" AND Affichage = "A" THEN
					W_SauveCleTrt = W_CleTrt
					W_CleTrt = W_CleTrt:"^":W_DescripAbs
				END
				GOSUB 1300
				IF W_DescripAbs # "" AND Affichage = "A" THEN
					W_CleTrt = W_SauveCleTrt
				END
		  * ci dessous : fin du "si affichage, ou si intervention active" ...
		  END


		END
	   END 
	END
NEXT i
RETURN

100 ***************************************************************************************
*		W_TabInterv contient toutes les interventions a notifier				*
*******************************************************************************************

	*************************************************************************
	*   Nb : si l'on veut restreindre l'EDITION aux aidants ayant au moins	*
	* une intervention (MOI ?), faire ici un test sur W_TabInterv		*
	*************************************************************************
	

	IF ParAide = "" THEN
		* 1 => W_TabInterv contient les interventions + les exceptions + les absencesaids/aidant
		* intgration de la MOI
		GOSUB 200
	END
	

	* 2 W_TabInterv contient les interventions + la MOI 
	* Intgration des indisponibilits de l'aidant/aide...
	GOSUB 300
	

	IF ParAide = "" THEN
		* 3 W_TabInterv contient les interventions avec ousans anomalies, plus les indisponibilits 
		* de l'aidant. Croiser ce tableau avec les absences de l'aidant...
		GOSUB 400
	END ELSE
		* 3 W_TabInterv contient les interventions avec ousans anomalies, plus les indisponibilits 
		* de l'aidant. Croiser ce tableau avec les absences de l'aide...
		GOSUB 1800
	END
	



* 4  On a bascul dans W_TabAidant les jours pour lesquels il y a eu absence de l'aidant, reste les jours complets...

IF Affichage = "E" OR Affichage = "ES" OR (Affichage = "A" AND TraitementExtract = "1") THEN
	W_IndTempo = W_IndTempo + 1
	
	IF ParAide = "" THEN
	   ENR_TEMPO<W_IndTempo> = "#":"Interv":W_TamponAidant
	   IF Tri = "S" THEN
		READ ENR_CIVILAIDANT FROM F.CIVILAIDANT, W_TamponAidant THEN
		   READ ENR_SECTEUR FROM F.SECTEUR, ENR_CIVILAIDANT<31> THEN
			ENR_TEMPO<W_IndTempo> = ENR_TEMPO<W_IndTempo>:ENR_SECTEUR<1>
		   END
		END
	   END
	END ELSE
	   ENR_TEMPO<W_IndTempo> = "#":"Interv":W_TamponAide
	END
END
W_Cumul = ""
W_NbMois = 0
W_TamponMois = ""
W_ListeAidesAidants = ""

IF ParAide # "" THEN
	* Traitement par l'aid : initialisation d'ENR_BESOINSAIDE
	READ ENR_BESOINSAIDE FROM F.BESOINSAIDE, W_TamponAide THEN
		IF ENR_BESOINSAIDE<7> = "" THEN
			ENR_BESOINSAIDE<7> = "N"
		END
	END ELSE
		ENR_BESOINSAIDE = ""
		ENR_BESOINSAIDE<7> = "N"
	END
END
FOR i = 1 TO NbJours
	IF W_TabInterv<i> # "" THEN
		W_TabAidant<i> = W_TabInterv<i>
		W_TabInterv<i> = ""
	END
	ENR_RAPPORT<-1> = W_TabAidant<i>

	W_NbMv = DCOUNT(W_TabAidant<i,1>,CHAR(252))
	W_PasseCumul="FAUX"
	
	* Attention : le code ci dessous a t plac ici car il faut que le mois soit valoris mme 
	* s'il n'y a aucune plage (ni abs, ni interv,...) sur le mois (ie W_NbMv = 0, ne rentre pas dans la boucle FOR k= !)...
	IF TraitementRecapMens # "1" THEN
	* en Edition, on ne valorise pas le nb heure. -  Le 21/12/04 : Si, maintenant on le fait !
	   IF Affichage # "A" AND NbJours > 8 THEN
		* Intgration des paies, suivi de contrat de prospective : on peut avoir plusieurs mois dans la priode...
		IF W_TamponMois # OCONV(DateDeb +i-1,"D4/")[3,8] THEN
			W_NbMois = W_NbMois + 1
			W_TamponMois = OCONV(DateDeb +i-1,"D4/")[3,8]
			W_Cumul<W_NbMois,5> = OCONV(DateDeb +i-1,"D4/")[7,4]:OCONV(DateDeb +i-1,"D4/")[4,2]
		END
	   END ELSE
		* Affichage : on a maximum un mois
		W_NbMois = 1
	   END 
	END


	* Explication : selon que l'on soit sur une entit ou une autre, le jour de solidarit n'est pas forcment le mme...
	* Donc ci dessous : on examine la possibilit que l'on soit un jour fri, et si oui (W_jourferieprosglobal # "F")
	* on retestera pour CHAQUE INTERVENTION (seul moyen d'tre sur de l'asso) si l'on est bien sur un jour fri !
	W_JourFerieProsp = DateDeb + i - 1
	*W_Assoc2000 = W_AssocParDefaut2000
	GOSUB 2001
	W_JourFerieProspGlobal = W_JourFerieProsp
	W_Trier = "F"
	FOR k = 1 TO W_NbMv
		W_ExcluGestionDimJf = "F"

		IF Affichage = "E" THEN
		  * Jours fris : On SUPPRIME les interventions d'un bnficiaire chez qui l'on n'intervient pas...

		  IF INDEX(W_TabAidant<i,1,k>,"Interv",1) # 0 THEN
			
			IF W_JourFerieProspGlobal # "F" THEN
			  IF ParAide = "" THEN
		  	   READ ENR_BESOINSAIDE FROM F.BESOINSAIDE, W_TabAidant<i,4,k>[6,5] THEN
				IF ENR_BESOINSAIDE<7> # "O" THEN
				   W_JourFerieProsp = DateDeb + i - 1
				   W_Assoc2000 = W_TabAidant<i,4,k>[16,3]
				   GOSUB 2000
				   IF W_JourFerieProsp # "F" THEN
					W_ExcluGestionDimJf = "V"
					DEL W_TabAidant<i,1,k>
					DEL W_TabAidant<i,2,k>
					DEL W_TabAidant<i,3,k>
					DEL W_TabAidant<i,4,k>
					IF TraitementRecapMens = "" THEN
						DEL W_TabAidant<i,5,k>
						DEL W_TabAidant<i,6,k>
						DEL W_TabAidant<i,7,k>
						DEL W_TabAidant<i,8,k>
					END
					k = k - 1
					W_NbMv = W_NbMv - 1
				   END
				   
				END
			   END ELSE
				W_JourFerieProsp = DateDeb + i - 1
				W_Assoc2000 = W_TabAidant<i,4,k>[16,3]
				GOSUB 2000
				IF W_JourFerieProsp # "F" THEN

				   W_ExcluGestionDimJf = "V"
				   DEL W_TabAidant<i,1,k>
				   DEL W_TabAidant<i,2,k>
				   DEL W_TabAidant<i,3,k>
				   DEL W_TabAidant<i,4,k>
				   IF TraitementRecapMens = "" THEN
					DEL W_TabAidant<i,5,k>
					DEL W_TabAidant<i,6,k>
					DEL W_TabAidant<i,7,k>
					DEL W_TabAidant<i,8,k>
				   END
				   k = k - 1
				   W_NbMv = W_NbMv - 1
				END

			   END		
			  END ELSE
			   
			   IF ENR_BESOINSAIDE<7> # "O" THEN
				W_JourFerieProsp = DateDeb + i - 1
				W_Assoc2000 = W_TabAidant<i,4,k>[16,3]
				GOSUB 2000
				IF W_JourFerieProsp # "F" THEN

					W_ExcluGestionDimJf = "V"
					* On n'affiche pas l'aidant qui n'a d'intervention QUE le jour fri (sera annule plus bas...)
				END
			   END
			  END
			END
		  END
		  IF W_ExcluGestionDimJf = "F" THEN
		  	* On tablit d'une part la liste des aids chez qui il y a intervention, 
			* d'autre part la liste des absences incluant le libelle rubrique de la MOI...
			
			IF LEN(W_TabAidant<i,1,k>) = 7 AND INDEX(W_TabAidant<i,1,k>,"Interv",1) # 0 THEN
				IF ParAide = "" THEN
				   IF INDEX(W_ListeAidesAidants,W_TabAidant<i,4,k>[6,5]:"|",1) = 0 THEN
					W_ListeAidesAidants = W_ListeAidesAidants:W_TabAidant<i,4,k>[6,5]:"|"
				   END
				END ELSE
				   IF INDEX(W_ListeAidesAidants,W_TabAidant<i,4,k>[1,5]:"|",1) = 0 THEN
					W_ListeAidesAidants = W_ListeAidesAidants:W_TabAidant<i,4,k>[1,5]:"|"
				   END
				END
			END
			IF W_TabAidant<i,1,k> = "MOI" THEN

				IF LEN(W_ListeAbsences<W_IndListeAbsences>) > 35 + LongueurLibAbsence THEN
					W_IndListeAbsences = W_IndListeAbsences + 1
				END

				W_DateMoi = DateDeb + i - 1
				W_DateMoi = OCONV(W_DateMoi,"D4/")
				W_HreDebMoi = W_TabAidant<i,2,k>[3,2]
				W_HreDebMoi = INT(W_HreDebMoi/100 * 60 +1/2)
				W_HreDebMoi = W_HreDebMoi"R%2"
				W_HreDebMoi = W_TabAidant<i,2,k>[1,2]:"h":W_HreDebMoi

				W_HreFinMoi = W_TabAidant<i,3,k>[3,2]
				W_HreFinMoi = INT(W_HreFinMoi/100 * 60 +1/2)
				W_HreFinMoi = W_HreFinMoi"R%2"
				W_HreFinMoi = W_TabAidant<i,3,k>[1,2]:"h":W_HreFinMoi
				W_LibMoi = W_TabAidant<i,4,k>[16,LongueurLibAbsence]:SPACE(1)
*				W_LibMoi = W_LibMoi:SPACE(LongueurLibAbsence+1 - LEN(W_LibMoi[1,LongueurLibAbsence]) )
				W_ListeAbsences<W_IndListeAbsences> = W_ListeAbsences<W_IndListeAbsences>:W_LibMoi:W_DateMoi:" ":W_HreDebMoi:" ":W_DateMoi:" ":W_HreFinMoi:" "
				
			END
		    END
		* 21/12/04 :
		END ELSE
		   * Malheureusement, ici on teste TOUTES les interventions
			W_JourFerieProsp = DateDeb + i - 1
			W_Assoc2000 = W_TabAidant<i,4,k>[16,3]
			GOSUB 2000	
		END	
		*21/12/04 END ELSE


********************************
* MODIF VANES 15/12/08
	IF Affichage = "A" AND ParAide = "1" AND W_TabAidant<i,1,1>= "AbsAide" THEN
		* si affichage par aid et abs de l'aid : ne pas cumuler les interventions dans les compteurs
	END ELSE
***********	
		IF W_ExcluGestionDimJf = "F" THEN
		   IF i # NbJours OR (i = NbJours AND Affichage = "E" AND TraitementRecapMens # "1") THEN
			* Cumul des valeurs en Att. 5 par type activit...
			IF W_TabAidant<i,1,k>="MOI" OR (INDEX(W_TabAidant<i,1,k>,"Interv",1) # 0 AND LEN(W_TabAidant<i,1,k>)=7) THEN
				* MOI ou intervention 
				W_Exclu2300 = "F"
				IF W_TabAidant<i,5,k> # CHAR(208) AND (W_JourFerieProsp = "F" OR ParAide = "" OR ENR_BESOINSAIDE<7> = "O") THEN
					* Nb : par aid, on ne comptabilise pas les hres sur jour fri, alors que par aidant, si !
					IF W_TabAidant<i,1,k>="MOI" THEN
						W_TypeActEnCours= W_TabAidant<i,4,k>[15,1]
					END ELSE
						IF W_TabAidant<i,1,k>[1,6]="Interv" THEN
							W_TypeActEnCours= W_TabAidant<i,1,k>[7,1]
						END ELSE
							* libelle "EXCEPTInterv"+type act
							W_TypeActEnCours= W_TabAidant<i,1,k>[13,1]
						END
					END
					IF W_TabAidant<i,1,k> # "MOI" AND W_JourFerieProsp # "F" THEN
						READ ENR_BESOINSAIDE FROM F.BESOINSAIDE, W_TabAidant<i,4,k>[6,5] THEN
						END ELSE
							ENR_BESOINSAIDE = ""
							ENR_BESOINSAIDE<7> = "N"
						END
						*******************************************************************
*						IMPORTANT : pour que le fait que le salari de - de 3 mois d'anciennet
*						ne soit pas indemnis les jrs fris
*						soit pris en comtpe dans les compteurs d'heures, 
*						effectuer ici le GOSUB 2300
						*******************************************************************
					END
					IF W_TabAidant<i,1,k> = "MOI" OR (W_JourFerieProsp # "F" AND ENR_BESOINSAIDE<7> # "O")  THEN
						* Soit il s'agit d'une MOI, soit d'une intervention JF a valoriser en tant que MOI...
						BEGIN CASE
							CASE W_TypeActEnCours = "P"
								W_Cumul<W_NbMois,6> = W_Cumul<W_NbMois,6> + W_TabAidant<i,5,k>
							CASE W_TypeActEnCours = "M"
								W_Cumul<W_NbMois,7> = W_Cumul<W_NbMois,7> + W_TabAidant<i,5,k>
							CASE W_TypeActEnCours = "I"
								W_Cumul<W_NbMois,8> = W_Cumul<W_NbMois,8> + W_TabAidant<i,5,k>
							CASE W_TypeActEnCours = "S"
								W_Cumul<W_NbMois,9> = W_Cumul<W_NbMois,9> + W_TabAidant<i,5,k>
						END CASE

						IF TraitementPaie # "" AND W_TabAidant<i,1,k> # "MOI" THEN
							* On transforme l'intervention en MOI...
						   GOSUB 2300
						   IF W_Exclu2300 = "F" THEN
							W_TabAidant<i,1,k> = "MOI"
							W_TabAidant<i,4,k> = W_TabAidant<i,4,k>[1,5]:W_TabAidant<i,4,k>[11,5]:W_TabAidant<i,4,k>[23,4]:W_TypeActEnCours:W_TabAidant<i,4,k>[6,5]
							* Nb : on mets en fin de l'att. 4 le code aid, au lieu du code contrat (que l'on ne connat pas !)
							* => devra tre gr par le basculement en paie...
							
							BEGIN CASE
							   CASE W_TypeActEnCours = "P"
								IF W_TabAidant<i,6,k> = CHAR(208) OR W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<10,1> THEN
									W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<9,W_Ind1TPSPARAMBASCUL>
								END ELSE
									W_Ind2400 = 1
									GOSUB 2400
									W_TabAidant<i,6,k> = W_Rub2400
								END
							   CASE W_TypeActEnCours = "M"
								IF W_TabAidant<i,6,k> = CHAR(208) OR W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<10,2> THEN
									W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<9,W_Ind2TPSPARAMBASCUL>
								END ELSE
									W_Ind2400 = 2
									GOSUB 2400
									W_TabAidant<i,6,k> = W_Rub2400
								END
							   CASE W_TypeActEnCours = "I"
								IF W_TabAidant<i,6,k> = CHAR(208) OR W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<10,3> THEN
									W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<9,W_Ind3TPSPARAMBASCUL>
								END ELSE
									W_Ind2400 = 3
									GOSUB 2400
									W_TabAidant<i,6,k> = W_Rub2400
								END
							   CASE W_TypeActEnCours = "S"
								IF W_TabAidant<i,6,k> = CHAR(208) OR W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<10,4> THEN
									W_TabAidant<i,6,k> = ENR_TPSPARAMBASCUL<9,W_Ind4TPSPARAMBASCUL>
								END ELSE
									W_Ind2400 = 4
									GOSUB 2400
									W_TabAidant<i,6,k> = W_Rub2400
								END
							END CASE
						   END ELSE
							* On va faie en sorte que l'intervention n'aie aucune incidence sur la paie...
							* Plutot que de l'effacer, prfre mettre zro en valeur...
							* Sera fait plus bas pour ne par modifier les cumuls d'heure :
						      * W_TabAidant<i,5,k> = 0
						   END
						END
					END ELSE
					
					END
					
					IF W_SauveTabAidant2<i># "" AND W_SauveTabAidant2<i># "0" THEN
						IF W_PasseCumul="FAUX" THEN
							W_MvTemp = DCOUNT(W_SauveTabAidant2<i,1>,CHAR(252))
							FOR iTemp=1 TO W_MvTemp
								BEGIN CASE
									CASE W_TypeActEnCours = "P"
										W_Cumul<W_NbMois,1> = W_Cumul<W_NbMois,1> + W_SauveTabAidant2<i,5,iTemp>
									CASE W_TypeActEnCours = "M"
										W_Cumul<W_NbMois,2> = W_Cumul<W_NbMois,2> + W_SauveTabAidant2<i,5,iTemp>
									CASE W_TypeActEnCours = "I"
										W_Cumul<W_NbMois,3> = W_Cumul<W_NbMois,3> + W_SauveTabAidant2<i,5,iTemp>
									CASE W_TypeActEnCours = "S"
										W_Cumul<W_NbMois,4> = W_Cumul<W_NbMois,4> + W_SauveTabAidant2<i,5,iTemp>
								END CASE
								W_PasseCumul="VRAI"
							NEXT iTemp
						END
					END ELSE

					
						BEGIN CASE
							CASE W_TypeActEnCours = "P"
								W_Cumul<W_NbMois,1> = W_Cumul<W_NbMois,1> + W_TabAidant<i,5,k>
								ENR_RAPPORT<-1> = "Ajoute ":W_TabAidant<i,5,k>:" pour ":i:" - ":k:" - ":W_TabAidant<i,4,k>
							CASE W_TypeActEnCours = "M"
								W_Cumul<W_NbMois,2> = W_Cumul<W_NbMois,2> + W_TabAidant<i,5,k>
							CASE W_TypeActEnCours = "I"
								W_Cumul<W_NbMois,3> = W_Cumul<W_NbMois,3> + W_TabAidant<i,5,k>
							CASE W_TypeActEnCours = "S"
								W_Cumul<W_NbMois,4> = W_Cumul<W_NbMois,4> + W_TabAidant<i,5,k>
						END CASE					
					END

					IF W_Exclu2300 = "V" THEN
						W_TabAidant<i,5,k> = 0
					END

				END
			END
		   END
		   * ci dessus : fin du IF i # NbJours...
		   IF INDEX(W_TabAidant<i,1,k>,"Interv",1) # 0 AND ParAide = "" THEN
			IF W_JourFerieProsp # "F" THEN
		  	   READ ENR_BESOINSAIDE FROM F.BESOINSAIDE, W_TabAidant<i,4,k>[6,5] THEN
				IF ENR_BESOINSAIDE<7> # "O" THEN
				   IF INDEX(W_TabAidant<i,1,k>,"AbsAide",1) = 0 THEN
					W_TabAidant<i,1,k> = W_TabAidant<i,1,k>:"AbsAide"
					W_TabAidant<i,4,k> = W_TabAidant<i,4,k>:"^Absence aid - Jour fri non travaill"
					W_Trier = "V"
				   END
				END
			   END ELSE
				IF INDEX(W_TabAidant<i,1,k>,"AbsAide",1) = 0 THEN
					W_TabAidant<i,1,k> = W_TabAidant<i,1,k>:"AbsAide"
					W_TabAidant<i,4,k> = W_TabAidant<i,4,k>:"^Absence aid - Jour fri non travaill"
					W_Trier = "V"
			      END
			   END		
			END
		   END
		END
		* 21/12/04 END
	*******	
	* MODIF VANES 15/12/08
	END
	*******
	NEXT k
	
	IF ParAide # "" THEN
	
		IF W_JourFerieProsp # "F" THEN
	
		   IF ENR_BESOINSAIDE<7> = "N" THEN
	
			   IF Affichage = "A" THEN
	
				W_TabAidant = INSERT(W_TabAidant,i,1,1;"AbsAide")
				W_TabAidant = INSERT(W_TabAidant,i,2,1;"0000")
				W_TabAidant = INSERT(W_TabAidant,i,3,1;"2400")
				W_TabAidant = INSERT(W_TabAidant,i,4,1;"XXXXX":W_TamponAide:"Absence aid - Jour fri non travaill")
				W_TabAidant = INSERT(W_TabAidant,i,5,1;CHAR(208))
				W_TabAidant = INSERT(W_TabAidant,i,6,1;CHAR(208))
				W_TabAidant = INSERT(W_TabAidant,i,7,1;CHAR(208))
	
			   END ELSE
				W_TabAidant<i> = ""
				W_TabAidant<i,1,1>="AbsAide"
				W_TabAidant<i,2,1>="0000"
				W_TabAidant<i,3,1>="2400"
				W_TabAidant<i,4,1>="XXXXX":W_TamponAide
				IF TraitementRecapMens # "1" THEN
					W_TabAidant<i,5,1>=CHAR(208)
					W_TabAidant<i,6,1>=CHAR(208)
					W_TabAidant<i,7,1>=CHAR(208)
				END
			   END
		   END
		END
	END ELSE
		* Maj 31/10/2005 : trier pour que les absences aid cres pour JF non travaill s'affichent SOUS les interventions effectives :
		IF W_Trier = "V" AND Affichage = "A" THEN
			W_IndInsert = 0
			FOR k = 1 TO W_NbMv
				IF W_TabAidant<i,1,k> = "INDISPO" THEN
					W_IndInsert = k
				END
			NEXT k
			IF W_IndInsert = 0 THEN
			  FOR k = 1 TO W_NbMv
				IF INDEX(W_TabAidant<i,1,k>,"AbsAide",1) # 0 THEN
					W_TabAidant<i,1,-1> = W_TabAidant<i,1,k>
					W_TabAidant<i,2,-1> = W_TabAidant<i,2,k>
					W_TabAidant<i,3,-1> = W_TabAidant<i,3,k>
					W_TabAidant<i,4,-1> = W_TabAidant<i,4,k>
					W_TabAidant<i,5,-1> = W_TabAidant<i,5,k>
					W_TabAidant<i,6,-1> = W_TabAidant<i,6,k>
					W_TabAidant<i,7,-1> = W_TabAidant<i,7,k>
					DEL W_TabAidant<i,1,k>
					DEL W_TabAidant<i,2,k>
					DEL W_TabAidant<i,3,k>
					DEL W_TabAidant<i,4,k>
					DEL W_TabAidant<i,5,k>
					DEL W_TabAidant<i,6,k>
					DEL W_TabAidant<i,7,k>
					k = k - 1
					W_NbMv = W_NbMv - 1
				END
			  NEXT k
			END ELSE
			  FOR k = 1 TO W_IndInsert
				IF INDEX(W_TabAidant<i,1,k>,"AbsAide",1) # 0 THEN
					W_TabAidant = INSERT(W_TabAidant,i,1,W_IndInsert;W_TabAidant<i,1,k>)
					W_TabAidant = INSERT(W_TabAidant,i,2,W_IndInsert;W_TabAidant<i,2,k>)
					W_TabAidant = INSERT(W_TabAidant,i,3,W_IndInsert;W_TabAidant<i,3,k>)
					W_TabAidant = INSERT(W_TabAidant,i,4,W_IndInsert;W_TabAidant<i,4,k>)
					W_TabAidant = INSERT(W_TabAidant,i,5,W_IndInsert;W_TabAidant<i,5,k>)
					W_TabAidant = INSERT(W_TabAidant,i,6,W_IndInsert;W_TabAidant<i,6,k>)
					W_TabAidant = INSERT(W_TabAidant,i,7,W_IndInsert;W_TabAidant<i,7,k>)
					DEL W_TabAidant<i,1,k>
					DEL W_TabAidant<i,2,k>
					DEL W_TabAidant<i,3,k>
					DEL W_TabAidant<i,4,k>
					DEL W_TabAidant<i,5,k>
					DEL W_TabAidant<i,6,k>
					DEL W_TabAidant<i,7,k>
					k = k - 1
					W_IndInsert = W_IndInsert - 1
				END
			  NEXT k
	
			END
		END
	END

	* IF Traitement recap' mens / feuille pres = false ...
	IF TraitementRecapMens # "1" THEN
		W_IndTempo = W_IndTempo + 1
		ENR_TEMPO<W_IndTempo> = W_TabAidant<i>
	END
	* Fin IF traitement recap' mens

	W_TabAidant<i> = ""

NEXT i

ENR_RAPPORT<-1> = "*-*"
ENR_RAPPORT<-1> = W_Cumul
ENR_RAPPORT<-1> = "*-*"

IF Affichage = "E" AND TraitementRecapMens # "1" THEN
	W_IndTempo = W_IndTempo + 1
	i = 1
	ENR_TEMPO<W_IndTempo,1> = "#Heures":W_TamponAidant
	ENR_TEMPO<W_IndTempo,i+1,1> = W_Cumul<i,5>
	ENR_TEMPO<W_IndTempo,i+1,2> = W_Cumul<i,1>
	ENR_TEMPO<W_IndTempo,i+1,3> = W_Cumul<i,2>
	ENR_TEMPO<W_IndTempo,i+1,4> = W_Cumul<i,3>
	ENR_TEMPO<W_IndTempo,i+1,5> = W_Cumul<i,4>
	* Restriction MOD : on a cumul la MOI, MOD = Nb hres totales - MOI...
	ENR_TEMPO<W_IndTempo,i+1,6> = W_Cumul<i,1> - W_Cumul<i,6>
	ENR_TEMPO<W_IndTempo,i+1,7> = W_Cumul<i,2> - W_Cumul<i,7>
	ENR_TEMPO<W_IndTempo,i+1,8> = W_Cumul<i,3> - W_Cumul<i,8>
	ENR_TEMPO<W_IndTempo,i+1,9> = W_Cumul<i,4> - W_Cumul<i,9>
END

* Nb : ajouter ici gestion Feuilles Presence, recap' mens : il va falloir indiquer la liste des couples... 
IF Affichage = "E" AND TraitementPaie = "" THEN

* Ecriture dans TEMPO des listes d'aids/aidants et d'absences...
	GOSUB 500
END


RETURN

200 ***************************************************************************************
*                       		Gestion de la MOI							*
*******************************************************************************************
* Maj 22/09 : on gre maintenant chevauchements entre MOI et interventions dans le cas d'interventions 
* non valides (= exceptions, absences aid). En cas de tel chevauchement, faire en sorte que la plage = MOI 
* soit affiche par VB AVANT toute intervention non valide, de manire  ce que la plage valide soit visible pour l'utilisateur...
* 01/10/03 : On gre mlaintenant chevauchement MOI avec TOUTES les interventions, en affichage + en dition...
IF Asso = "" THEN
	W_Temp = 'SELECT TPSMOI AVEC CodeAidantMoi = "':W_TamponAidant:'" AND AVEC DateMoi <= "':DateFin:'" AND AVEC DateMoi >= "':DateDeb:'"'
END ELSE
	W_Temp = 'SELECT TPSMOI AVEC CodeAidantMoi = "':W_TamponAidant:'" AND AVEC DateMoi <= "':DateFin:'" AND AVEC DateMoi >= "':DateDeb:'" AND AVEC AssoMOI = "':Asso:'"'
END

IF LEN(TypesAct) # 4 THEN
	* On n'a pas demand tous les types d'activit => restreindre !
	W_Temp = W_Temp:' AND AVEC TypeActMOI = "':TypesAct[1,1]:'"'
	IF LEN(TypesAct)>= 2 THEN
		W_Temp = W_Temp:' OR = "':TypesAct[2,1]:'"'
		IF LEN(TypesAct) = 3 THEN
			W_Temp = W_Temp:' OR = "':TypesAct[3,1]:'"'
		END
	END 
END
EXECUTE W_Temp
W_NomReqMOITps="ReqMOITps":User:Affichage:TIME()
EXECUTE 'SAUVE-LISTE ':W_NomReqMOITps
EXECUTE 'LISTE ':W_NomReqMOITps RETURNING MSGCODE

IF MSGCODE<1> # 209 THEN
  SELECT F.TPSMOI TO W_ReqMOITps
  W_FinMOI = "F"
  LOOP
	READNEXT W_CleMOI FROM W_ReqMOITps ELSE W_FinMOI = "V"

  WHILE W_FinMOI = "F"
	READ ENR_TPSMOI FROM F.TPSMOI, W_CleMOI THEN
		W_HreDeb = W_CleMOI[11,4]
		W_HreFin = ENR_TPSMOI<1>
		W_DateMOI = W_CleMOI[6,5]
		W_ValeurMoi = ENR_TPSMOI<2>"R%4"
		W_RubSaiMOI = ENR_TPSMOI<3>
		i = W_DateMOI - DateDeb + 1
		
		W_LibMoi = ""
		* on mets le type d'activit dans la MOI...
		GOSUB 1400
		IF W_LibMoi # "" THEN
		  IF TraitementPaie # "" THEN
			* Spcif trt paie : on mets el code contrat a partir du caractre 16 de la Mv 4
			W_LibMoi = W_LibMoi:ENR_TPSMOI<4>
		  END ELSE
		    IF INDEX(W_TabLibRub<1>,ENR_TPSMOI<3>,1) # 0 THEN
			
			W_LibMoi = W_LibMoi:W_TabLibRub<2,(INDEX(W_TabLibRub<1>,ENR_TPSMOI<3>,1))/4 +1>[1,LongueurLibAbsence]:SPACE(LongueurLibAbsence+1-LEN(W_TabLibRub<2,(INDEX(W_TabLibRub<1>,ENR_TPSMOI<3>,1))/4 +1>[1,LongueurLibAbsence]))
			W_Hre2500 = W_HreDeb
			GOSUB 2500
			W_LibMoi = W_LibMoi :" - ":W_Texte2500:"  "
			W_Hre2500 = W_HreFin
			GOSUB 2500
			W_LibMoi = W_LibMoi :W_Texte2500

		    END ELSE
			* W_LibMoi = ""
		    END
		  END

		  W_NbMv = DCOUNT(W_TabInterv<i,1>, CHAR(252)) 
              * -> classer les interventions par hre de dbut :                  
		  IF W_NbMv > 0 THEN
		    W_IndiceInsert = 0
		    FOR k = 1 TO W_NbMv
		      IF W_TabInterv<i,2,k> > W_HreDeb THEN
			  W_IndiceInsert = k
			  k = W_NbMv
		      END
		    NEXT k

		    IF Affichage = "A" THEN
		  * Le but de ce bloc conditionnel est de dterminer W_IndiceInsert !
			* Rgles a respecter : Si intervention non valide(=Abs Aide ou Exception)
			* on permet de saisir une MOI "par dessus" = chevauchement.
			* Dans ces cas de figure, il faut que VB affiche la MOI 
			* en premier lieu afin qu'elle soit au premier plan de l'affichage.
			* 01/10/03 : Grer mme si intervention valide !
			
		 	 * Vrifier que les interventions prcdentes
			 * sont valides, tout au moins s'il y a chevauchement...
			 IF W_IndiceInsert = 0 THEN
			 	k = W_NbMv
			 END ELSE
			 	k = W_IndiceInsert-1
			 END
			 W_FinBoucle = "F"
			 LOOP
			 WHILE k > 0 AND W_FinBoucle = "F"
				IF W_TabInterv<i,3,k> > W_HreDeb THEN
					* Nb : on sait qu'il va falloir mettre la MOI avant l'intervention 
					* en cours, mais y en a-t-il une autre ? (= chevauchement d'une intervention valide avec une exception,...)
					* => on continue la boucle.
	
					W_IndiceInsert = k
				END ELSE
					* Pas de chevauchement avec l'intervention en cours. Nanmoins, il peut y avoir une intervention qui 
					* chevauche l'intervention en cours (si celle ci est une exception), et la premire de l'intervention valide peut se terminer le plus tard !
					* => vrifier l'intervention prcdente, jusqu' intervention valide ou k = 0
					IF LEN(W_TabInterv<i,1,k>) # 7 THEN
						* Il peut bel et bien y avoir chevauchement de 2 interventions, il faut alors mettre la MOI avant la premire
					END ELSE
						* On est sur une intervention valide. Or 2 interventions valides ne peuvent se chevaucher 
						* et donc la MOI peut tre insre ici.
						W_FinBoucle = "V"	
					END
				END

				k = k - 1	
			  REPEAT
			  IF W_IndiceInsert # 0 THEN			
			     W_IndChevauchMoi = W_IndiceInsert - 1
			     W_FinRechercheChevauchMoi = "F"
			     LOOP
				W_IndChevauchMoi = W_IndChevauchMoi + 1
			     WHILE W_TabInterv<i,1,W_IndChevauchMoi> # "" AND W_FinRechercheChevauchMoi = "F"
				IF LEN(W_TabInterv<i,1,W_IndChevauchMoi>) = 7 THEN
					* Intervention valide : il va falloir rduire sa dure si chevauchement avec la MOI a insrer
					IF W_TabInterv<i,2,W_IndChevauchMoi> < W_HreFin THEN
						* Il ya bel et bien chevauchement
						* + il faut "rduire" la valeur de l'intervention qui chevauche la MOI...
						W_DureeIntervMoi = W_TabInterv<i,3,W_IndChevauchMoi> - W_TabInterv<i,2,W_IndChevauchMoi>
						IF W_TabInterv<i,3,W_IndChevauchMoi> < W_HreFin THEN
							W_DureeChevauchMoi = W_TabInterv<i,3,W_IndChevauchMoi>
						END ELSE
							W_DureeChevauchMoi = W_HreFin
						END
						IF W_TabInterv<i,2,W_IndChevauchMoi> > W_HreDeb THEN
							W_DureeChevauchMoi = W_DureeChevauchMoi - W_TabInterv<i,2,W_IndChevauchMoi>
						END ELSE
							W_DureeChevauchMoi = W_DureeChevauchMoi - W_HreDeb
						END
						W_TabInterv<i,5,W_IndChevauchMoi> = INT(W_TabInterv<i,5,W_IndChevauchMoi>*(W_DureeIntervMoi - W_DureeChevauchMoi)/W_DureeIntervMoi+1/2)"R%4"
						* Nb : on continue de parcourir car on peut avoir une MOI qui "couvre" deux interventions successives : 
						* MOI de 7h00 a 12h00, intervA de 7h30 a 8h30, intervB de 9h30 a 10h30 ...
					END ELSE
						W_FinRechercheChevauchMoi = "V"
					END
				END
			     REPEAT
			
			  END
		  * ci dessous : Fin du "si affichage alors grer chevauchement interventions valides..."
		    END ELSE

			* 01/10 : Grer chevauchement avec interventions.
			* Nb : 2 interventions ne peuvent se chevaucher
			* (sommes en dition, suivi contrat et paie, donc uniquement interventions valides)
			 IF W_IndiceInsert # 1 THEN 
			    IF W_IndiceInsert = 0 THEN
			 		k = W_NbMv
			    END ELSE
			 		k = W_IndiceInsert-1
			    END
			    IF W_TabInterv<i,3,k> > W_HreDeb THEN
				* Chevauchement avec l'intervention prcdente !	
				IF W_TabInterv<i,3,k> > W_HreFin THEN
					
					W_SauveFin = W_TabInterv<i,3,k>
					W_TabInterv<i,3,k> = W_HreDeb
					IF TraitementRecapMens # "1" THEN
					* On proratise la valeur de l'intervention avec laquelle il y a chevauchement...
						W_DureeIntervMoi = W_SauveFin - W_TabInterv<i,2,k> 
						W_DureeChevauchMoi = W_HreDeb - W_TabInterv<i,2,k>
						W_SauveValeurMoi = W_TabInterv<i,5,k>
						W_TabInterv<i,5,k> = INT(W_SauveValeurMoi*(W_DureeChevauchMoi)/W_DureeIntervMoi+1/2)"R%4"
					END

					* On cr une deuxime portion d'intervention
					IF k < W_NbMv THEN
						W_TabInterv = INSERT(W_TabInterv,i,1,k+1,W_TabInterv<i,1,k>)
				  		W_TabInterv = INSERT(W_TabInterv,i,2,k+1,W_HreFin)
				  		W_TabInterv = INSERT(W_TabInterv,i,3,k+1,W_SauveFin)
			  	 		W_TabInterv = INSERT(W_TabInterv,i,4,k+1,W_TabInterv<i,4,k>)
						IF TraitementRecapMens # "1" THEN
							W_DureeChevauchMoi = W_SauveFin - W_HreFin
							W_TabInterv = INSERT(W_TabInterv,i,5,k+1,INT(W_SauveValeurMoi*(W_DureeChevauchMoi)/W_DureeIntervMoi+1/2)"R%4")
							W_TabInterv = INSERT(W_TabInterv,i,6,k+1,W_RubSaiMOI)
							W_TabInterv = INSERT(W_TabInterv,i,7,k+1,W_TabInterv<i,7,k>)
						END
						W_NbMv = W_NbMv + 1
						W_IndiceInsert= k + 1
					END ELSE
						W_TabInterv<i,1,k+1>=W_TabInterv<i,1,k>
				  		W_TabInterv<i,2,k+1>=W_HreFin
				  		W_TabInterv<i,3,k+1>=W_SauveFin
			  	 		W_TabInterv<i,4,k+1>=W_TabInterv<i,4,k>
						IF TraitementRecapMens # "1" THEN
							W_DureeChevauchMoi = W_SauveFin - W_HreFin
							W_TabInterv<i,5,k+1>=INT(W_SauveValeurMoi*(W_DureeChevauchMoi)/W_DureeIntervMoi+1/2)"R%4"
							W_TabInterv<i,6,k+1>=W_RubSaiMOI
							W_TabInterv<i,7,k+1>=W_TabInterv<i,7,k>

						END
						W_NbMv = W_NbMv + 1
						W_IndiceInsert= W_NbMv
					END
				END ELSE
					W_DureeIntervMoi = W_TabInterv<i,3,k> - W_TabInterv<i,2,k>	
					
					W_TabInterv<i,3,k> = W_HreDeb
					IF W_TabInterv<i,2,k> >= W_TabInterv<i,3,k> THEN
						
						* L'intervention prcdente a t compltement annule !
						DEL W_TabInterv<i,1,k>
						DEL W_TabInterv<i,2,k>
						DEL W_TabInterv<i,3,k>
						DEL W_TabInterv<i,4,k>
						IF TraitementRecapMens # "1" THEN
							DEL W_TabInterv<i,5,k>
							DEL W_TabInterv<i,6,k>
							DEL W_TabInterv<i,7,k>
						END
						W_NbMv = W_NbMv - 1
						W_IndiceInsert = W_IndiceInsert -1	
					END ELSE
					   IF TraitementRecapMens # "1" THEN
						W_DureeChevauchMoi = W_TabInterv<i,3,k> - W_TabInterv<i,2,k>	
						W_TabInterv<i,5,k> = INT(W_TabInterv<i,5,k>*W_DureeChevauchMoi/W_DureeIntervMoi+1/2)"R%4"
					   END
					END
				
				END
			    END
			 END
			 IF W_IndiceInsert # 0 THEN
				k = W_IndiceInsert - 1
				LOOP
					k = k + 1
				WHILE k <= W_NbMv AND W_TabInterv<i,2,k> < W_HreFin
					* Chevauchement avec l'intervention suivante (ou LES interventions suivant...)
					IF W_TabInterv<i,3,k> <= W_HreFin THEN
						DEL W_TabInterv<i,1,k>
						DEL W_TabInterv<i,2,k>
						DEL W_TabInterv<i,3,k>
						DEL W_TabInterv<i,4,k>
						IF TraitementRecapMens # "1" THEN
							DEL W_TabInterv<i,5,k>
							DEL W_TabInterv<i,6,k>
							DEL W_TabInterv<i,7,k>
						END
						W_NbMv = W_NbMv - 1
						* Attention : on "dcale" les interventions suivantes => prendre en compte celle qui vient de passer en position k
						k = k - 1
						IF W_NbMv < W_IndiceInsert THEN
							W_IndiceInsert = 0
						END
						* Nb : si plusieurs inteventions suivantes, d'autres peuvent tre affectes par la MOI...
					END ELSE
						* On "raccourcit" l'intervention suivante, de manire a ce qu'elle commence  la fin de la MOI
						IF TraitementRecapMens # "1" THEN
							W_DureeIntervMoi = W_TabInterv<i,3,k> - W_TabInterv<i,2,k>
							W_DureeChevauchMoi = W_TabInterv<i,3,k> - W_HreFin
							W_TabInterv<i,5,k> = INT(W_TabInterv<i,5,k>*W_DureeChevauchMoi/W_DureeIntervMoi+1/2)"R%4"
						END
						W_TabInterv<i,2,k> = W_HreFin
						 * De plus, on sait que d'ventuelles interventions suivantes sont OK...
						k = W_NbMv 
					END
				REPEAT
				
			
			 END
			
		    END		  

		    IF W_IndiceInsert = 0 THEN
				W_TabInterv<i,1,W_NbMv+1> = "MOI"
			  	W_TabInterv<i,2,W_NbMv+1> = W_HreDeb
			  	W_TabInterv<i,3,W_NbMv+1> = W_HreFin
		  	  	W_TabInterv<i,4,W_NbMv+1> = W_CleMOI:W_LibMoi
				IF TraitementRecapMens # "1" THEN
					W_TabInterv<i,5,W_NbMv+1> = W_ValeurMoi
					W_TabInterv<i,6,W_NbMv+1> = W_RubSaiMOI
					W_TabInterv<i,7,W_NbMv+1> = CHAR(208)

				END
		    END ELSE
				W_TabInterv = INSERT(W_TabInterv,i,1,W_IndiceInsert,"MOI")
			  	W_TabInterv = INSERT(W_TabInterv,i,2,W_IndiceInsert,W_HreDeb)
			  	W_TabInterv = INSERT(W_TabInterv,i,3,W_IndiceInsert,W_HreFin)
		  	 	W_TabInterv = INSERT(W_TabInterv,i,4,W_IndiceInsert,W_CleMOI:W_LibMoi)
				IF TraitementRecapMens # "1" THEN
					W_TabInterv = INSERT(W_TabInterv,i,5,W_IndiceInsert,W_ValeurMoi)
					W_TabInterv = INSERT(W_TabInterv,i,6,W_IndiceInsert,W_RubSaiMOI)
					W_TabInterv = INSERT(W_TabInterv,i,7,W_IndiceInsert,CHAR(208))
				END
		    END

		  * ci dessous : sinon du "Si W_NbMv <> 0..."
		  END ELSE
	  	    W_TabInterv<i,1,1> = "MOI"
	  	    W_TabInterv<i,2,1> = W_HreDeb
	  	    W_TabInterv<i,3,1> = W_HreFin
	  	    W_TabInterv<i,4,1> = W_CleMOI:W_LibMoi
		    IF TraitementRecapMens # "1" THEN
			  W_TabInterv<i,5,1> = W_ValeurMoi
			  W_TabInterv<i,6,1> = W_RubSaiMOI
			  W_TabInterv<i,7,1> = CHAR(208)
		    END

		  END
		* Ci dessous : Fin du "Si W_LibMoi <> "" ..."
		END
	END    

  REPEAT
END

EXECUTE 'EFFACER-LISTE ':W_NomReqMOITps
RETURN

300 ***************************************************************************************
*            		Gestion des indisponibilits de l'aidant/aid				*
*******************************************************************************************
IF ParAide = "" THEN
READ ENR_TPSAIDANTDISPO FROM F.TPSAIDANTDISPO, W_TamponAidant ELSE ENR_TPSAIDANTDISPO = ""
W_IndAidantAide = 2
END ELSE
READ ENR_TPSAIDANTDISPO FROM F.BESOINSAIDE, W_TamponAide ELSE ENR_TPSAIDANTDISPO = ""
W_IndAidantAide = 0
END
IF ENR_TPSAIDANTDISPO<9+W_IndAidantAide> # "" THEN
FOR i = 1 TO NbJours
    W_JourEnCours = DateDeb + i - 1
    W_JourClair = MOD(W_JourEnCours,7) - 1
    IF W_JourClair = -1 THEN
		W_JourClair = 6
    END
    k = 0
    LOOP
	k = k + 1
    WHILE ENR_TPSAIDANTDISPO<9+W_IndAidantAide,k> # ""
	IF ENR_TPSAIDANTDISPO<9+W_IndAidantAide,k> = W_JourClair THEN
		W_HreDeb = ENR_TPSAIDANTDISPO<10+W_IndAidantAide,k>
		W_HreFin = ENR_TPSAIDANTDISPO<11+W_IndAidantAide,k>
		IF W_HreFin = 0 THEN
			W_HreFin = 2400
		END
		 
            
		IF Affichage = "A" THEN
		
			* Affichage : on passe a VB la totalite de l'indispo
			W_NbMv = DCOUNT(W_TabInterv<i,1>, CHAR(252))
			W_TabInterv<i,1,W_NbMv+1> = "INDISPO"
			W_TabInterv<i,2,W_NbMv+1> = W_HreDeb
		  	W_TabInterv<i,3,W_NbMv+1> = W_HreFin
			IF ParAide = "" THEN
				W_Hre2500=W_HreDeb
				GOSUB 2500
				W_TabInterv<i,4,W_NbMv+1> = "De ":W_Texte2500:"  "
				W_Hre2500=W_HreFin
				GOSUB 2500
				W_TabInterv<i,4,W_NbMv+1> = W_TabInterv<i,4,W_NbMv+1>:W_Texte2500
				IF ENR_TPSAIDANTDISPO<15,k> = "O" THEN
					W_TabInterv<i,4,W_NbMv+1> = W_TabInterv<i,4,W_NbMv+1>:" - Autre employeur "
				END
					W_TabInterv<i,4,W_NbMv+1> = W_TabInterv<i,4,W_NbMv+1>:" - ":TRIM(ENR_TPSAIDANTDISPO<14,k>)
			END ELSE
				W_Hre2500=W_HreDeb
				GOSUB 2500
				W_TabInterv<i,4,W_NbMv+1> = "De ":W_Texte2500:"  "
				W_Hre2500=W_HreFin
				GOSUB 2500
				W_TabInterv<i,4,W_NbMv+1> = W_TabInterv<i,4,W_NbMv+1>:W_Texte2500
				W_TabInterv<i,4,W_NbMv+1> = W_TabInterv<i,4,W_NbMv+1>:" - ":TRIM(ENR_TPSAIDANTDISPO<12,k>)
			END
			BEGIN CASE
				CASE W_JourClair = "0"
					W_TabInterv<i,4,W_NbMv+1> = "Lundi - ":W_TabInterv<i,4,W_NbMv+1>
				CASE W_JourClair = "1"
					W_TabInterv<i,4,W_NbMv+1> = "Mardi - ":W_TabInterv<i,4,W_NbMv+1>
				CASE W_JourClair = "2"
					W_TabInterv<i,4,W_NbMv+1> = "Mercredi - ":W_TabInterv<i,4,W_NbMv+1>
				CASE W_JourClair = "3"
					W_TabInterv<i,4,W_NbMv+1> = "Jeudi - ":W_TabInterv<i,4,W_NbMv+1>
				CASE W_JourClair = "4"
					W_TabInterv<i,4,W_NbMv+1> = "Vendredi - ":W_TabInterv<i,4,W_NbMv+1>
				CASE W_JourClair = "5"
					W_TabInterv<i,4,W_NbMv+1> = "Samedi - ":W_TabInterv<i,4,W_NbMv+1>
				CASE 1
					W_TabInterv<i,4,W_NbMv+1> = "Dimanche - ":W_TabInterv<i,4,W_NbMv+1>

			END CASE

			W_TabInterv<i,5,W_NbMv+1> = CHAR(208)
			W_TabInterv<i,6,W_NbMv+1> = CHAR(208)
			W_TabInterv<i,7,W_NbMv+1> = CHAR(208)
			
		END ELSE
			GOSUB 1500
			* ci dessous : fin du "Si affichage = "A"..."
		END
	END
    REPEAT	

NEXT i
END
RETURN

400 *********************************************************************************
*				Gestion des absences de l'aidant					*
* On en profite pour "restructurer" les infos collectes jusqu'ici, 			*
* avec pour consigne qu'une absence de l'aidant doit toujours tre dite en cas de	*
* chevauchement avec un autre type de plage, sauf  l'affichage o tout doit tre 	*
* visualis (Nb : intgration paie idem dition, on ignore ce qui est saisi sur une	*
* absence de l'aidant).											*
*************************************************************************************
W_TabAidant = ""
W_ListeAbsences = ""
W_IndListeAbsences = 1
W_SauveTabAidant=""
W_SauveTabAidant2=""
W_SauveTabInterv=""
* Modif Greg - 02/01/09 - On remplace "FinAbsAidant" par "2" car des pbs ont t dtect (le descripteur ne fonctionne pas toujours, sans qu'on sache pourquoi).
EXECUTE 'SELECT ABSENCESAIDANT AVEC CodeAidant = "':W_TamponAidant:'" AND AVEC DebAbsAidant <= "':DateFin:'" AND AVEC 2 >= "':DateDeb:'" AND AVEC NumMotifAidant # "03" PAR DebAbsAidant'
W_NomReqAbsAidantTps="ReqAbsAidantTPS":User:Affichage:TIME()
EXECUTE 'SAUVE-LISTE ':W_NomReqAbsAidantTps
EXECUTE 'LISTE ':W_NomReqAbsAidantTps RETURNING MSGCODE
IF MSGCODE<1> # 209 THEN
  SELECT F.ABSENCESAIDANT TO W_ReqAbsAidantTps
  W_FinAbs = "F"
  LOOP
	READNEXT W_CleAbs FROM W_ReqAbsAidantTps ELSE W_FinAbs = "V"
  WHILE W_FinAbs = "F"
	READ ENR_ABSENCESAIDANT FROM F.ABSENCESAIDANT, W_CleAbs THEN		
	   W_DescripAbs = "Absence aidant - "
	   W_IDescrip = 0
	   W_TrouveDescrip = "F"
	   LOOP
		W_IDescrip = W_IDescrip + 1
	   WHILE ENR_TABLESABSENCES<2,W_IDescrip> # "" AND W_TrouveDescrip = "F"
		IF ENR_TABLESABSENCES<2,W_IDescrip> = W_CleAbs[6,2] THEN
			W_DescripAbs = W_DescripAbs:ENR_TABLESABSENCES<3,W_IDescrip>
			W_TrouveDescrip = "V"
		END
	   REPEAT
	   IF ENR_ABSENCESAIDANT<28> = "1" THEN
		W_DescripAbs = W_DescripAbs:" - A confirmer -"	
	   END
	   W_DescripAbs = W_DescripAbs:" du ":OCONV(W_CleAbs[8,5],"D4/"):" au ":OCONV(ENR_ABSENCESAIDANT<2>,"D4/")	
	   W_MotifAbs = W_CleAbs[6,2]
  	   BEGIN CASE
		CASE W_MotifAbs <= "06"	
		  IF TraitementRempl = "1" THEN
			W_LibAbs = "ARRET":W_CleAbs
		  END ELSE
			W_LibAbs = "ARRET"
		  END
		  W_AbsAtt = CHAR(208)

		CASE (W_MotifAbs < "18" AND W_MotifAbs > "06") OR W_MotifAbs > "21"
		  IF TraitementRempl = "1" THEN
			W_LibAbs = "CONGES":W_CleAbs
		  END ELSE
			W_LibAbs = "CONGES"
		  END
		  IF W_MotifAbs = "22" THEN
			W_AbsAtt = "V"
		  END ELSE
			W_AbsAtt = CHAR(208)
		  END
		
		CASE W_MotifAbs >= "18"
			W_LibAbs = "VM"
			W_AbsAtt = CHAR(208)
   	   END CASE
	   IF Affichage # "E" THEN
	      W_AbsAtt = W_AbsAtt:W_DescripAbs
	   END
	   W_DateDebAbs = W_CleAbs[8,5]
	   IF W_DateDebAbs < DateDeb THEN
		W_DateDebAbs = DateDeb
	   END
	   W_DateFinAbs = ENR_ABSENCESAIDANT<2>
	   IF W_DateFinAbs > DateFin THEN
		W_DateFinAbs = DateFin
	   END

	   * Remlissage du tableau W_ListeAbs
	   GOSUB 1100

	   W_IndiceJour = W_DateDebAbs - DateDeb + 1
	   LOOP
		
		W_JourEnCours = DateDeb + W_IndiceJour - 1 		
	   WHILE W_JourEnCours <= W_DateFinAbs  

	   * Correction d'un oubli : on peut avoir 2 absences le mme jour (ex : VM le matin, 
	   * et conges a partir de l'a.-m.)
	   * La gestion de la premire absence va "vider" W_TabInterv => le rtablir...
	   
		W_SauveTabAidant=W_TabAidant
		W_SauveTabInterv=W_TabInterv
		
	   	IF W_TabInterv<W_IndiceJour> = "" AND W_TabAidant<W_IndiceJour> # "" THEN
			W_TabInterv<W_IndiceJour> = W_TabAidant<W_IndiceJour>
			W_TabAidant<W_IndiceJour>=""
	   	END
		IF Affichage = "A" THEN
			IF QuiAppel="APPELVISU" THEN
				GOSUB 410
				W_SauveTabAidant2<W_IndiceJour>=W_TabAidant<W_IndiceJour>				
			END
			
			* Affichage : on notifie toutes les absences, l'ordre importe peu 
			W_TabAidant<W_IndiceJour>=W_SauveTabAidant<W_IndiceJour>
			W_TabInterv<W_IndiceJour>=W_SauveTabInterv<W_IndiceJour>
			IF W_TabInterv<W_IndiceJour> = "" AND W_TabAidant<W_IndiceJour> # "" THEN
				W_TabInterv<W_IndiceJour> = W_TabAidant<W_IndiceJour>
				W_TabAidant<W_IndiceJour>=""
			END  	   
			IF W_LibAbs[1,6] # "CONGES" THEN
				* Nb : reste a dfinir s'il faut notifier AUSSI les indispo de l'aidant en cas d'absence,
				* ce qui ne devrait pas poser pb, mais n'a pas t voqu a ma connaissance
				
				W_NbMv = DCOUNT(W_TabInterv<i,1>, CHAR(252)) 
				W_TabAidant<W_IndiceJour,1> = W_TabInterv<W_IndiceJour,1>
				W_TabAidant<W_IndiceJour,2> = W_TabInterv<W_IndiceJour,2>
				W_TabAidant<W_IndiceJour,3> = W_TabInterv<W_IndiceJour,3>
				W_TabAidant<W_IndiceJour,4> = W_TabInterv<W_IndiceJour,4>
				W_TabAidant<W_IndiceJour,5> = W_TabInterv<W_IndiceJour,5>
				W_TabAidant<W_IndiceJour,6> = W_TabInterv<W_IndiceJour,6>
				W_TabAidant<W_IndiceJour,7> = W_TabInterv<W_IndiceJour,7>

				W_TabInterv<W_IndiceJour> = ""

				IF W_TabAidant<W_IndiceJour,1> = "" THEN
					W_TabAidant<W_IndiceJour,1,1> = W_LibAbs
					IF W_MotifAbs <= "06" THEN
						W_TabAidant<W_IndiceJour,2,1> = "0000"
						W_TabAidant<W_IndiceJour,3,1> = "2400"
					END ELSE
						W_HeureDebAbs = ENR_ABSENCESAIDANT<4>"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
						W_HeureFinAbs = (ENR_ABSENCESAIDANT<4>+1)"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
						W_TabAidant<W_IndiceJour,2,1> = W_HeureDebAbs
						W_TabAidant<W_IndiceJour,3,1> = W_HeureFinAbs
					END
					W_TabAidant<W_IndiceJour,4,1> = W_AbsAtt
					W_TabAidant<W_IndiceJour,5,1> = CHAR(208)	
					W_TabAidant<W_IndiceJour,6,1> = CHAR(208)	
					W_TabAidant<W_IndiceJour,7,1> = CHAR(208)	

				END ELSE
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,1,1,W_LibAbs)
					IF W_MotifAbs <= "06" THEN
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,2,1,"0000")
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,"2400")
					END ELSE
						W_HeureDebAbs = ENR_ABSENCESAIDANT<4>"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
						W_HeureFinAbs = (ENR_ABSENCESAIDANT<4>+1)"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,2,1,W_HeureDebAbs)
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,W_HeureFinAbs)
					END
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,4,1,W_AbsAtt)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,5,1,CHAR(208))
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,6,1,CHAR(208))
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,7,1,CHAR(208))


				END
				
				
			END ELSE

			  * Cas des conges : soit il y a des exceptions, et dans ce cas si exception sur un aid
			  * pour lequel il y a intervention, on considere que l'aidant n'est plus en absence
			  * sur la dure de cette intervention....
			  
			  				  
			  IF W_CleAbs[8,5] = W_JourEnCours AND ENR_ABSENCESAIDANT<1> = "2" THEN
				W_HreDebAbs = MidiConges
			  END ELSE
				W_HreDebAbs = "0000"
			  END
			  IF ENR_ABSENCESAIDANT<2> = W_JourEnCours AND ENR_ABSENCESAIDANT<3> = "1" THEN
				W_HreFinAbs = MidiConges
			  END ELSE
				W_HreFinAbs = "2400"
			  END

			  IF ENR_ABSENCESAIDANT<26> # "" THEN
				* Gestion des exceptions		
				W_TabExcept = ""
				W_IndTabExcept = 0
				iInterv = 0
				LOOP
				  iInterv = iInterv + 1
				WHILE W_TabInterv<W_IndiceJour,1,iInterv> # ""
				  	IF W_TabInterv<W_IndiceJour,1,iInterv> # "INDISPO" AND W_TabInterv<W_IndiceJour,1,iInterv> # "MOI" THEN
						* On a une intervention sur un aide
						W_CodeAideInterv = W_TabInterv<W_IndiceJour,4,iInterv>[6,5]
						W_TypeActInterv = W_TabInterv<W_IndiceJour,1,iInterv>[INDEX(W_TabInterv<W_IndiceJour,1,iInterv>,"Interv",1)+6,1]
						
						* On dtermine si l'aidant est en conges pour cet aide sur l'intervention....
						iContrat =0
						W_Trouve = "F"
						LOOP
						   IF W_Trouve = "F" THEN
							iContrat = iContrat + 1
						   END
						WHILE ENR_ABSENCESAIDANT<26,iContrat> # "" AND W_Trouve = "F"
						   READ ENR_CONTRAT FROM F.CONTRAT, ENR_ABSENCESAIDANT<26,iContrat> THEN
							IF (W_TypeActInterv = "M" AND ENR_CONTRAT<3> = W_CodeAideInterv AND ENR_CONTRAT<1> = "02") OR (W_TypeActInterv # "M" AND ENR_CONTRAT<1> # "02") THEN
								W_Trouve = "V"
							END
						   END
						REPEAT
						IF W_Trouve = "V" THEN
						  * On dtermine maintenant si l'aidant est absent ou non sur cette intervention...
						  W_DateDebExcept = ENR_ABSENCESAIDANT<22,iContrat>
						  W_DateFinExcept = ENR_ABSENCESAIDANT<24,iContrat>
						  IF (W_JourEnCours < W_DateDebExcept OR W_JourEnCours > W_DateFinExcept) OR ENR_ABSENCESAIDANT<21,iContrat>="N" THEN 
							* On a bien exception....
							W_IndTabExcept = W_IndTabExcept + 1
							W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
							W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>
						  END ELSE
							*IF W_DateDebExcept = W_JourEnCours AND ENR_ABSENCESAIDANT<23,iContrat> = "A" THEN
							*	W_HreDebExcept = MidiConges
							*END ELSE
							*	W_HreDebExcept = "0000"		
							*END
							*
							*IF W_DateFinExcept = W_JourEnCours AND ENR_ABSENCESAIDANT<25,iContrat> = "M" THEN
							*	W_HreFinExcept = MidiConges
							*END ELSE
							*	W_HreFinExcept = "2400"		
							*END
							*
							*IF W_HreFinExcept > W_TabInterv<W_IndiceJour,2,iInterv> THEN
							*	* Pas d'exception (en conges au dbut de l'interv)
							*END ELSE
							*	IF W_HreDebExcept < W_TabInterv<W_IndiceJour,3,iInterv> THEN
							*		* Pas d'exception : le conge commence pendant ou avant l'intervention.
							*	END ELSE
							*		* exception : le conge commence apres ou finit avant l'intervention
							*		W_IndTabExcept = W_IndTabExcept + 1
							*		W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
							*		W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>
							*	END
							*END
							IF W_DateDebExcept = W_JourEnCours AND ENR_ABSENCESAIDANT<23,iContrat> = "A" THEN
								IF ENR_ABSENCESAIDANT<1> = "2" AND W_DateDebExcept = W_CleAbs[8,5] THEN
									* Debut d'arrt contrat = dbut abs 
									W_HreDebExcept = "0000"
								END ELSE
									W_HreDebExcept = MidiConges
								END
							END ELSE
								W_HreDebExcept = "0000"		
							END
							IF W_DateFinExcept = W_JourEnCours AND ENR_ABSENCESAIDANT<25,iContrat> = "M" THEN
								IF ENR_ABSENCESAIDANT<3> = "1" AND ENR_ABSENCESAIDANT<2> = W_DateFinExcept THEN
									* Fin d'arrt contrat = fin abs 
									W_HreFinExcept = "2400"
								END ELSE
									W_HreFinExcept = MidiConges
								END
							END ELSE
								W_HreFinExcept = "2400"		
							END
							
							IF W_HreFinExcept > W_TabInterv<W_IndiceJour,2,iInterv> THEN
								IF W_HreDebExcept < W_TabInterv<W_IndiceJour,3,iInterv> THEN
									* Pas d'exception : le conge commence pendant ou avant l'intervention.
								END ELSE
									* exception : le conge commence apres l'intervention
									W_IndTabExcept = W_IndTabExcept + 1
									W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
									W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>

								END
								
							END ELSE
								
									* exception : le conge finit avant l'intervention
									W_IndTabExcept = W_IndTabExcept + 1
									W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
									W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>
								
							END
						  END
						END ELSE
							* Nb : il est possible d'avoir cr une absence avant d'avoir cr le contrat  
							* Dans ce cas l, on ne fait rien = l'aidant est en cong !
						END
					END ELSE
						* On ne fait rien : si indisposition de l'aidant pendant conges,
						* on notifie le conge = pas d'exception.
					END
				REPEAT

				* On a fini de parcourir les interventions a notifier => On "dcoupe" l'arrt suivant les exceptions dfinies...
				* Nb : les exceptions sont dans l'ordre des interventions = ordre chronologique...

				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				W_TabAidant<W_IndiceJour,1> = W_TabInterv<W_IndiceJour,1>
				W_TabAidant<W_IndiceJour,2> = W_TabInterv<W_IndiceJour,2>
				W_TabAidant<W_IndiceJour,3> = W_TabInterv<W_IndiceJour,3>
				W_TabAidant<W_IndiceJour,4> = W_TabInterv<W_IndiceJour,4>
				W_TabAidant<W_IndiceJour,5> = W_TabInterv<W_IndiceJour,5>
				W_TabAidant<W_IndiceJour,6> = W_TabInterv<W_IndiceJour,6>
				W_TabAidant<W_IndiceJour,7> = W_TabInterv<W_IndiceJour,7>


				W_TabInterv<W_IndiceJour> = ""
	

				IF W_IndTabExcept # 0 THEN
				   FOR i = 1 TO W_IndTabExcept
					IF W_TabExcept<i,1> > W_HreDebAbs AND W_TabExcept<i,1> < W_HreFinAbs THEN
						IF W_TabAidant<W_IndiceJour,1> = "" THEN
							W_TabAidant<W_IndiceJour,1,1> = W_LibAbs
							W_TabAidant<W_IndiceJour,2,1> = W_HreDebAbs
							IF W_HreFinAbs < W_TabExcept<i,1> THEN
							* Ne devrait pas arriver : exception en dehors de la plage de conges....
								W_TabAidant<W_IndiceJour,3,1> = W_HreFinAbs
							END ELSE
								W_TabAidant<W_IndiceJour,3,1> = W_TabExcept<i,1>
								W_HreDebAbs	= W_TabExcept<i,2>
							END
							W_TabAidant<W_IndiceJour,4,1> = W_AbsAtt
							W_TabAidant<W_IndiceJour,5,1> = CHAR(208)	
							W_TabAidant<W_IndiceJour,6,1> = CHAR(208)	
							W_TabAidant<W_IndiceJour,7,1> = CHAR(208)	

						END ELSE
							W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,1,1,W_LibAbs)
							W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,2,1,W_HreDebAbs)
							IF W_HreFinAbs < W_TabExcept<i,1> THEN
							* Ne devrait pas arriver : exception en dehors de la plage de conges....
								W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,W_HreFinAbs)
							END ELSE
								W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,W_TabExcept<i,1>)
								W_HreDebAbs	= W_TabExcept<i,2>
							END
							W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,4,1,W_AbsAtt)
							W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,5,1,CHAR(208))
							W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,6,1,CHAR(208))
							W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,7,1,CHAR(208))

						END
						W_NbMv = W_NbMv + 1
					END ELSE
						* Exception sur le dbut de l'arrt...
						IF W_HreDebAbs < W_TabExcept<i,2> AND W_TabExcept<i,2> <= W_HreFinAbs THEN
							W_HreDebAbs	= W_TabExcept<i,2>
						END ELSE
							* Ne devrait pas arriver : exception en dehors de la plage de conges....
						END
					END
				   NEXT i
				   IF W_HreDebAbs < W_HreFinAbs THEN
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,1,1,W_LibAbs)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,2,1,W_HreDebAbs)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,W_HreFinAbs)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,4,1,W_AbsAtt)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,5,1,CHAR(208))
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,6,1,CHAR(208))
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,7,1,CHAR(208))

				   END
				END ELSE
					* Pas d'exception
					IF W_TabAidant<W_IndiceJour,1> = "" THEN
						W_TabAidant<W_IndiceJour,1,1> = W_LibAbs
						W_TabAidant<W_IndiceJour,2,1> = W_HreDebAbs
						W_TabAidant<W_IndiceJour,3,1> = W_HreFinAbs
						W_TabAidant<W_IndiceJour,4,1> = W_AbsAtt
						W_TabAidant<W_IndiceJour,5,1> = CHAR(208)	
						W_TabAidant<W_IndiceJour,6,1> = CHAR(208)	
						W_TabAidant<W_IndiceJour,7,1> = CHAR(208)	

					END ELSE
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,1,1,W_LibAbs)
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,2,1,W_HreDebAbs)
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,W_HreFinAbs)
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,4,1,W_AbsAtt)
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,5,1,CHAR(208))
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,6,1,CHAR(208))
						W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,7,1,CHAR(208))
					END
				END
				
			  END ELSE
				* ENR_ABSENCESDAIDANT<26> = "", dc pas d'exceptions sur le cong trait...	
				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				W_TabAidant<W_IndiceJour,1> = W_TabInterv<W_IndiceJour,1>
				W_TabAidant<W_IndiceJour,2> = W_TabInterv<W_IndiceJour,2>
				W_TabAidant<W_IndiceJour,3> = W_TabInterv<W_IndiceJour,3>
				W_TabAidant<W_IndiceJour,4> = W_TabInterv<W_IndiceJour,4>
				W_TabAidant<W_IndiceJour,5> = W_TabInterv<W_IndiceJour,5>
				W_TabAidant<W_IndiceJour,6> = W_TabInterv<W_IndiceJour,6>
				W_TabAidant<W_IndiceJour,7> = W_TabInterv<W_IndiceJour,7>
				W_TabInterv<W_IndiceJour> = ""
				
				IF W_TabAidant<W_IndiceJour,1> = "" THEN
					W_TabAidant<W_IndiceJour,1,1> = W_LibAbs
					W_TabAidant<W_IndiceJour,2,1> = W_HreDebAbs
					W_TabAidant<W_IndiceJour,3,1> = W_HreFinAbs
					W_TabAidant<W_IndiceJour,4,1> = W_AbsAtt
					W_TabAidant<W_IndiceJour,5,1> = CHAR(208)	
					W_TabAidant<W_IndiceJour,6,1> = CHAR(208)	
					W_TabAidant<W_IndiceJour,7,1> = CHAR(208)	

				END ELSE
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,1,1,W_LibAbs)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,2,1,W_HreDebAbs)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,3,1,W_HreFinAbs)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,4,1,W_AbsAtt)
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,5,1,CHAR(208))
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,6,1,CHAR(208))
					W_TabAidant=INSERT(W_TabAidant,W_IndiceJour,7,1,CHAR(208))
				END
				
			  END
			
			* fin traitement conges	
			END
		END ELSE
			* edition / paie : on supprime littralement les interventions / indispo
		   GOSUB 410
		END
		
*		IF QuiAppel="APPELVISU" THEN

*			W_NbMv = DCOUNT(W_SauveTabAidant2<W_IndiceJour,1>,CHAR(252))
*			FOR k=1 TO W_NbMv
*				IF INDEX(W_SauveTabAidant2<W_IndiceJour,1,k>,"Interv",1) # 0 AND LEN(W_SauveTabAidant2<W_IndiceJour,1,k>)=7 THEN
*					W_TypeActEnCours = W_SauveTabAidant2<W_IndiceJour,1,k>[7,1]		
*				END
*				BEGIN CASE
*					CASE W_TypeActEnCours = "P"
*						W_SauveCumul<W_IndiceJour,1> = W_SauveCumul<W_IndiceJour,1> + W_SauveTabAidant2<W_IndiceJour,5,k>
*					CASE W_TypeActEnCours = "M"
*						W_SauveCumul<W_IndiceJour,2> = W_SauveCumul<W_IndiceJour,2> + W_SauveTabAidant2<W_IndiceJour,5,k>
*					CASE W_TypeActEnCours = "I"
*						W_SauveCumul<W_IndiceJour,3> = W_SauveCumul<W_IndiceJour,3> + W_SauveTabAidant2<W_IndiceJour,5,k>
*					CASE W_TypeActEnCours = "S"
*						W_SauveCumul<W_IndiceJour,4> = W_SauveCumul<W_IndiceJour,4> + W_SauveTabAidant2<W_IndiceJour,5,k>
*				END CASE
*			NEXT k				
*		END		
		W_IndiceJour = W_IndiceJour + 1
	   REPEAT
	END
  REPEAT
END
EXECUTE 'EFFACER-LISTE ':W_NomReqAbsAidantTps
RETURN


410**********************************************************************
*QuiAppel est le 14me argument.
*Si on est en visualisation du planning,le traitement ne doit concerner que W_TabInterv<W_IndiceJour,5>, tant donn que c'est cette variable
* qui traite les compteurs.
*Plusieurs conditions on donc t poses pour dterminer si l'on ne s'occupe que de W_TabInterv<W_IndiceJour,5>.
*Pour rappel: en visualisation du planning, les interventions doivent apparatres dans tous les cas!!. En dition elles n'apparaissent pas!!
*************************************************************************

BEGIN CASE
			CASE W_MotifAbs <= "06"	
			* Arrts de travail -> Les jours d'absence sont complets, et donc
			* en dition, on efface toutes les saisies/indispo ventuelles du jour, 
				W_TabAidant<W_IndiceJour,1,1> = W_LibAbs
				W_TabAidant<W_IndiceJour,2,1> = "0000"
				W_TabAidant<W_IndiceJour,3,1> = "2400"
				W_TabAidant<W_IndiceJour,4,1> = W_AbsAtt
				IF TraitementRecapMens # "1" THEN
					W_TabAidant<W_IndiceJour,5,1> = CHAR(208)
					W_TabAidant<W_IndiceJour,6,1> = CHAR(208)
					W_TabAidant<W_IndiceJour,7,1> = CHAR(208)
				END		
				W_TabInterv<W_IndiceJour> = ""					
				
			CASE (W_MotifAbs < "18" AND W_MotifAbs > "06") OR W_MotifAbs > "21"
			* Conges : ne supprimer que les intervention / indispo en dehors de la plage des conges (matin / a.-m.)
			* Rgle adopte : si une intervention commence pendant un conge ou finit pendant un conge,
			* on la "coupe" de faon a n'afficher que l'absence et l'ventuelle partie de l'intervention
			* qui ne chevauche pas cette absence.
			* + Grer les exceptions...

			  IF W_CleAbs[8,5] = W_JourEnCours AND ENR_ABSENCESAIDANT<1> = "2" THEN
				W_HreDebAbs = MidiConges
			  END ELSE
				W_HreDebAbs = "0000"
			  END
			  IF ENR_ABSENCESAIDANT<2> = W_JourEnCours AND ENR_ABSENCESAIDANT<3> = "1" THEN
				W_HreFinAbs = MidiConges
			  END ELSE
				W_HreFinAbs = "2400"
			  END

			  IF ENR_ABSENCESAIDANT<26> # "" THEN
				* Gestion des exceptions		
				W_TabExcept = ""
				W_IndTabExcept = 0
				W_TabArret = ""
				W_IndTabArret = 1
				iInterv = 0
				LOOP
				  iInterv = iInterv + 1
				WHILE W_TabInterv<W_IndiceJour,1,iInterv> # ""
				  	IF W_TabInterv<W_IndiceJour,1,iInterv> # "INDISPO" AND W_TabInterv<W_IndiceJour,1,iInterv> # "MOI" AND LEN(W_TabInterv<W_IndiceJour,1,iInterv>) = 7 THEN
						* On a une intervention sur un aide
						W_CodeAideInterv = W_TabInterv<W_IndiceJour,4,iInterv>[6,5]
						W_TypeActInterv = W_TabInterv<W_IndiceJour,1,iInterv>[INDEX(W_TabInterv<W_IndiceJour,1,iInterv>,"Interv",1)+6,1]
						
						* On dtermine si l'aidant est en conges pour cet aide sur l'intervention....
						iContrat =0
						W_Trouve = "F"
						LOOP
						   IF W_Trouve = "F" THEN
							iContrat = iContrat + 1
						   END
						WHILE ENR_ABSENCESAIDANT<26,iContrat> # "" AND W_Trouve = "F"
						   READ ENR_CONTRAT FROM F.CONTRAT, ENR_ABSENCESAIDANT<26,iContrat> THEN
							IF (W_TypeActInterv = "M" AND ENR_CONTRAT<3> = W_CodeAideInterv AND ENR_CONTRAT<1> = "02") OR (W_TypeActInterv # "M" AND ENR_CONTRAT<1> # "02") THEN
								W_Trouve = "V"
							END
						   END
						REPEAT
						
						IF W_Trouve = "V" THEN
						  * On dtermine maintenant si l'aidant est absent ou non sur cette intervention...
						  W_DateDebExcept = ENR_ABSENCESAIDANT<22,iContrat>
						  W_DateFinExcept = ENR_ABSENCESAIDANT<24,iContrat>
						  IF (W_JourEnCours < W_DateDebExcept OR W_JourEnCours > W_DateFinExcept) OR ENR_ABSENCESAIDANT<21,iContrat>="N" THEN 
							* On a bien exception....
							W_IndTabExcept = W_IndTabExcept + 1
							W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
							W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>
						  END ELSE
							
							IF W_DateDebExcept = W_JourEnCours AND ENR_ABSENCESAIDANT<23,iContrat> = "A" THEN
								IF ENR_ABSENCESAIDANT<1> = "2" AND W_DateDebExcept = W_CleAbs[8,5] THEN
									* Debut d'arrt contrat = dbut abs 
									W_HreDebExcept = "0000"
								END ELSE
									W_HreDebExcept = MidiConges
								END
							END ELSE
								W_HreDebExcept = "0000"		
							END
							IF W_DateFinExcept = W_JourEnCours AND ENR_ABSENCESAIDANT<25,iContrat> = "M" THEN
								IF ENR_ABSENCESAIDANT<3> = "1" AND ENR_ABSENCESAIDANT<2> = W_DateFinExcept THEN
									* Fin d'arrt contrat = fin abs 
									W_HreFinExcept = "2400"
								END ELSE
									W_HreFinExcept = MidiConges
								END
							END ELSE
								W_HreFinExcept = "2400"		
							END
							IF W_HreFinExcept > W_TabInterv<W_IndiceJour,2,iInterv> THEN
								IF W_HreDebExcept < W_TabInterv<W_IndiceJour,3,iInterv> THEN
									* Pas d'exception : le conge commence pendant ou avant l'intervention.
								END ELSE
									* exception : le conge commence apres l'intervention
									W_IndTabExcept = W_IndTabExcept + 1
									W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
									W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>

								END
								
							END ELSE
								
									* exception : le conge finit avant l'intervention
									W_IndTabExcept = W_IndTabExcept + 1
									W_TabExcept<W_IndTabExcept,1> = W_TabInterv<W_IndiceJour,2,iInterv>
									W_TabExcept<W_IndTabExcept,2> = W_TabInterv<W_IndiceJour,3,iInterv>
								
							END
						  END
						END ELSE
							* Nb : il est possible d'avoir cr une absence avant d'avoir cr le contrat  
							* Dans ce cas l, on ne fait rien = l'aidant est en cong !
						END
					END ELSE
						* On ne fait rien : si indisposition de l'aidant pendant conges,
						* on notifie le conge = pas d'exception.
					END
				REPEAT
				* On a fini de parcourir les interventions a notifier => On "dcoupe" l'arrt suivant les exceptions dfinies...
				* Nb : les exceptions sont dans l'ordre des interventions = ordre chronologique...
				* Attention : par rapport a l'affichage, on mets les morceaux d'arrts dans un tableau
				
 				W_TabArret = ""
				W_IndTabArret = 1
				IF W_IndTabExcept # 0 THEN
				   FOR i = 1 TO W_IndTabExcept
					IF W_TabExcept<i,1> > W_HreDebAbs AND W_TabExcept<i,1> < W_HreFinAbs THEN
						W_TabArret<1,W_IndTabArret> = W_LibAbs
						W_TabArret<2,W_IndTabArret> = W_HreDebAbs
						IF W_HreFinAbs < W_TabExcept<i,1> THEN
							* Ne devrait pas arriver : exception en dehors de la plage de conges....
							W_TabArret<3,W_IndTabArret> = W_HreFinAbs
						END ELSE
							W_TabArret<3,W_IndTabArret> = W_TabExcept<i,1>
							W_HreDebAbs	= W_TabExcept<i,2>
						END
						W_TabArret<4,W_IndTabArret> = ""
						W_IndTabArret = W_IndTabArret + 1
					END ELSE
						* Exception sur le dbut de l'arrt...
						IF W_HreDebAbs < W_TabExcept<i,2> AND W_TabExcept<i,2> <= W_HreFinAbs THEN
							W_HreDebAbs	= W_TabExcept<i,2>
						END ELSE
							* Ne devrait pas arriver : exception en dehors de la plage de conges....
						END
					END
				   NEXT i
				   IF W_HreDebAbs < W_HreFinAbs THEN
						W_TabArret<1,W_IndTabArret> = W_LibAbs
						W_TabArret<2,W_IndTabArret> = W_HreDebAbs
						W_TabArret<3,W_IndTabArret> = W_HreFinAbs
						W_TabArret<4,W_IndTabArret> = CHAR(208)
						W_IndTabArret = W_IndTabArret + 1
				   END
				END ELSE
					* Pas d'exception
					W_TabArret<1,1> = W_LibAbs
					W_TabArret<2,1> = W_HreDebAbs
					W_TabArret<3,1> = W_HreFinAbs
					W_TabArret<4,1> = CHAR(208)
					W_IndTabArret = 2
				END
				
				FOR k = 1 TO W_IndTabArret - 1 
				  W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				  FOR i = 1 TO W_NbMv
					IF W_TabInterv<W_IndiceJour,2,i> < W_TabArret<2,k> THEN
						* On garde au moins le dbut de l'intervention / MOI / Indispo
						IF W_TabInterv<W_IndiceJour,3,i> > W_TabArret<2,k> THEN
							
							* On "tronque" la plage
							IF (TraitementRecapMens # "1") AND W_TabInterv<W_IndiceJour,5,i> # CHAR(208) THEN
								W_TabInterv<W_IndiceJour,5,i> = INT(W_TabInterv<W_IndiceJour,5,i>/(W_TabInterv<W_IndiceJour,3,i>-W_TabInterv<W_IndiceJour,2,i>) * (W_TabArret<2,k>-W_TabInterv<W_IndiceJour,2,i>) + 1/2)
							END
							W_TabInterv<W_IndiceJour,3,i> = W_TabArret<2,k>
						END ELSE
							* On peut garder la plage telle quelle
						END	
					END ELSE
						* La plage commence en mme temps ou aprs l'arrt
						IF W_TabInterv<W_IndiceJour,2,i> < W_TabArret<3,k> THEN
							* en mme temps : on tronque ou on supprime !
							IF W_TabInterv<W_IndiceJour,3,i> > W_TabArret<3,k> AND W_TabInterv<W_IndiceJour,3,i> <= "2400" THEN
								* On tronque
								IF (TraitementRecapMens # "1") AND W_TabInterv<W_IndiceJour,5,i> # CHAR(208) THEN
									W_TabInterv<W_IndiceJour,5,i> = INT(W_TabInterv<W_IndiceJour,5,i>/(W_TabInterv<W_IndiceJour,3,i>-W_TabInterv<W_IndiceJour,2,i>) * (W_TabInterv<W_IndiceJour,3,i>-W_TabArret<3,k>) + 1/2)
								END		
								W_TabInterv<W_IndiceJour,2,i> = W_TabArret<3,k>
							END ELSE
								DEL W_TabInterv<W_IndiceJour,1,i>
								DEL W_TabInterv<W_IndiceJour,2,i>
								DEL W_TabInterv<W_IndiceJour,3,i>
								DEL W_TabInterv<W_IndiceJour,4,i>
								IF TraitementRecapMens # "1" THEN
									DEL W_TabInterv<W_IndiceJour,5,i>
									DEL W_TabInterv<W_IndiceJour,6,i>
									DEL W_TabInterv<W_IndiceJour,7,i>
								END
								W_NbMv = W_NbMv - 1
								i = i - 1							
							END
						END ELSE

							* La plage commence aprs l'arrt. Dans la mesure o elles sont 
							* tries par ordre chronologique, toutes les plages suivantes sont aprs l'arrt...
							i = W_NbMv
						END
					END
				  NEXT i	
				NEXT k
				
				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				W_Decalage = 0
				
					FOR i = 1 TO W_NbMv
						LOOP WHILE W_TabInterv<W_IndiceJour,2,i> > W_TabArret<2,W_Decalage+1> AND W_TabArret<2,W_Decalage+1> # "" 
							W_TabAidant<W_IndiceJour,1,i+W_Decalage> = W_LibAbs
							W_TabAidant<W_IndiceJour,2,i+W_Decalage> = W_TabArret<2,W_Decalage+1>
							W_TabAidant<W_IndiceJour,3,i+W_Decalage> = W_TabArret<3,W_Decalage+1>
							W_TabAidant<W_IndiceJour,4,i+W_Decalage> = W_AbsAtt
							IF TraitementRecapMens # "1" THEN
								W_TabAidant<W_IndiceJour,5,i+W_Decalage> = CHAR(208)
								W_TabAidant<W_IndiceJour,6,i+W_Decalage> = CHAR(208)
								W_TabAidant<W_IndiceJour,7,i+W_Decalage> = CHAR(208)
							END
							W_Decalage = W_Decalage + 1
						REPEAT
						
						W_TabAidant<W_IndiceJour,1,i+W_Decalage> = W_TabInterv<W_IndiceJour,1,i>
						W_TabAidant<W_IndiceJour,2,i+W_Decalage> = W_TabInterv<W_IndiceJour,2,i>
						W_TabAidant<W_IndiceJour,3,i+W_Decalage> = W_TabInterv<W_IndiceJour,3,i>
						W_TabAidant<W_IndiceJour,4,i+W_Decalage> = W_TabInterv<W_IndiceJour,4,i>
						IF TraitementRecapMens # "1" THEN
							W_TabAidant<W_IndiceJour,5,i+W_Decalage> = W_TabInterv<W_IndiceJour,5,i>
							W_TabAidant<W_IndiceJour,6,i+W_Decalage> = W_TabInterv<W_IndiceJour,6,i>
							W_TabAidant<W_IndiceJour,7,i+W_Decalage> = W_TabInterv<W_IndiceJour,7,i>
						END

						
					NEXT i
					FOR k = W_Decalage + 1 TO W_IndTabArret - 1
					* la boucle FOR est inutile puisqu'il reste au maximum la derniere portion d'arrt a notifier,
					* mais elle permet de ne rien faire si W_Decalage = W_IndTabArret - 1
					* c'est a dire que tous les arrts ont t traits.
						W_TabAidant<W_IndiceJour,1,i+k-1> = W_LibAbs
						W_TabAidant<W_IndiceJour,2,i+k-1> = W_TabArret<2,k>
						W_TabAidant<W_IndiceJour,3,i+k-1> = W_TabArret<3,k>
						W_TabAidant<W_IndiceJour,4,i+k-1> = W_AbsAtt
						IF TraitementRecapMens # "1" THEN
							W_TabAidant<W_IndiceJour,5,i+k-1> = CHAR(208)
							W_TabAidant<W_IndiceJour,6,i+k-1> = CHAR(208)
							W_TabAidant<W_IndiceJour,7,i+k-1> = CHAR(208)
						END
					NEXT k
					W_TabInterv<W_IndiceJour> = ""
			  END ELSE
			    * Pas d'exceptions dans l'absence - Grer quand mme heure / fin dbut...	
				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				FOR i = 1 TO W_NbMv
					IF W_TabInterv<W_IndiceJour,2,i> < W_HreDebAbs THEN
						* On garde au moins le dbut de l'intervention / MOI / Indispo
						IF W_TabInterv<W_IndiceJour,3,i> > W_HreDebAbs THEN
							* On "tronque" la plage
							IF (TraitementRecapMens # "1") AND W_TabInterv<W_IndiceJour,5,i> # CHAR(208) THEN
								W_TabInterv<W_IndiceJour,5,i> = INT(W_TabInterv<W_IndiceJour,5,i>/(W_TabInterv<W_IndiceJour,3,i>-W_TabInterv<W_IndiceJour,2,i>) * (W_HreDebAbs-W_TabInterv<W_IndiceJour,2,i>) + 1/2)
							END		
							W_TabInterv<W_IndiceJour,3,i> = W_HreDebAbs
						END ELSE
							* On peut garder la plage telle quelle
						END	
					END ELSE
						* La plage commence en mme temps ou aprs l'arrt
						IF W_TabInterv<W_IndiceJour,2,i> < W_HreFinAbs THEN
							* en mme temps : on tronque ou on supprime !
							IF W_TabInterv<W_IndiceJour,3,i> > W_HreFinAbs AND W_TabInterv<W_IndiceJour,3,i> <= "2400" THEN
								* On tronque
								IF (TraitementRecapMens # "1") AND W_TabInterv<W_IndiceJour,5,i> # CHAR(208) THEN
									W_TabInterv<W_IndiceJour,5,i> = INT(W_TabInterv<W_IndiceJour,5,i>/(W_TabInterv<W_IndiceJour,3,i>-W_TabInterv<W_IndiceJour,2,i>) * (W_TabInterv<W_IndiceJour,3,i>-W_HreFinAbs) + 1/2)
								END	
								W_TabInterv<W_IndiceJour,2,i> = W_HreFinAbs
							END ELSE
								DEL W_TabInterv<W_IndiceJour,1,i>
								DEL W_TabInterv<W_IndiceJour,2,i>
								DEL W_TabInterv<W_IndiceJour,3,i>
								DEL W_TabInterv<W_IndiceJour,4,i>
								IF (TraitementRecapMens # "1") THEN
									DEL W_TabInterv<W_IndiceJour,5,i>
									DEL W_TabInterv<W_IndiceJour,6,i>
									DEL W_TabInterv<W_IndiceJour,7,i>
								END
								W_NbMv = W_NbMv - 1
								i = i - 1							
							END
						END ELSE

							* La plage commence aprs l'arrt. Dans la mesure o elles sont 
							* tries par ordre chronologique, toutes les plages suivantes sont aprs l'arrt...
							i = W_NbMv
						END
					END
				NEXT i
				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				W_Decalage = 0
					FOR i = 1 TO W_NbMv

						IF W_TabInterv<W_IndiceJour,2,i> > W_HreDebAbs AND W_Decalage = 0 THEN
							W_TabAidant<W_IndiceJour,1,i> = W_LibAbs
							W_TabAidant<W_IndiceJour,2,i> = W_HreDebAbs
							W_TabAidant<W_IndiceJour,3,i> = W_HreFinAbs
							W_TabAidant<W_IndiceJour,4,i> = W_AbsAtt
							IF (TraitementRecapMens # "1") THEN
								W_TabAidant<W_IndiceJour,5,i> = CHAR(208)
								W_TabAidant<W_IndiceJour,6,i> = CHAR(208)
								W_TabAidant<W_IndiceJour,7,i> = CHAR(208)
							END
							W_Decalage = 1
						END 

						W_TabAidant<W_IndiceJour,1,i+W_Decalage> = W_TabInterv<W_IndiceJour,1,i>
						W_TabAidant<W_IndiceJour,2,i+W_Decalage> = W_TabInterv<W_IndiceJour,2,i>
						W_TabAidant<W_IndiceJour,3,i+W_Decalage> = W_TabInterv<W_IndiceJour,3,i>
						W_TabAidant<W_IndiceJour,4,i+W_Decalage> = W_TabInterv<W_IndiceJour,4,i>
						IF (TraitementRecapMens # "1") THEN
							W_TabAidant<W_IndiceJour,5,i+W_Decalage> = W_TabInterv<W_IndiceJour,5,i>
							W_TabAidant<W_IndiceJour,6,i+W_Decalage> = W_TabInterv<W_IndiceJour,6,i>
							W_TabAidant<W_IndiceJour,7,i+W_Decalage> = W_TabInterv<W_IndiceJour,7,i>
						END
					
					NEXT i
					IF W_Decalage = 0 THEN
						W_TabAidant<W_IndiceJour,1,W_NbMv+1> = W_LibAbs
						W_TabAidant<W_IndiceJour,2,W_NbMv+1> = W_HreDebAbs
						W_TabAidant<W_IndiceJour,3,W_NbMv+1> = W_HreFinAbs
						W_TabAidant<W_IndiceJour,4,W_NbMv+1> = W_AbsAtt
						IF (TraitementRecapMens # "1") THEN
							W_TabAidant<W_IndiceJour,5,W_NbMv+1> = CHAR(208)
							W_TabAidant<W_IndiceJour,6,W_NbMv+1> = CHAR(208)
							W_TabAidant<W_IndiceJour,7,W_NbMv+1> = CHAR(208)
						END
					END			
					W_TabInterv<W_IndiceJour> = ""
			  END

			CASE W_MotifAbs >= "18"
			* VM : ne supprimer que les interventions / indispo pendant l'heure de VM...
			* Nb : les VM durent 1 hre... EN DUR.
			* + Les minutes sont en clair dans ABSENCESAIDANT, ie on a att.4= 10 et att. 5 = 45 pour noter 10h45 !
				W_HreDebAbs = ENR_ABSENCESAIDANT<4>"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
				W_HreFinAbs = (ENR_ABSENCESAIDANT<4>+1)"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
			    
				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				FOR i = 1 TO W_NbMv
					IF W_TabInterv<W_IndiceJour,2,i> < W_HreDebAbs THEN
						* On garde au moins le dbut de l'intervention / MOI / Indispo
						IF W_TabInterv<W_IndiceJour,3,i> > W_HreDebAbs THEN
							* On "tronque" la plage
							IF (TraitementRecapMens # "1") AND W_TabInterv<W_IndiceJour,5,i> # CHAR(208) THEN
								W_TabInterv<W_IndiceJour,5,i> = INT(W_TabInterv<W_IndiceJour,5,i>/(W_TabInterv<W_IndiceJour,3,i>-W_TabInterv<W_IndiceJour,2,i>) * (W_HreDebAbs-W_TabInterv<W_IndiceJour,2,i>) + 1/2)
							END	
							W_TabInterv<W_IndiceJour,3,i> = W_HreDebAbs
						END ELSE
							* On peut garder la plage telle quelle
						END	
					END ELSE
						* La plage commence en mme temps ou aprs l'arrt
						IF W_TabInterv<W_IndiceJour,2,i> < W_HreFinAbs THEN
							* en mme temps : on tronque ou on supprime !
							IF W_TabInterv<W_IndiceJour,3,i> > W_HreFinAbs AND W_TabInterv<W_IndiceJour,3,i> <= "2400" THEN
								* On tronque
								IF (TraitementRecapMens # "1") AND W_TabInterv<W_IndiceJour,5,i> # CHAR(208) THEN
									W_TabInterv<W_IndiceJour,5,i> = INT(W_TabInterv<W_IndiceJour,5,i>/(W_TabInterv<W_IndiceJour,3,i>-W_TabInterv<W_IndiceJour,2,i>) * (W_TabInterv<W_IndiceJour,3,i>-W_HreFinAbs) + 1/2)
								END	
								W_TabInterv<W_IndiceJour,2,i> = W_HreFinAbs
							END ELSE
								DEL W_TabInterv<W_IndiceJour,1,i>
								DEL W_TabInterv<W_IndiceJour,2,i>
								DEL W_TabInterv<W_IndiceJour,3,i>
								DEL W_TabInterv<W_IndiceJour,4,i>
								IF (TraitementRecapMens # "1") THEN
									DEL W_TabInterv<W_IndiceJour,5,i>
									DEL W_TabInterv<W_IndiceJour,6,i>
									DEL W_TabInterv<W_IndiceJour,7,i>
								END
								W_NbMv = W_NbMv - 1
								i = i - 1							
							END
						END ELSE
								* La plage commence aprs l'arrt. Dans la mesure o elles sont 
							* tries par ordre chronologique, toutes les plages suivantes sont aprs l'arrt...
							i = W_NbMv
						END
					END
				NEXT i
				W_NbMv = DCOUNT(W_TabInterv<W_IndiceJour,1>, CHAR(252)) 
				W_Decalage = 0
					FOR i = 1 TO W_NbMv
						IF W_TabInterv<W_IndiceJour,2,i> > W_HreDebAbs AND W_Decalage = 0 THEN
							W_TabAidant<W_IndiceJour,1,i> = W_LibAbs
							W_TabAidant<W_IndiceJour,2,i> = W_HreDebAbs
							W_TabAidant<W_IndiceJour,3,i> = W_HreFinAbs
							W_TabAidant<W_IndiceJour,4,i> = W_AbsAtt
							IF (TraitementRecapMens # "1") THEN
								W_TabAidant<W_IndiceJour,5,i> = CHAR(208)
								W_TabAidant<W_IndiceJour,6,i> = CHAR(208)
								W_TabAidant<W_IndiceJour,7,i> = CHAR(208)
							END
							W_Decalage = 1
						END 
						W_TabAidant<W_IndiceJour,1,i+W_Decalage> = W_TabInterv<W_IndiceJour,1,i>
						W_TabAidant<W_IndiceJour,2,i+W_Decalage> = W_TabInterv<W_IndiceJour,2,i>
						W_TabAidant<W_IndiceJour,3,i+W_Decalage> = W_TabInterv<W_IndiceJour,3,i>
						W_TabAidant<W_IndiceJour,4,i+W_Decalage> = W_TabInterv<W_IndiceJour,4,i>
						IF (TraitementRecapMens # "1") THEN
							W_TabAidant<W_IndiceJour,5,i+W_Decalage> = W_TabInterv<W_IndiceJour,5,i>
							W_TabAidant<W_IndiceJour,6,i+W_Decalage> = W_TabInterv<W_IndiceJour,6,i>
							W_TabAidant<W_IndiceJour,7,i+W_Decalage> = W_TabInterv<W_IndiceJour,7,i>
						END

					NEXT i
					IF W_Decalage = 0 THEN
						W_TabAidant<W_IndiceJour,1,W_NbMv+1> = W_LibAbs
						W_TabAidant<W_IndiceJour,2,W_NbMv+1> = W_HreDebAbs
						W_TabAidant<W_IndiceJour,3,W_NbMv+1> = W_HreFinAbs
						W_TabAidant<W_IndiceJour,4,W_NbMv+1> = W_AbsAtt
						IF (TraitementRecapMens # "1") THEN
							W_TabAidant<W_IndiceJour,5,W_NbMv+1> = CHAR(208)
							W_TabAidant<W_IndiceJour,6,W_NbMv+1> = CHAR(208)
							W_TabAidant<W_IndiceJour,7,W_NbMv+1> = CHAR(208)
						END
					END			
					W_TabInterv<W_IndiceJour> = ""
		   END CASE

RETURN


500 * *******************************************************************
*           Ecriture dans TEMPO des listes aids / absences			*
*************************************************************************
W_IndTempo = W_IndTempo + 1
IF ParAide = "" THEN
   ENR_TEMPO<W_IndTempo> = "#":"Aides":W_TamponAidant
END ELSE
   ENR_TEMPO<W_IndTempo> = "#":"Aidants":W_TamponAide
END
W_TabLigneAide = ""
W_TabObsAide = ""

******modif val 14/11/07******
W_TabClefs=""
*****************************

W_ListeAidesAidantsAlpha = ""
IF W_ListeAidesAidants # "" THEN
   IF VraimentRecapMens # "1" THEN
	W_NbMv = DCOUNT(W_ListeAidesAidants,"|")
	* Attention : W_NbMv = [nombre d'aids] + 1 car W_ListeAidesAidants finit par un "|"...

	FOR kt = 1 TO W_NbMv - 1
		W_CodeRef = FIELD(W_ListeAidesAidants,"|",kt)
		IF ParAide = "" THEN
			GOSUB 510
		END ELSE
			GOSUB 520
		END
		W_ListeAidesAidantsAlpha<kt> = W_LigneAide[7,25]
		W_TabLigneAide<kt> = W_LigneAide
		IF TraitementRecapMens = "" AND VraimentRecapMens = "" AND TraitementPaie = "" AND TraitementRempl = "" AND TraitementExtract = "" THEN
			*IF W_ObsAide # "" THEN
				W_TabObsAide<kt> = W_ObsAide
			*END
		END
		***modif val 14/11/07***
		W_TabClefs<kt>=W_Clefs
		***********************
		W_IndTempo = W_IndTempo - 1 
	
	NEXT kt



	W_AncienneRef = "AAAA"
	W_IndAPrendre = W_NbMv
	ik = 0
	LOOP
	W_CodeRef = "ZZZZ"
	ik = ik + 1
	i = W_NbMv
	WHILE ik < W_NbMv
		LOOP
		i = i - 1
		WHILE i > 0
			IF W_ListeAidesAidantsAlpha<i> < W_CodeRef AND W_ListeAidesAidantsAlpha<i> > W_AncienneRef THEN
				W_CodeRef = W_ListeAidesAidantsAlpha<i>
				W_IndAPrendre = i
			END
		REPEAT
		W_IndTempo = W_IndTempo + 1
		ENR_TEMPO<W_IndTempo> = W_TabLigneAide<W_IndAPrendre>
		IF TraitementRecapMens = "" AND VraimentRecapMens = "" AND TraitementPaie = "" AND TraitementRempl = "" AND TraitementExtract = "" THEN
			IF TRIM(W_TabObsAide<W_IndAPrendre>) # "" THEN
				ENR_TEMPO<W_IndTempo,2> = W_TabObsAide<W_IndAPrendre>
				
			END
		END
		***modif val 14/11/07***
		ENR_TEMPO<W_IndTempo,1>=ENR_TEMPO<W_IndTempo,1>[1,29]:W_TabClefs<W_IndAPrendre>:ENR_TEMPO<W_IndTempo,1>[32,LEN(ENR_TEMPO<W_IndTempo,1>)-31]
		***********************
		W_AncienneRef = W_CodeRef
	REPEAT
	W_TabLigneAide = ""

   END ELSE
	GOSUB 530
   END
END

W_IndTempo = W_IndTempo + 1
IF ParAide = "" THEN
	ENR_TEMPO<W_IndTempo> = "#":"Absences":W_TamponAidant
END ELSE
	ENR_TEMPO<W_IndTempo> = "#":"Absences":W_TamponAide
END
IF W_ListeAbsences # "" THEN
   FOR i = 1 TO W_IndListeAbsences
	W_IndTempo = W_IndTempo + 1
	ENR_TEMPO<W_IndTempo> = W_ListeAbsences<i>
   NEXT i
END

RETURN

510 *********************************************************************
*              Edition : insertion de l'aid dans ENR_TEMPO			*
*************************************************************************
READ ENR_CIVILAIDE FROM F.CIVILAIDE, W_CodeRef THEN

   W_ObsAide = ""

   IF TraitementRecapMens = "" AND VraimentRecapMens = "" AND TraitementPaie = "" AND TraitementRempl = "" AND TraitementExtract = "" THEN

	W_LigneAide = W_CodeRef:" "
	W_Temp = ENR_CIVILAIDE<2>:" ":ENR_CIVILAIDE<3>
	W_Temp = W_Temp[1,25]
	W_Temp = W_Temp"L 25"
	W_LigneAide = W_LigneAide:W_Temp:" "
	W_Temp = TRIM(ENR_CIVILAIDE<5>:" ":ENR_CIVILAIDE<6>:" ":ENR_CIVILAIDE<7>:" ":ENR_CIVILAIDE<8>)
	*W_Temp = W_Temp[1,25]
	*W_Temp = W_Temp"L 25"
	IF W_Temp # "" THEN
		W_LigneAide = W_LigneAide:W_Temp:" - "
	END

	W_Temp = TRIM(ENR_CIVILAIDE<9>)
	*W_Temp = W_Temp[1,20]
	*W_Temp = W_Temp"L 20"
	IF W_Temp # "" THEN
	   W_LigneAide = W_LigneAide:W_Temp:" - "
	END

	W_Temp = TRIM(ENR_CIVILAIDE<11>)
	*W_Temp = W_Temp[1,20]
	*W_Temp = W_Temp"L 20"
	IF W_Temp # "" THEN
	   W_LigneAide = W_LigneAide:W_Temp:" "
	END

	W_LigneAide = W_LigneAide[1,99]
	W_LigneAide = W_LigneAide"L 100"

	IF ENR_TPSPARAM<21> = "1" AND ENR_CIVILAIDE<46> #"1" THEN
	   IF ENR_CIVILAIDE<50> = "N" THEN
	     IF TRIM(ENR_CIVILAIDE<14>) # "" THEN
		ENR_CIVILAIDE<14> = "*":ENR_CIVILAIDE<14>[2,LEN(ENR_CIVILAIDE<14>)-1]
	     END ELSE
		ENR_CIVILAIDE<14> = "*"
	     END
	   END
	   W_LigneAide = W_LigneAide:ENR_CIVILAIDE<14>
	END
	READ ENR_TPSOBS510 FROM F.TPSOBS, W_TamponAidant:W_CodeRef ELSE ENR_TPSOBS510 = ""
	IF ENR_TPSOBS510<2> = "" THEN
		READ ENR_BESOINSAIDE510 FROM F.BESOINSAIDE, W_CodeRef THEN
			W_ObsAide = SPACE(32):TRIM(ENR_BESOINSAIDE510<17>)
		END
	END ELSE
		W_ObsAide = SPACE(32):TRIM(ENR_TPSOBS510<2>)
	END 
	
   END ELSE

	W_LigneAide = W_CodeRef:" "
	W_Temp = ENR_CIVILAIDE<2>:" ":ENR_CIVILAIDE<3>
	W_Temp = W_Temp[1,25]
	W_Temp = W_Temp"L 25"
	W_LigneAide = W_LigneAide:W_Temp:" "
	W_Temp = TRIM(ENR_CIVILAIDE<5>:" ":ENR_CIVILAIDE<6>:" ":ENR_CIVILAIDE<7>:" ":ENR_CIVILAIDE<8>)
	W_Temp = W_Temp[1,25]
	W_Temp = W_Temp"L 25"
	W_LigneAide = W_LigneAide:W_Temp:" "

	W_Temp = TRIM(ENR_CIVILAIDE<9>)
	W_Temp = W_Temp[1,20]
	W_Temp = W_Temp"L 20"
	W_LigneAide = W_LigneAide:W_Temp:" "

	W_Temp = TRIM(ENR_CIVILAIDE<11>)
	W_Temp = W_Temp[1,20]
	W_Temp = W_Temp"L 20"
	W_LigneAide = W_LigneAide:W_Temp:" "

	IF ENR_TPSPARAM<21> = "1" AND ENR_CIVILAIDE<46> #"1" THEN
		W_LigneAide = W_LigneAide:ENR_CIVILAIDE<14>
	END
  END

  *****modif valentin 14/11/07*******
W_Clefs="  "
READ ENR_BESOINSAIDE510 FROM F.BESOINSAIDE, W_CodeRef THEN
  
  IF ENR_BESOINSAIDE510<22>="O" THEN
	W_Clefs=" "
  END
END
  **********************************
  
  W_IndTempo = W_IndTempo + 1
  ENR_TEMPO<W_IndTempo> = W_LigneAide

END
RETURN

520 *********************************************************************
*              Edition : insertion de l'aidant dans ENR_TEMPO		*
*************************************************************************
READ ENR_CIVILAIDANT FROM F.CIVILAIDANT, W_CodeRef THEN
	W_LigneAide = W_CodeRef:" "
	W_Temp = ENR_CIVILAIDANT<2>:" ":ENR_CIVILAIDANT<3>
	W_Temp = W_Temp[1,51]
	W_Temp = W_Temp"L 51"
	W_LigneAide = W_LigneAide:W_Temp:" "
	
	W_IndTempo = W_IndTempo + 1
	ENR_TEMPO<W_IndTempo> = W_LigneAide
	W_Clefs="  "
END
RETURN

530 *********************************************************************
* 		Rcap mensuelles : on trie par nom prnom aid			*
*************************************************************************
W_NbMv = DCOUNT(W_ListeAidesAidants,"|")
W_TabLigneAide = ""
* Attention : W_NbMv = [nombre d'aids] + 1 car W_ListeAidesAidants finit par un "|"...
FOR kt = 1 TO W_NbMv - 1
	W_CodeRef = FIELD(W_ListeAidesAidants,"|",kt)
	GOSUB 510
	W_ListeAidesAidantsAlpha<kt> = W_LigneAide[7,25]
	W_TabLigneAide<kt> = W_LigneAide
	W_IndTempo = W_IndTempo - 1 
	
NEXT kt

W_AncienneRef = "AAAA"
W_IndAPrendre = W_NbMv
ik = 0
LOOP
W_CodeRef = "ZZZZ"
ik = ik + 1
i = W_NbMv
WHILE ik < W_NbMv
	LOOP
	i = i - 1
	WHILE i > 0
		IF W_ListeAidesAidantsAlpha<i> < W_CodeRef AND W_ListeAidesAidantsAlpha<i> > W_AncienneRef THEN
			W_CodeRef = W_ListeAidesAidantsAlpha<i>
			W_IndAPrendre = i
		END
	REPEAT
	W_IndTempo = W_IndTempo + 1
	ENR_TEMPO<W_IndTempo> = W_TabLigneAide<W_IndAPrendre>
	W_AncienneRef = W_CodeRef
REPEAT
W_TabLigneAide = ""
RETURN

600 *********************************************************************
*	Affichage : on passe a VB le nom etprnom de l'aid			*
*************************************************************************
IF ENR_TPSDETAILSINTERV<6> # "" AND Affichage = "A" THEN
	W_CleTrt = W_CleTrt:"|"
END 
READ ENR_CIVILAIDE FROM F.CIVILAIDE, W_CleTrt[6,5] THEN
	W_CleTrt = W_CleTrt:TRIM(ENR_CIVILAIDE<2>:" ":ENR_CIVILAIDE<3>):" ~ "
END
W_Hre2500 = W_CleTrt[23,4]
GOSUB 2500
W_CleTrt = W_CleTrt:W_Texte2500:"  "
W_Hre2500 = ENR_TPSDETAILSINTERV<2>
GOSUB 2500
W_CleTrt = W_CleTrt:W_Texte2500
IF TRIM(ENR_CIVILAIDE<14>) # "" AND TRIM(ENR_CIVILAIDE<16>) # "" THEN
	W_CleTrt = W_CleTrt:" ~ ":ENR_CIVILAIDE<14>:"/":ENR_CIVILAIDE<16>
END ELSE
	IF TRIM(ENR_CIVILAIDE<14>:ENR_CIVILAIDE<16>) # "" THEN
		W_CleTrt = W_CleTrt:" ~ ":TRIM(ENR_CIVILAIDE<14>:ENR_CIVILAIDE<16>)		
	END
END

RETURN

610 *********************************************************************
*	Affichage : on passe a VB le nom etprnom de l'aid			*
*************************************************************************
IF ENR_TPSDETAILSINTERV<6> # "" AND Affichage = "A" THEN
	W_CleTrt = W_CleTrt:"|"
END 
READ ENR_CIVILAIDANT FROM F.CIVILAIDANT, W_CleTrt[1,5] THEN
	W_CleTrt = W_CleTrt:TRIM(ENR_CIVILAIDANT<2>:" ":ENR_CIVILAIDANT<3>):" ~ "
END
W_Hre2500 = W_CleTrt[23,4]
GOSUB 2500
W_CleTrt = W_CleTrt:W_Texte2500:"  "
W_Hre2500 = ENR_TPSDETAILSINTERV<2>
GOSUB 2500
W_CleTrt = W_CleTrt:W_Texte2500
IF TRIM(ENR_CIVILAIDANT<14>) # "" AND TRIM(ENR_CIVILAIDANT<12>) # "" THEN
	W_CleTrt = W_CleTrt:" ~ ":ENR_CIVILAIDANT<12>:"/":ENR_CIVILAIDANT<14>
END ELSE
	IF TRIM(ENR_CIVILAIDANT<14>:ENR_CIVILAIDANT<12>) # "" THEN
		W_CleTrt = W_CleTrt:" ~ ":TRIM(ENR_CIVILAIDANT<12>:ENR_CIVILAIDANT<14>)		
	END
END

RETURN


1000 ********************************************************************
*         	Remplissage du tableau W_TabTypeAct					*
*************************************************************************
EXECUTE 'SELECT ACTIVITES PAR @ID'
W_FinAct = "F"
IF Asso = "" THEN
	W_AssocParDefaut2000 = ""
END ELSE
	W_AssocParDefaut2000 = Asso
END
LOOP
READNEXT W_CleAct ELSE W_FinAct = "V"
WHILE W_FinAct = "F"
READ ENR_ACTIVITES FROM F.ACTIVITES, W_CleAct THEN
	W_TabTypeAct<W_CleAct[1,3],W_CleAct[4,3]>=ENR_ACTIVITES<12>
	IF ENR_ACTIVITES<12> = "P" AND W_AssocParDefaut2000 = "" THEN
		W_AssocParDefaut2000 = W_CleAct[1,3]
	END
END
REPEAT
IF W_AssocParDefaut2000 = "" THEN
	W_AssocParDefaut2000 = "001"
END
ENR_ACTIVITES = ""
RETURN

1100 ********************************************************************
*          Remplissage du tableau W_ListeAbsence				*
*************************************************************************
IF W_MotifAbs >= "18" AND W_MotifAbs <= "21" THEN
	W_LibMotifAbs = "Visite mdicale"
END ELSE
  IF W_MotifAbs >= "07" AND W_MotifAbs <= "11" THEN
	W_LibMotifAbs = "Evnement familial"
  END ELSE
	W_LibMotifAbs = ""
	W_IndParcoursMotifsAbs = 0
	LOOP
		W_IndParcoursMotifsAbs = W_IndParcoursMotifsAbs + 1
	WHILE ENR_TABLES<2,W_IndParcoursMotifsAbs> # ""
		IF ENR_TABLES<2,W_IndParcoursMotifsAbs> = W_MotifAbs THEN
			W_LibMotifAbs = ENR_TABLES<3,W_IndParcoursMotifsAbs>
		END
	REPEAT
  END
END
W_LibMotifAbs = W_LibMotifAbs[1,LongueurLibAbsence]
W_LibMotifAbs = W_LibMotifAbs:SPACE(LongueurLibAbsence-LEN(W_LibMotifAbs))
IF LEN(W_ListeAbsences<W_IndListeAbsences>) > 35 + LongueurLibAbsence THEN
	W_IndListeAbsences = W_IndListeAbsences + 1
END
BEGIN CASE 
	CASE W_MotifAbs <= "06"
		W_ListeAbsences<W_IndListeAbsences> = W_ListeAbsences<W_IndListeAbsences>:W_LibMotifAbs:" ":OCONV(W_CleAbs[8,5],"D4/"):"       ":OCONV(ENR_ABSENCESAIDANT<2>,"D4/"):"       " 

	CASE (W_MotifAbs >= "07" AND W_MotifAbs <= "17") OR W_MotifAbs > "21"
		IF ENR_ABSENCESAIDANT<1> = 2 THEN
			W_DebMat = "A.-M."
		END ELSE
			W_DebMat = "     "
		END
		IF ENR_ABSENCESAIDANT<3> = 1 THEN
			W_FinMat = "Midi "
		END ELSE
			W_FinMat = "     "
		END
		W_ListeAbsences<W_IndListeAbsences> = W_ListeAbsences<W_IndListeAbsences>:W_LibMotifAbs:" ":OCONV(W_CleAbs[8,5],"D4/"):" ":W_DebMat:" ":OCONV(ENR_ABSENCESAIDANT<2>,"D4/"):" ":W_FinMat:" " 

	CASE 1
		W_DebMat = ENR_ABSENCESAIDANT<4>"R 2":"h":ENR_ABSENCESAIDANT<5>"R%2"
		W_FinMat = (ENR_ABSENCESAIDANT<4>+1)"R 2":"h":ENR_ABSENCESAIDANT<5>"R%2"
		W_ListeAbsences<W_IndListeAbsences> = W_ListeAbsences<W_IndListeAbsences>:W_LibMotifAbs:" ":OCONV(W_CleAbs[8,5],"D4/"):" ":W_DebMat:" ":OCONV(ENR_ABSENCESAIDANT<2>,"D4/"):" ":W_FinMat:" " 

END CASE
RETURN

1150 ********************************************************************
*          Remplissage du tableau W_ListeAbsence				*
*************************************************************************
IF ENR_ABSENCESAIDE<4,k> # "" THEN
	i1150 = 0
	W_Trouve1150 = "F"
	LOOP
	i1150 = i1150 + 1
	WHILE ENR_TABLESMOTIFSORTIE<4,i1150> # "" AND W_Trouve1150 = "F"
		IF ENR_TABLESMOTIFSORTIE<4,i1150> = ENR_ABSENCESAIDE<4,k> THEN
			W_Trouve1150 = "V"
			i1150  = i1150 - 1
		END
	REPEAT
	W_LibMotifAbs = ENR_TABLESMOTIFSORTIE<3,i1150>[1,LongueurLibAbsence]
      W_LibMotifAbs = W_LibMotifAbs:SPACE(LongueurLibAbsence-LEN(W_LibMotifAbs))

END ELSE
   W_LibMotifAbs = ENR_ABSENCESAIDE<3,k>[1,LongueurLibAbsence]
   W_LibMotifAbs = W_LibMotifAbs:SPACE(LongueurLibAbsence-LEN(W_LibMotifAbs))
END
IF LEN(W_ListeAbsences<W_IndListeAbsences>) > 35 + LongueurLibAbsence THEN
	W_IndListeAbsences = W_IndListeAbsences + 1
END
W_ListeAbsences<W_IndListeAbsences> = W_ListeAbsences<W_IndListeAbsences>:W_LibMotifAbs:" ":OCONV(W_JourDeb,"D4/"):"       ":OCONV(W_JourFin,"D4/"):"       "

RETURN

1200 **************************************************************************
*          Remplissage du tableau contenant les libelles de rubriques		*
* de saisie utilise (ou non !) pour la saisie de MOI					*
*******************************************************************************
EXECUTE 'SELECT RUBSAISIE AVEC 2 = "5"'
W_FinRub = "F"
W_IndTabLibRub = 1
LOOP
	READNEXT W_CleRub ELSE W_FinRub = "V"
WHILE W_FinRub = "F"
   IF LEN(W_CleRub) = 3 THEN
	* Nb : ce test car plutot que de parcourir tout le tableau a la recherche d'une rubrique, 
	* on va aller chercher le libelle en fonction de l'emplacement du code rubrique dans le tableau,
	* qui doit tre un multiple de 3 aux sparateurs prs...
	* nb : de toute faon, le code doit effectivement tre sur 3 chiffres...
	READ ENR_RUBSAISIE FROM F.RUBSAISIE, W_CleRub THEN
		W_TabLibRub<1,W_IndTabLibRub> = W_CleRub
		W_TabLibRub<2,W_IndTabLibRub> = ENR_RUBSAISIE<1>
		W_IndTabLibRub = W_IndTabLibRub + 1
	END
   END
REPEAT
RETURN

1300 **************************************************************************
*  			Insertion des donnes de l'intervention dans le 		*
* tableau W_Tabinterv										*
*******************************************************************************
* Attention : dans cette procdure, i est l'indice de la boucle FOR i = ... de la procdure 10
* Ne pas le rutiliser... (a l'origine, le code ci dessous tait dans la procdure 10,
* mais a t intgr dans cette procdure suite  modif importante concernant les interventions 
* dbutant entre 0 et 7h00 et finissant aprs 7h00 : on les clate en deux parties, donc 2 appels de cette procdure.

IF i # 0 THEN
  
  W_NbMv = DCOUNT(W_TabInterv<i,1>, CHAR(252))

  * -> classer les interventions par hre de dbut :                  
  IF W_NbMv > 0 THEN
	W_IndiceInsert = 0
	FOR k = 1 TO W_NbMv
	   IF W_TabInterv<i,2,k> > W_HreDebInterv THEN
		W_IndiceInsert = k
		k = W_NbMv
	   END
  	NEXT k
	IF Affichage = "A" THEN
* Le but de ce bloc conditionnel est de dterminer W_IndiceInsert !
		* Rgles a respecter : Si intervention non valide(=Abs Aide ou Exception)
		* on permet de saisir une autre intervention "par dessus" = chevauchement.
		* Dans ces cas de figure, il faut que VB affiche l'intervention valide 
		* en premier lieu afin qu'elle soit au premier plan.
		* Donc en cas de chevauchement, il faut que l'intervention valide soit "avant"
		* d'ventuelles exceptions / absences aide.
		* Nb : il ne peut y avoir chevauchement sur deux interventions valides !
		
		IF LEN(W_LibInterv) = 7 THEN
	 	   * On traite une intervention valide : vrifier que les interventions prcdentes
		   * le sont aussi, tout au moins s'il y a chevauchement...

		   IF W_IndiceInsert = 0 THEN
			k = W_NbMv
		   END ELSE
			k = W_IndiceInsert-1
		   END
		   W_FinBoucle = "F"
		   LOOP
		   WHILE k > 0 AND W_FinBoucle = "F"
			IF LEN(W_TabInterv<i,1,k>) # 7 THEN
				* Intevention non valide - Y a-t-il chevauchement ?
				IF W_TabInterv<i,3,k> > W_HreDebInterv THEN
					* nb : on sait qu'il va falloir mettre l'intervention valide avant celle
					* en cours, mais y en a-t-il une autre ? => on continue la boucle.
					W_IndiceInsert = k
				END ELSE
					* Pas de chevauchement avec l'exception en cours. Nanmoins, il peut y avoir deux exceptions qui 
					* se chevauchent, et la premire de celle ci (celle qui commence le plus tt) peut se terminer le plus tard !
					* => vrifier l'intervention prcdente, jusqu' intervention valide ou k = 0
				END
			END ELSE
				* Intervention valide : il ne peut y avoir chevauchement qu'avec interv suivante,
				* et dans ce cas l'ordre est respect => on laisse W_IndiceInsert tel quel
				W_FinBoucle = "V"
			END
			k = k - 1	
		   REPEAT
		END ELSE
		  * on traite une intervention non valide : vrifier que les interventions suivantes
		  * sont valides, s'il y a chevauchement
		  IF W_IndiceInsert = 0 THEN
			* Ouf, on n'a rien a faire car on va mettre cette intervention non valide en fin de ligne !
		  END ELSE
			k = W_IndiceInsert
			W_FinBoucle = "F"
			LOOP WHILE k <= W_NbMv AND W_FinBoucle = "F"
				IF LEN(W_TabInterv<i,1,k>) = 7 THEN
					* Intervention valide. Y a-t-il chevauchement ?
					IF W_TabInterv<i,2,k> < W_HreFinInterv THEN
						* Chevauchement => On sait qu'il va falloir mettre l'intervention APRES
						* celle en cours...
						* Mais il peut y avoir encore chevauchement avec l'intervention suivante si 
						* deux interventions remplacent celle initialement prvue, mais annule.
						* De plus, ajouter test en fin de parcours : on peut avoir k > W_NbMv, et donc mettre W_IndiceInsert = 0
						W_IndiceInsert = k + 1 
					END ELSE
						* Pas de chevauchement avec l'intervention en cours - il n'y en aura pas non plus avec les suivantes.
						W_FinBoucle = "V"
					END
				END ELSE
					* Intervention en cours non valide. S'il y a chevauchement avec une intervention valide,
					* celle ci a forcment t place AVANT => on peut insrer.
					W_FinBoucle = "V"
				END	
				k = k + 1
			REPEAT
			IF W_IndiceInsert > W_NbMv THEN
				W_IndiceInsert = 0
			END
		  END
			
		END
	* ci dessous : Fin si affichage, grer chevauchement interventions non valides...
	END
	IF W_IndiceInsert = 0 THEN
		W_TabInterv<i,1,W_NbMv+1> = W_LibInterv
	  	W_TabInterv<i,2,W_NbMv+1> = W_HreDebInterv
  		W_TabInterv<i,3,W_NbMv+1> = W_HreFinInterv
	  	W_TabInterv<i,4,W_NbMv+1> = W_CleTrt
		IF (TraitementRecapMens # "1") THEN
			W_TabInterv<i,5,W_NbMv+1> = W_ValeurInterv
			W_TabInterv<i,6,W_NbMv+1> = W_RubSaiInterv
			W_TabInterv<i,7,W_NbMv+1> = W_ActiviteInterv
		END
		

	END ELSE
		W_TabInterv = INSERT(W_TabInterv,i,1,W_IndiceInsert,W_LibInterv)
	  	W_TabInterv = INSERT(W_TabInterv,i,2,W_IndiceInsert,W_HreDebInterv)
  		W_TabInterv = INSERT(W_TabInterv,i,3,W_IndiceInsert,W_HreFinInterv)
	  	W_TabInterv = INSERT(W_TabInterv,i,4,W_IndiceInsert,W_CleTrt)
		IF (TraitementRecapMens # "1") THEN
			W_TabInterv = INSERT(W_TabInterv,i,5,W_IndiceInsert,W_ValeurInterv)
			W_TabInterv = INSERT(W_TabInterv,i,6,W_IndiceInsert,W_RubSaiInterv)
			W_TabInterv = INSERT(W_TabInterv,i,7,W_IndiceInsert,W_ActiviteInterv)
		END
		

	END

  END ELSE
	* ci dessus : Sinon du "Si W_NbMv <> 0"
  		W_TabInterv<i,1,1> = W_LibInterv
 	  	W_TabInterv<i,2,1> = W_HreDebInterv
 	  	W_TabInterv<i,3,1> = W_HreFinInterv
	  	W_TabInterv<i,4,1> = W_CleTrt
		IF (TraitementRecapMens # "1") THEN
			W_TabInterv<i,5,1> = W_ValeurInterv
			W_TabInterv<i,6,1> = W_RubSaiInterv
			W_TabInterv<i,7,1> = W_ActiviteInterv
		END
		
  END
			  					
* ci dessous : fin du si i <> 0...
END
RETURN

1400 ********************************************************************
*             Donnes MOI : passer  VB le type d'activit			*
*                afin qu'il renseigne son cumul d'heures.			*
* + Cas du calcul du Suivi de contrat de prospective : Permets de 	*
* dterminer s'il faut prendre en compte les heures MOI			*
*************************************************************************
* Attention : si l'on modifie la structure d'Att. 4 du tableau concernant la MOI,
* penser aux incidences en procdure 100 o l'on extrait le libell rubrique pour tablir la liste de la MOI. 
READ ENR_CONTRAT FROM F.CONTRAT, ENR_TPSMOI<4> THEN
	READ ENR_ACTIVITES FROM F.ACTIVITES, ENR_CONTRAT<36,1> THEN
		W_LibMoi = ENR_ACTIVITES<12>
	END
END
ENR_ACTIVITES = ""
ENR_CONTRAT = ""
RETURN

1500 ********************************************************************
*		Indisponibilits de l'aidant/aid en dition			*
* On dcoupe l'indisponibilit en plusieurs plages s'il y a lieu,		*
* et on insre ces plages dans l'ordre chronologique.				*
*************************************************************************

  W_NbMv = DCOUNT(W_TabInterv<i,1>, CHAR(252))
  IF W_NbMv > 0 THEN
	W_IndiceInsert = 0
	t = 0
  	LOOP
		t = t + 1
	WHILE W_HreDeb < W_HreFin AND t <= W_NbMv 
	  	IF W_TabInterv<i,2,t> > W_HreDeb THEN
			W_IndiceInsert = t
			IF W_HreFin > W_TabInterv<i,2,t> THEN
				* On notifie une part de l'indispo, puis on fait le test sur l'intervention suivante
				W_HreFinPart = W_TabInterv<i,2,t>
				W_TabInterv = INSERT(W_TabInterv,i,1,W_IndiceInsert,"INDISPO")
	  	  		W_TabInterv = INSERT(W_TabInterv,i,2,W_IndiceInsert,W_HreDeb)
				
				W_HreDeb = W_TabInterv<i,3,t>
		  	  	W_TabInterv = INSERT(W_TabInterv,i,3,W_IndiceInsert,W_HreFinPart)
  			  	W_TabInterv = INSERT(W_TabInterv,i,4,W_IndiceInsert,CHAR(208))
				IF (TraitementRecapMens # "1") THEN
					W_TabInterv = INSERT(W_TabInterv,i,5,W_IndiceInsert,CHAR(208))
					W_TabInterv = INSERT(W_TabInterv,i,6,W_IndiceInsert,CHAR(208))
					W_TabInterv = INSERT(W_TabInterv,i,7,W_IndiceInsert,CHAR(208))
				END
				 
				* IMPORTANT : on a ajout une MV, et il est possible que l'on aie encore une partie de l'indispo a notifier...
				t = t + 1
				W_NbMv = W_NbMv + 1
			END ELSE
				* On notifie simplement l'indispo...
				W_TabInterv = INSERT(W_TabInterv,i,1,W_IndiceInsert,"INDISPO")
		  	  	W_TabInterv = INSERT(W_TabInterv,i,2,W_IndiceInsert,W_HreDeb)
	  		  	W_TabInterv = INSERT(W_TabInterv,i,3,W_IndiceInsert,W_HreFin)
 		  		W_TabInterv = INSERT(W_TabInterv,i,4,W_IndiceInsert,CHAR(208))
				IF (TraitementRecapMens # "1") THEN
					W_TabInterv = INSERT(W_TabInterv,i,5,W_IndiceInsert,CHAR(208))
					W_TabInterv = INSERT(W_TabInterv,i,6,W_IndiceInsert,CHAR(208))
					W_TabInterv = INSERT(W_TabInterv,i,7,W_IndiceInsert,CHAR(208))
				END
				W_HreDeb = W_HreFin
			END
		END ELSE
			IF W_TabInterv<i,3,t> > W_HreDeb THEN
			   * Deb intervention < deb indispo, mais fin intervention > deb indispo :
			   * on fait comme si l'indispo commencait juste aprs l'intervention.
				   IF W_TabInterv<i,3,t> > W_HreFin THEN
					* L'indispo n'est plus a notifier, car entirement crase par l'intervention
					W_HreDeb = W_HreFin
				   END ELSE
				* Il reste une indispo  notifier aprs l'intervention, sauf si une autre intervention suit...
				W_HreDeb = W_TabInterv<i,3,t>
				   END
			END ELSE
				IF t = W_NbMv THEN
					W_TabInterv<i,1,W_NbMv + 1> = "INDISPO"
 	  				W_TabInterv<i,2,W_NbMv + 1> = W_HreDeb
 	  				W_TabInterv<i,3,W_NbMv + 1> = W_HreFin
  	  				W_TabInterv<i,4,W_NbMv + 1> = CHAR(208)
					IF (TraitementRecapMens # "1") THEN
						W_TabInterv<i,5,W_NbMv + 1> = CHAR(208)
						W_TabInterv<i,6,W_NbMv + 1> = CHAR(208)
						W_TabInterv<i,7,W_NbMv + 1> = CHAR(208)
					END
					W_HreDeb = W_HreFin
				END ELSE
					* Seul cas ou l'on ne fait rien : l'intervention traite est avant l'indispo,
					* mais il reste des interventions a traiter...
				END
			END
		END
	REPEAT
	IF W_HreDeb < W_HreFin THEN
		W_TabInterv<i,1,W_NbMv + 1> = "INDISPO"
		W_TabInterv<i,2,W_NbMv + 1> = W_HreDeb
		W_TabInterv<i,3,W_NbMv + 1> = W_HreFin
		W_TabInterv<i,4,W_NbMv + 1> = CHAR(208)
		IF (TraitementRecapMens # "1") THEN
			W_TabInterv<i,5,W_NbMv + 1> = CHAR(208)
			W_TabInterv<i,6,W_NbMv + 1> = CHAR(208)
			W_TabInterv<i,7,W_NbMv + 1> = CHAR(208)

		END
	END
  END ELSE
 	  	W_TabInterv<i,1,1> = "INDISPO"
 	  	W_TabInterv<i,2,1> = W_HreDeb
 	  	W_TabInterv<i,3,1> = W_HreFin
 	  	W_TabInterv<i,4,1> = CHAR(208)
 	  	IF (TraitementRecapMens # "1") THEN
			W_TabInterv<i,5,1> = CHAR(208)
			W_TabInterv<i,6,1> = CHAR(208)
			W_TabInterv<i,7,1> = CHAR(208)
		END
  END
  * On est en dition / suivi contrat / intgration paie...
RETURN

1600 ********************************************************************
*		Trt par aid : Slection des absenceset MOI  de l'aidant	*
*************************************************************************
IF W_NomReqAbsAidantTps # "" THEN
	EXECUTE 'EFFACER-LISTE ':W_NomReqAbsAidantTps
END
EXECUTE 'SELECT ABSENCESAIDANT AVEC CodeAidant = "':W_TamponAidant:'" AND AVEC DebAbsAidant <= "':DateFin:'" AND AVEC FinAbsAidant >= "':DateDeb:'" AND AVEC NumMotifAidant # "03" PAR DebAbsAidant'
W_NomReqAbsAidantTps="ReqAbsAidantTPS":User:Affichage:TIME()
EXECUTE 'SAUVE-LISTE ':W_NomReqAbsAidantTps

IF W_NomReqMOITps # "" THEN
	EXECUTE 'EFFACER-LISTE ':W_NomReqMOITps
END
W_NomReqMOITps="ReqMOITps":User:Affichage:TIME()
EXECUTE 'SELECT TPSMOI AVEC CodeAidantMoi = "':W_TamponAidant:'" AND AVEC DateMoi <= "':DateFin:'" AND AVEC DateMoi >= "':DateDeb:'" PAR DateMoi'
EXECUTE 'SAUVE-LISTE ':W_NomReqMOITps

RETURN

1700*********************************************************************
*		Trt par aid : exploitation des absences de l'aidant		*
*************************************************************************
* Nb : NE PAS UTILISER LA VARIABLE i DANS CETTE PROCEDURE (DEJA UTILISEE DS PROC 10)
EXECUTE 'LISTE ':W_NomReqAbsAidantTps RETURNING MSGCODE
IF MSGCODE<1> # 209 THEN
  SELECT F.ABSENCESAIDANT TO W_ReqAbsAidantTps
  W_DescripAbs = ""
  W_FinAbs = "F"
  LOOP
	READNEXT W_CleAbs FROM W_ReqAbsAidantTps ELSE W_FinAbs = "V"
	
  WHILE W_FinAbs = "F"
	READ ENR_ABSENCESAIDANT FROM F.ABSENCESAIDANT, W_CleAbs THEN		
	   

	   W_MotifAbs = W_CleAbs[6,2]
  	   BEGIN CASE
		CASE W_MotifAbs <= "06"	
			W_LibAbs = "ARRET"
			W_AbsAtt = ""
			
		CASE (W_MotifAbs < "18" AND W_MotifAbs > "06") OR W_MotifAbs > "21"
			W_LibAbs = "CONGES"
			IF W_MotifAbs = "22" THEN
					W_AbsAtt = "V"
			END ELSE
					W_AbsAtt = ""
			END
		
		CASE W_MotifAbs >= "18"
			W_LibAbs = "VM"
			W_AbsAtt = ""

   	   END CASE

	   W_DateDebAbs = W_CleAbs[8,5]
	   IF W_DateDebAbs < DateDeb THEN
		W_DateDebAbs = DateDeb
	   END
	   W_DateFinAbs = ENR_ABSENCESAIDANT<2>
	   IF W_DateFinAbs > DateFin THEN
		W_DateFinAbs = DateFin
	   END

	   W_DateJour = DateDeb + i-1
	   IF W_DateJour <= W_DateFinAbs AND W_DateJour >= W_DateDebAbs THEN


		IF W_LibAbs[1,6] # "CONGES" THEN
				IF W_LibAbs[1,5] = "ARRET" THEN
					W_HreDebAbs = "0000"
					W_HreFinAbs = "2400"

				END ELSE
					* Visites mdicales
					W_HreDebAbs = ENR_ABSENCESAIDANT<4>"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
					W_HreFinAbs = (ENR_ABSENCESAIDANT<4>+1)"R%2":INT(ENR_ABSENCESAIDANT<5>/60*100 + 1/2)"R%2"
				END
		END ELSE
		  * Cas des conges : soit il y a des exceptions, et dans ce cas si exception sur un l'aid trait
		  *  on considere que l'aidant n'est plus en absence sur la dure de cette intervention....
		  IF ENR_ABSENCESAIDANT<26> # "" THEN
		
			k = 0 
			LOOP
			   k = k + 1 
			WHILE ENR_ABSENCESAIDANT<26,k> # ""
				READ ENR_CONTRAT FROM F.CONTRAT,ENR_ABSENCESAIDANT<26,k> THEN
				
					IF (ENR_CONTRAT<3> = W_CodeAide AND W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]> = "M") OR (W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]> # "M" AND W_TabTypeAct<W_ActiviteInterv[1,3],W_ActiviteInterv[4,3]> = W_TabTypeAct<ENR_CONTRAT<36,1>[1,3],ENR_CONTRAT<36,1>[4,3]>) THEN
					
						IF ENR_ABSENCESAIDANT<21,k> = "N" THEN
							* Pas de conges pour ce contrat...
							W_LibAbs = ""
						END ELSE
						    IF ENR_ABSENCESAIDANT<22,k> > W_DateJour OR ENR_ABSENCESAIDANT<24,k> < W_DateJour THEN
							* Pas de conges CE JOUR LA pour ce contrat...
							W_LibAbs = ""
						    END ELSE
							IF ENR_ABSENCESAIDANT<22,k> = W_DateJour AND ENR_ABSENCESAIDANT<23,k> = "A" THEN
								W_HreDebAbs = MidiConges
		  					END ELSE
								W_HreDebAbs = "0000"
		  					END
		  					IF ENR_ABSENCESAIDANT<24,k> = W_DateJour AND ENR_ABSENCESAIDANT<25,k> = "M" THEN
								W_HreFinAbs = MidiConges
		  					END ELSE
								W_HreFinAbs = "2400"
		  					END
						    END
						END
						k = 99
					END
				END
			REPEAT
		  END ELSE
			* Pas de gestion des exceptions...
			IF W_CleAbs[8,5] = W_DateJour AND ENR_ABSENCESAIDANT<1> = "2" THEN
				W_HreDebAbs = MidiConges
		  	END ELSE
				W_HreDebAbs = "0000"
		  	END
		  	IF ENR_ABSENCESAIDANT<2> = W_DateJour AND ENR_ABSENCESAIDANT<3> = "1" THEN
				W_HreFinAbs = MidiConges
		  	END ELSE
				W_HreFinAbs = "2400"
		  	END
		  END
		 
		* Ci dessous : fin du Si Abs # "CONGES"
		END
		
		IF Affichage = "A" THEN
	* Affichage : on notifie l'absence sur l'intervention en cours,
	* Alors qu'en dition, il va falloir couper la plage d'interv qui est en absence...
	   	   	 IF W_LibAbs # "" AND W_HreDebInterv < W_HreFinAbs AND W_HreFinInterv > W_HreDebAbs THEN
				W_DescripAbs = "Absence aidant - "
			      W_IDescrip = 0
			      W_TrouveDescrip = "F"
			      LOOP
				W_IDescrip = W_IDescrip + 1
			      WHILE ENR_TABLESABSENCES<2,W_IDescrip> # "" AND W_TrouveDescrip = "F"
				   IF ENR_TABLESABSENCES<2,W_IDescrip> = W_CleAbs[6,2] THEN
					W_DescripAbs = W_DescripAbs:ENR_TABLESABSENCES<3,W_IDescrip>
					W_TrouveDescrip = "V"
				   END
			      REPEAT
				IF ENR_ABSENCESAIDANT<28> = "1" THEN
					W_DescripAbs = W_DescripAbs:" - A confirmer -"
				END
			      W_DescripAbs = W_DescripAbs:" du ":OCONV(W_CleAbs[8,5],"D4/"):" au ":OCONV(ENR_ABSENCESAIDANT<2>,"D4/")	
				
				IF W_HreDebAbs < W_HreDebInterv THEN
					W_HreDebAbs = W_HreDebInterv
				END
				IF W_HreFinAbs > W_HreFinInterv THEN
					W_HreFinAbs = W_HreFinInterv
				END
				
				W_LibInterv = W_LibInterv:W_LibAbs:W_HreDebAbs"R%4":W_HreFinAbs"R%4":W_AbsAtt
				
			  END		  
		END ELSE
			* Affichage # "A" : il faut "dcouper" l'intervention de manire a n'afficher que ce qui n'est pas annul par l'absence aidant...
			IF W_LibAbs # "" AND W_HreDebInterv < W_HreFinAbs AND W_HreFinInterv > W_HreDebAbs THEN
				IF W_HreDebInterv < W_HreDebAbs THEN
					IF W_HreFinInterv > W_HreFinAbs THEN

						* L'absence "coupe" l'intervention en deux 
						W_SauveValeurIntervAbs = W_ValeurInterv
						W_SauveFinIntervAbs = W_HreFinInterv
						W_SauveDebIntervAbs = W_HreDebInterv

						W_HreFinInterv = W_HreDebAbs
						W_ValeurInterv = INT(W_SauveValeurIntervAbs/(W_SauveFinIntervAbs-W_HreDebInterv) * (W_HreFinInterv-W_HreDebInterv) + 1/2)				

						* Nb : on gre tout de mme une ventuelle MOI :
						GOSUB 2100
						
						IF (Affichage = "A" AND (ParAide = "" OR INDEX(W_LibInterv,"MOI",1) = 0)) OR LEN(W_LibInterv) = 7 THEN
							GOSUB 1300
						END

						W_ValeurInterv = INT(W_SauveValeurIntervAbs/(W_SauveFinIntervAbs-W_SauveDebIntervAbs) * (W_SauveFinIntervAbs-W_HreFinAbs) + 1/2)
						W_HreFinInter = W_SauveFinIntervAbs
						W_HreDebInterv = W_HreFinAbs

					END ELSE
								
						W_ValeurInterv = INT(W_ValeurInterv/(W_HreFinInterv-W_HreDebInterv) * (W_HreDebAbs-W_HreDebInterv) + 1/2)
						W_HreFinInterv = W_HreDebAbs

					END
				END ELSE
					IF W_HreFinInterv > W_HreFinAbs THEN
						* Absence sur le dbut de l'intervention...
						W_ValeurInterv = INT(W_ValeurInterv/(W_HreFinInterv-W_HreDebInterv) * (W_HreFinInterv-W_HreFinAbs) + 1/2)
						W_HreDebInterv = W_HreFinAbs

					END ELSE 
						W_LibInterv = W_LibInterv:W_LibAbs:W_AbsAtt
					END
				END
			END		
		END
	   END
	END
  REPEAT
END
RETURN

1800*********************************************************************
*     	Traitement par l'aid : Intgration des absences aid		*
*************************************************************************
W_TabAidant = ""
W_ListeAbsences = ""
W_IndListeAbsences = 1

READ ENR_ABSENCESAIDE FROM F.ABSENCESAIDE, W_TamponAide THEN

	* Nb : contrairement au traitement (compliqu !) des absences de l'aidant en traitement par aidant, 
	* o pour chaque intervention il fallait se poser la question :  Y a-t-il abs pour ce contrat ?, 
	* on ne remplit pas W_TabAidant, car il n'est pas ncessaire de travailler sur plusieurs tableaux (gestion facile)
	* De toute faon, il est prvu en procdure 100 de basculer le rsiduel de W_TabInterv (jours sans abs. aidant)
	* dans W_TabAidant...
	* Par contre :
	W_TabAidant = ""
	* est ncessaire...
	W_NbAbsAide = DCOUNT(ENR_ABSENCESAIDE<1>, CHAR(253))
	FOR k = 1 TO W_NbAbsAide
		IF ENR_ABSENCESAIDE<1,k> <= DateFin AND ENR_ABSENCESAIDE<2,k> >= DateDeb THEN
		   W_DescripAbs = ""
		   IF ENR_ABSENCESAIDE<4,k> # "" THEN
			W_iDescrAbs = 0
			LOOP
				W_iDescrAbs = W_iDescrAbs + 1
			WHILE ENR_ABSENCESAIDE<4,k> # ENR_TABLESMOTIFSORTIE<2,W_iDescrAbs> AND ENR_TABLESMOTIFSORTIE<2,W_iDescrAbs> # ""
			REPEAT
			IF ENR_TABLESMOTIFSORTIE<2,W_iDescrAbs> # "" THEN
				W_DescripAbs = "Absence aid - ":ENR_TABLESMOTIFSORTIE<3,W_iDescrAbs>
			END
		   END
		   IF W_DescripAbs = "" THEN
			W_DescripAbs = "Absence aid - ":ENR_ABSENCESAIDE<3,k>
		   END
		   W_DescripAbs = W_DescripAbs:" du ":OCONV(ENR_ABSENCESAIDE<1,k>,"D4/"):" au ":OCONV(ENR_ABSENCESAIDE<2,k>,"D4/")	
		   IF ENR_ABSENCESAIDE<1,k> < DateDeb THEN
			W_JourDeb = DateDeb
		   END ELSE
			W_JourDeb = ENR_ABSENCESAIDE<1,k>
		   END
		   IF ENR_ABSENCESAIDE<2,k> < DateFin THEN
			W_JourFin = ENR_ABSENCESAIDE<2,k>
		   END ELSE
			W_JourFin = DateFin
		   END
		   GOSUB 1150
		   FOR i = W_JourDeb TO W_JourFin
			IF Affichage = "A" THEN
				IF W_TabInterv<i-DateDeb +1,1> # "" THEN
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,1,1;"AbsAide")
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,2,1;"0000")
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,3,1;"2400")
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,4,1;"XXXXX":W_TamponAide:W_DescripAbs)
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,5,1;CHAR(208))
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,6,1;CHAR(208))
					W_TabInterv = INSERT(W_TabInterv,i-DateDeb +1,7,1;CHAR(208))
	
				END ELSE
					W_TabInterv<i-DateDeb +1,1,1> = "AbsAide"
					W_TabInterv<i-DateDeb +1,2,1> = "0000"
					W_TabInterv<i-DateDeb +1,3,1> = "2400"
					W_TabInterv<i-DateDeb +1,4,1> = "XXXXX":W_TamponAide:W_DescripAbs
					W_TabInterv<i-DateDeb +1,5,1> = CHAR(208)
					W_TabInterv<i-DateDeb +1,6,1> = CHAR(208)
					W_TabInterv<i-DateDeb +1,7,1> = CHAR(208)
				END
			END ELSE
				W_TabInterv<i-DateDeb +1> = ""
				* Edition : On supprime tout ce qui avait t notifi jusque l ! (Interventions, indispo)
				W_TabInterv<i-DateDeb +1,1,1> = "AbsAide"
				W_TabInterv<i-DateDeb +1,2,1> = "0000"
				W_TabInterv<i-DateDeb +1,3,1> = "2400"
				W_TabInterv<i-DateDeb +1,4,1> = "XXXXX":W_TamponAide
				IF (TraitementRecapMens # "1") THEN
					W_TabInterv<i-DateDeb +1,5,1> = CHAR(208)
					W_TabInterv<i-DateDeb +1,6,1> = CHAR(208)
					W_TabInterv<i-DateDeb +1,7,1> = CHAR(208)
				END
			END

		   NEXT i	
		END
	NEXT k

END
RETURN

2000 ********************************************************
*  On dtermine si W_JourFerieProsp (date interne) est un	*
* jour fri, si non on a en sortie W_JourFerieProsp = "F"	*
*************************************************************

* ATTENTION : ne pas utiliser variables i, k, W_NbMv,...
* pour viter tous risques, les variables utilises par cette procdure se nomment toutes [XX]FerieProsp
* + penser en dbut de programme a initialiser W_DerniereAnneeFerieProsp afin d'viter les avertissements d'unidata.

W_AnneeFerieProsp = OCONV(W_JourFerieProsp,"D4/")[7,4]
IF W_AnneeFerieProsp # W_DerniereAnneeFerieProsp THEN

*	READ ENR_PAQUES FROM F.PAQUES, W_AnneeFerieProsp THEN
*		ENR_PAQUES<2> = ICONV(ENR_PAQUES<1>[1,2]:"/":ENR_PAQUES<1>[3,2]:"/":W_AnneeFerieProsp,"D4/")
*	END ELSE
*		ENR_PAQUES = ""
*		ENR_PAQUES<2> = 0
*	END

	W_DerniereAnneeFerieProsp = W_AnneeFerieProsp
END

W_JourClairFerieProsp = OCONV(W_JourFerieProsp,"D4/")

IF OCONV(W_JourFerieProsp,"DWA") = "Sunday" OR OCONV(W_JourFerieProsp,"DWA") = "Dimanche" THEN
   	W_JourFerieProsp = "F"
END ELSE

  	W_Param2000=W_JourClairFerieProsp:"|":W_Assoc2000
  	CALL DIMJF(RETURNVAL,W_Param2000,Ferie)

  	IF Ferie[1,5] # "FERIE" THEN
		W_JourFerieProsp = "F"
  	END

*   W_JourClairFerieProsp = OCONV(W_JourFerieProsp,"D4/")
*   BEGIN CASE
*	CASE W_JourClairFerieProsp[1,5] = "01/01"
*	CASE W_JourClairFerieProsp[1,5] = "01/05"
*	CASE W_JourClairFerieProsp[1,5] = "08/05"
*	CASE W_JourClairFerieProsp[1,5] = "14/07"
*	CASE W_JourClairFerieProsp[1,5] = "15/08"
*	CASE W_JourClairFerieProsp[1,5] = "01/11"
*	CASE W_JourClairFerieProsp[1,5] = "11/11"
*	CASE W_JourClairFerieProsp[1,5] = "25/12"
*	CASE W_JourFerieProsp = ENR_PAQUES<2> + 1
*	CASE W_JourFerieProsp = ENR_PAQUES<2> + 39
*	CASE W_JourFerieProsp = ENR_PAQUES<2> + 39 + 11
*		* On ne considre plus le lundi de pentecote comme un jour fri... *** A REVOIR :
*		W_JourFerieProsp = "F"
*	CASE 1
*		W_JourFerieProsp = "F"
*   END CASE
END

RETURN

2001 ********************************************************
*  On dtermine si W_JourFerieProsp (date interne) est un	*
* jour fri, si non on a en sortie W_JourFerieProsp = "F"	*
*************************************************************

* ATTENTION : ne pas utiliser variables i, k, W_NbMv,...
* pour viter tous risques, les variables utilises par cette procdure se nomment toutes [XX]FerieProsp
* + penser en dbut de programme a initialiser W_DerniereAnneeFerieProsp afin d'viter les avertissements d'unidata.

W_AnneeFerieProsp = OCONV(W_JourFerieProsp,"D4/")[7,4]
IF W_AnneeFerieProsp # W_DerniereAnneeFerieProsp THEN
	READ ENR_PAQUES FROM F.PAQUES, W_AnneeFerieProsp THEN
		ENR_PAQUES<2> = ICONV(ENR_PAQUES<1>[1,2]:"/":ENR_PAQUES<1>[3,2]:"/":W_AnneeFerieProsp,"D4/")
	END ELSE
		ENR_PAQUES = ""
		ENR_PAQUES<2> = 0
	END
	W_DerniereAnneeFerieProsp = W_AnneeFerieProsp
END

IF OCONV(W_JourFerieProsp,"DWA") = "Sunday" OR OCONV(W_JourFerieProsp,"DWA") = "Dimanche" THEN
   W_JourFerieProsp = "F"
END ELSE
   W_JourClairFerieProsp = OCONV(W_JourFerieProsp,"D4/")
   BEGIN CASE
	CASE W_JourClairFerieProsp[1,5] = "01/01"
	CASE W_JourClairFerieProsp[1,5] = "01/05"
	CASE W_JourClairFerieProsp[1,5] = "08/05"
	CASE W_JourClairFerieProsp[1,5] = "14/07"
	CASE W_JourClairFerieProsp[1,5] = "15/08"
	CASE W_JourClairFerieProsp[1,5] = "01/11"
	CASE W_JourClairFerieProsp[1,5] = "11/11"
	CASE W_JourClairFerieProsp[1,5] = "25/12"
	CASE W_JourFerieProsp = ENR_PAQUES<2> + 1
	CASE W_JourFerieProsp = ENR_PAQUES<2> + 39
	CASE W_JourFerieProsp = ENR_PAQUES<2> + 39 + 11
	  * le 05/05 : maintenant, on considre tous les jours SUSCEPTIBLES d'tre fris, donc lundi pentecte compris : 
	  *	* On ne considre plus le lundi de pentecote comme un jour fri... *** A REVOIR :
	  *	W_JourFerieProsp = "F"
	CASE 1
		W_JourFerieProsp = "F"
   END CASE
END
RETURN


2100 ********************************************************
*    Traitement par aid : intgration de la MOI		*
*************************************************************
EXECUTE 'LISTE ':W_NomReqMOITps RETURNING MSGCODE
IF MSGCODE<1> # 209 THEN
  SELECT F.TPSMOI TO W_ReqMOITps
  W_FinMoiTps = "F"
  LOOP
	READNEXT W_CleMoiTps FROM W_ReqMOITps ELSE W_FinMoiTps = "V"
  WHILE W_FinMoiTps = "F"	
	READ ENR_TPSMOI FROM F.TPSMOI, W_CleMoiTps THEN		
	      
	   W_DateDebMoi = W_CleMoiTps[6,5]
	   
	   W_DateFinMoi = W_DateDebMoi
	   
	   W_DateJour = DateDeb + i-1
	   IF W_DateJour = W_DateFinMoi THEN
	   * La MOI a bien lieu le jour en cours...

		W_HreDebMoi = W_CleMoiTps[11,4]
		W_HreFinMoi = ENR_TPSMOI<1>"R%4"
	   		
	      * Nb : a la diffrence de ce qui se passe en affichage par aidant, 
		* on "dcoupe" l'intervention de manire a ce que seule la partie 
		* qui n'est pas "crase" par la MOI soit prise en compte
		IF W_HreDebInterv < W_HreFinMoi AND W_HreFinInterv > W_HreDebMoi THEN
		   IF Affichage #"A" THEN
			IF W_HreDebInterv < W_HreDebMoi THEN
				IF W_HreFinInterv > W_HreFinMoi THEN

					* L'absence "coupe" l'intervention en deux 
					W_SauveValeurIntervMoi = W_ValeurInterv
					W_SauveFinIntervMoi = W_HreFinInterv

					W_HreFinInterv = W_HreDebMoi
					W_ValeurInterv = INT(W_SauveValeurIntervMoi/(W_SauveFinIntervMoi-W_HreDebInterv) * (W_HreFinInterv-W_HreDebInterv) + 1/2)				
					
					IF (Affichage = "A" AND (ParAide = "" OR INDEX(W_LibInterv,"MOI",1) = 0)) OR LEN(W_LibInterv) = 7 THEN
						GOSUB 1300
					END

					W_ValeurInterv = INT(W_SauveValeurIntervMoi/(W_SauveFinIntervMoi-W_HreDebInterv) * (W_SauveFinIntervMoi-W_HreFinMoi) + 1/2)
					W_HreFinInterv = W_SauveFinIntervMoi
					W_HreDebInterv = W_HreFinMoi

				END ELSE
					* Absence sur la fin d'intervention....
					
					W_ValeurInterv = INT(W_ValeurInterv/(W_HreFinInterv-W_HreDebInterv) * (W_HreDebMoi-W_HreDebInterv) + 1/2)
					W_HreFinInterv = W_HreDebMoi
				END	
			END ELSE
				IF W_HreFinInterv > W_HreFinMoi THEN
					* Absence sur le dbut de l'intervention...
					W_ValeurInterv = INT(W_ValeurInterv/(W_HreFinInterv-W_HreDebInterv) * (W_HreFinInterv-W_HreFinMoi) + 1/2)
					W_HreDebInterv = W_HreFinMoi
				END ELSE 
				   
				   W_LibInterv = W_LibInterv:"MOI"
				   
				END
			END

		   END ELSE
			IF W_HreDebInterv < W_HreDebMoi THEN
				IF W_HreFinInterv > W_HreFinMoi THEN

					* L'absence "coupe" l'intervention en deux 
					W_SauveValeurIntervMoi = W_ValeurInterv
					W_SauveFinIntervMoi = W_HreFinInterv

					W_ValeurInterv = INT(W_SauveValeurIntervMoi/(W_HreFinInterv-W_HreDebInterv) * (W_HreDebMoi-W_HreDebInterv) + 1/2)				
					

					W_ValeurInterv = W_ValeurInterv + INT(W_SauveValeurIntervMoi/(W_HreFinInterv-W_HreDebInterv) * (W_HreFinInterv-W_HreFinMoi) + 1/2)


					* Absence sur la fin d'intervention....
					
					W_ValeurInterv = INT(W_ValeurInterv/(W_HreFinInterv-W_HreDebInterv) * (W_HreDebMoi-W_HreDebInterv) + 1/2)
				END	
			END ELSE
				IF W_HreFinInterv > W_HreFinMoi THEN
					* Absence sur le dbut de l'intervention...
					W_ValeurInterv = INT(W_ValeurInterv/(W_HreFinInterv-W_HreDebInterv) * (W_HreFinInterv-W_HreFinMoi) + 1/2)
			*		W_HreDebInterv = W_HreFinMoi
				END ELSE 
				   
				  * W_LibInterv = W_LibInterv:"MOI"
				   
				END
			END
						W_DescripAbs = "MOI - "
			READ ENR_RUBSAISIE FROM F.RUBSAISIE, ENR_TPSMOI<3> THEN
				W_DescripAbs = W_DescripAbs:ENR_RUBSAISIE<1>:" - "
			END
		      W_IDescrip = 0
		      W_TrouveDescrip = "F"
		      
		      W_DescripAbs = W_DescripAbs:" Le ":OCONV(W_DateDebMoi,"D4/")
			
			IF W_HreDebMoi < W_HreDebInterv THEN
				W_HreDebMoi = W_HreDebInterv
			END
			IF W_HreFinMoi > W_HreFinInterv THEN
				W_HreFinMoi = W_HreFinInterv
			END
			
			W_LibInterv = W_LibInterv:"MOI":W_HreDebMoi"R%4":W_HreFinMoi"R%4"

		   END


		END		
	   END
	
	END

  REPEAT
END
RETURN

2200 **************************************************************************
*				Traitement des remplacements : 				*
* Restriction des interventions  celles concernes par l'absence			*
*******************************************************************************
*READ ENR_ABSENCESAIDANT FROM F.ABSENCESAIDANT, CodeAbsRempl THEN
	W_Sortie2 = ""
	FOR i = 1 TO NbJours
		
		k = 0
		LOOP
		k = k + 1
		WHILE W_Sortie<i,1,k> # "" 
		   IF (W_Sortie<i,1,k>[1,6]="CONGES" AND W_Sortie<i,1,k>[7,12]=CodeAbsRempl) OR (W_Sortie<i,1,k>[1,5]="ARRET" AND W_Sortie<i,1,k>[6,12]=CodeAbsRempl) THEN
			t = k
			LOOP
			t = t + 1
			WHILE W_Sortie<i,1,t> # ""	
			   IF INDEX(W_Sortie<i,1,t>,"Interv",1) # 0 AND LEN(W_Sortie<i,1,t>)=7 THEN
				IF W_Sortie<i,2,t> < W_Sortie<i,3,k> AND W_Sortie<i,3,t> > W_Sortie<i,2,k> THEN
				   * Intervention pendant l'absence concerne
				   IF INDEX(W_Sortie2,W_Sortie<i,4,t>[1,26],1) = 0 THEN
					W_Sortie2<-1> = W_Sortie<i,4,t>[1,26]
				   END
				END
			   END
			REPEAT
		   END
		REPEAT
		
	NEXT i
	* Tri des inteventions par code aide, par activit, par jour puis par heure :
	W_CountReqDetails = 1
      LOOP WHILE W_CountReqDetails # 0
         W_CountReqDetails = 0
         i = 0
	   LOOP
		i = i + 1	
         WHILE W_Sortie2<i + 1> # ""
            IF W_Sortie2<i>[6, 5]:W_Sortie2<i>[17,10] > W_Sortie2<i+1>[6, 5]:W_Sortie2<i+1>[17,10] THEN
            	W_AncAide = W_Sortie2<i + 1>
            	W_Sortie2<i + 1> = W_Sortie2<i>
            	W_Sortie2<i> = W_AncAide
            	W_CountReqDetails = W_CountReqDetails + 1
            END
         REPEAT
      REPEAT
	W_Sortie = W_Sortie2
*END
RETURN

*************************************************************************
*	Transformation des interventions les jours fris en MOI :		*
*  n'effectuer que si l'aidant a au mons trois mois d'anciennet		*
* IMPORTANT : ne pas utiliser variablmes i, k , etc...			*
*************************************************************************
2300
W_Exclu2300 = "V"
ENR_RAPPORT<-1> = "** 2300 **"
W_Date2300 = DateDeb+i-1
IF W_TypeActEnCours # "M" THEN
	* Prestataire, intermdiaire, SSIAD
	EXECUTE 'SELECT CONTRAT AVEC CodeAidant = "':W_TabAidant<i,4,k>[1,5]:'" AND AVEC ConvColContrat # "02" AND AVEC SupprContrat # "O" AND AVEC AssocContrat = "':Asso:'" AND AVEC DatDebContrat <= "':W_Date2300:'" AND AVEC DatFinContrat >= "':W_Date2300:'" OR = ""'
ENR_RAPPORT<-1> = "Req : ":'SELECT CONTRAT = "':W_TabAidant<i,4,k>[1,5]:']" AVEC 1 # "02" AND AVEC 65 # "O" AND AVEC 2 = "':Asso:'" AND AVEC 7 <= "':W_Date2300:'" AND AVEC 8 >= "':W_Date2300:'" OR = ""'  

END ELSE
	* Mandataire
	EXECUTE 'SELECT CONTRAT AVEC CodeAidant = "':W_TabAidant<i,4,k>[1,5]:'" AND AVEC CodeAide = "':W_TabAidant<i,4,k>[6,5]:'" AND AVEC SupprContrat # "O" AND AVEC AssocContrat = "':Asso:'" AND AVEC DatDebContrat <= "':W_Date2300:'" AND AVEC DatFinContrat >= "':W_Date2300:'" OR = ""'
ENR_RAPPORT<-1> = "Req : ":'SELECT CONTRAT = "':W_TabAidant<i,4,k>[1,5]:']" AVEC 3 = "':W_TabAidant<i,4,k>[6,5]:'" AND AVEC 65 # "O" AND AVEC 2 = "':Asso:'" AND AVEC 7 <= "':W_Date2300:'" AND AVEC 8 >= "':W_Date2300:'" OR = ""'  

END

W_Fin2300 = "F"
LOOP
READNEXT W_Cle2300 ELSE W_Fin2300 = "V"
WHILE W_Fin2300 = "F"
	READ ENR_CONTRAT FROM F.CONTRAT, W_Cle2300 THEN
		IF W_Date2300-ENR_CONTRAT<7> >= 89 THEN
			W_Exclu2300 = "F"
		END
	END	
REPEAT
ENR_RAPPORT<-1> = "Resultat : exclu = ":W_Exclu2300 
RETURN

*************************************************************************
*	Transformation des interventions les jours fris en MOI :		*
* Chercher la rubrique jours fris non travaill a associer  la MOI	*
* IMPORTANT : ne pas utiliser variablmes i, k , etc...			*
*************************************************************************
2400
W_Rub2400 = "999"
i2400 = 0
W_Trouve2400 = "F"
LOOP
i2400 = i2400+1
WHILE ENR_TPSPARAMBASCUL<5,i2400> # "" AND W_Trouve2400 = "F"
	IF ENR_TPSPARAMBASCUL<5,i2400> = W_TabAidant<i,6,k> THEN
	   IF ENR_TPSPARAMBASCUL<9,i2400> # "" THEN
		W_Rub2400 = ENR_TPSPARAMBASCUL<9,i2400>
	   END
	   W_Trouve2400 = "V"
	END
REPEAT
RETURN


*************************************************************************
*		Convertit W_Hre2500 qui est en centiemmes 			*
* vers l'heure en minutes et en texte						*
*************************************************************************
2500
IF LEN(W_Hre2500) = 3 THEN
	W_Texte2500 = W_Hre2500[1,1]:"h"
	W_Cent2500 = W_Hre2500[2,2]
END ELSE
	W_Texte2500 = INT(W_Hre2500[1,2]):"h"
	W_Cent2500 = W_Hre2500[3,2]
END
W_Cent2500 = INT(W_Cent2500 /100 * 60 + 1/2)
W_Texte2500 = W_Texte2500:W_Cent2500"R%2"
W_Texte2500 = W_Texte2500
RETURN
