<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="COMPTA000069" label="Liste des écritures Banques" 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_COMPTA000069.HTML">
	<VIEWPROPERTIES>
		<PROPERTY name="ECRITURES_SELECT" value="[EVAL 
							$select = '';
							
							$select = $select . &quot;AND v_historique_ecritures_1.clinique_honoraire = '[CH]' &quot; ;

							

							if ('[CH]' == 'C' &amp; '[COMPTE_C]' != '-1') {
								if (substr('[COMPTE_C]',0,2) == 'LI') {
									$select = $select . ' AND v_historique_ecritures_1.compte_id IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_C]',2) . ')';
								}
								if (substr('[COMPTE_C]',0,2) == 'SL') {
									$select = $select . ' AND v_historique_ecritures_1.compte_id NOT IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_C]',2) . ')';
								}
								if ('[COMPTE_C]' == 'SAISIECODE') {
									$select = $select . &quot; AND v_historique_ecritures_1.compte_id IN (SELECT oid FROM compta.t_comptes WHERE &quot; . sql_codes_list_a('[COMPTE_C_CODES]', 'numero') . &quot;)&quot;; 
								}
								if (substr('[COMPTE_C]',0,2) == 'CP') {
									$select = $select . ' AND v_historique_ecritures_1.compte_id = ' . substr('[COMPTE_C]',2); 
								}
								if (substr('[COMPTE_C]',0,2) == 'CL') {
									$select = $select . ' AND (';
									$select = $select . ' v_historique_ecritures_1.classe_1_id = ' . substr('[COMPTE_C]',2); 
									$select = $select . ' OR ';
									$select = $select . ' v_historique_ecritures_1.classe_2_id = ' . substr('[COMPTE_C]',2); 
									$select = $select . ' OR ';
									$select = $select . ' v_historique_ecritures_1.classe_3_id = ' . substr('[COMPTE_C]',2); 
									$select = $select . ' )';
								}
								
								$select = $select . ' ';
							}
												
							if ('[CH]' == 'H' &amp; '[COMPTE_H]' != '-1') {
								if (substr('[COMPTE_H]',0,2) == 'LI') {
									$select = $select. ' AND v_historique_ecritures_1.compte_id IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_H]',2) . ')';
								}
								if (substr('[COMPTE_H]',0,2) == 'SL') {
									$select = $select. ' AND v_historique_ecritures_1.compte_id NOT IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_H]',2) . ')';
								}
								if ('[COMPTE_H]' == 'SAISIECODE') {
									$select = $select . &quot; AND v_historique_ecritures_1.compte_id IN (SELECT oid FROM compta.t_comptes WHERE &quot; . sql_codes_list_a('[COMPTE_H_CODES]', 'numero') . &quot;)&quot;; 
								}
								if (substr('[COMPTE_H]',0,2) == 'CP') {
									$select = $select. ' AND v_historique_ecritures_1.compte_id = ' . substr('[COMPTE_H]',2); 
								}
								if (substr('[COMPTE_H]',0,2) == 'CL') {
									$select = $select . ' AND (';
									$select = $select . ' v_historique_ecritures_1.classe_1_id = ' . substr('[COMPTE_H]',2); 
									$select = $select . ' OR ';
									$select = $select . ' v_historique_ecritures_1.classe_2_id = ' . substr('[COMPTE_H]',2); 
									$select = $select . ' OR ';
									$select = $select . ' v_historique_ecritures_1.classe_3_id = ' . substr('[COMPTE_H]',2); 
									$select = $select . ' )';
								}
								$select = $select . ' ';
							}
												
													
							return $select;
																
			EVAL]"/>
		<PROPERTY name="COMPTES_SELECT" value="[EVAL 
							$select = '';
							
							$select = $select . &quot; clinique_honoraire = '[CH]' AND banque = '1' &quot; ;


							if ('[CH]' == 'C' &amp; '[COMPTE_C]' != '-1') {
								if (substr('[COMPTE_C]',0,2) == 'LI') {
									$select = $select . ' AND oid IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_C]',2) . ')';
								}
								if (substr('[COMPTE_C]',0,2) == 'SL') {
									$select = $select . ' AND oid NOT IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_C]',2) . ')';
								}
								if ('[COMPTE_C]' == 'SAISIECODE') {
									$select = $select . ' AND ' . sql_codes_list_a('[COMPTE_C_CODES]', 'numero') . ' ' ; 
								}
								if (substr('[COMPTE_C]',0,2) == 'CP') {
									$select = $select . ' AND oid = ' . substr('[COMPTE_C]',2); 
								}
								if (substr('[COMPTE_C]',0,2) == 'CL') {
									$select = $select . ' AND (';
									$select = $select . ' classe_1_id = ' . substr('[COMPTE_C]',2); 
									$select = $select . ' OR ';
									$select = $select . ' classe_2_id = ' . substr('[COMPTE_C]',2); 
									$select = $select . ' OR ';
									$select = $select . ' classe_3_id = ' . substr('[COMPTE_C]',2); 
									$select = $select . ' )';
								}
								
								$select = $select . ' ';
							}
												
							if ('[CH]' == 'H' &amp; '[COMPTE_H]' != '-1') {
								if (substr('[COMPTE_H]',0,2) == 'LI') {
									$select = $select. ' AND oid IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_H]',2) . ')';
								}
								if (substr('[COMPTE_H]',0,2) == 'SL') {
									$select = $select. ' AND oid NOT IN (SELECT to_id FROM compta.t_listes_contenu WHERE liste_id = ' . substr('[COMPTE_H]',2) . ')';
								}
								if ('[COMPTE_H]' == 'SAISIECODE') {
									$select = $select . ' AND ' . sql_codes_list_a('[COMPTE_H_CODES]', 'numero') . ' ' ; 
								}
								if (substr('[COMPTE_H]',0,2) == 'CP') {
									$select = $select. ' AND oid = ' . substr('[COMPTE_H]',2); 
								}
								if (substr('[COMPTE_H]',0,2) == 'CL') {
									$select = $select . ' AND (';
									$select = $select . ' classe_1_id = ' . substr('[COMPTE_H]',2); 
									$select = $select . ' OR ';
									$select = $select . ' classe_2_id = ' . substr('[COMPTE_H]',2); 
									$select = $select . ' OR ';
									$select = $select . ' classe_3_id = ' . substr('[COMPTE_H]',2); 
									$select = $select . ' )';
								}
								$select = $select . ' ';
							}
												
												
													
							return $select;
																
			EVAL]"/>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
	</VIEWPROPERTIES>
    <SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
	
						
					display = display + '  #B#Compte banque#/B# : ';
					if (SELECT.CH == 'C') {
						if (SELECT.COMPTE_C != 'SAISIECODE') {
							display = display + SELECT.COMPTE_C_LABEL;
						}
						else {
							display = display + SELECT.COMPTE_C_CODES;
						}
					}
					else {
						display = display + '  #B#Compte#/B# : ';
						if (SELECT.COMPTE_H != 'SAISIECODE') {
							display = display + SELECT.COMPTE_H_LABEL;
						}
						else {
							display = display + SELECT.COMPTE_H_CODES;
						}
					}
							
						
					
					return display;
					">
		<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" tree="true" width="200" default="*FIRST" globalListProvider="DATE_DEBUT">
			</FIELD>
			<FIELD name="TOMOIS" label="" UI="combo" tree="true" width="200" default="*FIRST" globalListProvider="DATE_FIN">
			</FIELD>
		</GROUP>
        <GROUP label="">
			<FIELD name="COMPTE_C" label="Compte" UI="combo" width="300" tree="true" default="-1" globalListProvider="COMPTES_BANQUE_C" showIfNotDefault="true" visible="= SELECT.CH == 'C'">
			</FIELD>
			<FIELD name="COMPTE_C_CODES" label="Codes" UI="text" width="150" default="" showIfNotDefault="true" visible="= SELECT.CH == 'C' &amp;&amp; SELECT.COMPTE_C == 'SAISIECODE' "/>
		</GROUP>
		<GROUP label="">
			<FIELD name="COMPTE_H" label="Compte" UI="combo" width="300" tree="true" default="-1" globalListProvider="COMPTES_BANQUE_H" showIfNotDefault="true" visible="= SELECT.CH == 'H'">
			</FIELD>
			<FIELD name="COMPTE_H_CODES" label="Codes" UI="text" width="150" default="" showIfNotDefault="true" visible="= SELECT.CH == 'H' &amp;&amp; SELECT.COMPTE_H == 'SAISIECODE' "/>
		</GROUP>
	</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, 
						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 compte_banque = '1' AND journal_a_nouveaux &lt;&gt; '1' AND ecriture_consolidee &lt;= '0' AND v_historique_ecritures_1.date_ecriture BETWEEN '[MOIS]' AND '[TOMOIS]'
                        [VIEW.ECRITURES_SELECT]
						[VIEW.ECRITURES_SELECT_COMP]
					
					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), 
						MAX(v_historique_ecritures_1.fin_exercice), 
						MAX(v_historique_ecritures_1.ajustement)
						
						
					FROM compta.v_historique_ecritures_1
					WHERE compte_banque = '1' AND journal_a_nouveaux &lt;&gt; '1' AND ecriture_consolidee &lt;= '0' AND v_historique_ecritures_1.date_ecriture BETWEEN '[MOIS]' AND '[TOMOIS]'
							[VIEW.ECRITURES_SELECT_COMP]
                            [VIEW.ECRITURES_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="Q13"/>
					<FIELD name="QAJ"/>
				</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="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>
