<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ACTI000034" 
	label="Activité. Synthèse temporelle personnalisée" 
	title="= SELECT.RAPPORT_LABEL + ' par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
	database="iCTI" swf="*CTI_view1" 
	softCode="iCTI_activite"
	globals="ACTI_globals.XML"
	componentsFile="ACTI_components.XML">
	<VIEWPROPERTIES componentName="PROPERTIES_RAPPORT"/>
	<VIEWPROPERTIES>
		<PROPERTY name="RAPPORT_ID">
			<value><![CDATA[[EVAL 
				if (is_numeric('[RAPPORT]')) {
					return '[RAPPORT]';
				} else {
					return 'SELECT oid FROM activite.t_rapports WHERE code = \'[RAPPORT]\' LIMIT 1';
				}
			EVAL]]]></value>
		</PROPERTY>
		<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 name="TOPERIODE" label="à" UI="combo" tree="true" width="150" default="2007-01-31" globalListProvider="DATE_FIN"  />
		</GROUP>
		<GROUP label="Périodicité">
			<FIELD name="PERIODICITE" width="200" UI="combo" default="MONTH" globalListProvider="PERIODICITE" />
		</GROUP>
		<GROUP label="Comparaison">
			<FIELD name="LINE1" label="" UI="combo" default="-1" width="150">
				<OPTION label="" data="-1" />
				<OPTION label="Période -1" data="N1" />
				<OPTION label="Période -2" data="N2" />
				<OPTION label="Budget période" data="B" />
				<OPTION label="Budget année" data="BT" />
			</FIELD>
			<FIELD name="LINE2" label="" UI="combo" default="-1" width="150">
				<OPTION label="" data="-1" />
				<OPTION label="Période -1" data="N1" />
				<OPTION label="Période -2" data="N2" />
				<OPTION label="Budget période" data="B" />
				<OPTION label="Budget année" data="BT" />
			</FIELD>
			<FIELD name="LINE3" label="" UI="combo" default="-1" width="150">
				<OPTION label="" data="-1" />
				<OPTION label="Période -1" data="N1" />
				<OPTION label="Période -2" data="N2" />
				<OPTION label="Budget période" data="B" />
				<OPTION label="Budget année" data="BT" />
			</FIELD>
		</GROUP>
		
		

		<GROUP label="Rapport">
			<FIELD name="RAPPORT" label="" UI="combo" tree="true"  default="-1"  globalListProvider="RAPPORT" />
		</GROUP>
		
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" 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>
			<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">
				<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="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N}
						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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_OCCUPATION#1],
						}	
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_OCCUPATION#1], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_mouvements_sejour_r_1 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_OCCUPATION#1]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[		
					[EVAL 
						if ('[LINE1]' == 'N1' || '[LINE2]' == 'N1' || '[LINE3]' == 'N1') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '1 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_OCCUPATION#1],
									}	
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_OCCUPATION#1], 
									}
									INDICATORS_TEXT{'N1'}
								FROM activite.v_mouvements_sejour_r_1 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '1 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_OCCUPATION#1]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN" >
				<select><![CDATA[	
					[EVAL 
						if ('[LINE1]' == 'N2' || '[LINE2]' == 'N2' || '[LINE3]' == 'N2') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '2 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_OCCUPATION#1],
									}	
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_OCCUPATION#1], 
									}
									INDICATORS_TEXT{'N2'}
								FROM activite.v_mouvements_sejour_r_1 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '2 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_OCCUPATION#1]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
					
				]]></select>
			</SQL>
			<SQL optimizer="" >
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_PLACES#1],
						}	
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_PLACES#1], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_places_r_1
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_PLACES#1]
						[VIEW.ETAGE_PLACES_SELECT]
						
					AFTER{	
						UPDATE ACTI000034_N SET 
							indicateurs = base.cti_array_sum(ACTI000034_N.indicateurs, ACTI000034_PLACES.indicateurs)					
						FROM ACTI000034_PLACES
						WHERE 
							(ACTI000034_PLACES.oidt = ACTI000034_N.oidt OR ACTI000034_PLACES.oidt = -111) AND
							(ACTI000034_PLACES.oid1 = ACTI000034_N.oid1 OR ACTI000034_PLACES.oid1 = -111) AND
							(ACTI000034_PLACES.oid2 = ACTI000034_N.oid2 OR ACTI000034_PLACES.oid2 = -111) AND
							(ACTI000034_PLACES.oid3 = ACTI000034_N.oid3 OR ACTI000034_PLACES.oid3 = -111)
					}
						
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_SEJOURS#2],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_SEJOURS#2], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_reference_r_2 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_SEJOURS#2]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_SEJOURS#5],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_SEJOURS#5], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_reference_r_5 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_SEJOURS#5]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_CLINIQUE#1],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#1], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_c_r_1 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#1]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[	
					[EVAL 
						if ('[LINE1]' == 'N1' || '[LINE2]' == 'N1' || '[LINE3]' == 'N1') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '1 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#1],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#1], 
									}
									INDICATORS_TEXT{'N1'}
								FROM activite.v_factures_lignes_c_r_1 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '1 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#1]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					[EVAL 
						if ('[LINE1]' == 'N2' || '[LINE2]' == 'N2' || '[LINE3]' == 'N2') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '2 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#1],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#1], 
									}
									INDICATORS_TEXT{'N2'}
								FROM activite.v_factures_lignes_c_r_1 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '2 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#1]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
					
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_CLINIQUE#2],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#2], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_c_r_2 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#2]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[	
					[EVAL 
						if ('[LINE1]' == 'N1' || '[LINE2]' == 'N1' || '[LINE3]' == 'N1') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '1 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#2],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#2], 
									}
									INDICATORS_TEXT{'N1'}
								FROM activite.v_factures_lignes_c_r_2 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '1 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#2]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					[EVAL 
						if ('[LINE1]' == 'N2' || '[LINE2]' == 'N2' || '[LINE3]' == 'N2') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '2 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#2],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#2], 
									}
									INDICATORS_TEXT{'N2'}
								FROM activite.v_factures_lignes_c_r_2 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '2 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#2]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
					
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_CLINIQUE#3],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#3], 
						}
						INDICATORS_TEXT{'N'}						
					FROM activite.v_factures_lignes_c_r_3 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#3]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[	
					[EVAL 
						if ('[LINE1]' == 'N1' || '[LINE2]' == 'N1' || '[LINE3]' == 'N1') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '1 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#3],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#3], 
									}
									INDICATORS_TEXT{'N1'}
								FROM activite.v_factures_lignes_c_r_3 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '1 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#3]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					[EVAL 
						if ('[LINE1]' == 'N2' || '[LINE2]' == 'N2' || '[LINE3]' == 'N2') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '2 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#3],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#3], 
									}
									INDICATORS_TEXT{'N2'}
								FROM activite.v_factures_lignes_c_r_3 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '2 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#3]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
					
				]]></select>
			</SQL>
			
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_CLINIQUE#4],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#4], 
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_c_r_4 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[	
					[EVAL 
						if ('[LINE1]' == 'N1' || '[LINE2]' == 'N1' || '[LINE3]' == 'N1') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '1 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#4],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#4], 
									}
									INDICATORS_TEXT{'N1'}
								FROM activite.v_factures_lignes_c_r_4 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '1 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#4]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					[EVAL 
						if ('[LINE1]' == 'N2' || '[LINE2]' == 'N2' || '[LINE3]' == 'N2') {
							return "
								CTIPREPAR_TREE
									WORKTABLE{ACTI000034_N,, 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]}
									COLUMNBY[PERIODICITE]{date(date_reference + interval '2 year'),, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
									INDICATORS{
										[VIEW.INDICATEURS_FACTURATION_CLINIQUE#4],
									}
									INDICATORS_COLUMNS{
										[VIEW.INDICATEURS_COLUMNS_FACTURATION_CLINIQUE#4], 
									}
									INDICATORS_TEXT{'N2'}
								FROM activite.v_factures_lignes_c_r_4 #V_RAPPORT_JOIN#
								WHERE date(date_reference + interval '2 year') BETWEEN '[PERIODE]' AND '[TOPERIODE]'
									[VIEW.INDICATEURS_WHERE_FACTURATION_CLINIQUE#4]
									[VIEW.RAPPORT_SELECT]
						";}
						return "";
					EVAL]
					
				]]></select>
			</SQL>
			
			
			

			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_HONORAIRE#1],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#1],
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_h_r_1 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#1]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_HONORAIRE#2],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#2],
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_h_r_2 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#2]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_HONORAIRE#3],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#3],
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_h_r_3 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#3]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_FACTURATION_HONORAIRE#4],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_FACTURATION_HONORAIRE#4],
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_lignes_h_r_4 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_FACTURATION_HONORAIRE#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_CLIENTS_CLINIQUE#4],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_CLIENTS_CLINIQUE#4],
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_facture_solde_tiers_c_r_4 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_CLIENTS_CLINIQUE#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>
			<SQL optimizer="V_RAPPORT_JOIN">
				<select><![CDATA[		
					CTIPREPAR_TREE
						WORKTABLE{ACTI000034_N,, 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]}
						COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
						INDICATORS{
							[VIEW.INDICATEURS_EN_COURS#4],
						}
						INDICATORS_COLUMNS{
							[VIEW.INDICATEURS_COLUMNS_EN_COURS#4],
						}
						INDICATORS_TEXT{'N'}
					FROM activite.v_factures_encours_lignes_c_r_4 #V_RAPPORT_JOIN#
					WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.INDICATEURS_WHERE_EN_COURS#4]
						[VIEW.RAPPORT_SELECT]
				]]></select>
			</SQL>

			<SQL>
				<select><![CDATA[	
						[EVAL 
							if ('[LINE1]' == 'BT' || '[LINE2]' == 'BT' || '[LINE3]' == 'BT' || '[LINE3]' == 'BT') {
								return "
									CTIPREPAR_TREE
										WORKTABLE{ACTI000034_N,, ADD}
										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]}
										COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, date(date_trunc('year','[TOPERIODE]'::date) + interval '1 year' - interval '1 day') ,, 12,, }
										INDICATORS{
											[VIEW.INDICATEURS_BUDGET],
										}
										INDICATORS_COLUMNS{
											[VIEW.INDICATEURS_COLUMNS_BUDGET],
										}
										INDICATORS_TEXT{'BT'}
									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]
								";}

							if ('[LINE1]' == 'B' || '[LINE2]' == 'B' || '[LINE3]' == 'B' || '[LINE3]' == 'B') {
								return "
									CTIPREPAR_TREE
										WORKTABLE{ACTI000034_N,, ADD}
										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]}
										COLUMNBY[PERIODICITE]{date_reference,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12,, }
										INDICATORS{
											[VIEW.INDICATEURS_BUDGET],
										}
										INDICATORS_COLUMNS{
											[VIEW.INDICATEURS_COLUMNS_BUDGET],
										}
										INDICATORS_TEXT{'B'}
									FROM activite.v_budget_cle_budget_r_1
									WHERE date_reference BETWEEN '[PERIODE]' AND '[TOPERIODE]'
										[VIEW.INDICATEURS_WHERE_BUDGET]
										[VIEW.BUDGET_SELECT]
								";}
								return "";
						EVAL]
				]]></select>
			</SQL>
			
			
			
			<SQL>
				<select><![CDATA[

					DELETE FROM ACTI000034_N
					WHERE level = 3 AND oid3 = -111;
					
					DELETE FROM ACTI000034_N
					WHERE level = 2 AND oid2 = -111;
					
					DELETE FROM ACTI000034_N
					WHERE level = 1 AND oid1 = -111;
				
					DROP TABLE IF EXISTS ACTI000034_T;
					CREATE TEMP TABLE ACTI000034_T AS
					SELECT oidt, labelt, textet,  						
					oid1, code1,  						
					oid2, code2,  		
					oid3, code3,
					oid, code, texte, level,
					indicateurs_text[1] AS periode_line,
					0::integer AS periode_line_sort,
					ARRAY[[VIEW.RUBRIQUES_RAPPORT]] as indicateurs_mois					
					FROM ACTI000034_N						
					GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14 ;
					
					UPDATE ACTI000034_T
					SET periode_line_sort = 1
					WHERE periode_line = 'N';
					
					UPDATE ACTI000034_T
					SET periode_line_sort = 11
					WHERE periode_line = '[LINE1]' AND periode_line_sort = 0;
					
					UPDATE ACTI000034_T
					SET periode_line_sort = 12
					WHERE periode_line = '[LINE2]' AND periode_line_sort = 0;
					
					UPDATE ACTI000034_T
					SET periode_line_sort = 13
					WHERE periode_line = '[LINE3]' AND periode_line_sort = 0;
					
					
					UPDATE ACTI000034_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 ACTI000034_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 ACTI000034_L;
					CREATE TEMP TABLE ACTI000034_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 ACTI000034_T;
					
					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
					FROM ACTI000034_T, ACTI000034_L
					WHERE periode_line_sort > 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 + periode_line_sort 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 + periode_line_sort ELSE oid3 END END AS oid3,
						code3,
						t_rapports_rubriques.numero_rubrique * 10000 + t_rapports_rubriques.indicateur_id + periode_line_sort AS oid4,   
						trim(to_char(numero_rubrique,'0000'))::text || periode_line_sort::text AS code4,						
						t_rapports_rubriques.indicateur_id AS oid, 
						numero_rubrique::text AS code, 
						CASE WHEN periode_line = 'N' OR periode_line = '' THEN
							CASE WHEN t_rapports_rubriques.entete_etendue <> '' THEN t_rapports_rubriques.entete_etendue ELSE t_indicateurs.entete_etendue END 
						ELSE
							CASE periode_line WHEN 'N1' THEN 'Période N-1' WHEN 'N2' THEN 'Période N-2' WHEN 'B' THEN 'Budget' WHEN 'BT' THEN 'Budget' END  
						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 + CASE WHEN periode_line <> 'N' AND periode_line <> '' THEN 50 ELSE 0 END, 
						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]

					FROM ACTI000034_T, ACTI000034_L
						JOIN activite.t_rapports_rubriques ON rapport_id = [RAPPORT]
						JOIN activite.t_indicateurs ON indicateur_id = t_indicateurs.oid
					WHERE periode_line_sort > 0 AND
						(periode_line = '' OR periode_line = 'N' OR indicateurs_mois[numero_rubrique][1] <> 0)
										
					
					ORDER BY 4,6,8,10

				]]></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="N"/>
					<FIELD name="N0"/>
					<FIELD name="N1"/>
					<FIELD name="N2"/>
					<FIELD name="N3"/>
					<FIELD name="N4"/>
					<FIELD name="N5"/>
					<FIELD name="N6"/>
					<FIELD name="N7"/>
					<FIELD name="N8"/>
					<FIELD name="N9"/>
					<FIELD name="N10"/>
					<FIELD name="N11"/>
					<FIELD name="N12"/>
				</FIELDS>
			</SQL>
		</QUERY>
	
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL>
				<select><![CDATA[	
				
					SELECT * FROM activite.cti_prepare_rapport_month([RAPPORT]) AS (name text, value text)

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

	</QUERIES>
	
	<PRESENTATION>
	
		<VIEWLINKS>
		
			
		
		</VIEWLINKS>
	
		<ONGLET excelLabel="Evolution mensuelle" label="Evolution mensuelle" multiTab="true">
			
			<DATAGRID title="" total="false" showOthers="true" headerHeight="36" 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>
				<COLUMN dataField="OID1" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD1" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="OID2" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD2" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="OID3" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD3" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="OID4" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD4" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="60" type="Char" visible="false" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="150" 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="N" width="80" visible="true" type="Number" outputFormat="= ROW.OUTFMT" headerText="Total" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="N0" width="70" visibleCondition="VIEW.COLH0 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" headerText="&lt;&lt;" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N1" width="70" visibleCondition="VIEW.COLH1 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH1" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N2" width="70" 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>
				<COLUMN dataField="N3" width="70" 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>
				<COLUMN dataField="N4" width="70" 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>
				<COLUMN dataField="N5" width="70" 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="N6" width="70" visibleCondition="VIEW.COLH6 != null" type="Number" selectable="false" outputFormat="= ROW.OUTFMT" fixed="false" headerText="VIEW.COLH6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N7" width="70" 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="N8" width="70" 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="N9" width="70" visibleCondition="VIEW.COLH9 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH9" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N10" width="70" visibleCondition="VIEW.COLH10 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH10" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N11" width="70" visibleCondition="VIEW.COLH11 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH11" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N12" width="70" visibleCondition="VIEW.COLH12 != null" type="Number" outputFormat="= ROW.OUTFMT" fixed="false" selectable="false" headerText="VIEW.COLH12" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
		
	</PRESENTATION>
	
</VUE>

			
