<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000140"
     label="RH. Ventilation Capsante"
     title="= 'Ventilation Capsante ' + ' de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL "
     database="iCTI"
     swf="*CTI_view1"
     globals="RH_globals.XML"
     dboptimizer="RH_dboptimizer.XML"
     componentsFile="RH_components.XML"
     visibleKeys="consolidationOnly"
     softCode="iCTI_rh">
    <VIEWPROPERTIES componentName="PROPERTIES_PAIE"/>
    <VIEWPROPERTIES componentName="PROPERTIES_GROUPBY"/>
    <VIEWPROPERTIES>
        <PROPERTY name="VENTILATION_CAPSANTE" value="1" />
        <PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
        <PROPERTY name="ORDERBY">
            <value><![CDATA[[EVAL 
					
					$groupBys = array(
						'[GROUPBY]', 
						'[GROUPBY_2]', 
						'[GROUPBY_3]'
					);
					$exceptions = array('AMCAL', 'ATRIMCAL', 'ACAL', 'MCAL', 'TRIMCAL', 'AMACT', 'ATRIMACT', 'AACT', 'MACT', 'TRIMACT');
					
					$result = array_intersect($groupBys, $exceptions);
					
					if (count($result) > 0) {
						return "DEFAULT";
					} else {
						return "indicateurs[19]";
					}
					
			EVAL]]]></value>
        </PROPERTY>
    </VIEWPROPERTIES>
    <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>
        <GROUP label="Regroupement">
            <FIELD name="GROUPBY" label="" UI="combo" width="250" default="RUP" tree="true" >
                <OPTION label="Ventilation Capsante Entreprise" data="" treeLevel="1" globalListProvider="VENTILATION_CAPSANTE_ENTREPRISE_GROUPBY"/>
                <OPTION label="Paie" data="RUP" treeLevel="1" globalListProvider="PAIE_GROUPBY"/>
                <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_PAIE_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="250" UI="combo" default="-1" tree="true" >
                <OPTION label="Pas de second niveau" data="-1"/>
                <OPTION label="Ventilation Capsante Entreprise" data="" treeLevel="1" globalListProvider="VENTILATION_CAPSANTE_ENTREPRISE_GROUPBY"/>
                <OPTION label="Paie" data="RUP" treeLevel="1" globalListProvider="PAIE_GROUPBY"/>
                <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_PAIE_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="250" UI="combo" default="-1" tree="true" >
                <OPTION label="Pas de troisième niveau" data="-1"/>
                <OPTION label="Ventilation Capsante Entreprise" data="" treeLevel="1" globalListProvider="VENTILATION_CAPSANTE_ENTREPRISE_GROUPBY"/>
                <OPTION label="Paie" data="RUP" treeLevel="1" globalListProvider="PAIE_GROUPBY"/>
                <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_PAIE_GROUPBY"/>
                <OPTION label="Référentiel SAE" data="REFERENTIEL_SAE" treeLevel="1" globalListProvider="REFERENTIEL_SAE_GROUPBY"/>
            </FIELD>
        </GROUP>
    </SELECTIONS>
    <SELECTIONS componentName="FILTRES_SALCNT_SOUSSELECTIONS"/>
    <SELECTIONS componentName="FILTRES_PAIE_SELECTIONS"/>
    <SELECTIONS componentName="FILTRES_SALARIES_SELECTIONS"/>
    <SELECTIONS componentName="FILTRES_CONTRATS_SELECTIONS"/>
    <SELECTIONS componentName="FILTRES_REFERENTIEL_SAE_SELECTIONS"/>
    <QUERIES>
        <QUERY label="">
            <SQL optimizer="V_HP_X" optimizer2="V_ALL_X">
                <select><![CDATA[
					CTISELECT_TREE
                        WORKTABLE{RH000140}
						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]}
						SIGNIFDATA{[VIEW.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
						OPTIONS{NOTZERO=1}
						ORDERBY{[VIEW.ORDERBY],, DESC}
						INDICATORS{
                            SUM(v_rh_view_1.montant_brut * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)::double precision),                            
                            SUM(v_rh_view_1.montant_cotisation_patronale * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)::double precision),
                            SUM(v_rh_view_1.montant_masse_salariale * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)::double precision),
                            SUM(v_rh_view_1.heures_contrat * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)::double precision),
                            base.cti_division(SUM(v_rh_view_1.etp_contrat * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)),
                            SUM(v_rh_view_1.heures_payees * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)::double precision),
                            base.cti_division(SUM(v_rh_view_1.etp_paye * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)),
                            SUM(v_rh_view_1.heures_travaillees * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)::double precision),
                            base.cti_division(SUM(v_rh_view_1.etp_travaille * COALESCE(v_ventilation_capsante_1.ventilation_capsante_ratio::numeric / 100::numeric, 1::numeric)), base.cti_months_between('[PERIODE]'::date, '[TOPERIODE]'::date)),
						}
                    FROM #V_HP_X##V_ALL_X#
                    LEFT JOIN rh.v_ventilation_capsante_1 ON 
                        v_ventilation_capsante_1.ventilation_capsante_salarie_id = v_rh_view_1.salarie_id AND
                        v_ventilation_capsante_1.ventilation_capsante_mois_paie = v_rh_view_1.mois_paie_id AND
						v_ventilation_capsante_1.ventilation_capsante_ratio > 0
					WHERE 1=1
						AND v_rh_view_1.date_paie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.PAIE_SELECT]
						[VIEW.SALARIES_SELECT]
						[VIEW.CONTRATS_SELECT]
						[VIEW.REFERENTIEL_SAE_SELECT]
                ]]></select>
                <FIELDS>
                    <INSERT name="CTISELECT_TREE_FIELDS"/>
                    <FIELD name="SORT" /><!-- colonne exploitée pour le mécanisme de tri uniquement ORDERBY{indicateur[7]} -->
                    <FIELD name="MBRU" />
                    <FIELD name="MCOP" />
                    <FIELD name="MBRP" />
                    <FIELD name="NHEC" />
                    <FIELD name="NETPC" />
                    <FIELD name="NHEU" />
                    <FIELD name="NETP" />
                    <FIELD name="NHTR" />
                    <FIELD name="NETPT" />
                </FIELDS>
            </SQL>
        </QUERY>
        <QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
            <SQL>
                <select><![CDATA[
                        SELECT 'X_PERIODE_D', greatest(('[PERIODE]'::date - '1 year'::interval)::date, (SELECT (min(mois)::text||'01')::date FROM rh.p_chiffrier_production))::text
                    UNION ALL
                        SELECT 'X_TOPERIODE_D', greatest(('[TOPERIODE]'::date - '1 year'::interval)::date, (SELECT (min(mois)::text||'01')::date FROM rh.p_chiffrier_production))::text
                    UNION ALL
                        SELECT 'X_PERIODE', greatest(('[PERIODE]'::date - '3 years'::interval)::date, (SELECT (min(mois)::text||'01')::date FROM rh.p_chiffrier_production))::text
                ]]></select>
                <FIELDS>
                    <FIELD name="name" />
                    <FIELD name="value" />
                </FIELDS>
            </SQL>
            <SQL>
                <select><![CDATA[
				
						SELECT 
							'QAJUST',
							COALESCE(CASE WHEN valeur = '1' THEN '1' ELSE '0' END,'0')
						FROM rh.t_divers
                        WHERE code = 'OCTIME_TPS_VALIDE_A'
						;
							
				]]></select>
                <FIELDS>
                    <FIELD name="name"/>
                    <FIELD name="value"/>
                </FIELDS>
            </SQL>
        </QUERY>
    </QUERIES>
    <PRESENTATION>
<!--        <VIEWLINKS>
            <VIEWLINK label="Evolution" shortLabel="Evolution" view="RH000135.XML" enabled="true" rowContext="false" componentName="PERIODICITE_VIEWLINK" buttonType="EVOLUTION">
            </VIEWLINK>
            <VIEWLINK label="Justificatif" shortLabel="Justificatif" view="RH000136.XML" componentName="RH_VIEWLINK" >
                <ARGS name="SPEC" >
                    <value><![CDATA[
                        LINKVARIABLES['GROUPBY_2'] = 'SAL'
                        return 'OK';
                    ]]></value>
                </ARGS>
            </VIEWLINK>
        </VIEWLINKS>-->
        <ONGLET label="Temps" multiTab="true" >
            <DATAGRID
                    title=""
                    total="true"
                    headerHeight="54"
                    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="TXT"
                        type="Char"
                        minWidth="110"
                        headerText="Texte"
                        textAlign="left"
                        totalComplement="*ROW"/>
                <COLUMN dataField="MBRU"
                        type="Number"
                        width="100"
                        outputFormat="#E"
                        headerText="Brut"
                        textAlign="right"
                        fixed="false"
                        totalComplement="*ROW" />
                <COLUMN dataField="MCOP"
                        type="Number"
                        width="90"
                        outputFormat="#E"
                        headerText="Cotisations Patronales"
                        textAlign="right"
                        fixed="false"
                        totalComplement="*ROW" />
                <COLUMN dataField="MBRP"
                        type="Number"
                        width="100"
                        outputFormat="#E"
                        headerText="Masse salariale"
                        description="&lt;i&gt;Brut&lt;/i&gt; + &lt;i&gt;Cotisations patronales&lt;/i&gt; + &lt;i&gt;OD/Net patronales&lt;/i&gt; + &lt;i&gt;Avantages en nature&lt;/i&gt; + &lt;i&gt;Frais imposables&lt;/i&gt;"
                        textAlign="right"
                        totalComplement="*ROW" />
                <COLUMN dataField="NHEC"
                        type="Number"
                        width="70"
                        outputFormat="#"
                        headerText="Heures contrat"
                        description="Heures issues de la rubrique de paie paramétrée comme &#171;&lt;i&gt;Heures contrat&lt;/i&gt;&#187; dans la table des rubriques."
                        textAlign="right"
                        totalComplement="*ROW" />
                <COLUMN dataField="NETPC"
                        type="Number"
                        width="70"
                        outputFormat="#,00"
                        headerText="ETP contrat"
                        description="Equivalent temps plein basé sur les &lt;i&gt;Heures contrat&lt;/i&gt;.&#xD;&#xD;Heures contrat &#247; Base de calcul de l'ETP (par défaut 151,67 h.) &#247; Nb mois de la période."
                        textAlign="right"
                        totalComplement="*ROW" />
                <COLUMN dataField="NHEU"
                        type="Number"
                        width="70"
                        outputFormat="#"
                        headerText="Heures payées"
                        description="Heures issues de la rubrique de paie paramétrée comme &#171;&lt;i&gt;Heures payées&lt;/i&gt;&#187; dans la table des rubriques."
                        textAlign="right"
                        totalComplement="*ROW" />
                <COLUMN dataField="NETP"
                        type="Number"
                        width="70"
                        outputFormat="#,00"
                        headerText="ETP payé"
                        description="Equivalent temps plein basé sur les &lt;i&gt;Heures payées&lt;/i&gt;.&#xD;&#xD;Heures payées &#247; Base de calcul de l'ETP (par défaut 151,67 h.) &#247; Nb mois de la période."
                        textAlign="right"
                        totalComplement="*ROW" />
                <COLUMN dataField="NHTR"
                        type="Number"
                        width="70"
                        outputFormat="#"
                        headerText="Heures travaillées"
                        description="Heures paramétrées comme &#171;&lt;i&gt;travaillées&lt;/i&gt;&#187; OU heures payées - heures paramétrées comme &#171;&lt;i&gt;Heures non travaillées&lt;/i&gt;&#187;."
                        textAlign="right"
                        fixed="false"
                        totalComplement="*ROW" />
                <COLUMN dataField="NETPT"
                        type="Number"
                        width="70"
                        outputFormat="#,00"
                        headerText="ETP travaillé"
                        description="Equivalent temps plein basé sur les &lt;i&gt;Heures travaillées&lt;/i&gt;.&#xD;&#xD;Heures travaillées &#247; Base de calcul de l'ETP (par défaut 151,67 h.) &#247; Nb mois de la période."
                        textAlign="right"
                        totalComplement="*ROW" />
            </DATAGRID>
        </ONGLET>
    </PRESENTATION>
</VUE>