<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000023" 
	label="RH. Analyse population"
	database="iCTI" 
	swf="*CTI_view1" 
	globals="RH_globals.XML" 
	componentsFile="RH_components.XML" 
	softCode="iCTI_rh"
	dboptimizer="RH_dboptimizer.XML"
	helpDokuWIkiDir="rh:vues:population" helpDokuWIkiFile="rh000023"  helpFile=""
>
	<title>
		<![CDATA[	
			=
			var periode:String = '';
			periode = ' de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL;
			return 'Analyse population par ' +  SELECT.GROUPBY_LABEL + periode;
		]]>
	</title>
	<VIEWPROPERTIES componentName="PROPERTIES_CONTRAT"/>
	<VIEWPROPERTIES componentName="PROPERTIES_GROUPBY"/>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Date">
			<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="" UI="combo" tree="true" width="200" default="2010-01-31" globalListProvider="PERIODE_FIN" />
		</GROUP>
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" label="" UI="combo" width="200" default="SAL" tree="true" >
				<OPTION label="[DICT.RH.SALARIE#1]" data="SAL" treeLevel="1" globalListProvider="SALARIE_GROUPBY"/>
				<OPTION label="[DICT.RH.CONTRAT#1]" data="CNT" treeLevel="1" globalListProvider="CONTRAT_GROUPBY"/>
				<OPTION label="Temporel" data="MOIACT" treeLevel="1" globalListProvider="TEMPOREL_GROUPBY"/>
				<OPTION label="Référentiel SAE" data="REFERENTIEL_SAE" treeLevel="1" globalListProvider="REFERENTIEL_SAE_GROUPBY"/>
			</FIELD>
			<FIELD name="GROUPBY_TAB" width="100" label="Présentation" UI="combo" default="AUTO" visible="= SELECT.GROUPBY_2 != '-1' ">
				<OPTION label="Automatique" data="AUTO"/>
				<OPTION label="Arbre" data="TREE"/>
				<OPTION label="Onglet" data="TAB"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_2" label="" width="200" UI="combo" default="-1" tree="true" >
				<OPTION label="Pas de second niveau" data="-1"/>
				<OPTION label="[DICT.RH.SALARIE#1]" data="SAL" treeLevel="1" globalListProvider="SALARIE_GROUPBY"/>
				<OPTION label="[DICT.RH.CONTRAT#1]" data="CNT" treeLevel="1" globalListProvider="CONTRAT_GROUPBY"/>
				<OPTION label="Temporel" data="MOIACT" treeLevel="1" globalListProvider="TEMPOREL_GROUPBY"/>
				<OPTION label="Référentiel SAE" data="REFERENTIEL_SAE" treeLevel="1" globalListProvider="REFERENTIEL_SAE_GROUPBY"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_3" label="" width="200" UI="combo" default="-1" tree="true" >
				<OPTION label="Pas de troisième niveau" data="-1"/>
				<OPTION label="[DICT.RH.SALARIE#1]" data="SAL" treeLevel="1" globalListProvider="SALARIE_GROUPBY"/>
				<OPTION label="[DICT.RH.CONTRAT#1]" data="CNT" treeLevel="1" globalListProvider="CONTRAT_GROUPBY"/>
				<OPTION label="Temporel" data="MOIACT" treeLevel="1" globalListProvider="TEMPOREL_GROUPBY"/>
				<OPTION label="Référentiel SAE" data="REFERENTIEL_SAE" treeLevel="1" globalListProvider="REFERENTIEL_SAE_GROUPBY"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<!-- <SELECTIONS componentName="FILTRES_CONTRAT_SOUSSELECTIONS"/> -->
	<SELECTIONS componentName="FILTRES_SALARIES_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_CONTRATS_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_REFERENTIEL_SAE_SELECTIONS"/>
	<QUERIES>
		<QUERY label=""> 
			<SQL optimizer="V_CNT_X" optimizer2="V_ALL_X">
				<select><![CDATA[		

					CTISELECT_TREE
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
						GROUPBY3{[VIEW.GROUPBY_3_OID_FIELD],, [VIEW.GROUPBY_3_COD_FIELD],, [VIEW.GROUPBY_3_TXT_FIELD]}
						OPTIONS{NOTZERO=1}
						INDICATORS{
							count(DISTINCT v_rh_view_1.salarie_id),
							count(DISTINCT CASE WHEN v_rh_view_1.sexe_code = 'M' THEN v_rh_view_1.salarie_id ELSE null END),
							count(DISTINCT CASE WHEN v_rh_view_1.sexe_code IS DISTINCT FROM 'M' THEN v_rh_view_1.salarie_id ELSE null END),
							0 - count(DISTINCT CASE WHEN v_rh_view_1.sexe_code = 'M' THEN v_rh_view_1.salarie_id ELSE null END),
							count(DISTINCT CASE WHEN v_rh_view_1.sexe_code IS DISTINCT FROM 'M' THEN v_rh_view_1.salarie_id ELSE null END),
							base.cti_avg_distinct_on(DISTINCT ARRAY[salarie_id::numeric, age_id::numeric]),
							AVG(anciennete_mois) / 12,
							AVG(anciennete_reprise_mois) / 12,
							count(DISTINCT CASE WHEN nationalite_section_code[9] = 'FR' THEN v_rh_view_1.salarie_id ELSE null END),
							count(DISTINCT CASE WHEN nationalite_section_code[9] = 'UE' THEN v_rh_view_1.salarie_id ELSE null END),
							count(DISTINCT CASE WHEN nationalite_section_code[9] = 'ET' THEN v_rh_view_1.salarie_id ELSE null END)
						}
					FROM #V_CNT_X##V_ALL_X#
					WHERE 1=1
						AND v_rh_view_1.date_fin_activite BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						AND est_hors_periode IS DISTINCT FROM '1'
						[VIEW.SALARIES_SELECT]
						[VIEW.CONTRATS_SELECT]
						[VIEW.REFERENTIEL_SAE_SELECT]
						
					;
					
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="NSAL" />
					<FIELD name="NSALM" />
					<FIELD name="NSALF" />
					<FIELD name="NSALMPYR" />
					<FIELD name="NSALFPYR" />
					<FIELD name="AGEM" />
					<FIELD name="ANCM" />
					<FIELD name="ANCREPMOY" />
					<FIELD name="NATFR" />
					<FIELD name="NATUE" />
					<FIELD name="NATET" />
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Liste des contrats" shortLabel="Liste contrats" view="RH000006.XML" componentName="RH_VIEWLINK" >
				<ARGS name="SPEC" >
					<value><![CDATA[
						if(SELECT.GROUPBY_2 == 'ANNACT' && ROW.OID2 != '-9999999'){
							LINKVARIABLES['PERIODE'] = ROW.COD2.toString()+'-01-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD2.toString()+'-12-31';
						}
						if(SELECT.GROUPBY == 'ANNACT'){
							LINKVARIABLES['PERIODE'] = ROW.COD1.toString()+'-01-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD1.toString()+'-12-31';
						}
						if(SELECT.GROUPBY_2 == 'MOIACT' && ROW.OID2 != '-9999999'){
							var lastDay:Date = new Date(Number(ROW.COD2.toString().substr(0,4)), Number(ROW.COD2.toString().substr(4,2)), 0);
							LINKVARIABLES['PERIODE'] = ROW.COD2.toString().substr(0,4)+'-'+ROW.COD2.toString().substr(4,2)+'-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD2.toString().substr(0,4)+'-'+ROW.COD2.toString().substr(4,2)+'-'+lastDay.getDate();
						}
						if(SELECT.GROUPBY == 'MOIACT'){
							var lastDay:Date = new Date(Number(ROW.COD1.toString().substr(0,4)), Number(ROW.COD1.toString().substr(4,2)), 0);
							LINKVARIABLES['PERIODE'] = ROW.COD1.toString().substr(0,4)+'-'+ROW.COD1.toString().substr(4,2)+'-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD1.toString().substr(0,4)+'-'+ROW.COD1.toString().substr(4,2)+'-'+lastDay.getDate();
						}
						LINKVARIABLES['GROUPBY_2'] = 'CNT';
						return 'OK';
					]]></value>
				</ARGS>
			</VIEWLINK>
			<VIEWLINK label="Liste des [DICT.RH.SALARIE#4]" shortLabel="Liste [DICT.RH.SALARIE#4]" view="RH000006.XML" componentName="RH_VIEWLINK" >
				<ARGS name="SPEC" >
					<value><![CDATA[
						if(SELECT.GROUPBY_2 == 'ANNACT' && ROW.OID2 != '-9999999'){
							LINKVARIABLES['PERIODE'] = ROW.COD2.toString()+'-01-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD2.toString()+'-12-31';
						}
						if(SELECT.GROUPBY == 'ANNACT'){
							LINKVARIABLES['PERIODE'] = ROW.COD1.toString()+'-01-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD1.toString()+'-12-31';
						}
						if(SELECT.GROUPBY_2 == 'MOIACT' && ROW.OID2 != '-9999999'){
							var lastDay:Date = new Date(Number(ROW.COD2.toString().substr(0,4)), Number(ROW.COD2.toString().substr(4,2)), 0);
							LINKVARIABLES['PERIODE'] = ROW.COD2.toString().substr(0,4)+'-'+ROW.COD2.toString().substr(4,2)+'-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD2.toString().substr(0,4)+'-'+ROW.COD2.toString().substr(4,2)+'-'+lastDay.getDate();
						}
						if(SELECT.GROUPBY == 'MOIACT'){
							var lastDay:Date = new Date(Number(ROW.COD1.toString().substr(0,4)), Number(ROW.COD1.toString().substr(4,2)), 0);
							LINKVARIABLES['PERIODE'] = ROW.COD1.toString().substr(0,4)+'-'+ROW.COD1.toString().substr(4,2)+'-01';
							LINKVARIABLES['TOPERIODE'] = ROW.COD1.toString().substr(0,4)+'-'+ROW.COD1.toString().substr(4,2)+'-'+lastDay.getDate();
						}
						LINKVARIABLES['GROUPBY_2'] = 'SAL';
						return 'OK';
					]]></value>
				</ARGS>
			</VIEWLINK>
		</VIEWLINKS>		
		<ONGLET label="Onglet" multiTab="true" >
		
			<CHART title="Pyramide" type="barChart" subType="overlaid" sortField="COD" sortSeq="A" maxItems="150" visibleCondition="SELECT.GROUPBY.substr(0,6) == 'AGECLS' || SELECT.GROUPBY == 'AGE' || SELECT.GROUPBY.substr(0,6) == 'ANCCLS' || SELECT.GROUPBY == 'ANC'" condition="ROW.LVL == '1'">
				<CATEGORY field="TXT" type="Number"/>
				<SERIEx field="NSAL" displayName="Total"/>
				<SERIE field="NSALMPYR" displayName="Hommes"/>
				<SERIE field="NSALFPYR" displayName="Femmes"/>
			</CHART>
			<CHART title="Sexes" type="pieChart" subType="" fromTotal="true" serieIsCategory="true" visibleCondition="SELECT.GROUPBY.substr(0,6) == 'AGECLS' || SELECT.GROUPBY == 'AGE' || SELECT.GROUPBY.substr(0,6) == 'ANCCLS' || SELECT.GROUPBY == 'ANC'">
				<CATEGORY field="TXT" type="Number"/>
				<SERIE field="NSALM" displayName="Hommes"/>
				<SERIE field="NSALF" displayName="Femmes"/>
			</CHART>
			<CHART title="Décomposition masculin/féminin" type="columnChart" subType="" sortField="NSAL" sortSeq="D" maxItems="20" maxItemsSortOn="NSAL" maxItemsSortSeq="D" visibleCondition="SELECT.GROUPBY.substr(0,6) != 'AGECLS' &amp;&amp; SELECT.GROUPBY != 'AGE' &amp;&amp; SELECT.GROUPBY.substr(0,6) != 'ANCCLS' &amp;&amp; SELECT.GROUPBY != 'ANC'">
				<CATEGORY field="COD" type="Number"/>
				<SERIE field="NSAL" displayName="Total"/>
				<SERIE field="NSALM" displayName="Hommes"/>
				<SERIE field="NSALF" displayName="Femmes"/>
			</CHART>
			<CHART title="Age moyen" type="lineChart" subType="" sortField="NSAL" sortSeq="D" maxItems="20" maxItemsSortOn="NSAL" maxItemsSortSeq="D" visibleCondition="SELECT.GROUPBY.substr(0,6) != 'AGECLS' &amp;&amp; SELECT.GROUPBY != 'AGE'" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY.substr(0,6) != 'ANCCLS' &amp;&amp; SELECT.GROUPBY != 'ANC'">
				<CATEGORY field="COD" type="Number"/>
				<SERIE field="AGEM" displayName="Age moyen"/>
			</CHART>
			<DATAGRID 	title="" 
						total="true" 
						headerHeight="40" 
						selectRowInRows="= ROW.OID == '-9999997'" 
						otherRowInRows="= ROW.OID == '-9999998'" 
						totalRowInRows="= ROW.OID == '-9999999'"
						variableRowHeight="true" 
						sortable="= SELECT.GROUPBY_3 == '-1' &amp;&amp; (SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB')"> 
				
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				
				<COLUMN dataField="OID"
					type="Number"
					visible="false" />
				<COLUMN dataField="COD" 
					type="Char" 
					width="90"
					outputFormat="#"
					headerText="Code" 
					textAlign="left" 
					totalComplement="*ROW">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="NSALMPYR"
					type="Number"
					visible="false" />
				<COLUMN dataField="NSALFPYR"
					type="Number"
					visible="false" />
				<COLUMN dataField="TXT" 
					type="Char" 
					minWidth="110"
					headerText="Texte" 
					textAlign="left" 
					totalComplement="*ROW"/>
				<COLUMN dataField="NSAL" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Nb [DICT.RH.SALARIE#3]" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="PSAL" 
					type="Number" 
					width="70"
					outputFormat="#,0%"
					headerText="% [DICT.RH.SALARIE#3]" 
					textAlign="right"
					totalComplement="" 
					calc="true">
					<CALC formula="ROW.NSAL / TOTALROW.NSAL * 100" />
				</COLUMN>
				<COLUMN dataField="NSALM" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Nb [DICT.RH.SALARIE#3] Hommes" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NSALF" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Nb [DICT.RH.SALARIE#3] Femmes" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="PFEM" 
					type="Number" 
					width="70"
					outputFormat="#,0%"
					headerText="% Femmes" 
					textAlign="right"
					totalComplement="" 
					calc="true">
					<CALC formula="ROW.NSALF / ROW.NSAL * 100" />
				</COLUMN>
				<COLUMN dataField="AGEM" 
					type="Number" 
					width="80"
					outputFormat="#,0"
					headerText="Age moyen" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="ANCM" 
					type="Number" 
					width="80"
					outputFormat="#,0"
					headerText="Ancienneté Etablissement moyenne" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="ANCREPMOY" 
					type="Number" 
					width="80"
					outputFormat="#,0"
					headerText="Ancienneté Reprise moyenne" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NATFR" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Nationalité Française" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NATUE" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Nationalité Européenne" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="NATET" 
					type="Number" 
					width="80"
					outputFormat="#"
					headerText="Nationalité Etrangère" 
					textAlign="right"
					totalComplement="*ROW" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
