<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE 
	name="PMSI003694"
	label="PMSI. Analyse LPP Simulation FG 2324 LPP" 
	title="= 'Analyse LPP Simulation FG 2324 par ' +  SELECT.GROUPBY_LABEL + ' (' +   SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_pmsi" 
	globals="PMSI_globals.XML" 
	componentsFile="PMSI_components.XML" 
>
	<VIEWPROPERTIES componentName="PROPERTIES_LPP"/>
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE"/>
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					if (SELECT.LPP != '-1') {display = display + '#B#Analyse LPP#/B# : #B#' + SELECT.LPP_LABEL + '#/B#'}
					return display;
					">
		<GROUP label="Période">
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2023-03-01">
				<OPTION dataLink="DATE_DEBUT" treeLevelField="lvl" dataField="cod" aliasField="alias" data2Field="mois" labelField="txt" />
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2024-02-29" >
				<OPTION dataLink="DATE_FIN" treeLevelField="lvl" dataField="cod" aliasField="alias" data2Field="mois" labelField="txt" />
			</FIELD>
		</GROUP>
		<GROUP label="LPP">
			<FIELD name="LPP" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="LPP" showIfNotDefault="true">
			</FIELD>
		</GROUP>
		<GROUP label="Regroupements">
			<FIELD name="GROUPBY" width="200" label="" UI="combo" default="LPP" tree="true">
				<OPTION label="Options" data="" globalListProvider="LPP_GROUPBY_OPTIONS"/>
			</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" width="200" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1"/>
				<OPTION label="Options" data="" globalListProvider="LPP_GROUPBY_OPTIONS"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_LPP_SOUSSELECTIONS"/>
	<SELECTIONS componentName="FILTRES_RSS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_RSS_X" cacheEnabled="false">
				<select><![CDATA[
    				DROP TABLE IF EXISTS w_lpp_199
    				;
    				CREATE TEMP TABLE w_lpp_199 AS
    					SELECT t_lpp.code as lpp_code 
    						FROM pmsi.t_listes
    							JOIN pmsi.t_listes_contenu ON t_listes_contenu.liste_id = t_listes.oid 
    							JOIN pmsi.t_listes_tables ON t_listes_tables.oid = t_listes.table_id
    							JOIN pmsi.t_lpp ON t_lpp.oid = t_listes_contenu.to_id
    						WHERE 1=1
    							AND t_listes.is_cti = '1' 
    							AND t_listes_tables.name = 't_lpp' 
    							AND t_listes.code = 'CTI_DR23_1L'
    				;
					SELECT [VIEW.SELECT_TABTREE_COLUMNS],
						base.cti_sum_distinct_on(DISTINCT ARRAY[v_rss_1.rss_id::text, v_rss_1.nb_rsa::text]),
						sum(nombre),
						sum(montant_facture),
						sum(nombre) - SUM(CASE WHEN lpp_code IN (SELECT lpp_code FROM w_lpp_199) THEN nombre ELSE 0 END),
						sum(montant_facture) - SUM(CASE WHEN lpp_code IN (SELECT lpp_code FROM w_lpp_199) THEN montant_facture ELSE 0 END),
						0 - SUM(CASE WHEN lpp_code IN (SELECT lpp_code FROM w_lpp_199) THEN nombre ELSE 0 END),
						0 - SUM(CASE WHEN lpp_code IN (SELECT lpp_code FROM w_lpp_199) THEN montant_facture ELSE 0 END) 
					FROM 
						#V_RSS_X#
                        , pmsi.p_simulation_fg2324
                        , pmsi.v_rss_lpp_1,
						[VIEW.SELECT_TABTREE_VIEW]
					WHERE 
						p_simulation_fg2324.rss_id = v_rss_1.rss_id
						AND v_rss_1.rss_id = v_rss_lpp_1.rss_id 
						AND p_simulation_fg2324.est_envoye = '1'
						AND p_simulation_fg2324.est_regroupe = '1'
						AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.LPP_SELECT]
						[VIEW.FILTRE_RSS_SELECT]
						[VIEW.SELECT_TABTREE_WHERE]
					GROUP BY 1,2,3,4,5,6,7,8,9,10,11
					ORDER BY 2,5,7
					;
				]]></select>
				<FIELDS>
					<FIELD name="TABD"/>
					<FIELD name="TABDL"/>
					<FIELD name="TABDLL"/>
					<FIELD name="OID1"/>
					<FIELD name="COD1"/>
					<FIELD name="OID2"/>
					<FIELD name="COD2"/>
					<FIELD name="OID"/>
					<FIELD name="COD"/>
					<FIELD name="TXT"/>
					<FIELD name="LVL"/>
					<FIELD name="NRSS"/>
					<FIELD name="NB12"/>
					<FIELD name="MF12"/>
					<FIELD name="NB13"/>
					<FIELD name="MF13"/>
					<FIELD name="NBEC"/>
					<FIELD name="MFEC"/>
				</FIELDS>
			</SQL>
		</QUERY>
        <QUERY type="comboLink" name="DATE_DEBUT" > 
            <SQL select="SELECT date, alias, texte, mois, level 
				FROM pmsi.v_calendrier_1 
				WHERE date_part('year',date) IN (SELECT annee_sortie FROM pmsi.p_simulation_fg2324 WHERE est_envoye &lt;&gt; '0' GROUP BY 1)" >
                <FIELDS>
                    <FIELD name="cod" />
                    <FIELD name="alias" />
                    <FIELD name="txt" />
                    <FIELD name="mois" />
                    <FIELD name="lvl" />
                </FIELDS>
            </SQL>
        </QUERY>
        <QUERY type="comboLink" name="DATE_FIN" > 
            <SQL select="SELECT date, alias, texte, mois, level 
				FROM pmsi.v_calendrier_2 
				WHERE date_part('year',date) IN (SELECT annee_sortie FROM pmsi.p_simulation_fg2324 WHERE est_envoye &lt;&gt; '0' GROUP BY 1)" >
                <FIELDS>
                    <FIELD name="cod" />
                    <FIELD name="alias" />
                    <FIELD name="txt" />
                    <FIELD name="mois" />
                    <FIELD name="lvl" />
                </FIELDS>
            </SQL>
        </QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Justificatif par RSS" shortLabel="Justificatif RSS" view="PMSI000600.XML" componentName="RSS_BASE_VIEWLINK" component2Name="LPP_VIEWLINK" component3Name="">
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Analyse LPP" label="Analyse LPP" multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
			<DATAGRID title="" total="true" showOthers="true" headerHeight="48" variableRowHeight="true" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'"
				sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'">
				<ROWSTYLE name="rowHeight" value="20" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="backgroundColor" value="0xFFD393" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="borderSides" value="top bottom" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="borderStyle" value="solid" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<ROWSTYLE name="borderThickness" value="2" condition="ROW.LVL == '1' &amp;&amp; SELECT.GROUPBY_2 != '-1' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				<COLUMN dataField="LVL" width="50" type="Char" visible="false" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" />
				<COLUMN dataField="OID1" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD1" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="OID2" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD2" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD" width="80" type="Char" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text">
					<CELLSTYLE name="paddingLeft" value="15" condition="ROW.LVL == '2' &amp;&amp; SELECT.GROUPBY_TAB != 'TAB'"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="200" maxWidth="300" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres" />
				<COLUMN dataField="CODTXT" type="Char" visible="false" totalFunction="text" otherFunction="text" calc="true">
					<CALC formula="ROW.COD + ' ' + ROW.TXT.toString().substr(0,20)"/>
				</COLUMN>
				<COLUMN dataField="NRSS" width="80" type="Number" visible="true" outputFormat="#" headerText="Nb Séjours" textAlign="right" totalFunction="sum" otherFunction="sum" />
				<COLUMN dataField="NB12" width="80" type="Number" visibleCondition="SELECT.GROUPBY == 'LPP' || SELECT.LPP != '-1'" outputFormat="#" headerText="FG 2023 Nb LPP" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="MF12" width="80" type="Number" outputFormat="#E" headerText="FG 2023 Montant LPP" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="NB13" width="80" type="Number" visibleCondition="SELECT.GROUPBY == 'LPP' || SELECT.LPP != '-1'" outputFormat="#" headerText="FG 2024 Nb LPP" textAlign="right" totalFunction="sum" otherFunction="sum">
					<HEADERCELLSTYLE name="color" value="0xff5001"/>
					<CELLSTYLE name="color" value="0xff5001"/>
				</COLUMN>
				<COLUMN dataField="MF13" width="80" type="Number" outputFormat="#E" headerText="FG 2024 Montant LPP" textAlign="right" totalFunction="sum" otherFunction="sum">
					<HEADERCELLSTYLE name="color" value="0xff5001"/>
					<CELLSTYLE name="color" value="0xff5001"/>
				</COLUMN>
				<COLUMN dataField="MFEC" width="80" type="Number" outputFormat="#E" headerText="Ecart. Montant LPP" textAlign="right" totalFunction="sum" otherFunction="sum" />
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>