<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000025" 
    label="RH. Indicateurs de planning" 
    title="= 'Indicateurs de planning par ' +  SELECT.GROUPBY_LABEL + ' de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL " 
    database="iCTI" 
    swf="*CTI_view1" 
    globals="RH_globals.XML" 
    dboptimizer="RH_dboptimizer.XML"
    componentsFile="RH_components.XML" 
    softCode="iCTI_rh">
    <VIEWPROPERTIES componentName="PROPERTIES_PLANNING"/>
    <VIEWPROPERTIES componentName="PROPERTIES_GROUPBY"/>
    <VIEWPROPERTIES>
        <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[3]";
                }
                    
            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_JOUR" />
            <FIELD name="TOPERIODE" label="au" UI="combo" tree="true" width="200" default="2010-01-31" globalListProvider="PERIODE_FIN_JOUR" />
        </GROUP>
        <GROUP label="Regroupement">
            <FIELD name="GROUPBY" label="" UI="combo" width="200" default="SAL" tree="true" >
                <OPTION label="Entreprise" data="ENT" treeLevel="1" globalListProvider="ENTREPRISE_GROUPBY"/>
                <OPTION label="Planning" data="PLA" treeLevel="1" globalListProvider="PLANNING_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_PLANNING_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="Entreprise" data="ENT" treeLevel="1" globalListProvider="ENTREPRISE_GROUPBY"/>
                <OPTION label="Planning" data="PLA" treeLevel="1" globalListProvider="PLANNING_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_PLANNING_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="Entreprise" data="ENT" treeLevel="1" globalListProvider="ENTREPRISE_GROUPBY"/>
                <OPTION label="Planning" data="PLA" treeLevel="1" globalListProvider="PLANNING_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_PLANNING_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_PLANNING_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_SALARIES_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_CONTRATS_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_REFERENTIEL_SAE_SELECTIONS"/>
    <QUERIES>
        <QUERY label=""> 
            <SQL optimizer="V_PLA_X" optimizer2="V_ALL_X">
                <select><![CDATA[
                    
                    CTIPREPAR_TREE
                        WORKTABLE{rh000028_du} 
                        GROUPBY1{[VIEW.GROUPBY_OID_FIELD_DU],, [VIEW.GROUPBY_COD_FIELD_DU],, [VIEW.GROUPBY_TXT_FIELD_DU]}
                        GROUPBY1MODE{[GROUPBY_TAB]}
                        GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD_DU],, [VIEW.GROUPBY_2_COD_FIELD_DU],, [VIEW.GROUPBY_2_TXT_FIELD_DU]}
                        GROUPBY3{[VIEW.GROUPBY_3_OID_FIELD_DU],, [VIEW.GROUPBY_3_COD_FIELD_DU],, [VIEW.GROUPBY_3_TXT_FIELD_DU]}
                        SIGNIFDATA{[VIEW.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
                        OPTIONS{NOTZERO=1}
                        ORDERBY{[VIEW.ORDERBY],, DESC}
                        INDICATORS{
                            SUM(v_rh_view_1.temps_du),,
                            SUM(v_rh_view_1.temps_du_ajuste),,
                        }
                        
                    FROM #V_PLA_X##V_ALL_X#
                    WHERE 1=1
                        AND v_rh_view_1.date_fin_activite BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.SALARIES_SELECT]
						[VIEW.CONTRATS_SELECT]
						[VIEW.REFERENTIEL_SAE_SELECT]
                        [VIEW.PLANNING_SELECT]

                ]]></select>
            </SQL>
            <SQL optimizer="V_PLA_X" optimizer2="V_ALL_X">
                <select><![CDATA[

                    CTISELECT_TREE
                        WORKTABLE{rh000028} 
                        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{
                            count(DISTINCT v_rh_view_1.salarie_id),,
                            SUM(v_rh_view_1.temps_du_initial),,
                            0,,
                            SUM(v_rh_view_1.temps_du),,
                            0,,
                            SUM(v_rh_view_1.temps_valide),,
                            0,,
                            SUM(v_rh_view_1.temps_du) - SUM(v_rh_view_1.temps_valide),,
                            0,,
                            SUM(v_rh_view_1.temps_absence),,
                            0,,
                            SUM(v_rh_view_1.temps_absence),,
                            
                            SUM(v_rh_view_1.temps_du_ajuste),,
                            0,,
                            SUM(v_rh_view_1.temps_valide_ajuste),,
                            0,,
                            SUM(v_rh_view_1.temps_presence_ajuste),,
                            0,,
                            SUM(v_rh_view_1.temps_absence),,
                            0,,
                            SUM(v_rh_view_1.temps_absence),,

                        }
                    FROM #V_PLA_X##V_ALL_X#
                    WHERE 1=1
                        AND v_rh_view_1.date_fin_activite BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.SALARIES_SELECT]
						[VIEW.CONTRATS_SELECT]
						[VIEW.REFERENTIEL_SAE_SELECT]
                        [VIEW.PLANNING_SELECT]
                        [VIEW.PLANNING_ABSENCE_SELECT]

                    AFTER{ 
                        UPDATE rh000028 SET 
                            indicateurs[12] = base.cti_division(rh000028.indicateurs[12] , COALESCE(rh000028_du.indicateurs[1],0)) * 100.00,
                            indicateurs[21] = base.cti_division(rh000028.indicateurs[21] , COALESCE(rh000028_du.indicateurs[2],0)) * 100.00                             
                        FROM rh000028 rh000028_bis
                            LEFT JOIN rh000028_du ON    (rh000028_du.oidt = rh000028_bis.oidt OR rh000028_du.oidt = -111) AND 
                                            (rh000028_du.oid1 = rh000028_bis.oid1 OR rh000028_du.oid1 = -111) AND 
                                            (rh000028_du.oid2 = rh000028_bis.oid2 OR rh000028_du.oid2 = -111) AND 
                                            (rh000028_du.oid3 = rh000028_bis.oid3 OR rh000028_du.oid3 = -111) 
                        WHERE rh000028_bis.oidt = rh000028.oidt AND 
                            rh000028_bis.oid1 = rh000028.oid1 AND 
                            rh000028_bis.oid2 = rh000028.oid2 AND 
                            rh000028_bis.oid3 = rh000028.oid3 
						.,
						UPDATE rh000028 SET
							indicateurs[3] = indicateurs[2]/base_etp,
							indicateurs[5] = indicateurs[4]/base_etp,
							indicateurs[7] = indicateurs[6]/base_etp,
							indicateurs[9] = indicateurs[8]/base_etp,
							indicateurs[11] = indicateurs[10]/base_etp,
							indicateurs[14] = indicateurs[13]/base_etp,
							indicateurs[16] = indicateurs[15]/base_etp,
							indicateurs[18] = indicateurs[17]/base_etp,
							indicateurs[20] = indicateurs[19]/base_etp
						FROM (
							SELECT 
								CASE 
								WHEN MAX(t_divers.valeur) = '1' THEN sum(nb_jour_ouvre)*7.22
								WHEN MAX(t_divers.valeur) = '2' THEN sum(nb_jour_semaine)*7
								ELSE count(DISTINCT date_trunc('month',date)) * 151.67 
								END AS base_etp 
							FROM base.v_calendrier_indicateurs_1 
							LEFT JOIN rh.t_divers ON t_divers.code = 'PLANNING_BASE_ETP' 
							WHERE date BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							) subview
                    }
                        
                        
                ]]></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="NSAL" />
                    <FIELD name="HRDUI" />
                    <FIELD name="ETDUI" />
                    <FIELD name="HRDU" />
                    <FIELD name="ETDU" />
                    <FIELD name="HRVAL" />
                    <FIELD name="ETVAL" />
                    <FIELD name="HRECA" />
                    <FIELD name="ETECA" />
                    <FIELD name="HRABS" />
                    <FIELD name="ETABS" />
                    <FIELD name="TXABS" />
                    
                    <FIELD name="HRDUA" />
                    <FIELD name="ETDUA" />
                    <FIELD name="HRVALA" />
                    <FIELD name="ETVALA" />
                    <FIELD name="HRPRE" />
                    <FIELD name="ETPRE" />
                    <FIELD name="HRABSA" />
                    <FIELD name="ETABSA" />
                    <FIELD name="TXABSA" />
                    
                </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="Comparatif" shortLabel="Comparatif" view="RH000029.XML" enabled="true" rowContext="false" buttonType="COMPARATIF">
                <ARG name="PERIODE_D" value="return VIEW.X_PERIODE_D;" />
                <ARG name="TOPERIODE_D" value="return VIEW.X_TOPERIODE_D;" />
                <ARG name="DATA1" value="'HRVAL'" />
                <ARG name="DATA2" value="''" />
                <ARG name="DATA3" value="''" />
            </VIEWLINK>
            <VIEWLINK label="Evolution" shortLabel="Evolution" view="RH000028.XML" enabled="true" rowContext="false" componentName="PERIODICITE_VIEWLINK" buttonType="EVOLUTION">
                <ARG name="DATA" value="'HRVAL'" />
            </VIEWLINK>
            <VIEWLINK label="Analyse croisée" shortLabel="Analyse croisée" view="RH000027.XML" enabled="true" rowContext="false" buttonType="ANALYSE_CROISEE">
                <ARG name="PERIODE" value="return VIEW.X_PERIODE;" />
                <ARG name="DATA" value="'HRVAL'" />
                <ARG name="COLUMNBY" value="'PQU'" />
                <ARG name="GROUPBY" value="return SELECT.GROUPBY;" />
                <ARG name="GROUPBY_TAB" value="'TAB'" />
                <ARG name="GROUPBY_2" value="''" />
                <ARG name="COLUMNBYCOUNT" value="'12'" />
            </VIEWLINK>
            <VIEWLINK label="Justificatif" shortLabel="Justificatif" view="RH000026.XML" componentName="RH_VIEWLINK" >
                <ARGS name="SPEC" >
                    <value><![CDATA[
                        LINKVARIABLES['GROUPBY_2'] = 'SAL'
                        return 'OK';
                    ]]></value>
                </ARGS>
            </VIEWLINK>
        </VIEWLINKS>        
        <ONGLET label="Temps" multiTab="true" >
            <CHART title="" type="group" subType="h" percentHeight="100" maxItems="10">
                <CHART title="Temps Dus/Validés" condition="ROW.LVL == '1'" type="columnChart" subType="" fromTotal="false"  >
                    <CATEGORY field="COD" type="Char" />
                    <SERIE field="HRDU" displayName="Temps Du"/>
                    <SERIE field="HRVAL" displayName="Temps Validé" />
                </CHART>
                <CHART title="Temps Absences" condition="ROW.LVL == '1'" type="columnChart" subType="" fromTotal="false"  >
                    <CATEGORY field="COD" type="Char" />
                    <SERIE field="HRABS" displayName="Temps Absence" />
                </CHART>
            </CHART>
            <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="NSAL" 
                    type="Number" 
                    width="80"
                    outputFormat="#"
                    headerText="Nb [DICT.RH.SALARIE#3]" 
                    textAlign="right"
                    totalComplement="*ROW" />
				<COLUMN dataField="HRPRE" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Temps Présence(H)" 
                    textAlign="right"
                    totalComplement="*ROW" />
				<COLUMN dataField="ETPRE" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Temps Présence(ETP)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="HRDUI" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Temps Du Initial(H)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="ETDUI" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0"
                    headerText="Temps Du Initial (ETP)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="HRDU" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Temps Du (H)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="ETDU" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0"
                    headerText="Temps Du (ETP)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="HRVAL" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Temps Validé (H)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="ETVAL" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0"
                    headerText="Temps Validé (ETP)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="HRECA" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Ecart@LF@(H)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="ETECA" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0"
                    headerText="Ecart@LF@(ETP)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="HRABS" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0h"
                    headerText="Temps Absence (H)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="ETABS" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0"
                    headerText="Temps Absence (ETP)" 
                    textAlign="right"
                    totalComplement="*ROW" />
                <COLUMN dataField="TXABS" 
                    type="Number" 
                    width="80"
                    outputFormat="#,0%"
                    headerText="Taux Absence (%)" 
                    textAlign="right"
                    totalComplement="*ROW" />
            </DATAGRID>
        </ONGLET>
        
    </PRESENTATION>
</VUE>
