<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ACTI000024" label="Chiffrier SHS" 
	title="= 'Chiffrier SHS - ' + SELECT.CH_LABEL + ' (' + SELECT.ANNEE_D + '-' + SELECT.ANNEE_F + ')'"
	database="iCTI" swf="*CTI_view1" softCode="iCTI_activite" admProvider="shs">
	
	<VIEWPROPERTIES>
		<PROPERTY name="CH" value="[EVAL 
				if ('[CH]' != 'H') {return '_c';} else {return '_h';}
			EVAL]" />
			
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>
	

	<SELECTIONS label="Paramètres" >
		<GROUP  label="Période">
			<FIELD name="ANNEE_D" label="" UI="combo" width="150" default="2006" >
				<OPTION dataLink="ANNEES" dataField="annee" labelField="annee" />
			</FIELD>
			<FIELD name="ANNEE_F" label="à" UI="combo" width="150" default="2008" >
				<OPTION dataLink="ANNEES" dataField="annee" labelField="annee" />
			</FIELD>
		</GROUP>
		<GROUP>
			<FIELD name="CH" label="C/H" UI="combo" width="150" default="C" >
				<OPTION data="C" label="Clinique" />
				<OPTION data="H" label="Honoraires"/>
			</FIELD>
		</GROUP>
	</SELECTIONS>
		
	
	<QUERIES> 
		<QUERY> 
			<SQL select="SELECT date_comptable, montant_ventes[VIEW.CH], montant_reglements[VIEW.CH], montant_solde_client[VIEW.CH]
						FROM activite.p_chiffrier_shs
						WHERE date_comptable &gt;= '[ANNEE_D]-01-01' AND date_comptable &lt;= '[ANNEE_F]-12-31'
						ORDER BY date_comptable" >
				<FIELDS>
					<FIELD name="DATE" />
					<FIELD name="VEN" />
					<FIELD name="REG" />
					<FIELD name="CLI" />
				</FIELDS>
			</SQL>
			
		</QUERY>
		
		<QUERY> 
			<SQL select="SELECT date,
							p_chiffrier_shs.montant_ventes[VIEW.CH], 
							CASE WHEN to_char(p_chiffrier_shs_1.date_comptable, 'YYYY')::numeric >= [ANNEE_D] THEN p_chiffrier_shs_1.montant_ventes[VIEW.CH] ELSE 0 END, 
							CASE WHEN to_char(p_chiffrier_shs_2.date_comptable, 'YYYY')::numeric >= [ANNEE_D] THEN p_chiffrier_shs_2.montant_ventes[VIEW.CH] ELSE 0 END
						FROM base.p_calendrier 
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs ON p_calendrier.date = p_chiffrier_shs.date_comptable
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs_1 
							ON to_char(p_calendrier.date, 'YYYY')::numeric = to_char(p_chiffrier_shs_1.date_comptable, 'YYYY')::numeric + 1
							AND to_char(p_calendrier.date, 'MM')::numeric = to_char(p_chiffrier_shs_1.date_comptable, 'MM')::numeric 
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs_2 
							ON to_char(p_calendrier.date, 'YYYY')::numeric = to_char(p_chiffrier_shs_2.date_comptable, 'YYYY')::numeric + 2
							AND to_char(p_calendrier.date, 'MM')::numeric = to_char(p_chiffrier_shs_2.date_comptable, 'MM')::numeric 
						WHERE dernier_jour = '1' 
							AND to_char(date, 'YYYY')::numeric = [ANNEE_F]
						ORDER BY date" >
				<FIELDS>
					<FIELD name="DATE" />
					<FIELD name="M" />
					<FIELD name="M1" />
					<FIELD name="M2" />

				</FIELDS>
			</SQL>
			
			
		</QUERY>
		
		<QUERY> 
			<SQL select="SELECT date, 
							p_chiffrier_shs.montant_reglements[VIEW.CH], 
							CASE WHEN to_char(p_chiffrier_shs_1.date_comptable, 'YYYY')::numeric >= [ANNEE_D] THEN p_chiffrier_shs_1.montant_reglements[VIEW.CH] ELSE 0 END, 
							CASE WHEN to_char(p_chiffrier_shs_2.date_comptable, 'YYYY')::numeric >= [ANNEE_D] THEN p_chiffrier_shs_2.montant_reglements[VIEW.CH] ELSE 0 END
						FROM base.p_calendrier 
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs ON p_calendrier.date = p_chiffrier_shs.date_comptable
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs_1 
							ON to_char(p_calendrier.date, 'YYYY')::numeric = to_char(p_chiffrier_shs_1.date_comptable, 'YYYY')::numeric + 1
							AND to_char(p_calendrier.date, 'MM')::numeric = to_char(p_chiffrier_shs_1.date_comptable, 'MM')::numeric 
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs_2 
							ON to_char(p_calendrier.date, 'YYYY')::numeric = to_char(p_chiffrier_shs_2.date_comptable, 'YYYY')::numeric + 2
							AND to_char(p_calendrier.date, 'MM')::numeric = to_char(p_chiffrier_shs_2.date_comptable, 'MM')::numeric 
						WHERE dernier_jour = '1' 
							AND to_char(date, 'YYYY')::numeric = [ANNEE_F]
						ORDER BY date" >
				<FIELDS>
					<FIELD name="DATE" />
					<FIELD name="M" />
					<FIELD name="M1" />
					<FIELD name="M2" />

				</FIELDS>
			</SQL>
			
			
		</QUERY>
		
		
		<QUERY> 
			<SQL select="SELECT date, 
							p_chiffrier_shs.montant_solde_client[VIEW.CH], 
							CASE WHEN to_char(p_chiffrier_shs_1.date_comptable, 'YYYY')::numeric >= [ANNEE_D] THEN p_chiffrier_shs_1.montant_solde_client[VIEW.CH] ELSE 0 END, 
							CASE WHEN to_char(p_chiffrier_shs_2.date_comptable, 'YYYY')::numeric >= [ANNEE_D] THEN p_chiffrier_shs_2.montant_solde_client[VIEW.CH] ELSE 0 END
						FROM base.p_calendrier 
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs ON p_calendrier.date = p_chiffrier_shs.date_comptable
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs_1 
							ON to_char(p_calendrier.date, 'YYYY')::numeric = to_char(p_chiffrier_shs_1.date_comptable, 'YYYY')::numeric + 1
							AND to_char(p_calendrier.date, 'MM')::numeric = to_char(p_chiffrier_shs_1.date_comptable, 'MM')::numeric 
							LEFT OUTER JOIN activite.p_chiffrier_shs p_chiffrier_shs_2 
							ON to_char(p_calendrier.date, 'YYYY')::numeric = to_char(p_chiffrier_shs_2.date_comptable, 'YYYY')::numeric + 2
							AND to_char(p_calendrier.date, 'MM')::numeric = to_char(p_chiffrier_shs_2.date_comptable, 'MM')::numeric 
						WHERE dernier_jour = '1' 
							AND to_char(date, 'YYYY')::numeric = [ANNEE_F]
						ORDER BY date" >
				<FIELDS>
					<FIELD name="DATE" />
					<FIELD name="M" />
					<FIELD name="M1" />
					<FIELD name="M2" />

				</FIELDS>
			</SQL>
			
			
		</QUERY>
			
		
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false"> 
			<SQL   
				select="SELECT DISTINCT 'V'::text || ([ANNEE_F]  - annee)::text, annee
							FROM base.p_calendrier_mois
							WHERE annee &gt;= [ANNEE_D] AND annee &lt;= [ANNEE_F]
						UNION
						SELECT DISTINCT 'R'::text || ([ANNEE_F]  - annee)::text, annee
							FROM base.p_calendrier_mois
							WHERE annee &gt;= [ANNEE_D] AND annee &lt;= [ANNEE_F]
						UNION
						SELECT DISTINCT 'C'::text || ([ANNEE_F]  - annee)::text, annee
							FROM base.p_calendrier_mois
							WHERE annee &gt;= [ANNEE_D] AND annee &lt;= [ANNEE_F]
						ORDER BY annee" >
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
			
		</QUERY>
		
		<QUERY type="comboLink" name="ANNEES" forRows="false"> 
			<SQL select="SELECT DISTINCT to_char(p_calendrier.date, 'YYYY')::numeric
						FROM base.p_calendrier, activite.p_chiffrier_shs
						WHERE date = date_comptable 
						ORDER BY to_char(p_calendrier.date, 'YYYY')::numeric DESC " >
				<FIELDS>
					<FIELD name="annee" />
				</FIELDS>
			</SQL>
		</QUERY>
				
	</QUERIES> 
	
	<CALCFIELDS>
	</CALCFIELDS>
	
	<PRESENTATION>
	
		<LINKS>
		
		
		</LINKS>
			
		
		<ONGLET label="Ventes" queryNumber="1" chartsPercentHeight="98">
		
					
			<CHART title="Comparatif des ventes" type="columnChart" maxItems="12" sortField="DATE" sortSeq="A">
				<CATEGORY field="DATE" 
					type="Date"
					displayName="Mois"
					valueName="Montant ventes"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM"
					/>
				<SERIE field="M2" displayName="VIEW.V2" displayNameCalc="true" visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"/>
				<SERIE field="M1" displayName="VIEW.V1" displayNameCalc="true" visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"/>
				<SERIE field="M" displayName="VIEW.V0" displayNameCalc="true" />
			</CHART>
			
			<DATAGRID title="" key="DATE" keySeq="A"  headerHeight="36" printRatio="1">
				
				
				<COLUMN dataField="DATE" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMMM"
					minWidth="120"
					visible="true"
					headerText="Mois" 
					textAlign="left"
				/>
				
				<COLUMN dataField="M2"
					type="Number"
					outputFormat="#E"
					width="120"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"
					headerText="VIEW.V2"
					headerTextCalc="true"
					align="right" />
				<COLUMN dataField="M1M2"
					type="Number"
					outputFormat="#E"
					width="100"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"
					headerText="'Ecart ' + VIEW.V1 + ' - ' + VIEW.V2"
					headerTextCalc="true"
					align="right" 
					calc="true">
					<CALC dataField="M1" />
					<CALC dataField="M2" operator="-" />
				</COLUMN>
				<COLUMN dataField="M1"
					type="Number"
					outputFormat="#E"
					width="120"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"
					headerText="VIEW.V1"
					headerTextCalc="true"
					align="right" />
				<COLUMN dataField="M0M1"
					type="Number"
					outputFormat="#E"
					width="100"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"
					headerText="'Ecart ' + VIEW.V0 + ' - ' + VIEW.V1"
					headerTextCalc="true"
					align="right" 
					calc="true">
					<CALC dataField="M" />
					<CALC dataField="M1" operator="-" />
				</COLUMN>
				<COLUMN dataField="M"
					type="Number"
					outputFormat="#E"
					width="120"
					headerText="VIEW.V0"
					headerTextCalc="true"
					align="right" />
				
				
			</DATAGRID>
		
		</ONGLET>
		
		
		<ONGLET label="Règlements" queryNumber="2" chartsPercentHeight="98">
		
					
			<CHART title="Comparatif des règlements" type="columnChart" maxItems="12" sortField="DATE" sortSeq="A">
				<CATEGORY field="DATE" 
					type="Date"
					displayName="Mois"
					valueName="Montant règlements"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM"
					/>
				<SERIE field="M2" displayName="VIEW.R2" displayNameCalc="true" visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"/>
				<SERIE field="M1" displayName="VIEW.R1" displayNameCalc="true" visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"/>
				<SERIE field="M" displayName="VIEW.R0" displayNameCalc="true" />
			</CHART>
			
			<DATAGRID title="" key="DATE" keySeq="A"  headerHeight="36" printRatio="1">
				
				
				<COLUMN dataField="DATE" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMMM"
					minWidth="80"
					visible="true"
					headerText="Mois" 
					textAlign="left"
				/>
				
				<COLUMN dataField="M2"
					type="Number"
					outputFormat="#E"
					width="120"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"
					headerText="VIEW.R2"
					headerTextCalc="true"
					align="right" />
				<COLUMN dataField="M1M2"
					type="Number"
					outputFormat="#E"
					width="100"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"
					headerText="'Ecart ' + VIEW.R1 + ' - ' + VIEW.R2"
					headerTextCalc="true"
					align="right" 
					calc="true">
					<CALC dataField="M1" />
					<CALC dataField="M2" operator="-" />
				</COLUMN>
				<COLUMN dataField="M1"
					type="Number"
					outputFormat="#E"
					width="120"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"
					headerText="VIEW.R1"
					headerTextCalc="true"
					align="right" />
				<COLUMN dataField="M0M1"
					type="Number"
					outputFormat="#E"
					width="100"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"
					headerText="'Ecart ' + VIEW.R0 + ' - ' + VIEW.R1"
					headerTextCalc="true"
					align="right" 
					calc="true">
					<CALC dataField="M" />
					<CALC dataField="M1" operator="-" />
				</COLUMN>
				<COLUMN dataField="M"
					type="Number"
					outputFormat="#E"
					width="120"
					headerText="VIEW.R0"
					headerTextCalc="true"
					align="right" />
				
				
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET label="Solde clients" queryNumber="3" chartsPercentHeight="98">
		
			<CHART title="Comparatif des soldes clients" type="columnChart" maxItems="12" sortField="DATE" sortSeq="A">
				<CATEGORY field="DATE" 
					type="Date"
					displayName="Mois"
					valueName="Montant solde client"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM"
					/>
				<SERIE field="M2" displayName="VIEW.C2" displayNameCalc="true" visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"/>
				<SERIE field="M1" displayName="VIEW.C1" displayNameCalc="true" visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"/>
				<SERIE field="M" displayName="VIEW.C0" displayNameCalc="true" />
			</CHART>
			
			<DATAGRID title="" key="DATE" keySeq="A" headerHeight="36" printRatio="1">
				
				
				<COLUMN dataField="DATE" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMMM"
					minWidth="80"
					visible="true"
					headerText="Mois" 
					textAlign="left"
				/>
				
				<COLUMN dataField="M2"
					type="Number"
					outputFormat="#E"
					width="120"
					visible="false"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"
					headerText="VIEW.C2"
					headerTextCalc="true"
					align="right" />
				<COLUMN dataField="M1M2"
					type="Number"
					outputFormat="#E"
					width="120"
					visible="false"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 2"
					headerText="'Ecart ' + VIEW.C1 + ' - ' + VIEW.C2"
					headerTextCalc="true"
					align="right" 
					calc="true">
					<CALC dataField="M1" />
					<CALC dataField="M2" operator="-" />
				</COLUMN>
				<COLUMN dataField="M1"
					type="Number"
					outputFormat="#E"
					width="120"
					visible="false"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"
					headerText="VIEW.C1"
					headerTextCalc="true"
					align="right" />
				<COLUMN dataField="M0M1"
					type="Number"
					outputFormat="#E"
					width="120"
					visible="false"
					visibleCondition="Number(SELECT.ANNEE_F) - Number(SELECT.ANNEE_D) &gt;= 1"
					headerText="'Ecart ' + VIEW.C0 + ' - ' + VIEW.C1"
					headerTextCalc="true"
					align="right" 
					calc="true">
					<CALC dataField="M" />
					<CALC dataField="M1" operator="-" />
				</COLUMN>
				<COLUMN dataField="M"
					type="Number"
					outputFormat="#E"
					width="120"
					headerText="VIEW.C0"
					headerTextCalc="true"
					align="right" />
				
				
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET label="Détail">
		
			<CHART title="Ventes / règlements / clients 12 derniers mois" type="columnChart" sortField="DATE" sortSeq="A" maxItems="12"  maxItemsSortOn="DATE" maxItemsSortSeq="D" condition="ROW.CLI != 0" >
				<CATEGORY field="DATE" 
					type="Date"
					displayName="Mois"
					valueName="Montant"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="VEN" displayName="Ventes" />
				<SERIE field="REG" displayName="Règlements" />
				<SERIE field="CLI" displayName="Clients" />
			</CHART>
			<CHART title="Ventes / règlements / clients Historique" type="lineChart" sortField="DATE" sortSeq="A" maxItems="72"  maxItemsSortOn="DATE" maxItemsSortSeq="D" condition="ROW.CLI != 0" >
				<CATEGORY field="DATE" 
					type="Date"
					displayName="Mois"
					valueName="Montant"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="VEN" displayName="Ventes" />
				<SERIE field="REG" displayName="Règlements" />
				<SERIE field="CLI" displayName="Clients" />
			</CHART>
			
			<DATAGRID title="" key="DATE" keySeq="D" headerHeight="36" printRatio="1">
							
				
				<COLUMN dataField="DATE" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMMM YYYY"
					minWidth="80"
					visible="true"
					headerText="Mois" 
					textAlign="left"
				/>
				
				<COLUMN dataField="VEN"
					type="Number"
					outputFormat="#E"
					width="120"
					headerText="Ventes"
					align="right" />
				<COLUMN dataField="REG"
					type="Number"
					outputFormat="#E"
					width="120"
					headerText="Règlements"
					align="right" />
				<COLUMN dataField="CLI"
					type="Number"
					outputFormat="#E"
					width="120"
					headerText="Solde client"
					align="right" />
				
				
			</DATAGRID>
		
		</ONGLET>
		
		
		
				
	</PRESENTATION>
	
</VUE>

			
