<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000097" label="RH. Contrôles SHS Public" title="RH. Contrôles SHS Public" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_rh"
	rhProvider="shspub"
	helpDokuWIkiDir="rh:vues:controles" helpDokuWIkiFile="rh000097"  helpFile=""
>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer=""> 
				<select><![CDATA[		
				
					-- error_level :
					-- * 0 : avertissement/non bloquant/donnée automatiquement rectifiée
					-- * 1 : grave/bloquant/non traité
				
					DROP TABLE IF EXISTS w_erreur
					;

					CREATE TEMP TABLE w_erreur AS

					SELECT
						0 AS error_level,
						acdagt AS salarie,
						'\xa0\xbb Salarié : date de naissance incorrecte'::text AS erreur,
						'Valeur actuelle : ' || adtnai::text || '. Valeur prise par défaut : 1962-04-14' AS commentaire
					FROM prod_shspub.pippub184_agentp
					WHERE to_date(adtnai, 'YYYYMMDD') NOT BETWEEN '1900-01-01'::date AND now()::date

					/*
					UNION ALL

					SELECT 
						acdagt,
						'\xa0\xbb Affectation : date de début non renseignée' AS erreur,
						(sum(CASE WHEN dtdu IS NULL OR char_length(dtdu) = 0 THEN 1 ELSE 0 END) - 1)::text || ' date(s) non renseignée(s)'
					FROM prod_shspub.grh_histo_affec
					GROUP BY 1
					HAVING sum(CASE WHEN dtdu IS NULL OR char_length(dtdu) = 0 THEN 1 ELSE 0 END) > 1
					*/
					;

					(
						SELECT
							0,
							1,
							acdagt,
							acdagt AS salarie,
							count(*)::text||' erreur(s)',
							''
						FROM w_erreur
							JOIN prod_shspub.pippub184_agentp ON pippub184_agentp.acdagt = w_erreur.salarie
						WHERE 1=1
						GROUP BY 1,2,3
					)
					UNION ALL
					(
						SELECT
							error_level,
							2,
							salarie,
							'',
							w_erreur.erreur,
							w_erreur.commentaire
						FROM w_erreur
							JOIN prod_shspub.pippub184_agentp ON pippub184_agentp.acdagt = w_erreur.salarie
						WHERE 1=1
					)
					ORDER BY 3,2
					;
				]]></select>
				<FIELDS>
					<FIELD name="ERL"/>
					<FIELD name="LVL"/>
					<FIELD name="MAT"/>
					<FIELD name="SAL"/>
					<FIELD name="ERR"/>
					<FIELD name="COM"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<ONGLET label="Affectations - Date début > Date fin" queryNumber="0" newPage="true">
			<DATAGRID sortable="false">
				<ROWSTYLE name="backgroundColor" value="0xFFFF99" condition="ROW.LVL == '1'" />
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.LVL == '1'" />
				<COLUMN dataField="ERL"  type="Number" headerText="Erreur"	    width="80"  visible="false" />
				<COLUMN dataField="LVL"  type="Number" headerText="Niveau"	    width="80"  visible="false" />
				<COLUMN dataField="SAL"  type="Char"   headerText="[DICT.RH.SALARIE#1]"		width="80"  >
					<CELLSTYLE name="cellIndicator" value="circle, 5, right center, 0xFF0000" condition="ROW.ERL == '1'" />
				</COLUMN>
				<COLUMN dataField="ERR"  type="Char"   headerText="Erreur"   	width="300" />
				<COLUMN dataField="COM"  type="Char"   headerText="Commentaire" width="350" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
