<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE 
	name="ACTI000136" 
	essential="false" 
	comment="inutilisé"
	label="Essentiels SSR Activité" 
	title="= 'Essentiels SSR Activité' +  ' (' + VIEW.CURRENT_HEAD + ')'" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_activite" 
	skipFirstSelection="true" 
	globals="ACTI_globals.XML" 
	componentsFile="ACTI_components.XML" 
	helpFile="iCTI_ACTI_ACTI000229.HTML" 

	activeIf= 
	
	"[EVAL 
		if (file_exists('../../../modules/pmsissr/settings.xml')) {
			return true;
		};
		return false;
	EVAL]"

>
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
		<PROPERTY name="CONSO_VIEWLINK_PARAM">
			<value><![CDATA[[EVAL 
				
				if ('[ENV.CONSOLIDATION]' == '1') {
					
					return "regexp_replace(
										regexp_replace(
											regexp_replace(
												rub.viewlink_param, 
												'GROUPBY_2=[A-Z0-9_-]+', 
												replace(substring(rub.viewlink_param from 'GROUPBY=[A-Z0-9_-]+'), 'GROUPBY', 'GROUPBY_2')
											),
											'GROUPBY=[A-Z0-9_-]+',
											'GROUPBY=FIN'),
										'GROUPBY_TAB=(TREE|TAB|AUTO)', 
										'GROUPBY_TAB=TAB'
									)
								AS viewlink_param";
				} 
				else {
					return "rub.viewlink_param AS viewlink_param";
				} 
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="CONSO_VIEWLINK_LABEL">
			<value><![CDATA[[EVAL 
				
				if ('[ENV.CONSOLIDATION]' == '1') {
					
					return "regexp_replace(rub.viewlink_label, 'par(.+)et(.+)', E'par\\\\1') AS viewlink_label";
				} 
				else {
					return "rub.viewlink_label AS viewlink_label";
				} 
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DECIMALS">
			<value><![CDATA[[EVAL 
				
				return "CASE WHEN rub.output_format <> '' THEN rub.output_format::text ELSE ind.output_format::text END";
				
			EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="WHERE">
			<value><![CDATA[[EVAL 
				
				if ('[PERIODE]' == 'MONTH' && '[MOIS_ESSENTIELS]' != '-1') {
					return "AND date_trunc('month', date_comptable) <= date_trunc('month', '[MOIS_ESSENTIELS]'::date)";
				}
				else {
					return "AND montant_comptabilise_s_c > 0";
				}
				
			EVAL]]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	<VIEWPROPERTIES componentName="PROPERTIES_RSS"/>
	<VIEWPROPERTIES componentName="PROPERTIES_SELECT_TABTREE"/>
	<SELECTIONS label="" displayText="">
		<GROUP label="Période à  analyser">
			<FIELD name="PERIODE" width="170" label="" UI="combo" default="LAST" visible="= SELECT.GROUPBY_2 != '-1' ">
				<OPTION label="Dernier mois comptable" data="LAST" />
				<OPTION label="Autre mois comptable..." data="MONTH" />
			</FIELD>
			<FIELD name="MOIS_ESSENTIELS" label="" UI="combo" width="170" tree="true" default="-1" globalListProvider="MOIS_ESSENTIELS" printable="false" visible="= SELECT.PERIODE == 'MONTH'" />
		</GROUP>
	</SELECTIONS>
	<QUERIES>
		<QUERY label="Onglet 1">
			<SQL>
				<select><![CDATA[ 
				
						SELECT
							ind.code,
							ind.texte,
							CASE WHEN rub.entete <> '' THEN rub.entete ELSE ind.entete END AS entete,
							CASE WHEN rub.entete_etendue <> '' THEN rub.entete_etendue ELSE ind.entete_etendue END AS entete_etendue,
							base.cti_round(p1.value_cum, [VIEW.DECIMALS]) AS current_value,
							base.cti_round(p2.value_cum, [VIEW.DECIMALS]) AS previous_value,
							base.cti_round(p1.value, [VIEW.DECIMALS]) AS current_month_value,
							base.cti_round(p2.value, [VIEW.DECIMALS]) AS previous_month_value,
							CASE WHEN rub.output_format similar to '%(!%|ans|jours)' escape '!' OR ind.output_format similar to '%(!%|ans|jours)' escape '!' THEN to_char(base.cti_round(p1.value_cum, [VIEW.DECIMALS]) - base.cti_round(p2.value_cum, [VIEW.DECIMALS]), '999.0') ELSE to_char(100 * base.cti_division((base.cti_round(p1.value_cum, [VIEW.DECIMALS]) - base.cti_round(p2.value_cum, [VIEW.DECIMALS])), base.cti_round(p2.value_cum, [VIEW.DECIMALS])), '999.0') END as tendance,
							CASE WHEN rub.output_format similar to '%(!%|ans|jours)' escape '!' OR ind.output_format similar to '%(!%|ans|jours)' escape '!' THEN to_char(base.cti_round(p1.value, [VIEW.DECIMALS]) - base.cti_round(p2.value, [VIEW.DECIMALS]), '999.0') ELSE to_char(100 * base.cti_division((base.cti_round(p1.value, [VIEW.DECIMALS]) - base.cti_round(p2.value, [VIEW.DECIMALS])), base.cti_round(p2.value, [VIEW.DECIMALS])), '999.0') END as tendance_month,
							CASE WHEN rub.output_format <> '' THEN rub.output_format ELSE ind.output_format END AS output_format,
							CASE WHEN rub.width <> 0 THEN rub.width ELSE ind.width END AS width,
							rub.periode_reference AS periode_ref,
							rub.row_height,
							rub.padding,
							rub.font_size,
							rub.font_weight,
							rub.border_thickness AS border_thick,
							rub.color,
							rub.background_color AS bkgd_color,
							rub.base_nationale AS base_nationale,
							rub.base_nationale_qualifiee AS base_nationale_qualifiee,
							rub.viewlink AS viewlink,
							[VIEW.CONSO_VIEWLINK_LABEL],
							[VIEW.CONSO_VIEWLINK_PARAM],
							rub.picto_enabled AS picto_enabled,
							rub.positif_is_good AS positif_is_good,
							t_rapports.code as rapport_code
						FROM 
							activite.t_rapports
							JOIN activite.t_rapports_rubriques rub ON rub.rapport_id = t_rapports.oid
							JOIN activite.t_indicateurs ind ON ind.oid = rub.indicateur_id
							LEFT JOIN activite.p_indicateurs_cumules p1 ON p1.indicateur_id = ind.oid AND p1.date_reference = '[VIEW.CURRENT_DATE]' AND p1.periode_type = 'M'
							LEFT JOIN activite.p_indicateurs_cumules p2 ON p2.indicateur_id = ind.oid AND p2.date_reference = '[VIEW.PREVIOUS_DATE]' AND p2.periode_type = 'M'
						WHERE
							t_rapports.code IN ('ACTI_ESS_1', 'ACTI_ESS_2', 'ACTI_ESS_3', 'ACTI_ESS_4', 'ACTI_ESS_5', 'CTI_PORTFO')
							
						ORDER BY rub.numero_rubrique
					
				]]></select>
				<FIELDS>
					<FIELD name="CODE" />
					<FIELD name="TEXTE" />
					<FIELD name="ENTETE" />
					<FIELD name="ENTETE_ETENDUE" />
					<FIELD name="CURRENT_VALUE" />
					<FIELD name="PREVIOUS_VALUE" />
					<FIELD name="CURRENT_MONTH_VALUE" />
					<FIELD name="PREVIOUS_MONTH_VALUE" />
					<FIELD name="TENDANCE" />
					<FIELD name="TENDANCE_MONTH" />
					<FIELD name="OUTPUT_FORMAT" />
					<FIELD name="WIDTH" />
					<FIELD name="PERIODE_REF" />
					<FIELD name="ROW_HEIGHT" />
					<FIELD name="PADDING" />
					<FIELD name="FONT_SIZE" />
					<FIELD name="FONT_WEIGHT" />
					<FIELD name="BORDER_THICK" />
					<FIELD name="COLOR" />
					<FIELD name="BKGD_COLOR" />
					<FIELD name="BASE_NATIONALE" />
					<FIELD name="BASE_NATIONALE_QUALIFIEE" />
					<FIELD name="VIEWLINK" />
					<FIELD name="VIEWLINK_LABEL" />
					<FIELD name="VIEWLINK_PARAM" />
					<FIELD name="PICTO_ENABLED" />
					<FIELD name="POSITIF_IS_GOOD" />
					<FIELD name="RAPPORT_CODE" />
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL>
				<select><![CDATA[	
				
						SELECT 'CURRENT_DATE', to_char(date_trunc('month', max(date_comptable)), 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'CURRENT_PERIODE', to_char(date_trunc('year', max(date_comptable)), 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'CURRENT_TOPERIODE', to_char((date_trunc('month', max(date_comptable)) + interval '1 month') - interval '1 day', 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'CURRENT_MONTH_PERIODE', to_char(date_trunc('month', max(date_comptable)), 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'PREVIOUS_DATE', to_char(date_trunc('month', max(date_comptable)) - interval '1 year', 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'PREVIOUS_PERIODE', to_char(date_trunc('year', max(date_comptable)) - interval '1 year', 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'PREVIOUS_TOPERIODE', to_char(((date_trunc('month', max(date_comptable)) - interval '1 year') + interval '1 month') - interval '1 day', 'YYYY-MM-DD') FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'CURRENT_HEAD', base.cti_to_french(to_char(date_trunc('year', max(date_comptable)), 'Month')) ||
								CASE WHEN extract('month' from max(date_comptable)) <> 1 THEN 'à  ' || base.cti_to_french(to_char(date_trunc('month', max(date_comptable)), 'Month YYYY')) ELSE to_char(date_trunc('year', max(date_comptable)), ' YYYY') END FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'PREVIOUS_HEAD', base.cti_to_french(to_char(date_trunc('year', max(date_comptable) - interval '1 year'), 'Month')) ||
								CASE WHEN extract('month' from max(date_comptable)) <> 1 THEN 'à  ' || base.cti_to_french(to_char(date_trunc('month', max(date_comptable) - interval '1 year'), 'Month YYYY')) ELSE to_char(date_trunc('year', max(date_comptable) - interval '1 year'), ' YYYY') END FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'CURRENT_MONTH_HEAD', base.cti_to_french(to_char(date_trunc('month', max(date_comptable)), 'Month YYYY')) FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]
					UNION
						SELECT 'PREVIOUS_MONTH_HEAD', base.cti_to_french(to_char(date_trunc('month', max(date_comptable) - interval '1 year'), 'Month YYYY')) FROM activite.t_controle_chiffrier WHERE date_comptable <= CURRENT_DATE [VIEW.WHERE]

				]]></select>
				<FIELDS>
					<FIELD name="name"/>
					<FIELD name="value"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<ONGLET excelLabel="Occupation" label="Occupation">
			<INPUTSELECTION condition="ROW.RAPPORT_CODE == 'ACTI_ESS_5'" />
			<DATAGRID headerHeight="40" variableRowHeight="true" sortable="false">
				
				<ROWSTYLE name="fontSize" value="10"/>
				<ROWSTYLE name="fontSize" value="= ROW.FONT_SIZE.toString()" condition="Number(ROW.FONT_SIZE) &gt;= 8"/>
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.FONT_WEIGHT == 'bold'"/>
				<ROWSTYLE name="borderSides" value="top bottom" condition="Number(ROW.BORDER_THICK) &gt; 0"/>
				<ROWSTYLE name="borderStyle" value="solid" condition="Number(ROW.BORDER_THICK) &gt; 0"/>
				<ROWSTYLE name="borderThickness" value="= ROW.BORDER_THICK.toString()" condition="Number(ROW.BORDER_THICK) &gt; 0"/>
				<ROWSTYLE name="color" value="= ROW.COLOR.toString()" condition="ROW.COLOR != '' "/>
				<ROWSTYLE name="backgroundColor" value="= ROW.BKGD_COLOR.toString()" condition="ROW.BKGD_COLOR != '' "/>
				<ROWSTYLE name="rowHeight" value="= ROW.ROW_HEIGHT.toString()" condition="Number(ROW.ROW_HEIGHT) &gt; 0"/>
				
				<COLUMN dataField="OUTPUT_FORMAT" visible="false" />
				<COLUMN dataField="WIDTH" visible="false" />
				<COLUMN dataField="PERIODE_REF" visible="false" />
				<COLUMN dataField="ROW_HEIGHT" visible="false" />
				<COLUMN dataField="PADDING" visible="false" />
				<COLUMN dataField="FONT_SIZE" visible="false" />
				<COLUMN dataField="FONT_WEIGHT" visible="false" />
				<COLUMN dataField="BORDER_THICK" visible="false" />
				<COLUMN dataField="COLOR" visible="false" />
				<COLUMN dataField="BKGD_COLOR" visible="false" />
				<COLUMN dataField="CODE" visible="false" />
				<COLUMN dataField="TEXTE" visible="false" />
				<COLUMN dataField="ENTETE" visible="false" />
				<COLUMN dataField="VIEWLINK" visible="false" />
				<COLUMN dataField="VIEWLINK_PARAM" visible="false" />
				<COLUMN dataField="PICTO_ENABLED" visible="false" />
				<COLUMN dataField="POSITIF_IS_GOOD" visible="false" />
				<COLUMN dataField="ENTETE_ETENDUE" minWidth="300" type="Char" headerText="Indicateurs">
					<CELLSTYLE name="paddingLeft" value="= ROW.PADDING" condition="Number(ROW.PADDING) &gt; 0"/>
				</COLUMN>
				
				<COLUMN dataField="PREVIOUS_VALUE" width="100" type="Number" headerText="VIEW.PREVIOUS_HEAD" headerTextCalc="true" outputFormat="= ROW.OUTPUT_FORMAT" />
				<COLUMN dataField="CURRENT_VALUE" width="100" type="Number" headerText="VIEW.CURRENT_HEAD" headerTextCalc="true" outputFormat="= ROW.OUTPUT_FORMAT" />
				<COLUMN dataField="TENDANCE" width="65" type="Number" headerText="Tendance" outputFormat="= if (ROW.CODE == 'CTI_SEP') { return '#';} else if (ROW.OUTPUT_FORMAT.search(/(%|ans|jours)/) &gt; -1 ) { if (ROW.TENDANCE &gt; 0) { return '+#,0pt'; } else { return '#,0pt'; }} else { if (ROW.TENDANCE &gt; 0) { return '+0#,0%'; } else { return '0#,0%'; } }">
					<CELLSTYLE name="cellIndicator" value="triangle_down, 10, left middle, 0XD63E00" condition="ROW.PICTO_ENABLED == 1 &amp;&amp; (ROW.TENDANCE &lt; 0 &amp;&amp; ROW.POSITIF_IS_GOOD == 1 || ROW.TENDANCE &gt; 0 &amp;&amp; ROW.POSITIF_IS_GOOD == 0) &amp;&amp; ROW.CODE != 'CTI_SEP'" />
					<!--<CELLSTYLE name="cellIndicator" value="triangle_up, 10, left middle, 0x00AA00" condition="ROW.PICTO_ENABLED == 1 &amp;&amp; (ROW.TENDANCE &gt; 0 &amp;&amp; ROW.POSITIF_IS_GOOD == 1 || ROW.TENDANCE &lt; 0 &amp;&amp; ROW.POSITIF_IS_GOOD == 0) &amp;&amp; ROW.CODE != 'CTI_SEP'" />-->
					<CELLSTYLE name="cellIndicator" value="triangle_up, 10, left middle, 0x75a0eb" condition="ROW.PICTO_ENABLED == 1 &amp;&amp; (ROW.TENDANCE &gt; 0 &amp;&amp; ROW.POSITIF_IS_GOOD == 1 || ROW.TENDANCE &lt; 0 &amp;&amp; ROW.POSITIF_IS_GOOD == 0) &amp;&amp; ROW.CODE != 'CTI_SEP'" />
					<CELLSTYLE name="cellIndicator" value="rectangle, 10, left middle, 0xFFA500" condition="ROW.PICTO_ENABLED == 1 &amp;&amp; ROW.TENDANCE == 0 &amp;&amp; ROW.CODE != 'CTI_SEP'" />
				</COLUMN>

				<COLUMN dataField="PREVIOUS_MONTH_VALUE" width="100" type="Number" headerText="VIEW.PREVIOUS_MONTH_HEAD" headerTextCalc="true" outputFormat="= ROW.OUTPUT_FORMAT" />
				<COLUMN dataField="CURRENT_MONTH_VALUE" width="100" type="Number" headerText="VIEW.CURRENT_MONTH_HEAD" headerTextCalc="true" outputFormat="= ROW.OUTPUT_FORMAT" />
				<COLUMN dataField="TENDANCE_MONTH" width="65" type="Number" headerText="Tendance" outputFormat="= if (ROW.CODE == 'CTI_SEP') { return '#';} else if (ROW.OUTPUT_FORMAT.search(/(%|ans|jours)/) &gt; -1 ) { if (ROW.TENDANCE_MONTH &gt; 0) { return '+#,0pt'; } else { return '#,0pt'; }} else { if (ROW.TENDANCE_MONTH &gt; 0) { return '+0#,0%'; } else { return '0#,0%'; } }" />
				
				<COLUMN dataField="VIEWLINK_LABEL" minWidth="200" type="Viewlink" defaultViewLink="PMSI000008" headerText="Accà¨s aux détails" printable="false" />
			</DATAGRID>
		</ONGLET>
		
		<ONGLET excelLabel="Portfolio" label="Portfolio">
			<INPUTSELECTION condition="ROW.RAPPORT_CODE == 'CTI_PORTFO'" />
			<DATAGRID headerHeight="40" variableRowHeight="true" sortable="false">
				<ROWSTYLE name="fontSize" value="10"/>
				<ROWSTYLE name="fontSize" value="= ROW.FONT_SIZE.toString()" condition="Number(ROW.FONT_SIZE) &gt;= 8"/>
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.FONT_WEIGHT == 'bold'"/>
				<ROWSTYLE name="borderSides" value="top bottom" condition="Number(ROW.BORDER_THICK) &gt; 0"/>
				<ROWSTYLE name="borderStyle" value="solid" condition="Number(ROW.BORDER_THICK) &gt; 0"/>
				<ROWSTYLE name="borderThickness" value="= ROW.BORDER_THICK.toString()" condition="Number(ROW.BORDER_THICK) &gt; 0"/>
				<ROWSTYLE name="color" value="= ROW.COLOR.toString()" condition="ROW.COLOR != '' "/>
				<ROWSTYLE name="backgroundColor" value="= ROW.BKGD_COLOR.toString()" condition="ROW.BKGD_COLOR != '' "/>
				<ROWSTYLE name="rowHeight" value="= ROW.ROW_HEIGHT.toString()" condition="Number(ROW.ROW_HEIGHT) &gt; 0"/>
				
				<COLUMN dataField="OUTPUT_FORMAT" visible="false" />
				<COLUMN dataField="WIDTH" visible="false" />
				<COLUMN dataField="PERIODE_REF" visible="false" />
				<COLUMN dataField="ROW_HEIGHT" visible="false" />
				<COLUMN dataField="PADDING" visible="false" />
				<COLUMN dataField="FONT_SIZE" visible="false" />
				<COLUMN dataField="FONT_WEIGHT" visible="false" />
				<COLUMN dataField="BORDER_THICK" visible="false" />
				<COLUMN dataField="COLOR" visible="false" />
				<COLUMN dataField="BKGD_COLOR" visible="false" />
				<COLUMN dataField="CODE" visible="false" />
				<COLUMN dataField="TEXTE" visible="false" />
				<COLUMN dataField="ENTETE" visible="false" />
				<COLUMN dataField="BASE_NATIONALE" visible="false" />
				<COLUMN dataField="BASE_NATIONALE_QUALIFIEE" visible="false" />
				<COLUMN dataField="VIEWLINK" visible="false" />
				<COLUMN dataField="VIEWLINK_PARAM" visible="false" />
				<COLUMN dataField="PICTO_ENABLED" visible="false" />
				<COLUMN dataField="POSITIF_IS_GOOD" visible="false" />
				<COLUMN dataField="ENTETE_ETENDUE" minWidth="300" type="Char" headerText="Vues">
					<CELLSTYLE name="paddingLeft" value="= ROW.PADDING" condition="Number(ROW.PADDING) &gt; 0"/>
				</COLUMN>
				
				<COLUMN dataField="VIEWLINK_LABEL" minWidth="200" type="Viewlink" defaultViewLink="PMSI000008" headerText="Liens" printable="false" />
			</DATAGRID>
		</ONGLET>
</PRESENTATION>
</VUE>