<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="COMPTA000025" label="Liste des écritures" title="= 'Comptabilité ' + SELECT.CH_LABEL + '. Liste des écritures  (' + SELECT.MOIS_LABEL + ' - ' + SELECT.TOMOIS_LABEL + ')'" database="iCTI" swf="*CTI_view1" globals="COMPTA_globals.XML" dboptimizer="COMPTA_dboptimizer.XML" componentsFile="COMPTA_components.XML" softCode="iCTI_compta" helpFile="iCTI_COMPTA_COMPTA000025.HTML">
	<VIEWPROPERTIES>
		<PROPERTY name="INDICATEUR_SELECT" value="[EVAL 
						$select = '';
																		
						if ('[INDICATEUR]' != '-1') {
							$select = $select . 'AND ([VIEW.INDICATEUR_COLUMN]) &lt;&gt; 0 ' ;
						}
						
						return $select;
			EVAL]"/>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Comptabilité">
			<FIELD name="CH" label="" UI="combo" width="150" default="C">
				<OPTION data="C" label="Clinique"/>
				<OPTION data="H" label="Honoraires"/>
			</FIELD>
		</GROUP>
		<GROUP label="Période">
			<FIELD name="MOIS" label="" UI="combo" width="150" default="*FIRST" globalListProvider="MOIS">
			</FIELD>
			<FIELD name="TOMOIS" label="" UI="combo" width="150" default="*FIRST" globalListProvider="MOIS">
			</FIELD>
		</GROUP>
		<GROUP label="Indicateur">
			<FIELD name="INDICATEUR" label="" UI="combo" width="300" default="-1" globalListProvider="INDICATEURS">
			</FIELD>
		</GROUP>
	</SELECTIONS>
	<SELECTIONS componentName="ECRITURES_SELECTIONS"/>
	<SELECTIONS componentName="ECRITURES_SELECTIONS_COMPLEMENTAIRES"/>
	<QUERIES>
		<QUERY>
			<SQL select="

					SELECT 
						v_historique_ecritures_1.site_code, 
						v_historique_ecritures_1.cle_originale, 
						v_historique_ecritures_1.mois_comptable, 
						v_historique_ecritures_1.date_ecriture,
						v_historique_ecritures_1.compte_numero, 
						v_historique_ecritures_1.compte_texte, 
						v_historique_ecritures_1.compte_extra_numero, 
						COALESCE(t_comptes_c_contre.numero,''), 
						v_historique_ecritures_1.journal_code,
						v_historique_ecritures_1.texte, 
						v_historique_ecritures_1.dossier, 
						v_historique_ecritures_1.piece || 
							CASE 
								WHEN v_historique_ecritures_1.compte_numero LIKE '5%' AND v_historique_ecritures_1.numero_cheque &lt;&gt; '' AND v_historique_ecritures_1.numero_cheque &lt;&gt; '0'  THEN 'CHQ:'||v_historique_ecritures_1.numero_cheque
								ELSE '' END,
						CASE WHEN v_historique_ecritures_1.section_analytique_id &lt;&gt; 0 THEN v_historique_ecritures_1.section_analytique_code ELSE '' END,
						v_historique_ecritures_1.montant_debit,
						v_historique_ecritures_1.montant_credit, 
						v_historique_ecritures_1.montant_solde_debit, 
						[VIEW.INDICATEUR_COLUMN],
						v_historique_ecritures_1.fin_exercice, 
						v_historique_ecritures_1.ajustement
						
					FROM compta.v_historique_ecritures_1
					LEFT JOIN compta.t_comptes_c t_comptes_c_contre ON compte_contrepartie_id = t_comptes_c_contre.oid
					WHERE v_historique_ecritures_1.mois_comptable BETWEEN [MOIS] AND [TOMOIS]
						[VIEW.ECRITURES_SELECT]
						[VIEW.ECRITURES_SELECT_COMP]
						[VIEW.INDICATEUR_SELECT]
					
					UNION ALL
					
					(SELECT 
 
						'', 
						'',
						-9999999, 
						null,
						'', 
						'', 
						'', 
						'',
						'',
						'TOTAL '::text || COUNT(*)::text || ' écritures'::text, 
						'', 
						'', 
						'', 
						SUM(v_historique_ecritures_1.montant_debit),
						SUM(v_historique_ecritures_1.montant_credit), 
						SUM(v_historique_ecritures_1.montant_solde_credit), 
						SUM([VIEW.INDICATEUR_COLUMN]),
						MAX(v_historique_ecritures_1.fin_exercice), 
						MAX(v_historique_ecritures_1.ajustement)
						
						
					FROM compta.v_historique_ecritures_1
					WHERE v_historique_ecritures_1.mois_comptable BETWEEN [MOIS] AND [TOMOIS]
							[VIEW.ECRITURES_SELECT]
							[VIEW.ECRITURES_SELECT_COMP]
							[VIEW.INDICATEUR_SELECT]

					)


					ORDER BY 2 ">
				<FIELDS>
					<FIELD name="SIT"/>
					<FIELD name="CLE"/>
					<FIELD name="MOI"/>
					<FIELD name="DAT"/>
					<FIELD name="CPT"/>
					<FIELD name="CPTX"/>
					<FIELD name="CPX"/>
					<FIELD name="CCT"/>
					<FIELD name="JRN"/>
					<FIELD name="TXT"/>
					<FIELD name="FAC"/>
					<FIELD name="PIE"/>
					<FIELD name="SAN"/>
					<FIELD name="DEB"/>
					<FIELD name="CRE"/>
					<FIELD name="SOL"/>
					<FIELD name="IND"/>
					<FIELD name="Q13"/>
					<FIELD name="QAJ"/>
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			<SQL select="SELECT 'INDICATEUR_COLUMN', 
						replace(
							replace(
								replace(
									replace(
										column_name, 
										'[LISTE:', 
										' (SELECT to_id FROM compta.t_listes_contenu JOIN compta.t_listes ON (t_listes.oid = t_listes_contenu.liste_id) WHERE t_listes.code = ''')
									,']',''')'),
								' clinique_honoraire',
								' v_historique_ecritures_1.clinique_honoraire'),
							' classe_', ' v_historique_ecritures_1.classe_')
							FROM compta.t_indicateurs WHERE oid = [INDICATEUR]
						UNION ALL
						SELECT 'INDICATEUR_COLUMN', 0::text  WHERE [INDICATEUR] = -1
						UNION ALL
						SELECT 'INDICATEUR_ENTETE', entete FROM compta.t_indicateurs WHERE oid = [INDICATEUR]
						UNION ALL
						SELECT 'INDICATEUR_ENTETE', 0::text  WHERE [INDICATEUR] = -1
						UNION ALL
						SELECT 'INDICATEUR_FORMAT', output_format FROM compta.t_indicateurs WHERE oid = [INDICATEUR]
						UNION ALL
						SELECT 'INDICATEUR_FORMAT', '#'::text  WHERE [INDICATEUR] = -1
							">
				<FIELDS>
					<FIELD name="name"/>
					<FIELD name="value"/>
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
		</VIEWLINKS>
		<ONGLET excelLabel="Liste écritures" label="Liste écritures">
			<DATAGRID title="" total="true" headerHeight="36" variableRowHeight="true" totalRowInRows="= ROW.MOI == '-9999999'">
				<COLUMN dataField="MOI" type="Date" inputFormat="AAAAMM" outputFormat="MM/YYYY" width="70" visible="true" headerText="Mois comptable" textAlign="left"/>
				<COLUMN dataField="DAT" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD MMM YY" width="70" visible="true" headerText="Date écriture" textAlign="left"/>
				<COLUMN dataField="TXT" type="Char" minWidth="70" fixed="false" visible="true" headerText="Texte" textAlign="left" totalFunction="text" totalComplement="*ROW"/>
				<COLUMN dataField="SIT" type="Char" width="40" visible="true" fixed="false" headerText="Site" textAlign="left" totalFunction="text" totalComplement="">
				</COLUMN>
				<COLUMN dataField="CLE" type="Char" minWidth="90" visible="true" fixed="false" headerText="Clé" textAlign="left" totalFunction="text" totalComplement="">
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0x0000FF" condition="ROW.Q13 == '1'"/>
					<CELLSTYLE name="cellIndicator" value="circle, 5, right top, 0xFF6600" condition="ROW.QAJ == '1' || ROW.QAJ == '2'"/>
				</COLUMN>
				<COLUMN dataField="FAC" type="Char" width="80" fixed="false" visible="true" headerText="Facture - Dossier" textAlign="left"/>
				<COLUMN dataField="PIE" type="Char" width="80" fixed="false" visible="true" headerText="Pièce" textAlign="left"/>
				<COLUMN dataField="JRN" type="Char" width="50" visible="true" headerText="Jrn"/>
				<COLUMN dataField="CPT" type="Char" outputFormat="#" width="65" visible="true" headerText="Compte général"/>
				<COLUMN dataField="CPTX" type="Char" outputFormat="#" minWidth="65" visible="true" headerText="Compte général"/>
				<COLUMN dataField="CPX" type="Char" width="100" visible="true" headerText="Compte extra" />
				<COLUMN dataField="CCT" type="Char" width="65" visible="true" headerText="Compte contrep" />
				<COLUMN dataField="SAN" type="Char" outputFormat="#" width="65" visible="true" headerText="Section"/>
				<COLUMN dataField="IND" type="Number" outputFormat="= VIEW.INDICATEUR_FORMAT" visibleCondition="SELECT.INDICATEUR != '-1'" width="100" headerText="'Indicateur : ' + VIEW.INDICATEUR_ENTETE" headerTextCalc="true" align="right" totalFunction="sum" largeSeparator="true"/>
				<COLUMN dataField="DEB" type="Number" outputFormat="#,00E" width="100" headerText="Débit" align="right" totalFunction="sum"/>
				<COLUMN dataField="CRE" type="Number" outputFormat="#,00 E" width="90" headerText="Crédit" align="right" totalFunction="sum"/>
				<COLUMN dataField="SOL" type="Number" outputFormat="#,00E" width="100" headerText="Solde" align="right" totalFunction="sum"/>
				<COLUMN dataField="QAJ" type="Char" width="0" visible="false"/>
				<COLUMN dataField="Q13" type="Char" width="0" visible="false"/>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
