<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000103" 
	label="SHS - CP"
	database="iCTI" 
	swf="*CTI_view1" 
	globals="RH_globals.XML" 
	componentsFile="RH_components.XML" 
	softCode="iCTI_rh"
	rhProvider="shs">
	<title><![CDATA[	
		=
		var sal:String = '';
        var ets:String = '';

		if (SELECT.NOM != '') {
			sal = ' [DICT.RH.SALARIE#2] ' + SELECT.NOM;
		}
        if (SELECT.ENT != '') {
            ent = ' ent. ' + SELECT.ENT;
        }
        if (SELECT.ETS != '') {
            ets = ' ets. ' + SELECT.ETS;
        }
		
        return 'Suivi CP ' + sal + ent + ets + ' sur période de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL;

	]]></title>	
	<VIEWPROPERTIES componentName="PROPERTIES_PAIE"/>
	<VIEWPROPERTIES componentName="PROPERTIES_GROUPBY"/>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Période">
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2010-01-01" globalListProvider="PERIODE_DEBUT" />
			<FIELD name="TOPERIODE" label="au" UI="combo" tree="true" width="200" default="2010-01-31" globalListProvider="PERIODE_FIN" />
		</GROUP>
	</SELECTIONS>
	<SELECTIONS label="Filtres" displayText="">
        <GROUP label="Entreprise">
            <FIELD name="ENT" label="" UI="text" tree="true" width="200" default="" showIfNotDefault="true" />
        </GROUP>
		<GROUP label="Etablissement">
			<FIELD name="ETS" label="" UI="text" tree="true" width="200" default="" showIfNotDefault="true" />
		</GROUP>
		<GROUP label="Nom [DICT.RH.SALARIE#2]">
			<FIELD name="NOM" label="" UI="text" tree="true" width="200" default="" showIfNotDefault="true" />
		</GROUP>	
	</SELECTIONS>	
	<QUERIES>
		<QUERY label=""> 
			<SQL>
				<select><![CDATA[

					SELECT
						j0cent AS entreprise,
						j0cets AS etablissement,
						f8cmat AS matricule,
						f3nom || ' ' || f3pren AS prenom,
						f3nomp AS nomp,
						f3noss AS no_secu,
						f3ncss AS cle_secu,
						f3sexe AS sexe,
						max(jours_dus_A),
						max(jours_pris_A),
						max(base_CP_A),
						max(mont_paye_CP_A),
						max(jours_dus_A_1),
						max(jours_pris_A_1),
						max(base_CP_A_1),
						max(mont_paye_CP_A_1),
						max(jours_dus_A_2),
						max(jours_pris_A_2),
						max(base_CP_A_2),
						max(mont_paye_CP_A_2),
						max(solde_RC),
						max(solde_heur_recup),
						max(j0tcnt) AS typ_contrat,
						max(g2lpar) AS service,
						max(g1lpar) AS qualif,
						max(t_statuts.texte_court) AS statut
					FROM prod_shs.rhlibh_j0p01
						JOIN
							(SELECT
								f8cent,
								f8cets,
								f8cmat,
								f8dtpa,
								f8dtpm,
								sum(f8cpd0) AS jours_dus_A,
								sum(f8cpp0) AS jours_pris_A,
								sum(f8cpb0) AS base_CP_A,
								sum(f8cpm0) AS mont_paye_CP_A,
								sum(f8cpd1) AS jours_dus_A_1,
								sum(f8cpp1) AS jours_pris_A_1,
								sum(f8cpb1) AS base_CP_A_1,
								sum(f8cpm1) AS mont_paye_CP_A_1,
								sum(f8cpd2) AS jours_dus_A_2,
								sum(f8cpp2) AS jours_pris_A_2,
								sum(f8cpb2) AS base_CP_A_2,
								sum(f8cpm2) AS mont_paye_CP_A_2,
								sum(f8hrrc) AS solde_RC,
								sum(f8hrec) AS solde_heur_recup
							FROM prod_shs.rhlib_f8p01
							WHERE 1=1
								--AND rh.cti_to_date(f8dtpa, f8dtpm, '01') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
								AND f8dtpa||lpad(f8dtpm, 2, '0') = substr('[TOPERIODE]', 1, 4)||substr('[TOPERIODE]', 6, 2)
                                AND CASE WHEN nullif(trim('[ENT]'), '') IS NULL THEN TRUE ELSE f8cent::int = COALESCE(nullif(trim('[ENT]'), '')::int, 0) END
                                AND CASE WHEN nullif(trim('[ETS]'), '') IS NULL THEN TRUE ELSE f8cets::int = COALESCE(nullif(trim('[ETS]'), '')::int, 0) END
							GROUP BY 1,2,3,4,5) AS subq ON 1=1
								AND subq.f8cent = j0cent
								AND subq.f8cets = j0cets
								AND subq.f8cmat = j0cmat
								AND subq.f8dtpa = j0dfpa
								AND subq.f8dtpm = j0dfpm
						JOIN prod_shs.rhlib_f3p01 ON 1=1
							AND f3cent = j0cent
							--AND f3cets = j0cets
							AND f3cmat = j0cmat
						LEFT JOIN prod_shs.rhlib_g2p01 ON 1=1
							AND g2cent = j0cent
							AND g2cets = j0cets
							AND g2srvc = j0srvc
						LEFT JOIN prod_shs.rhlib_g1p01 ON 1=1
							AND g1cent = j0cent
							AND g1cets = j0cets
							AND g1cqua = j0cqua
						LEFT JOIN rh.t_statuts ON t_statuts.code_original = j0cstt
                    WHERE 1=1
                        AND CASE WHEN nullif(trim('[NOM]'), '') IS NULL THEN TRUE ELSE f3nom || ' ' || f3pren ilike trim('%[NOM]%') END
					GROUP BY 1,2,3,4,5,6,7,8
					ORDER BY 1,2,3,4,5,6,7,8

				]]></select>		
				<FIELDS>
					<FIELD name="ETA"/>
					<FIELD name="ETT"/>
					<FIELD name="MAT"/>
					<FIELD name="SAL"/>
					<FIELD name="NMP"/>
					<FIELD name="NSS"/>
					<FIELD name="CSS"/>
					<FIELD name="SEX"/>
					<FIELD name="JD1"/>
					<FIELD name="JP1"/>
					<FIELD name="BA1"/>
					<FIELD name="MT1"/>
					<FIELD name="JD2"/>
					<FIELD name="JP2"/>
					<FIELD name="BA2"/>
					<FIELD name="MT2"/>
					<FIELD name="JD3"/>
					<FIELD name="JP3"/>
					<FIELD name="BA3"/>
					<FIELD name="MT3"/>
					<FIELD name="SRC"/>
					<FIELD name="SHR"/>
					<FIELD name="CNT"/>
					<FIELD name="SER"/>
					<FIELD name="QUA"/>
					<FIELD name="STA"/>			
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<ONGLET excellabel="Suivi compteurs REC">
			<DATAGRID title="" total="true" headerHeight="36" variableRowHeight="true" totalRowInRows="= ROW.MOI == '-9999999'">
			   	<COLUMN dataField="ETT" type="Char" width="50" visible="true" headerText="Ent."/>
				<COLUMN dataField="MAT" type="Char" width="50" visible="true" headerText="Matr"/>
				<COLUMN dataField="SAL" type="Char" minWidth="130" maxWidth="250"  visible="true" headerText="[DICT.RH.SALARIE#1]"/>

				<COLUMN dataField="JD1" type="Number" outputFormat="#,00" width="60" headerText="J.dus A" align="right" totalFunction="sum" />
				<COLUMN dataField="JP1" type="Number" outputFormat="#,00" width="60" headerText="J.pris A" align="right" totalFunction="sum" />
				<COLUMN dataField="BA1" type="Number" outputFormat="#,00" width="60" headerText="Base CP A" align="right" totalFunction="sum" />
				<COLUMN dataField="MT1" type="Number" outputFormat="#,00" width="60" headerText="Payé CP A" align="right" totalFunction="sum" />
				<COLUMN dataField="SD1" type="Number" outputFormat="#,00" width="60" headerText="Solde A"  align="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.JD1 - ROW.JP1"/>
				</COLUMN>

				<COLUMN dataField="JD2" type="Number" outputFormat="#,00" width="60" headerText="J.dus A-1" align="right" totalFunction="sum" />
				<COLUMN dataField="JP2" type="Number" outputFormat="#,00" width="60" headerText="J.pris A-1" align="right" totalFunction="sum" />
				<COLUMN dataField="BA2" type="Number" outputFormat="#,00" width="60" headerText="Base CP A-1" align="right" totalFunction="sum" />
				<COLUMN dataField="MT2" type="Number" outputFormat="#,00" width="60" headerText="Payé CP A-1" align="right" totalFunction="sum" />
				<COLUMN dataField="SD2" type="Number" outputFormat="#,00" width="60" headerText="Solde A-1"  align="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.JD2 - ROW.JP2"/>
				</COLUMN>

				<COLUMN dataField="JD3" type="Number" outputFormat="#,00" width="60" headerText="J.dus A-2" align="right" totalFunction="sum" />
				<COLUMN dataField="JP3" type="Number" outputFormat="#,00" width="60" headerText="J.pris A-2" align="right" totalFunction="sum" />
				<COLUMN dataField="BA3" type="Number" outputFormat="#,00" width="60" headerText="Base CP A-2" align="right" totalFunction="sum" />
				<COLUMN dataField="MT3" type="Number" outputFormat="#,00" width="60" headerText="Payé CP A-2" align="right" totalFunction="sum" />
				<COLUMN dataField="SD3" type="Number" outputFormat="#,00" width="60" headerText="Solde A-2"  align="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.JD3 - ROW.JP3"/>
				</COLUMN>

				<COLUMN dataField="SDT" type="Number" outputFormat="#,00" width="60" headerText="Solde Total"  align="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.JD1 - ROW.JP1 + ROW.JD2 - ROW.JP2 + ROW.JD3 - ROW.JP3"/>
				</COLUMN>

				<COLUMN dataField="SRC" type="Number" outputFormat="#,00" width="60" headerText="Solde RC" align="right" totalFunction="sum" />
				<COLUMN dataField="SHR" type="Number" outputFormat="#,00" width="60" headerText="Solde HRec" align="right" totalFunction="sum" />
				<COLUMN dataField="CNT" type="Char" width="50" visible="true" headerText="Cont."/>
				<COLUMN dataField="SER" type="Char" minWidth="80" maxWidth="120" visible="true" headerText="Service"/>
				<COLUMN dataField="QUA" type="Char" minWidth="80" maxWidth="120" visible="true" headerText="Qualification"/>
				<COLUMN dataField="STA" type="Char" minWidth="80" maxWidth="120" visible="true" headerText="Statut"/>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
