<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ACTI000035" 
	label="Synthèse comparative" 
	database="iCTI" swf="*CTI_view1" 
	softCode="iCTI_activite"
	globals="ACTI_globals.XML"
	componentsFile="ACTI_components.XML">
	<title><![CDATA[=	
		
		var group_by_label = '';
		if (SELECT.GROUPBY != '-1') {
			group_by_label = ' par ' + SELECT.GROUPBY_LABEL;
		}
		if (SELECT.GROUPBY_2 != '-1') {
			group_by_label = group_by_label + ' et ' + SELECT.GROUPBY_2_LABEL;
		}

		return SELECT.RAPPORT_LABEL + ' comparatif ' + group_by_label + ' (' + VIEW.DATECOMPTITLE + ') - ' + VIEW.JOUROUVRE_LABEL;
		
	]]></title>
	
	<VIEWPROPERTIES componentName="PROPERTIES_RAPPORT" />
	
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse">
		<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="150" default="2007-01-01" globalListProvider="DATE_DEBUT" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="150" default="2007-01-31" globalListProvider="DATE_FIN" >
			</FIELD>
			<!--<FIELD name="PERIODE_REF" label="Période de réf. pour la comparaison" UI="check" selectedValue="1" unselectedValue="0" default="0" showIfNotDefault="true" />-->
		</GROUP>
		<GROUP label="Comparer avec">
			<FIELD name="TYPE_COMPARAISON" label="" UI="combo" default="S" width="200">
				<OPTION label="Pas de comparaison" data="-1" />
				<OPTION label="Année précédente" data="2" />
				<OPTION label="Deux années précédentes" data="3" />
				<OPTION label="Trois années précédentes" data="4" />
				<OPTION label="Saisie période" data="S" />
			</FIELD>
			<FIELD name="PERIODE_D" label="" UI="combo" tree="true" width="150" default="2006-01-01" globalListProvider="DATE_DEBUT" visible="= SELECT.TYPE_COMPARAISON == 'S'">
			</FIELD>
			<FIELD name="TOPERIODE_D" label="à" UI="combo" tree="true" width="150" default="2006-01-31" globalListProvider="DATE_FIN" visible="= SELECT.TYPE_COMPARAISON == 'S'">
			</FIELD>
		</GROUP>
		<!--
		<GROUP label="Année suppl.">
			<FIELD name="ANNEE_SUPP_OPTION" label="" UI="combo" tree="false" width="100" default="-1" globalListProvider="ANNEE_SUPP" enabled="= SELECT.TYPE_COMPARAISON != '-1'" />
		</GROUP>
		-->
		<GROUP label="Options">
			<FIELD name="LASTMONTH_OPTION" label="" UI="combo" default="-1" width="200" enabled="= SELECT.TYPE_COMPARAISON != '-1'">
				<OPTION label="" data="-1" />
				<OPTION label="Comparaison du dernier mois" data="LASTMONTH" />
				<OPTION label="Comparaison avec budget période" data="BUDGET" />
				<OPTION label="Comparaison avec budget total" data="BUDGETT" />
			</FIELD>
			<FIELD name="MODE_COMPARAISON" label="Comparer par rapport à" UI="combo" default="PREC" width="200" enabled="= SELECT.TYPE_COMPARAISON != '-1'" showIfNotDefault="true">
				<OPTION label="Période précédente" data="PREC" />
				<OPTION label="Première période (+ ancienne)" data="FIRST" />
				<OPTION label="Dernière période (+ récente)" data="LAST" />
			</FIELD>
		</GROUP>
		<GROUP label="Rapport">
			<FIELD name="RAPPORT" label="" UI="combo" tree="true" default="-1" globalListProvider="RAPPORT" width="400">
			</FIELD>
		</GROUP>
		
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" label="" UI="combo" default="-1" tree="true" width="200">
				<OPTION label="" data="-1" />
				<OPTION label="SEJOUR_GROUPBY" data="" globalListProvider="SEJOUR_GROUPBY"/>
				<OPTION label="Mois" data="MOIS" />
			</FIELD>
			<FIELD name="GROUPBY_TAB" label="Présentation" UI="combo" default="AUTO" >
				<OPTION label="Automatique" data="AUTO" />
				<OPTIONx label="Arbre" data="TREE" />
				<OPTION label="Onglet" data="TAB" />
			</FIELD>
		</GROUP>
		<GROUP label="Niveaux suivants">
			<FIELD name="GROUPBY_2" label="" UI="combo" default="-1" tree="true" width="200">
				<OPTION label="" data="-1" />
				<OPTION label="SEJOUR_GROUPBY" data="" globalListProvider="SEJOUR_GROUPBY"/>
				<OPTION label="Mois" data="MOIS" />
			</FIELD>
			<FIELD name="GROUPBY_3" label="" UI="combo" default="-1" tree="true">
				<OPTION label="" data="-1" />
				<OPTION label="SEJOUR_GROUPBY" data="" globalListProvider="SEJOUR_GROUPBY"/>
				<OPTION label="Mois" data="MOIS" />
			</FIELD>
		</GROUP>
		
	</SELECTIONS>
	
	<SELECTIONS componentName="FILTRES_SEJOURS_RAPPORTS_SELECTIONS" />
	
	

	<QUERIES>
	
		<QUERY label=""> 
		
			<SQL optimizer="" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_BUDGET_P,, }
						GROUPBY1{[VIEW.GROUPBY_BUDGET_OID_FIELD],, [VIEW.GROUPBY_BUDGET_COD_FIELD],, [VIEW.GROUPBY_BUDGET_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						GROUPBY2{[VIEW.GROUPBY_2_BUDGET_OID_FIELD],, [VIEW.GROUPBY_2_BUDGET_COD_FIELD],, [VIEW.GROUPBY_2_BUDGET_TXT_FIELD]}
						GROUPBY3{[VIEW.GROUPBY_3_BUDGET_OID_FIELD],, [VIEW.GROUPBY_3_BUDGET_COD_FIELD],, [VIEW.GROUPBY_3_BUDGET_TXT_FIELD]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_BUDGET],
						}	
					FROM activite.v_budget_cle_budget_r_1
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_BUDGET]
						[VIEW.BUDGET_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						OPTIONS{PROPERTYPREFIX=BT}
						WORKTABLE{ACTI000035_BUDGET_T,, }
						GROUPBY1{[VIEW.GROUPBY_BUDGET_OID_FIELD],, [VIEW.GROUPBY_BUDGET_COD_FIELD],, [VIEW.GROUPBY_BUDGET_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						GROUPBY2{[VIEW.GROUPBY_2_BUDGET_OID_FIELD],, [VIEW.GROUPBY_2_BUDGET_COD_FIELD],, [VIEW.GROUPBY_2_BUDGET_TXT_FIELD]}
						GROUPBY3{[VIEW.GROUPBY_3_BUDGET_OID_FIELD],, [VIEW.GROUPBY_3_BUDGET_COD_FIELD],, [VIEW.GROUPBY_3_BUDGET_TXT_FIELD]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, date(date_trunc('year','[TOPERIODE]'::date) + interval '1 year' - interval '1 day'),, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_BUDGET],
						}	
					FROM activite.v_budget_cle_budget_r_1
					WHERE date_reference BETWEEN '[PERIODE]' AND date(date_trunc('year','[TOPERIODE]'::date) + interval '1 year' - interval '1 day')
						[VIEW.INDICATEURS_WHERE_BUDGET]
						[VIEW.BUDGET_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_OCCUPATION#1],
						}	
					FROM activite.v_mouvements_sejour_r_1 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_OCCUPATION#1]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_PLACES}
						GROUPBY1{[VIEW.GROUPBY_PLACES_OID_FIELD],, [VIEW.GROUPBY_PLACES_COD_FIELD],, [VIEW.GROUPBY_PLACES_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						GROUPBY2{[VIEW.GROUPBY_2_PLACES_OID_FIELD],, [VIEW.GROUPBY_2_PLACES_COD_FIELD],, [VIEW.GROUPBY_2_PLACES_TXT_FIELD]}
						GROUPBY3{[VIEW.GROUPBY_3_PLACES_OID_FIELD],, [VIEW.GROUPBY_3_PLACES_COD_FIELD],, [VIEW.GROUPBY_3_PLACES_TXT_FIELD]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_PLACES#1], 
						}
					FROM activite.v_places_r_1
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_PLACES#1]
						[VIEW.ETAGE_PLACES_SELECT]
						
					AFTER{	
						UPDATE ACTI000035_P SET 
							indicateurs = base.cti_array_sum(ACTI000035_P.indicateurs, ACTI000035_PLACES.indicateurs)					
						FROM ACTI000035_PLACES
						WHERE 
							(ACTI000035_PLACES.oidt = ACTI000035_p.oidt OR ACTI000035_PLACES.oidt = -111) AND
							(ACTI000035_PLACES.oid1 = ACTI000035_p.oid1 OR ACTI000035_PLACES.oid1 = -111) AND
							(ACTI000035_PLACES.oid2 = ACTI000035_p.oid2 OR ACTI000035_PLACES.oid2 = -111) AND
							(ACTI000035_PLACES.oid3 = ACTI000035_p.oid3 OR ACTI000035_PLACES.oid3 = -111)
					}
						
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_SEJOURS#2], 
						}	
					FROM activite.v_factures_reference_r_2 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_SEJOURS#2]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_SEJOURS#5], 
						}	
					FROM activite.v_factures_reference_r_5 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_SEJOURS#5]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#1], 
						}	
					FROM activite.v_factures_lignes_c_r_1 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#1]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#2], 
						}	
					FROM activite.v_factures_lignes_c_r_2 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#2]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#3], 
						}	
					FROM activite.v_factures_lignes_c_r_3 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#3]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#4], 
						}	
					FROM activite.v_factures_lignes_c_r_4 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#1], 
						}	
					FROM activite.v_factures_lignes_h_r_1 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#1]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#2], 
						}	
					FROM activite.v_factures_lignes_h_r_2 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#2]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#3], 
						}	
					FROM activite.v_factures_lignes_h_r_3 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#3]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#4], 
						}	
					FROM activite.v_factures_lignes_h_r_4 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>		
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_CLIENTS_CLINIQUE#4], 
						}	
					FROM activite.v_facture_solde_tiers_c_r_4 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_CLIENTS_CLINIQUE#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000035_P,, ADD}
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB],,1}
						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]}
						COLUMNBYDATECOMP{date_reference,, '[PERIODE]' ,, '[TOPERIODE]',, '[PERIODE_D]' ,, '[TOPERIODE_D]',, ,, ,, ,, [TYPE_COMPARAISON] ,, [LASTMONTH_OPTION]}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_EN_COURS#4], 
						}	
					FROM activite.v_factures_encours_lignes_c_r_4 #V_RAPPORT_JOIN#
					WHERE [VIEW.DATECOMPSELECT]
						[VIEW.INDICATEURS_WHERE_EN_COURS#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			
			
			<SQL>
				<select><![CDATA[		
				
					
					DROP TABLE IF EXISTS ACTI000035_T;
					CREATE TABLE ACTI000035_T AS
					SELECT oidt, labelt, textet, 						
					oid1, code1, 						
					oid2, code2, 		
					oid3, code3,
					oid, code, texte, level, 						
					ARRAY[[VIEW.RUBRIQUES_RAPPORT]] as indicateurs_mois,
					NULL::numeric[] AS indicateurs_mois_budget_p,
					NULL::numeric[] AS indicateurs_mois_budget_t
					FROM ACTI000035_P						
					GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13;
					
					DROP TABLE IF EXISTS ACTI000035_BUDGET_W;
					CREATE TABLE ACTI000035_BUDGET_w AS
					SELECT oidt, labelt, textet, 						
					oid1, code1, 						
					oid2, code2, 		
					oid3, code3,
					oid, code, texte, level, 						
					ARRAY[[VIEW.RUBRIQUES_RAPPORT]] as indicateurs_mois					
					FROM ACTI000035_BUDGET_T
					WHERE 
						NOT
						((level = 3 AND oid3 = -111) OR
						(level = 2 AND oid2 = -111) OR
						(level = 1 AND oid1 = -111))
				
					GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13;
					
					INSERT INTO ACTI000035_T
					SELECT 
						ACTI000035_BUDGET_W.oidt, ACTI000035_BUDGET_W.labelt, ACTI000035_BUDGET_W.textet, 						
						ACTI000035_BUDGET_W.oid1, ACTI000035_BUDGET_W.code1, 						
						ACTI000035_BUDGET_W.oid2, ACTI000035_BUDGET_W.code2, 		
						ACTI000035_BUDGET_W.oid3, ACTI000035_BUDGET_W.code3,
						ACTI000035_BUDGET_W.oid, ACTI000035_BUDGET_W.code, ACTI000035_BUDGET_W.texte, ACTI000035_BUDGET_W.level, 						
						NULL::numeric[] AS indicateurs_mois,
						NULL::numeric[] AS indicateurs_mois_budget_p,
						NULL::numeric[] AS indicateurs_mois_budget_t
					FROM ACTI000035_BUDGET_W
					LEFT JOIN ACTI000035_T ON
						ACTI000035_T.oidt = ACTI000035_BUDGET_W.oidt AND
						ACTI000035_T.oid1 = ACTI000035_BUDGET_W.oid1 AND
						ACTI000035_T.oid2 = ACTI000035_BUDGET_W.oid2 AND
						ACTI000035_T.oid3 = ACTI000035_BUDGET_W.oid3
					WHERE ACTI000035_T.oid1 IS NULL;
					
					
					UPDATE ACTI000035_T
					SET indicateurs_mois_budget_t = ACTI000035_BUDGET_W.indicateurs_mois
					FROM ACTI000035_BUDGET_W
					WHERE
						ACTI000035_T.oidt = ACTI000035_BUDGET_W.oidt AND
						ACTI000035_T.oid1 = ACTI000035_BUDGET_W.oid1 AND
						ACTI000035_T.oid2 = ACTI000035_BUDGET_W.oid2 AND
						ACTI000035_T.oid3 = ACTI000035_BUDGET_W.oid3;
					
					
					DROP TABLE IF EXISTS ACTI000035_BUDGET_W;
					CREATE TABLE ACTI000035_BUDGET_w AS
					SELECT oidt, labelt, textet, 						
					oid1, code1, 						
					oid2, code2, 		
					oid3, code3,
					oid, code, texte, level, 						
					ARRAY[[VIEW.RUBRIQUES_RAPPORT]] as indicateurs_mois					
					FROM ACTI000035_BUDGET_P
					GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13;
					
					
					UPDATE ACTI000035_T
					SET indicateurs_mois_budget_p = ACTI000035_BUDGET_W.indicateurs_mois
					FROM ACTI000035_BUDGET_W
					WHERE
						ACTI000035_T.oidt = ACTI000035_BUDGET_W.oidt AND
						ACTI000035_T.oid1 = ACTI000035_BUDGET_W.oid1 AND
						ACTI000035_T.oid2 = ACTI000035_BUDGET_W.oid2 AND
						ACTI000035_T.oid3 = ACTI000035_BUDGET_W.oid3;
					

				
					
					
					

					
					UPDATE ACTI000035_T SET level = 1, code1 = chr(255), code2 = chr(255), code3 = chr(255), code = '', texte = 'TOTAL ' || code || ' ' || texte 
						WHERE level = 1 AND oidt <> -9999999 AND oid2 = -9999999;
					UPDATE ACTI000035_T SET level = 1, code1 = chr(255), code2 = chr(255), code3 = chr(255), code = '', texte = 'TOTAL' 
						WHERE level = 9 AND oidt = -9999999;
					
					
					DROP TABLE IF EXISTS ACTI000035_L;
					CREATE TABLE ACTI000035_L AS
					SELECT 
						MAX(CASE WHEN oidt < 0 THEN level ELSE 0 END) AS level_s,
						MAX(CASE WHEN oidt >= 0 THEN level ELSE 0 END) AS level_t
					FROM ACTI000035_T;
					
					UPDATE ACTI000035_L
					SET level_t = -1
					WHERE level_t = 0 AND
						level_s = 1 AND
						(SELECT count(*) FROM ACTI000035_T) <= 1;

					UPDATE ACTI000035_T
					SET level = 0
					FROM ACTI000035_L
					WHERE level_t < 0
					;
					
					
					SELECT 
						oidt, labelt, textet, 						
						oid1, code1, 						
						oid2, code2, 
						oid3, code3, 
						0 AS oid4, chr(1)::text AS code4,
						oid, code, code || ' ' || texte, 
						level,
						'#' AS output_format,
						CASE WHEN level = '1' AND level_s > 1 THEN 24 ELSE 20 END AS row_height, 
						CASE WHEN level = '1' THEN 0 ELSE 20 END AS padding , 
						CASE WHEN level = '1' AND level_s > 1 THEN 14 ELSE 12 END AS font_size, 
						'bold' AS font_weight, 
						2 AS border_thickness, 
						CASE 
							WHEN level = '1' AND level_s > 1 AND oidt < 0 THEN '0xF0F0F0' 
							WHEN level = '1' AND level_t > 1 AND oidt >= 0 THEN '0xF0F0F0' 
							ELSE '' END AS color, 
						CASE 
							WHEN level = '1' AND level_s > 1 AND oidt < 0 THEN '0x0000FF' 
							WHEN level = '1' AND level_t > 1 AND oidt >= 0 THEN '0x0000FF' 
							ELSE '0xFFD393' END AS background_color,
						0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
						,0,0,0,0,0,0
					FROM ACTI000035_T, ACTI000035_L
					WHERE level_t >= 0

					UNION

					SELECT 
						oidt, labelt, textet, 						
						oid1,
						code1,  						
						CASE WHEN oid2 != -9999999 THEN oid2 ELSE t_rapports_rubriques.numero_rubrique * 10000 + t_rapports_rubriques.indicateur_id END AS oid2,
						code2,
						CASE WHEN oid3 != -9999999 THEN oid3 ELSE CASE WHEN oid2 != -9999999 THEN t_rapports_rubriques.numero_rubrique * 10000 + t_rapports_rubriques.indicateur_id ELSE oid3 END END AS oid3,
						code3,
						t_rapports_rubriques.numero_rubrique * 10000 + t_rapports_rubriques.indicateur_id AS oid4,
						trim(to_char(numero_rubrique,'0000'))::text AS code4,							
						t_rapports_rubriques.indicateur_id AS oid, 
						numero_rubrique::text AS code, 
						CASE WHEN t_rapports_rubriques.entete_etendue <> '' THEN t_rapports_rubriques.entete_etendue ELSE t_indicateurs.entete_etendue END AS texte,						
						CASE
							WHEN oid3 != -9999999 THEN 4
							WHEN oid2 != -9999999 THEN 3
							WHEN oid1 = -9999999 AND
								CASE
									WHEN oid2 != -9999999 THEN oid2
									ELSE t_rapports_rubriques.indicateur_id
								END != -9999999 THEN 2
							WHEN oid1 != -9999999 THEN 2
							ELSE 1
						END AS level,
						CASE WHEN t_rapports_rubriques.output_format <> '' THEN t_rapports_rubriques.output_format ELSE t_indicateurs.output_format END,
						t_rapports_rubriques.row_height, 
						(level * 20) + t_rapports_rubriques.padding , 
						t_rapports_rubriques.font_size, 
						t_rapports_rubriques.font_weight, 
						t_rapports_rubriques.border_thickness, 
						t_rapports_rubriques.color, 
						CASE WHEN t_rapports_rubriques.background_color <> '' THEN t_rapports_rubriques.background_color ELSE '0xF0F0F0' END,

						indicateurs_mois[numero_rubrique][1],
						indicateurs_mois[numero_rubrique][2],
						indicateurs_mois[numero_rubrique][3],
						indicateurs_mois[numero_rubrique][4],
						indicateurs_mois[numero_rubrique][5],
						indicateurs_mois[numero_rubrique][6],
						indicateurs_mois[numero_rubrique][7],
						indicateurs_mois[numero_rubrique][8],
						indicateurs_mois[numero_rubrique][9],
						indicateurs_mois[numero_rubrique][10],
						indicateurs_mois[numero_rubrique][11],
						indicateurs_mois[numero_rubrique][12],
						indicateurs_mois[numero_rubrique][13],
						indicateurs_mois[numero_rubrique][14],
						indicateurs_mois[numero_rubrique][15],
						indicateurs_mois[numero_rubrique][16],
						indicateurs_mois[numero_rubrique][17],
						indicateurs_mois[numero_rubrique][18],
						indicateurs_mois[numero_rubrique][19],
						indicateurs_mois[numero_rubrique][20],
						indicateurs_mois[numero_rubrique][21],
						indicateurs_mois[numero_rubrique][22],
						indicateurs_mois[numero_rubrique][23],
						indicateurs_mois[numero_rubrique][24],
						
						indicateurs_mois_budget_p[numero_rubrique][1],
						CASE 
							WHEN COALESCE(indicateurs_mois_budget_p[numero_rubrique][1],0) <> 0 
							THEN indicateurs_mois[numero_rubrique][1] - indicateurs_mois_budget_p[numero_rubrique][1]
							ELSE 0 END,
						CASE 
							WHEN COALESCE(indicateurs_mois_budget_p[numero_rubrique][1],0) <> 0 
							THEN (base.cti_division(indicateurs_mois[numero_rubrique][1], indicateurs_mois_budget_p[numero_rubrique][1]) * 100)
							ELSE 0 END,
						
						indicateurs_mois_budget_t[numero_rubrique][1],
						CASE 
							WHEN COALESCE(indicateurs_mois_budget_t[numero_rubrique][1],0) <> 0 
							THEN indicateurs_mois[numero_rubrique][1] - indicateurs_mois_budget_t[numero_rubrique][1]
							ELSE 0 END,
						CASE 
							WHEN COALESCE(indicateurs_mois_budget_t[numero_rubrique][1],0) <> 0 
							THEN (base.cti_division(indicateurs_mois[numero_rubrique][1], indicateurs_mois_budget_t[numero_rubrique][1]) * 100)
							ELSE 0 END

					FROM ACTI000035_T, ACTI000035_L
						JOIN activite.t_rapports_rubriques ON rapport_id = [RAPPORT]
						JOIN activite.t_indicateurs ON indicateur_id = t_indicateurs.oid
					
					ORDER BY 4,6,8,10
					
					
					
					-- Cette requête produit quelque chose qui peur êter illustré de la sorte :
					
					-- Mode de comp				PREC		FIRST		LAST
					-- Type de comp
								-- Nom_champ		
					--
					-- 				NP1
					--		2					0			0			0
					--		3					0			0			0
					--		4					0			0			0
					--		S					0			0			0
					-------------------------------------------------------------
					--				EP1	
					--		2					0-1			0-1			.
					--		3					0-1			0-2			.
					--		4					0-1			0-3			.
					--		S					0-1			0-1			.
					-------------------------------------------------------------
					-- 				NP2
					--		2					1			1			1
					--		3					1			1			1
					--		4					1			1			1
					--		S					1			1			1
					-------------------------------------------------------------
					--				EP2
					--		2					.			.			0-1
					--		3					1-2			1-2			0-1
					--		4					1-2			1-3			0-1
					--		S					.			.			0-1
					-------------------------------------------------------------
					--				NP3	
					--		2					2			2			2
					--		3					2			2			2
					--		4					2			2			2
					--		S					2			2			2
					-------------------------------------------------------------
					--				EP3
					--		2					.			.			.
					--		3					.			.			0-2
					--		4					2-3			2-3			0-2
					--		S					.			.			.
					-------------------------------------------------------------
					--				NP4
					--		2					3			3			3
					--		3					3			3			3
					--		4					3			3			3
					--		S					3			3			3
					-------------------------------------------------------------
					--				EP4		
					--		2					.			.			.
					--		3					.			.			.
					--		4					.			.			0-3
					--		S					.			.			.
					-------------------------------------------------------------
					--				NP5
					--		2					4			4			4
					--		3					4			4			4
					--		4					4			4			4
					--		S					4			4			4
					-------------------------------------------------------------
					--				EP5
					--		2					4-5			4-5			.
					--		3					4-5			4-6			.
					--		4					4-5			4-7			.
					--		S					4-5			4-5			.
					-------------------------------------------------------------
					--				NP6
					--		2					5			5			5
					--		3					5			5			5
					--		4					5			5			5
					--		S					5			5			5
					-------------------------------------------------------------
					--				EP6
					--		2					.			.			4-5
					--		3					5-6			5-6			4-5
					--		4					5-6			5-7			4-5
					--		S					.			.			4-5
					-------------------------------------------------------------
					--				NP7
					--		2					6			6			6
					--		3					6			6			6
					--		4					6			6			6
					--		S					6			6			6
					-------------------------------------------------------------
					--				EP7	
					--		2					.			.			.
					--		3					.			.			4-6
					--		4					6-7			6-7			4-6
					--		S					.			.			.
					-------------------------------------------------------------
					--				NP8
					--		2					7			7			7
					--		3					7			7			7
					--		4					7			7			7
					--		S					7			7			7
					-------------------------------------------------------------
					--				EP8
					--		2					.			.			.
					--		3					.			.			.
					--		4					.			.			0-7
					--		S					.			.			.
					-------------------------------------------------------------

					-- Valeurs des paramètres des calculs
					-- 0 : valeur pour l'année n
					-- 1 : valeur pour l'année n-1
					-- 2 : valeur pour l'année n-2
					-- 3 : valeur pour l'année n-3
					-- 4 : valeur du dernier mois de l'année n
					-- 5 : valeur du dernier mois de l'année n-1
					-- 6 : valeur du dernier mois de l'année n-2
					-- 7 : valeur du dernier mois de l'année n-3
					
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS4" />
					<FIELD name="OUTFMT" />
					<FIELD name="ROWHEI" />
					<FIELD name="PAD" />
					<FIELD name="FNTSIZ" />
					<FIELD name="FNTWEI" />
					<FIELD name="BRDTHI" />
					<FIELD name="FNTCOL" />
					<FIELD name="BAKCOL" />
					
					<FIELD name="NP1" />
					<FIELD name="EP1" />
					<FIELD name="PP1" />
					<FIELD name="NP2" />
					<FIELD name="EP2" />
					<FIELD name="PP2" />
					<FIELD name="NP3" />
					<FIELD name="EP3" />
					<FIELD name="PP3" />
					<FIELD name="NP4" />
					<FIELD name="EP4" />
					<FIELD name="PP4" />
					<FIELD name="NP5" />
					<FIELD name="EP5" />
					<FIELD name="PP5" />
					<FIELD name="NP6" />
					<FIELD name="EP6" />
					<FIELD name="PP6" />
					<FIELD name="NP7" />
					<FIELD name="EP7" />
					<FIELD name="PP7" />
					<FIELD name="NP8" />
					<FIELD name="EP8" />
					<FIELD name="PP8" />
					
					<FIELD name="NBP" />
					<FIELD name="EBP" />
					<FIELD name="PBP" />
					<FIELD name="NBT" />
					<FIELD name="EBT" />
					<FIELD name="PBT" />
					
				</FIELDS>
			</SQL>
			
		</QUERY>
		
		
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false"> 
		
			<SQL>
				<select><![CDATA[	
				
					SELECT * FROM activite.cti_prepare_rapport_comp([RAPPORT], '[TYPE_COMPARAISON]', '[MODE_COMPARAISON]') AS (name text, value text)

				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
			
			<SQL>
				<select><![CDATA[	
				
					SELECT 'JOUROUVRE_LABEL',
					SUM(CASE WHEN date BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN nb_jour_ouvre ELSE 0 END) || ' jours ouvrés (N-1=' ||
					SUM(CASE WHEN date+interval '1 year' BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN nb_jour_ouvre ELSE 0 END) || ' budget=' ||
					SUM(CASE WHEN date BETWEEN '[PERIODE]' AND date(date_trunc('month','[TOPERIODE]'::date)+ interval '1 month' - interval '1 day') THEN nb_jour_ouvre ELSE 0 END) || ')'
					FROM base.v_calendrier_indicateurs_1
					WHERE '[TYPE_COMPARAISON]' = '2' AND '[LASTMONTH_OPTION]' = 'BUDGET'
					UNION
					SELECT 'JOUROUVRE_LABEL',
					SUM(CASE WHEN date BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN nb_jour_ouvre ELSE 0 END) || ' jours ouvrés (N-1=' ||
					SUM(CASE WHEN date+interval '1 year' BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN nb_jour_ouvre ELSE 0 END) || ')'
					FROM base.v_calendrier_indicateurs_1
					WHERE '[TYPE_COMPARAISON]' = '2' AND '[LASTMONTH_OPTION]' <> 'BUDGET'
					UNION
					SELECT 'JOUROUVRE_LABEL',
					SUM(CASE WHEN date BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN nb_jour_ouvre ELSE 0 END) || ' jours ouvrés '
					FROM base.v_calendrier_indicateurs_1
					WHERE '[TYPE_COMPARAISON]' NOT IN  ('2')

				]]></select>
				<FIELDS>
					<FIELD name="name"/>
					<FIELD name="value"/>
				</FIELDS>
			</SQL>

		</QUERY>
		
		
		
		
	</QUERIES>
	
	<PRESENTATION>
		<VIEWLINKS>
			
		</VIEWLINKS>		
		<ONGLET excelLabel="Comparatif" label="Comparatif" multiTab="true">
			
			<DATAGRID title="" total="false" showOthers="true" headerHeight="54" variableRowHeight="true" sortable="false" >

				<ROWSTYLE name="fontSize" value="10" />
				<ROWSTYLE name="fontSize" value="= ROW.FNTSIZ.toString()" condition="Number(ROW.FNTSIZ) &gt;= 8" />
				<ROWSTYLE name="fontWeight" value="bold" condition="ROW.FNTWEI == 'bold'" />
				<ROWSTYLE name="rowHeight" value="= ROW.ROWHEI.toString()" condition="Number(ROW.ROWHEI) &gt; 0" />
				<ROWSTYLE name="borderSides" value="top bottom" condition="Number(ROW.BRDTHI) &gt; 0" />
				<ROWSTYLE name="borderStyle" value="solid" condition="Number(ROW.BRDTHI) &gt; 0" />
				<ROWSTYLE name="borderThickness" value="= ROW.BRDTHI.toString()" condition="Number(ROW.BRDTHI) &gt; 0" />
				<ROWSTYLE name="color" value="= ROW.FNTCOL.toString()" condition="ROW.FNTCOL != '' " />
				<ROWSTYLE name="backgroundColor" value="= ROW.BAKCOL.toString()" condition="ROW.BAKCOL != '' " />
				
				<COLUMN dataField="OUTFMT" type="Char" visible="false" />
				<COLUMN dataField="ROWHEI" type="Char" visible="false" />
				<COLUMN dataField="PAD" type="Char" visible="false" />
				<COLUMN dataField="FNTSIZ" type="Char" visible="false" />
				<COLUMN dataField="FNTWEI" type="Char" visible="false" />
				<COLUMN dataField="BRDTHI" type="Char" visible="false" />
				<COLUMN dataField="FNTCOL" type="Char" visible="false" />
				<COLUMN dataField="BAKCOL" type="Char" visible="false" />
				
				<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="OID3" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD3" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="OID4" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD4" width="60" type="Char" visible="false" headerText="Oid" />
				
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid" />
				<COLUMN dataField="COD" width="60" type="Char" visible="false" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL" />
				<COLUMN dataField="TXT" type="Char" minWidth="50" headerText="Indicateur" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="*ROW">
					<CELLSTYLE name="paddingLeft" value="= ROW.PAD" condition="Number(ROW.PAD) &gt; 0" />
				</COLUMN>
				
				<COLUMN dataField="NP8" width="80" visibleCondition="VIEW.COLH8 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH8" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="EP8" width="80" visibleCondition="VIEW.COLH8 != null &amp;&amp; SELECT.MODE_COMPARAISON == 'LAST'" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE8" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="PP8" width="80" visibleCondition="VIEW.COLH8 != null &amp;&amp; SELECT.MODE_COMPARAISON == 'LAST'" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP8" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="NP7" width="80" visibleCondition="VIEW.COLH7 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH7" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="EP7" width="80" visibleCondition="VIEW.COLH7 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH8 != null)" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE7" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="PP7" width="80" visibleCondition="VIEW.COLH7 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH8 != null)" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP7" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="NP6" width="80" visibleCondition="VIEW.COLH6 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="EP6" width="80" visibleCondition="VIEW.COLH6 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH7 != null)" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="PP6" width="80" visibleCondition="VIEW.COLH6 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH7 != null)" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="NP5" width="80" visibleCondition="VIEW.COLH5 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH5" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="EP5" width="80" visibleCondition="VIEW.COLH5 != null &amp;&amp; SELECT.TYPE_COMPARAISON != '-1' &amp;&amp; SELECT.MODE_COMPARAISON != 'LAST'" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE5" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="PP5" width="80" visibleCondition="VIEW.COLH5 != null &amp;&amp; SELECT.TYPE_COMPARAISON != '-1' &amp;&amp; SELECT.MODE_COMPARAISON != 'LAST'" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP5" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				
				

				<COLUMN dataField="NP4" width="80" visibleCondition="VIEW.COLH4 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH4" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="EP4" width="80" visibleCondition="VIEW.COLH4 != null &amp;&amp; SELECT.MODE_COMPARAISON == 'LAST'" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE4" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="PP4" width="80" visibleCondition="VIEW.COLH4 != null &amp;&amp; SELECT.MODE_COMPARAISON == 'LAST'" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP4" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="NP3" width="80" visibleCondition="VIEW.COLH3 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH3" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="EP3" width="80" visibleCondition="VIEW.COLH3 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH4 != null)" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE3" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="PP3" width="80" visibleCondition="VIEW.COLH3 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH4 != null)" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP3" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="NP2" width="80" visibleCondition="VIEW.COLH2 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="EP2" width="80" visibleCondition="VIEW.COLH2 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH3 != null)" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="PP2" width="80" visibleCondition="VIEW.COLH2 != null &amp;&amp; (SELECT.MODE_COMPARAISON == 'LAST' || VIEW.COLH3 != null)" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="NP1" width="80" visibleCondition="VIEW.COLH1 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH1 + ' Réalisé'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="EP1" width="80" visibleCondition="VIEW.COLH2 != null &amp;&amp; SELECT.TYPE_COMPARAISON != '-1' &amp;&amp; SELECT.MODE_COMPARAISON != 'LAST'" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLHE1" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				<COLUMN dataField="PP1" width="80" visibleCondition="VIEW.COLH2 != null &amp;&amp; SELECT.TYPE_COMPARAISON != '-1' &amp;&amp; SELECT.MODE_COMPARAISON != 'LAST'" type="Number" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLHP1" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum" />
				
				<COLUMN dataField="NBP" width="80" type="Number" visibleCondition="SELECT.LASTMONTH_OPTION == 'BUDGET'" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH1 + ' Budget'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="EBP" width="80" type="Number" visibleCondition="SELECT.LASTMONTH_OPTION == 'BUDGET'" outputFormat="#,00" fixed="false" selectable="false" headerText="VIEW.COLH1 + '\rEcart Budget'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="PBP" width="80" type="Number" visibleCondition="SELECT.LASTMONTH_OPTION == 'BUDGET'" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.COLH1 + '\r%Budget'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				
				<COLUMN dataField="NBT" width="80" type="Number" visibleCondition="SELECT.LASTMONTH_OPTION == 'BUDGETT'" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.BTCOLH1 + ' Budget'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="EBT" width="80" type="Number" visibleCondition="SELECT.LASTMONTH_OPTION == 'BUDGETT'" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.BTCOLH1 + '\rEcart Budget'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				<COLUMN dataField="PBT" width="80" type="Number" visibleCondition="SELECT.LASTMONTH_OPTION == 'BUDGETT'" outputFormat="#,00 %" fixed="false" selectable="false" headerText="VIEW.BTCOLH1 + '\r%Budget'" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
					 
				</COLUMN>
				
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
	
</VUE>
