<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ECO000070" 
	label="ECO. Chiffrier CTI" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_eco"
	componentFile="ECO_components.XML">
	<CACHE cachable="false" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>
	
	<SELECTIONS>
		
	</SELECTIONS>
	
	<QUERIES>
		<QUERY> 
			
			<SQL select="SELECT  substr(mois, 1, 4) || '-' || substr(mois, 5, 2)  || '-01', 
							sum(montant_commande), 
							sum(montant_livraison),
							sum(montant_consommation)
							FROM eco.p_chiffrier_production GROUP BY mois  ORDER BY mois DESC " >
				<FIELDS>
					<FIELD name="MOIS" />
					<FIELD name="COM" />
					<FIELD name="LIV" />
					<FIELD name="CONS" />
				</FIELDS>
			</SQL>
			
		</QUERY>
		
		<QUERY> 
			
			<SQL select="SELECT  p_calendrier_mois.annee, 
						sum(montant_commande), 
						sum(montant_livraison),
						sum(montant_consommation)
				FROM eco.p_chiffrier_production, base.p_calendrier_mois 
				WHERE p_chiffrier_production.mois = p_calendrier_mois.mois
				GROUP BY annee
				ORDER BY annee DESC " >
				<FIELDS>
					<FIELD name="ANNEE" />
					<FIELD name="COM" />
					<FIELD name="LIV" />
					<FIELD name="CONS" />
				</FIELDS>
			</SQL>
			
		</QUERY>
		
	<!-- 	<QUERY> 
			
			<SQL select="(SELECT t_finess.code, t_finess.texte,
					SUM(CASE WHEN mois &gt;= 200801 AND mois &lt;= 200812 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 200801 AND mois &lt;= 200812 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 200901 AND mois &lt;= 200912 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 200901 AND mois &lt;= 200912 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201001 AND mois &lt;= 201012 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201001 AND mois &lt;= 201012 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201101 AND mois &lt;= 201112 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201101 AND mois &lt;= 201112 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201201 AND mois &lt;= 201212 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201201 AND mois &lt;= 201212 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201301 AND mois &lt;= 201312 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201301 AND mois &lt;= 201312 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201401 AND mois &lt;= 201412 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201401 AND mois &lt;= 201412 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201501 AND mois &lt;= 201512 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201501 AND mois &lt;= 201512 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201601 AND mois &lt;= 201612 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201601 AND mois &lt;= 201612 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201701 AND mois &lt;= 201712 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201701 AND mois &lt;= 201712 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201801 AND mois &lt;= 201812 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201801 AND mois &lt;= 201812 THEN mois::text || '01' ELSE null END)
					FROM base.t_finess LEFT JOIN eco.p_chiffrier_production ON (p_chiffrier.finess = t_finess.code AND nb_rsa_champ_ghs &lt;&gt; 0)
					WHERE t_finess.secondaire = '1'
					GROUP BY t_finess.code, t_finess.texte)

					UNION ALL

					(SELECT '000000000', COUNT(DISTINCT t_finess.code)::text || ' Etablissements',
					SUM(CASE WHEN mois &gt;= 200801 AND mois &lt;= 200812 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 200801 AND mois &lt;= 200812 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 200901 AND mois &lt;= 200912 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 200901 AND mois &lt;= 200912 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201001 AND mois &lt;= 201012 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201001 AND mois &lt;= 201012 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201101 AND mois &lt;= 201112 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201101 AND mois &lt;= 201112 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201201 AND mois &lt;= 201212 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201201 AND mois &lt;= 201212 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201301 AND mois &lt;= 201312 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201301 AND mois &lt;= 201312 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201401 AND mois &lt;= 201412 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201401 AND mois &lt;= 201412 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201501 AND mois &lt;= 201512 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201501 AND mois &lt;= 201512 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201601 AND mois &lt;= 201612 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201601 AND mois &lt;= 201612 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201701 AND mois &lt;= 201712 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201701 AND mois &lt;= 201712 THEN mois::text || '01' ELSE null END),
					SUM(CASE WHEN mois &gt;= 201801 AND mois &lt;= 201812 THEN nb_rsa ELSE null END),
					MAX(CASE WHEN mois &gt;= 201801 AND mois &lt;= 201812 THEN mois::text || '01' ELSE null END)
					FROM base.t_finess 
					LEFT JOIN eco.p_chiffrier_production ON (p_chiffrier.finess = t_finess.code AND nb_rsa_champ_ghs &lt;&gt; 0)
					WHERE t_finess.secondaire = '1')

					ORDER BY 1 " >
				<FIELDS>
					<FIELD name="FIN" />
					<FIELD name="FINTXT" />
					<FIELD name="RSA2008" />
					<FIELD name="DAT2008" />
					<FIELD name="RSA2009" />
					<FIELD name="DAT2009" />
					<FIELD name="RSA2010" />
					<FIELD name="DAT2010" />
					<FIELD name="RSA2011" />
					<FIELD name="DAT2011" />
					<FIELD name="RSA2012" />
					<FIELD name="DAT2012" />
					<FIELD name="RSA2013" />
					<FIELD name="DAT2013" />
					<FIELD name="RSA2014" />
					<FIELD name="DAT2014" />
					<FIELD name="RSA2015" />
					<FIELD name="DAT2015" />
					<FIELD name="RSA2016" />
					<FIELD name="DAT2016" />
					<FIELD name="RSA2017" />
					<FIELD name="DAT2017" />
					<FIELD name="RSA2018" />
					<FIELD name="DAT2018" />
				</FIELDS>
			</SQL>
			
		</QUERY> -->
	
	</QUERIES>
	
	<CALCFIELDS>
	</CALCFIELDS>
	
	<PRESENTATION>
	
		<ONGLET label="Chiffrier annuel" queryNumber="1">
		
			<CHART title="Séjours" type="columnChart" subType="" categoryField="ANNEE" sortField="ANNEE" sortSeq="A" maxItems="72"  maxItemsSortOn="ANNEE" maxItemsSortSeq="D"  >
				<CATEGORY field="ANNEE" 
					type="Char"
					/>

				<SERIE field="COM" displayName="Montant Commandé (HT)"/>
				<SERIE field="LIV" displayName="Montant Livré (HT)" />
				<SERIE field="CONS" displayName="Montant Cosommé (HT)" />
			</CHART>
					
			<DATAGRID title="Chiffrier" key="ANNEE" keySeq="D" headerHeight="48" >
				<COLUMN dataField="ANNEE"
					type="Char"
					width="100"
					outputFormat="#"
					headerText="Année"
					textAlign="left" />
				<COLUMN dataField="COM" 
					type="Number"
					width="110"
					outputFormat="#E"
					headerText="Montant Commandé (HT)" 
					textAlign="right" />
				<COLUMN dataField="LIV" 
					type="Number" 
					width="110"
					outputFormat="#E"
					headerText="Montant Livré (HT)" 
					textAlign="right" 
					largeSeparator="true"/>
				<COLUMN dataField="CONS" 
					type="Number"
					width="110"
					outputFormat="#E"
					headerText="Montant Consommé (HT)" 
					textAlign="right" />
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET label="Chiffrier mensuel" queryNumber="0">
			<CHART title="Séjours" type="columnChart" subType="" categoryField="MOIS" sortField="ANNEE" sortSeq="A" maxItems="72"  maxItemsSortOn="MOIS" maxItemsSortSeq="D"  >
				<CATEGORY field="MOIS" 
					type="Char"
					/>

				<SERIE field="COM" displayName="Montant Commandé (HT)"/>
				<SERIE field="LIV" displayName="Montant Livré (HT)" />
				<SERIE field="CONS" displayName="Montant Cosommé (HT)" />
			</CHART>
					
			<DATAGRID title="Chiffrier" key="ANNEE" keySeq="D" headerHeight="48" >
				<COLUMN dataField="MOIS"
					type="Char"
					width="100"
					outputFormat="#"
					headerText="Année"
					textAlign="left" />
				<COLUMN dataField="COM" 
					type="Number"
					width="110"
					outputFormat="#E"
					headerText="Montant Commandé (HT)" 
					textAlign="right" />
				<COLUMN dataField="LIV" 
					type="Number" 
					width="110"
					outputFormat="#E"
					headerText="Montant Livré (HT)" 
					textAlign="right" 
					largeSeparator="true"/>
				<COLUMN dataField="CONS" 
					type="Number"
					width="110"
					outputFormat="#E"
					headerText="Montant Consommé (HT)" 
					textAlign="right" />
			</DATAGRID>
		</ONGLET>
		
		<!-- <ONGLET label="Séjours par établisements (consolidation)" queryNumber="2">
		
					
			<CHARTx title="séjours" type="columnChart" subType="stacked" categoryField="MOIS" sortField="MOIS" sortSeq="A" maxItems="24"  maxItemsSortOn="MOIS" maxItemsSortSeq="D"  >
				<CATEGORY field="MOIS" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="RSA1" displayName="VIEW.TX1" displayNameCalc="true"/>
				<SERIE field="RSA2" displayName="VIEW.TX2" displayNameCalc="true"/>
				<SERIE field="RSA3" displayName="VIEW.TX3" displayNameCalc="true"/>
				<SERIE field="RSA4" displayName="VIEW.TX4" displayNameCalc="true"/>
				<SERIE field="RSA5" displayName="VIEW.TX5" displayNameCalc="true"/>
				<SERIE field="RSA6" displayName="VIEW.TX6" displayNameCalc="true"/>
				<SERIE field="RSA7" displayName="VIEW.TX7" displayNameCalc="true"/>
				<SERIE field="RSA8" displayName="VIEW.TX8" displayNameCalc="true"/>
				<SERIE field="RSA9" displayName="VIEW.TX9" displayNameCalc="true"/>
			</CHARTx>
			
					
			<DATAGRID title="Séjours par établissement (consolidation)" total="true" key="FIN" headerHeight="48" keySeq="A"
				totalRowInRows="= ROW.FIN == '000000000'"
			>
				
				<COLUMN dataField="FIN" 
					type="Char"
					width="80"
					headerText="FINESS" 
					textAlign="center"
					totalFunction="text"
					totalComplement="TOTAL"/>
				<COLUMN dataField="FINTXT" 
					type="Char"
					minWidth="200"
					headerText="Etablissement" 
					textAlign="left" />
				<COLUMN dataField="RSA2018" 
					type="Number"
					width="80"
					outputFormat="#"
					headerText="Séjours 2018" 
					textAlign="right" 
					fixed="false"
					visibleCondition="VIEW.DAT2018 != ''"
					/>
				<COLUMN dataField="DAT2018"
					type="Date"
					inputFormat="AAAAMMJJ"
					outputFormat="MMMM"
					width="100"
					headerText="Dernier mois 2018"
					textAlign="center"  
					fixed="false"
					visibleCondition="VIEW.DAT2018 != ''"
					>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" 
							condition="ROW.DAT2018 != VIEW.DAT2018 &amp;&amp; ROW.DAT2017 == VIEW.DAT2017" />
				</COLUMN>	
				<COLUMN dataField="RSA2017" 
					type="Number"
					width="80"
					outputFormat="#"
					headerText="Séjours 2017" 
					textAlign="right" 
					fixed="false"
					visibleCondition="VIEW.DAT2017 != ''"
					/>
				<COLUMN dataField="DAT2017"
					type="Date"
					inputFormat="AAAAMMJJ"
					outputFormat="MMMM"
					width="100"
					headerText="Dernier mois 2017"
					textAlign="center"  
					fixed="false"
					visibleCondition="VIEW.DAT2017 != ''"
					>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" 
							condition="ROW.DAT2017 != VIEW.DAT2017 &amp;&amp; ROW.DAT2016 == VIEW.DAT2016" />
				</COLUMN>
				
				<COLUMN dataField="RSA2016" 
					type="Number"
					width="80"
					outputFormat="#"
					headerText="Séjours 2016" 
					textAlign="right" 
					fixed="false"
					visibleCondition="VIEW.DAT2016 != ''"
					/>
				<COLUMN dataField="DAT2016"
					type="Date"
					inputFormat="AAAAMMJJ"
					outputFormat="MMMM"
					width="100"
					headerText="Dernier mois 2016"
					textAlign="center"  
					fixed="false"
					visibleCondition="VIEW.DAT2016 != ''"
					>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" 
							condition="ROW.DAT2016 != VIEW.DAT2016 &amp;&amp; ROW.DAT2015 == VIEW.DAT2015" />
				</COLUMN>
				
				<COLUMN dataField="RSA2015" 
					type="Number"
					width="80"
					outputFormat="#"
					headerText="Séjours 2015" 
					textAlign="right" 
					fixed="false"
					visibleCondition="VIEW.DAT2015 != ''"
					/>
				<COLUMN dataField="DAT2015"
					type="Date"
					inputFormat="AAAAMMJJ"
					outputFormat="MMMM"
					width="100"
					headerText="Dernier mois 2015"
					textAlign="center"  
					fixed="false"
					visibleCondition="VIEW.DAT2015 != ''"
					>
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF0000" 
							condition="ROW.DAT2015 != VIEW.DAT2015 &amp;&amp; ROW.DAT2014 == VIEW.DAT2014" />
				</COLUMN>
					
				<COLUMN dataField="RSA2014" 
					type="Number"
					width="80"
					outputFormat="#"
					headerText="Séjours 2014" 
					textAlign="right" 
					fixed="false"
					visibleCondition="VIEW.DAT2014 != ''"
					/>
				<COLUMN dataField="DAT2014"
					type="Date"
					inputFormat="AAAAMMJJ"
					outputFormat="MMMM"
					width="100"
					headerText="Dernier mois 2014"
					textAlign="center"  
					fixed="false"
					visibleCondition="VIEW.DAT2014 != ''"
					>
					<CELLSTYLEx name="cellIndicator" value="circle, 5, left top, 0xFF0000" 
							condition="ROW.DAT2014 != VIEW.DAT2014 &amp;&amp; ROW.DAT2013 == VIEW.DAT2013" />
				</COLUMN>
				
				
				
				
					
					
				
			</DATAGRID>
		
		</ONGLET> -->
		
		
		
				
	</PRESENTATION>
	
</VUE>

