<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ECO000017" 
	label="ECO. Comparatif factures" 
	title="= 'Comparatif par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ' vs ' + SELECT.PERIODE_D_LABEL + ' à ' + SELECT.TOPERIODE_D_LABEL + ')' " 
	database="iCTI" 
	swf="*CTI_view1" 
	globals="ECO_globals.XML" 
	componentsFile="ECO_components.XML"
	dboptimizer="ECO_dboptimizer.XML"
	softCode="iCTI_eco">	

	<VIEWPROPERTIES componentName="PROPERTIES_FACTURES"/>
	<VIEWPROPERTIES componentName="PROPERTIES_GROUPBY"/>
	
	<VIEWPROPERTIES>
		<PROPERTY name="DATA1">
			<value><![CDATA[[EVAL 
								switch ('[DATA1]') {
								case 'NFAC':
									return 'v_eco_view_1.facture_id';
									break;
								case 'MFACHT':
									return 'v_eco_view_1.montant_facture_ht';
									break;
								case 'MFACTTC':
									return 'v_eco_view_1.montant_facture_ttc';
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="AGGR1">
			<value><![CDATA[[EVAL 
								switch ('[DATA1]') {
								case 'NFAC':
									return 'COUNT(DISTINCT ';
									break;
								default:
									return 'SUM(';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DATA2">
			<value><![CDATA[[EVAL 
								switch ('[DATA2]') {
								case 'NFAC':
									return 'v_eco_view_1.facture_id';
									break;
								case 'MFACHT':
									return 'v_eco_view_1.montant_facture_ht';
									break;
								case 'MFACTTC':
									return 'v_eco_view_1.montant_facture_ttc';
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="AGGR2">
			<value><![CDATA[[EVAL 
								switch ('[DATA2]') {
								case 'NFAC':
									return 'COUNT(DISTINCT ';
									break;
								default:
									return 'SUM(';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DATA3">
			<value><![CDATA[[EVAL 
								switch ('[DATA3]') {
								case 'NFAC':
									return 'v_eco_view_1.facture_id';
									break;
								case 'MFACHT':
									return 'v_eco_view_1.montant_facture_ht';
									break;
								case 'MFACTTC':
									return 'v_eco_view_1.montant_facture_ttc';
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="AGGR3">
			<value><![CDATA[[EVAL 
								switch ('[DATA3]') {
								case 'NFAC':
									return 'COUNT(DISTINCT ';
									break;
								default:
									return 'SUM(';
								}
					EVAL]]]></value>
		</PROPERTY>
		
	</VIEWPROPERTIES>

	
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Période">
			<FIELD name="PERIODE" label="" UI="combo" tree="true" width="200" default="2010-01-01" globalListProvider="PERIODE_DEBUT">
			</FIELD>
			<FIELD name="TOPERIODE" label="au" UI="combo" tree="true" width="200" default="2010-01-31" globalListProvider="PERIODE_FIN">
			</FIELD>
		</GROUP>
		<GROUP label="Période précédente">
			<FIELD name="PERIODE_D" label="" UI="combo" tree="true" width="200" default="2010-01-01" globalListProvider="PERIODE_DEBUT">
			</FIELD>
			<FIELD name="TOPERIODE_D" label="au" UI="combo" tree="true" width="200" default="2010-01-31" globalListProvider="PERIODE_FIN">
			</FIELD>
		</GROUP>
		<GROUP label="Données">
			<FIELD name="DATA1" label="" UI="combo" default="MFACTTC">
				<OPTION label="Nombre de factures" data="NFAC" data2="#" data3="Nb factures"/>
				<OPTION label="Montant facturé HT" data="MFACHT" data2="#E" data3="HT facture"/>
				<OPTION label="Montant facturé TTC" data="MFACTTC" data2="#E" data3="TTC facture"/>
			</FIELD>
			<FIELD name="DATA2" label="" UI="combo" default="-1">
				<OPTION label="" data="-1" data2=""/>
				<OPTION label="Nombre de factures" data="NFAC" data2="#" data3="Nb factures"/>
				<OPTION label="Nombre d'articles" data="QFAC" data2="#" data3="Nb articles"/>
				<OPTION label="Montant facturé HT" data="MFACHT" data2="#E" data3="HT facture"/>
				<OPTION label="Montant facturé TTC" data="MFACTTC" data2="#E" data3="TTC facture"/>
			</FIELD>
			<FIELD name="DATA3" label="" UI="combo" default="-1">
				<OPTION label="" data="-1" data2=""/>
				<OPTION label="Nombre de factures" data="NFAC" data2="#" data3="Nb factures"/>
				<OPTION label="Nombre d'articles" data="QFAC" data2="#" data3="Nb articles"/>
				<OPTION label="Montant facturé HT" data="MFACHT" data2="#E" data3="HT facture"/>
				<OPTION label="Montant facturé TTC" data="MFACTTC" data2="#E" data3="TTC facture"/>
			</FIELD>
		</GROUP>
		
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" label="" UI="combo" width="200" default="ART" tree="true">
				<OPTION label="Site" data="SIT" treeLevel="1"  globalListProvider="SITE_GROUPBY"/>
				<OPTION label="Article" data="ART" treeLevel="1"  globalListProvider="ARTICLE_GROUPBY"/>
				<OPTION label="Compte" data="CPA" treeLevel="1"  globalListProvider="COMPTE_ARTICLE_GROUPBY"/>
				<OPTION label="Fournisseur" data="FOU" treeLevel="1"  globalListProvider="FOURNISSEUR_GROUPBY"/>
				<OPTION label="Gestionnaire" data="GES" treeLevel="1"  globalListProvider="GESTIONNAIRE_GROUPBY"/>
				<OPTION label="Lieu" data="LIE" treeLevel="1"  globalListProvider="LIEU_GROUPBY"/>
				<OPTION label="Unité fonctionnelle" data="UFO" treeLevel="1"  globalListProvider="UNITE_FONCTIONNELLE_GROUPBY"/>
				<OPTION label="Facture" data="FAC" treeLevel="1"  />
				<OPTION label="Commande" data="CMD" treeLevel="1"  />
				<OPTION label="Source de données" data="PVD" treeLevel="1"  globalListProvider="PROVIDER_GROUPBY"/>
			</FIELD>
			<FIELD name="GROUPBY_TAB" width="100" label="Présentation" UI="combo" default="AUTO" visible="= SELECT.GROUPBY_2 != '-1' ">
				<OPTION label="Automatique" data="AUTO"/>
				<OPTION label="Arbre" data="TREE"/>
				<OPTION label="Onglet" data="TAB"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_2" label="" width="200" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1"/>
				<OPTION label="Site" data="SIT" treeLevel="1"  globalListProvider="SITE_GROUPBY"/>
				<OPTION label="Article" data="ART" treeLevel="1"  globalListProvider="ARTICLE_GROUPBY"/>
				<OPTION label="Compte" data="CPA" treeLevel="1"  globalListProvider="COMPTE_ARTICLE_GROUPBY"/>
				<OPTION label="Fournisseur" data="FOU" treeLevel="1"  globalListProvider="FOURNISSEUR_GROUPBY"/>
				<OPTION label="Gestionnaire" data="GES" treeLevel="1"  globalListProvider="GESTIONNAIRE_GROUPBY"/>
				<OPTION label="Lieu" data="LIE" treeLevel="1"  globalListProvider="LIEU_GROUPBY"/>
				<OPTION label="Unité fonctionnelle" data="UFO" treeLevel="1"  globalListProvider="UNITE_FONCTIONNELLE_GROUPBY"/>
				<OPTION label="Facture" data="FAC" treeLevel="1"  />
				<OPTION label="Commande" data="CMD" treeLevel="1"  />
				<OPTION label="Source de données" data="PVD" treeLevel="1"  globalListProvider="PROVIDER_GROUPBY"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_3" label="" width="200" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de troisième niveau" data="-1"/>
				<OPTION label="Site" data="SIT" treeLevel="1"  globalListProvider="SITE_GROUPBY"/>
				<OPTION label="Article" data="ART" treeLevel="1"  globalListProvider="ARTICLE_GROUPBY"/>
				<OPTION label="Compte" data="CPA" treeLevel="1"  globalListProvider="COMPTE_ARTICLE_GROUPBY"/>
				<OPTION label="Fournisseur" data="FOU" treeLevel="1"  globalListProvider="FOURNISSEUR_GROUPBY"/>
				<OPTION label="Gestionnaire" data="GES" treeLevel="1"  globalListProvider="GESTIONNAIRE_GROUPBY"/>
				<OPTION label="Lieu" data="LIE" treeLevel="1"  globalListProvider="LIEU_GROUPBY"/>
				<OPTION label="Unité fonctionnelle" data="UFO" treeLevel="1"  globalListProvider="UNITE_FONCTIONNELLE_GROUPBY"/>
				<OPTION label="Facture" data="FAC" treeLevel="1"  />
				<OPTION label="Commande" data="CMD" treeLevel="1"  />
				<OPTION label="Source de données" data="PVD" treeLevel="1"  globalListProvider="PROVIDER_GROUPBY"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
	

	<SELECTIONS componentName="FILTRES_FACTURE_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_FOURNISSEUR_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_ARTICLE_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_PROVIDER_SELECTIONS"/>
	
	<QUERIES>
		<QUERY label="">
			<SQL>
				<select><![CDATA[		
					CTISELECT_TREE
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
						GROUPBY3{[VIEW.GROUPBY_3_OID_FIELD],, [VIEW.GROUPBY_3_COD_FIELD],, [VIEW.GROUPBY_3_TXT_FIELD]}
						OPTIONS{NOTZERO=1}
						INDICATORS{
							[VIEW.AGGR1] CASE WHEN v_eco_view_1.date_facture BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN [VIEW.DATA1] ELSE 0 END),
							[VIEW.AGGR1] CASE WHEN v_eco_view_1.date_facture BETWEEN '[PERIODE_D]' AND '[TOPERIODE_D]' THEN [VIEW.DATA1] ELSE 0 END),
							0,0,
							[VIEW.AGGR2] CASE WHEN v_eco_view_1.date_facture BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN [VIEW.DATA2] ELSE 0 END),
							[VIEW.AGGR2] CASE WHEN v_eco_view_1.date_facture BETWEEN '[PERIODE_D]' AND '[TOPERIODE_D]' THEN [VIEW.DATA2] ELSE 0 END),
							0,0,
							[VIEW.AGGR3] CASE WHEN v_eco_view_1.date_facture BETWEEN '[PERIODE]' AND '[TOPERIODE]' THEN [VIEW.DATA3] ELSE 0 END),
							[VIEW.AGGR3] CASE WHEN v_eco_view_1.date_facture BETWEEN '[PERIODE_D]' AND '[TOPERIODE_D]' THEN [VIEW.DATA3] ELSE 0 END),
							0,0
						}
					FROM eco.v_lignes_facture_1 v_eco_view_1 
					WHERE 
						(v_eco_view_1.date_facture BETWEEN '[PERIODE]' AND '[TOPERIODE]' OR
						v_eco_view_1.date_facture BETWEEN '[PERIODE_D]' AND '[TOPERIODE_D]')
						[VIEW.ARTICLE_SELECT]
						[VIEW.FOURNISSEUR_SELECT]
						[VIEW.FACTURE_SELECT]
						[VIEW.PROVIDER_SELECT]
					
					AFTER{
						UPDATE w_table SET 
							indicateurs[3] = indicateurs[1] - indicateurs[2],
							indicateurs[4] = base.cti_division(indicateurs[1] - indicateurs[2], @(indicateurs[2])) * 100,
							indicateurs[7] = indicateurs[5] - indicateurs[6],
							indicateurs[8] = base.cti_division(indicateurs[5] - indicateurs[6], @(indicateurs[6])) * 100,
							indicateurs[11] = indicateurs[9] - indicateurs[10],
							indicateurs[12] = base.cti_division(indicateurs[9] - indicateurs[10], @(indicateurs[10])) * 100
					}
					
					

				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="F1"/>
					<FIELD name="D1"/>
					<FIELD name="E1"/>
					<FIELD name="P1"/>
					<FIELD name="F2"/>
					<FIELD name="D2"/>
					<FIELD name="E2"/>
					<FIELD name="P2"/>
					<FIELD name="F3"/>
					<FIELD name="D3"/>
					<FIELD name="E3"/>
					<FIELD name="P3"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINKx label="Liste des séjours" shortLabel="Liste séjours" view="ACTI000019.XML" componentName="PRESTATIONS_BASE_VIEWLINK">
				
			</VIEWLINKx>
		</VIEWLINKS>
		<ONGLET excelLabel="Répartition mensuelle" label="Répartition mensuelle" multiTab="true">
			<CHART xtitle="Comparatif" type="columnChart" maxItems="20" maxItemsSortOn="F1" maxItemsSortSeq="D" sortField="COD" sortSeq="A" >
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="D1" displayName="SELECT.DATA13 + ' ' + SELECT.PERIODE_D_LABEL + '-' + SELECT.TOPERIODE_D_LABEL" displayNameCalc="true"/>
				<SERIE field="F1" displayName="SELECT.DATA13 + ' ' + SELECT.PERIODE_LABEL + '-' + SELECT.TOPERIODE_LABEL" displayNameCalc="true"/>
			</CHART>
			<CHART title="Comparatif" type="columnChart" maxItems="20" maxItemsSortOn="F2" maxItemsSortSeq="D" sortField="COD" sortSeq="A" visibleCondition="SELECT.DATA2 != '-1'">
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="D2" displayName="SELECT.DATA23 + ' ' + SELECT.PERIODE_D_LABEL + '-' + SELECT.TOPERIODE_D_LABEL" displayNameCalc="true"/>
				<SERIE field="F2" displayName="SELECT.DATA23 + ' ' + SELECT.PERIODE_LABEL + '-' + SELECT.TOPERIODE_LABEL" displayNameCalc="true"/>
			</CHART>
			<CHART title="Comparatif" type="columnChart" maxItems="20" maxItemsSortOn="F3" maxItemsSortSeq="D" sortField="COD" sortSeq="A" visibleCondition="SELECT.DATA3 != '-1'">
				<CATEGORY field="COD" type="Char"/>
				<SERIE field="D3" displayName="SELECT.DATA33 + ' ' + SELECT.PERIODE_D_LABEL + '-' + SELECT.TOPERIODE_D_LABEL" displayNameCalc="true"/>
				<SERIE field="F3" displayName="SELECT.DATA33 + ' ' + SELECT.PERIODE_LABEL + '-' + SELECT.TOPERIODE_LABEL" displayNameCalc="true"/>
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="70" variableRowHeight="true" sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'">
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="100" type="Char" visible="true" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="50" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="*ROW" >
				</COLUMN>
				<COLUMN dataField="D1" width="100" visible="true" type="Number" outputFormat="= SELECT.DATA12" fixed="false" selectable="true" headerText="SELECT.DATA13 + ' ' + SELECT.PERIODE_D_LABEL + '- ' + SELECT.TOPERIODE_D_LABEL" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="F1" width="100" visible="true" type="Number" outputFormat="= SELECT.DATA12" fixed="false" selectable="true" headerText="SELECT.DATA13 + ' ' + SELECT.PERIODE_LABEL + '- ' + SELECT.TOPERIODE_LABEL" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="E1" type="Number" headerText="Ecart" width="70" visible="true" outputFormat="= SELECT.DATA12" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="P1" type="Number" headerText="% évol." width="45" visible="true" outputFormat="= if (ROW.D01 != 0 &amp;&amp; ROW.F01 != 0) {return '0%'} else {return '#'}" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum" >
				</COLUMN>
				<COLUMN dataField="D2" width="100" visibleCondition="SELECT.DATA2 != '-1'" type="Number" outputFormat="= SELECT.DATA22" fixed="false" selectable="true" headerText="SELECT.DATA23 + ' ' + SELECT.PERIODE_D_LABEL + '- ' + SELECT.TOPERIODE_D_LABEL" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="F2" width="100" visibleCondition="SELECT.DATA2 != '-1'" type="Number" outputFormat="= SELECT.DATA22" fixed="false" selectable="true" headerText="SELECT.DATA23 + ' ' + SELECT.PERIODE_LABEL + '- ' + SELECT.TOPERIODE_LABEL" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="E2" type="Number" headerText="Ecart" width="70" visibleCondition="SELECT.DATA2 != '-1'" outputFormat="= SELECT.DATA22" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="P2" type="Number" headerText="% évol." width="45" visibleCondition="SELECT.DATA2 != '-1'" outputFormat="= if (ROW.D02 !=0  &amp;&amp;  ROW.F02 != 0) {return '0%'} else {return '#'}" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum" >
				</COLUMN>
				<COLUMN dataField="D3" width="100" visibleCondition="SELECT.DATA3 != '-1'" type="Number" outputFormat="= SELECT.DATA32" fixed="false" selectable="true" headerText="SELECT.DATA33 + ' ' + SELECT.PERIODE_D_LABEL + '- ' + SELECT.TOPERIODE_D_LABEL" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="F3" width="100" visibleCondition="SELECT.DATA3 != '-1'" type="Number" outputFormat="= SELECT.DATA32" fixed="false" selectable="true" headerText="SELECT.DATA33 + ' ' + SELECT.PERIODE_LABEL + '- ' + SELECT.TOPERIODE_LABEL" headerTextCalc="true" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="E3" type="Number" headerText="Ecart" width="70" visibleCondition="SELECT.DATA3 != '-1'" outputFormat="= SELECT.DATA32" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="P3" type="Number" headerText="% évol." width="45" visibleCondition="SELECT.DATA3 != '-1'" outputFormat="= if (ROW.D03 !=0  &amp;&amp;  ROW.F03 != 0) {return '0%'} else {return '#'}" fixed="false" textAlign="right" totalFunction="sum" totalComplement="" otherFunction="sum" >
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
