<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="ACTI000064" 
    label="Activité. Etude DMA" 
    title="= 'Etude DMA SSR. (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
    database="iCTI" 
    swf="*CTI_view1" 
    softCode="iCTI_activite" 
    globals="ACTI_globals.XML" 
    componentsFile="ACTI_components.XML" 
    helpFile="iCTI_ACTI_ACTI000123.HTML"
    helpDokuWIkiDir="activite:activite_facturee_et_valorisee:activite_clinique" 
    helpDokuWIkiFile="acti000061" 
>
	<VIEWPROPERTIES componentName="PROPERTIES_PRESTATIONS"/>
	<VIEWPROPERTIES>
        
	</VIEWPROPERTIES>
	<SELECTIONS label="Paramètres de l'analyse">
		<GROUP label="Période">
			
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="220" default="CUM_LAST_MONTH" tree="true" globalListProvider="ALIAS_PERIODE" />
            <FIELD name="PERIODE" label="de" UI="combo" tree="true" width="200" default="2009-01-01" globalListProvider="DATE_DEBUT" >
			</FIELD>
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2009-01-31" globalListProvider="DATE_FIN" >
			</FIELD>
		</GROUP>
		
		
		
	</SELECTIONS>

	<QUERIES>
		<QUERY label="">
		
			<SQL optimizer="V_SEJOURS_X" >
				<select><![CDATA[
					DROP TABLE IF EXISTS w_prestations;
					CREATE TEMP TABLE w_prestations AS
					SELECT t_prestations.oid, 
						t_prestations.code,
						MAX(CASE 
							WHEN t_prestations.code = 'DMASSR' THEN 'DMA'
							WHEN t_listes.code = 'DMAP_MFS' THEN 'MFS'
							WHEN t_listes.code = 'DMAP_MFSM' THEN 'MFSM'
							ELSE '' END) AS type_dma,
                        MAX(type_valorisation_non_facture) AS type_valorisation_non_facture
					FROM activite.t_prestations
					LEFT JOIN activite.t_listes_contenu ON t_listes_contenu.to_id = t_prestations.oid
					LEFT JOIN activite.t_listes ON liste_id = t_listes.oid
					WHERE t_listes.code IN ('DMAP_MFS','DMAP_MFSM') OR t_prestations.code = 'DMASSR' OR t_prestations.code = 'FJ' OR type_valorisation_non_facture = 'PJ'
					GROUP BY 1,2
					;
					
					DROP TABLE IF EXISTS w_dma;
					CREATE TEMP TABLE w_dma AS
					SELECT 
						p_factures.no_sejour,
						p_sejours.code_sorti,
						CASE WHEN p_sejours.code_sorti = '1' THEN p_sejours.date_sortie ELSE '20991231' END AS date_sortie,
						p_factures_lignes_c.date_debut,
						0::numeric AS sequence,
						MAX(CASE WHEN p_factures_lignes_c.date_fin >= '20170701' THEN '1' ELSE '0' END) AS juillet2017,
						MAX(CASE WHEN p_sejours.code_sorti = '1' AND p_factures_lignes_c.date_debut = p_sejours.date_sortie THEN '1' ELSE '0' END) AS est_jour_sortie,
						MAX(CASE WHEN t_prestations.code IN ('PJ','SNS','FS') OR type_valorisation_non_facture = 'PJ' THEN prix_unitaire ELSE 0 END) AS pj_pu,
                        (MAX(CASE WHEN t_prestations.code IN ('PJ','SNS','FS') OR type_valorisation_non_facture = 'PJ' THEN Array[p_factures.date_facture::text||to_char(nb_prestation,'FM00000'),taux_1::text] ELSE ARRAY['','0'] END))[2]::numeric AS pj_taux,
						SUM(CASE WHEN t_prestations.code IN ('PJ','SNS','FS') OR type_valorisation_non_facture = 'PJ' THEN nb_rubrique ELSE 0 END) AS pj_nb,
						SUM(CASE WHEN t_prestations.code IN ('PJ','SNS','FJ','FS') OR type_valorisation_non_facture = 'PJ' THEN montant_facture ELSE 0 END) AS pj_montant,
						SUM(CASE WHEN type_dma = 'MFS' AND t_prestations.code NOT IN ('PJ','SNS','FJ','FS') AND type_valorisation_non_facture <> 'PJ' THEN montant_facture ELSE 0 END) AS aut_montant,
						SUM(CASE WHEN type_dma = 'MFSM' THEN montant_facture ELSE 0 END) AS dmam_montant,
						MAX(CASE WHEN type_dma = 'MFSM' THEN '1' ELSE '0' END) AS dmam,
						MAX(CASE WHEN type_dma = 'DMA' THEN '1' ELSE '0' END) AS dma,
						MAX(CASE WHEN type_dma = 'DMA' THEN taux_1 ELSE 0 END) AS dma_taux,
						SUM(CASE WHEN type_dma = 'DMA' THEN nb_rubrique ELSE 0 END) AS dma_nb,
						SUM(CASE WHEN type_dma = 'DMA' THEN montant_facture ELSE 0 END) AS dma_montant
					FROM activite.p_factures_lignes_c
					JOIN activite.p_factures ON p_factures_lignes_c.no_facture = p_factures.no_facture
					JOIN activite.p_sejours ON p_factures.no_sejour = p_sejours.no_sejour
                    JOIN activite.t_lieux On p_sejours.lieu_sortie_id = t_lieux.oid
                    JOIN activite.t_services_facturation ON service_facturation_id = t_services_facturation.oid
					JOIN w_prestations t_prestations ON prestation_id = t_prestations.oid
					WHERE t_services_facturation.type_t2a NOT IN ('1','3') AND 
                        (
						p_sejours.code_sorti = '1' ANd p_sejours.date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]' OR
						p_factures_lignes_c.date_debut BETWEEN  '[PERIODE]' AND '[TOPERIODE]'
						) AND
						(t_prestations.code <> 'FJ' OR p_factures_lignes_c.date_debut <> p_sejours.date_sortie OR p_sejours.code_sorti <> '1')
					GROUP BY 1,2,3,4
					ORDER BY 1,4
					;

					UPDATE w_dma SET
						pj_taux = CASE WHEN w_dma.pj_taux = 0 THEN subview.pj_taux ELSE w_dma.pj_taux END,
                        pj_pu = CASE WHEN w_dma.pj_pu = 0 THEN subview.pj_pu ELSE w_dma.pj_pu END,
						dma_taux = CASE WHEN w_dma.dma_taux = 0 THEN subview.dma_taux ELSE w_dma.dma_taux END,
						dma = CASE WHEN w_dma.dma = '0' THEN subview.dma ELSE w_dma.dma END,
						dmam = CASE WHEN w_dma.dmam = '0' THEN subview.dmam ELSE w_dma.dmam END
					FROM
					(
					SELECT w_dma.no_sejour, w_dma.date_debut,
						COALESCE((MAX(ARRAY[CASE WHEN w_dma.pj_taux > 0 OR w_dma_2.pj_taux > 0 THEN w_dma_2.date_debut::text ELSE '00010101'::text END,CASE WHEN w_dma.pj_taux > 0 THEN w_dma.pj_taux::text WHEN w_dma_2.pj_taux > 0 THEN w_dma_2.pj_taux::text ELSE NULL END]))[2]::numeric,0) AS pj_taux,
						COALESCE((MAX(ARRAY[CASE WHEN w_dma.pj_pu > 0 OR w_dma_2.pj_pu > 0 THEN w_dma_2.date_debut::text ELSE '00010101'::text END,CASE WHEN w_dma.pj_pu > 0 THEN w_dma.pj_pu::text WHEN w_dma_2.pj_pu > 0 THEN w_dma_2.pj_pu::text ELSE NULL END]))[2]::numeric,0) AS pj_pu,
						COALESCE((MAX(ARRAY[CASE WHEN w_dma.dma = '1' OR w_dma_2.dma = '1' THEN w_dma_2.date_debut::text ELSE '00010101'::text END,CASE WHEN w_dma.dma = '1' THEN w_dma.dma::text WHEN w_dma_2.dma = '1' THEN w_dma_2.dma::text ELSE NULL END]))[2]::text,'0') AS dma,
						COALESCE((MAX(ARRAY[CASE WHEN w_dma.dma_taux > 0 OR w_dma_2.dma_taux > 0 THEN w_dma_2.date_debut::text ELSE '00010101'::text END,CASE WHEN w_dma.dma_taux > 0 THEN w_dma.dma_taux::text WHEN w_dma_2.dma_taux > 0 THEN w_dma_2.dma_taux::text ELSE NULL END]))[2]::numeric,0) AS dma_taux,
						COALESCE((MAX(ARRAY[CASE WHEN w_dma.dmam = '1' OR w_dma_2.dmam = '1' THEN w_dma_2.date_debut::text ELSE '00010101'::text END,CASE WHEN w_dma.dmam = '1' THEN w_dma.dmam::text WHEN w_dma_2.dmam = '1' THEN w_dma_2.dmam::text ELSE NULL END]))[2]::text,'0') AS dmam
					FROM w_dma
					LEFT JOIN w_dma w_dma_2 ON w_dma_2.no_sejour = w_dma.no_sejour AND w_dma_2.date_debut < w_dma.date_debut 
					GROUP BY 1,2
					) subview
					WHERE w_dma.no_sejour = subview.no_sejour AND
						w_dma.date_debut = subview.date_debut
					;

					
		
						

					UPDATE w_dma
					SET sequence = subview.sequence
					FROM
					(
					SELECT no_sejour, rank() OVER (PARTITION BY no_sejour ORDER BY date_debut) AS sequence, date_debut, date_fin
					FROM
					(
					SELECT no_sejour,
						rank() OVER w1 AS rank,
						first_value(date_debut) OVER w1 AS date_debut,
						first_value(date_debut) OVER w2 AS date_fin
					FROM w_dma
					
					WINDOW
						w1 as (
						    PARTITION BY no_sejour, pj_pu, pj_taux, dma, dma_taux, dmam, juillet2017
						    ORDER BY no_sejour, date_debut),
						w2 as (
						    PARTITION BY no_sejour, pj_pu, pj_taux, dma, dma_taux, dmam, juillet2017
						    ORDER BY no_sejour, date_debut desc)
					order by date_debut
					) subview 
					WHERE rank = 1
					ORDER BY 1
					) subview
					WHERE w_dma.no_sejour = subview.no_sejour AND
						w_dma.date_debut BETWEEN subview.date_debut AND subview.date_fin
						     
					;
					
					DROP TABLE IF EXISTS w_dma_aff;
					CREATE TEMP TABLE w_dma_aff AS
					SELECT no_sejour,
						'A'::text AS onglet,
						sequence,
						''::text AS typologie_dma,
						''::text AS typologie_fac,
						MIN(date_debut) AS date_debut,
						MAX(date_debut) AS date_fin,
						MAX(pj_pu) AS pj_pu,
                        MAX(pj_taux) AS pj_taux,
						SUM(pj_nb) AS pj_nb,
						SUM(pj_montant) AS pj_montant,
						SUM(aut_montant) AS aut_montant,
						SUM(pj_montant)+SUM(aut_montant) AS pre_montant,
						SUM(dmam_montant) AS dmam_montant,
						MAX(dma_taux) AS dma_taux,
						SUM(dma_montant) AS dma_montant,
						SUM(dma_montant) + SUM(dmam_montant) AS dma_ecart
					FROM w_dma
					WHERE date_debut BETWEEN '[PERIODE]' AND '[TOPERIODE]'
					GROUP BY 1,2,3
					UNION
					SELECT no_sejour,
						'S'::text AS onglet,
						sequence,
						''::text AS typologie_dma,
						''::text AS typologie_fac,
						MIN(date_debut) AS date_debut,
						MAX(date_debut) AS date_fin,
						MAX(pj_pu) AS pj_pu,
                        MAX(pj_taux) AS pj_taux,
						SUM(pj_nb) AS pj_nb,
						SUM(pj_montant) AS pj_montant,
						SUM(aut_montant) AS aut_montant,
						SUM(pj_montant)+SUM(aut_montant) AS pre_montant,
						SUM(dmam_montant) AS dmam_montant,
						MAX(dma_taux) AS dma_taux,
						SUM(dma_montant) AS dma_montant,
						SUM(dma_montant) + SUM(dmam_montant) AS dma_ecart
					FROM w_dma
					WHERE code_sorti = '1' AND date_sortie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
					GROUP BY 1,2,3
					
					ORDER BY 1,2,3;


					UPDATE w_dma_aff
					SET typologie_dma =
						CASE 
							WHEN gme_id <= 0 THEN 'ATT. Non expédié'
							WHEN code_sorti = '1' AND date_sortie < '20170301' AND dma_montant <> 0 THEN 'ATT. DMA<MARS'
							WHEN code_sorti = '1' AND date_sortie < '20170301' AND dma_montant = 0 THEN 'OK. DMA0<MARS'
							WHEN code_sorti = '1' AND date_sortie >= '20170301' AND dma_montant = 0 THEN 'ATT. DMA0>MARS'
							WHEN code_sorti = '1' AND date_sortie >= '20170301' AND dma_montant <> 0 THEN 'OK. DMA>MARS'
							WHEN code_sorti = '0' AND dma_montant = 0 THEN 'OK. DMA0-PRES'
							
						ELSE '' END
					FROM activite.p_sejours 
					WHERE w_dma_aff.no_sejour = p_sejours.no_sejour
						;

					UPDATE w_dma_aff
					SET typologie_fac =
						CASE 
							WHEN pj_montant =  0 THEN 'ATT. PJ0'
							WHEN date_fin < '20170701' AND dmam_montant <> 0 THEN 'ATT. MPJ<JUIL'
							WHEN date_fin >= '20170701' AND dmam_montant = 0 THEN 'ATT. MPJ0>JUIL'
							WHEN dmam_montant <> 0 AND round(0-dmam_montant,0) <> round(pre_montant/10,0) AND pj_taux <> 80 THEN 'ATT. <>10%'
							
						ELSE 'OK' END
					FROM activite.p_sejours 
					WHERE w_dma_aff.no_sejour = p_sejours.no_sejour
						;

				]]></select>
			</SQL>
            
			<SQL optimizer="V_SEJOURS_X" >
				<select><![CDATA[
                    
					CTISELECT_TREECOL
					WORKTABLE{ACTI000064}
					GROUPBY1{v_sejours_1.sejour_id,, v_sejours_1.no_sejour,, (nom || ' ' || prenom || CASE WHEN sequence > 1 THEN ' ('||sequence||')' ELSE '' END)} 
					GROUPBY1MODE{COL} 
					INDICATORS{
						MAX(pj_pu),,
                        MAX(pj_taux),,
						SUM(pj_nb),,
						SUM(pj_montant),,
						SUM(aut_montant),,
						SUM(pj_montant)+SUM(aut_montant),,
						SUM(dmam_montant),,
						MAX(dma_taux),,
						SUM(dma_montant),,
						SUM(dma_montant) + SUM(dmam_montant),,
					}
                    INDICATORS_TEXT{
                        MIN(to_char(v_sejours_1.date_entree,'YYYY-MM-DD')),,
                        MAX(CASE WHEN v_sejours_1.date_sortie &lt;&gt; '2099-12-31' AND code_sorti = '1' THEN to_char(v_sejours_1.date_sortie,'YYYY-MM-DD') ELSE ''::text END),,
						MAX(gme_code),,
						MIN(to_char(date_debut,'YYYY-MM-DD')),,
						MAx(to_char(date_fin,'YYYY-MM-DD')),,
                    }
                    
					FROM w_dma_aff
						JOIN #V_SEJOURS_X# ON v_sejours_1.no_sejour = w_dma_aff.no_sejour
                        JOIN activite.p_patients ON v_sejours_1.no_patient = p_patients.no_patient
					WHERE onglet = 'A'
					
					AFTER{	
						UPDATE ACTI000064 SET
                            indicateurs_text = NULL
                        WHERE level = 9
					}
					
				
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREECOL_FIELDS"/>
                    
                    
                    <FIELD name="PUPJ"/>
                    <FIELD name="TXPJ"/>
					<FIELD name="NBPJ"/>
					<FIELD name="MTPJ"/>
					<FIELD name="MTAUT"/>
					<FIELD name="MTPRE"/>
					<FIELD name="MTMDMA"/>
                    <FIELD name="MTDMAX"/>
					<FIELD name="MTDMA"/>
					<FIELD name="MTEDMA"/>
                    <FIELD name="DATENT"/>
                    <FIELD name="DATSOR"/>
					<FIELD name="GMECOD"/>
					<FIELD name="DATDEB"/>
					<FIELD name="DATFIN"/>
                    
                    
					
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY label="">
		
            
			<SQL optimizer="V_SEJOURS_X" >
				<select><![CDATA[
                    
					CTISELECT_TREECOL
					WORKTABLE{ACTI000064}
					GROUPBY1{v_sejours_1.sejour_id,, v_sejours_1.no_sejour,, (nom || ' ' || prenom || CASE WHEN sequence > 1 THEN ' ('||sequence||')' ELSE '' END)} 
					GROUPBY1MODE{COL} 
					INDICATORS{
						MAX(pj_pu),,
                        MAX(pj_taux),,
						SUM(pj_nb),,
						SUM(pj_montant),,
						SUM(aut_montant),,
						SUM(pj_montant)+SUM(aut_montant),,
						SUM(dmam_montant),,
						SUM(dma_montant),,
						MAX(dma_taux),,
						SUM(dma_montant) + SUM(dmam_montant),,
					}
                    INDICATORS_TEXT{
                        MIN(to_char(v_sejours_1.date_entree,'YYYY-MM-DD')),,
                        MAX(CASE WHEN v_sejours_1.date_sortie &lt;&gt; '2099-12-31' AND code_sorti = '1' THEN to_char(v_sejours_1.date_sortie,'YYYY-MM-DD') ELSE ''::text END),,
						MAX(gme_code),,
						MIN(to_char(date_debut,'YYYY-MM-DD')),,
						MAX(to_char(date_fin,'YYYY-MM-DD')),,
						MAX(typologie_dma),,
						MAX(typologie_fac),,
                    }
                    
					FROM w_dma_aff
						JOIN #V_SEJOURS_X# ON v_sejours_1.no_sejour = w_dma_aff.no_sejour
                        JOIN activite.p_patients ON v_sejours_1.no_patient = p_patients.no_patient
					WHERE onglet = 'S'	
					AFTER{	
						UPDATE ACTI000064 SET
                            indicateurs_text = NULL
                        WHERE level = 9
					}
				
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREECOL_FIELDS"/>
                    
                    
                    <FIELD name="PUPJ"/>
                    <FIELD name="TXPJ"/>
					<FIELD name="NBPJ"/>
					<FIELD name="MTPJ"/>
					<FIELD name="MTAUT"/>
					<FIELD name="MTPRE"/>
					<FIELD name="MTMDMA"/>
                    <FIELD name="MTDMA"/>
					<FIELD name="MTDMAX"/>
					<FIELD name="MTEDMA"/>
                    
                    <FIELD name="DATENT"/>
                    <FIELD name="DATSOR"/>
					<FIELD name="GMECOD"/>
					<FIELD name="DATDEB"/>
					<FIELD name="DATFIN"/>
					<FIELD name="TYPDMA"/>
					<FIELD name="TYPFAC"/>
                    
                    
					
				</FIELDS>
			</SQL>
		</QUERY>
        
        <QUERY label="">
		
            
			<SQL optimizer="V_SEJOURS_X" >
				<select><![CDATA[
				
					
                    DROP TABLE IF EXISTS w_erreur;
					CREATE TEMP TABLE w_erreur AS
					SELECT p_sejours.oid AS sejour_id, p_sejours.no_sejour, p_patients.nom || ' ' || p_patients.prenom AS patient_nom, 
						MIN(to_char(p_sejours.date_entree,'YYYY-MM-DD')) AS date_entree,
						MAX(CASE WHEN p_sejours.date_sortie <> '2099-12-31' AND code_sorti = '1' THEN to_char(p_sejours.date_sortie,'YYYY-MM-DD') ELSE ''::text END) AS date_sortie,
						MAX(t_services_facturation.code || ' ' || t_services_facturation.texte) AS service_texte,
						'SEJOUR ABSENT DU PMSI SSR' AS erreur
						FROM activite.p_sejours
						JOIN activite.p_patients ON p_sejours.no_patient = p_patients.no_patient 
						JOIN activite.p_sejour_pmsi ON p_sejours.oid = p_sejour_pmsi.sejour_id
					JOIN activite.t_lieux_c On lieu_sortie_id = t_lieux_c.oid
					JOIN activite.t_services_facturation ON service_facturation_id = t_services_facturation.oid
					
					WHERE code_sorti = '1' AND
						date_sortie BETWEEN  '[PERIODE]' AND '[TOPERIODE]' AND
						p_sejours.type_sejour <> '9' AND
						t_services_facturation.type_t2a = '2' AND p_sejour_pmsi.ssr_id = 0
						GROUP BY 1,2,3
					UNION
					SELECT ssr_id AS oid, ssr_num_admin_sejour AS no_sejour, patient_nom || ' ' || patient_prenom AS patient_nom, 
						MIN(to_char(ssr_date_entree,'YYYY-MM-DD')) AS date_entree,
							MAX(CASE WHEN ssr_date_sortie <> '2099-12-31'  THEN to_char(ssr_date_sortie,'YYYY-MM-DD') ELSE ''::text END) AS date_sortie,
							MAX(type_hospitalisation_texte) AS service_texte,
							'SEJOUR SSR ABSENT DE LA GAP' AS error
					FROM pmsissr.v_ssr_1
					WHERE ssr_date_sortie BETWEEN  '[PERIODE]' AND '[TOPERIODE]' AND
						(ssr_id <> ALL (SELECT unnest(ssr_id_array) FROM activite.p_sejour_pmsi))
						GROUP BY 1,2,3
					;
					
					CTISELECT_TREECOL
					WORKTABLE{ACTI000064_3}
					GROUPBY1{sejour_id,, no_sejour,, patient_nom} 
					GROUPBY1MODE{COL} 
					INDICATORS{
						0,,
					}
                    INDICATORS_TEXT{
                        MIN(date_entree),,
                        MAX(date_sortie),,
						MAX(erreur),,
                    }
                    
					FROM w_erreur

					AFTER{	
						UPDATE ACTI000064_3 SET
                            indicateurs_text = NULL
							
                        WHERE level = 9
					}
				
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREECOL_FIELDS"/>
                    
                    
                    <FIELD name="FILLER"    hide="true"/>
                    <FIELD name="DATENT"/>
                    <FIELD name="DATSOR"/>
					<FIELD name="ERR"/>
                    
                    
					
				</FIELDS>
			</SQL>
		</QUERY>
        
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forRows="false">
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		
		<VIEWLINKS>
			<VIEWLINK label="Détail séjour" shortLabel="Détail séjour" view="ACTI000020.XML">
                <ARG name="_ONGLET_O1_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O2_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O3_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O4_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O5_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O6_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O7_VISIBLE" value="'true'"/>
                <ARG name="_ONGLET_O8_VISIBLE" value="'true'"/>
				<ARG name="SEJOUR" value="ROW.COD1"/>
			</VIEWLINK>
		</VIEWLINKS>
        <ONGLET excelLabel="Date activité" label="Date activité" multiTab="true" >
           
			
			<DATAGRID title=""
                    total="true"
                    showOthers="true"
                    headerHeight="48"
                    variableRowHeight="true"
                    sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB' || 'COL' == 'COL'"
                    selectRowInRows="= ROW.OID == '-9999997'"
                    otherRowInRows="= ROW.OID == '-9999998'"
                    totalRowInRows="= ROW.OID == '-9999999'">
                    
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
                <HEADERROWSTYLE name="textAlign" value="center"/>
				<COLUMN dataField="OID"
                    width="60"
                    type="Char"
                    visible="false"
                    headerText="Oid">
				</COLUMN>
                
				<COLUMN dataField="COD"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="Code"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
				<COLUMN dataField="TXT"
                    type="Char"
                    minWidth="150"
                    maxWidth="300"
                    headerText="SELECT.GROUPBY_LABEL"
                    headerTextCalc="true"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                
                <COLUMN dataField="DATENT" width="70" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date entrée" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATSOR" width="70" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date sortie" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GMECOD"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="GME"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="">
				</COLUMN>
              
                <COLUMN dataField="DATDEB" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date début" width="70" textAlign="left"/>
				<COLUMN dataField="DATFIN" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date fin" width="70" textAlign="left"/>
				
				<COLUMN dataField="NBPJ" type="Number" outputFormat="#" visible="true" headerText="Nb Jours" width="70" textAlign="right"/>

				<COLUMN dataField="PUPJ" type="Number" outputFormat="#,00E" visible="true" headerText="P.U. PJ" width="70" textAlign="right"/>
                <COLUMN dataField="TXPJ" type="Number" outputFormat="#%" visible="true" headerText="Taux PJ" width="70" textAlign="right"/>
				<COLUMN dataField="MTPJ" type="Number" outputFormat="#,00E" visible="true" headerText="Montant PJ" width="100" textAlign="right"/>
				<COLUMN dataField="MTAUT" type="Number" outputFormat="#,00E" visible="true" headerText="Montant Autres" width="100" textAlign="right"/>
				<COLUMN dataField="MTPRE" type="Number" outputFormat="#,00E" visible="true" headerText="Montant Total" width="100" textAlign="right"/>
				<COLUMN dataField="MTMDMA" type="Number" outputFormat="#,00E" visible="true" headerText="Montant 10%" width="100" textAlign="right"/>
				
				<COLUMN dataField="MTDMAX" type="Number" outputFormat="#%" visible="true" headerText="Taux DMA" width="100" textAlign="right"/>
				
				
				<COLUMN dataField="MTDMA" type="Number" outputFormat="#,00E" visible="true" headerText="Montant DMA" width="100" textAlign="right"/>
				
				<COLUMN dataField="MTEDMA" type="Number" outputFormat="#,00E" visible="true" headerText="Ecart DMA" width="100" textAlign="right"/>
				
			</DATAGRID>
		</ONGLET>
		
		<ONGLET excelLabel="Date sortie" label="Date sortie" multiTab="true" queryNumber="1">
           
			
			<DATAGRID title=""
                    total="true"
                    showOthers="true"
                    headerHeight="48"
                    variableRowHeight="true"
                    sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB' || 'COL' == 'COL'"
                    selectRowInRows="= ROW.OID == '-9999997'"
                    otherRowInRows="= ROW.OID == '-9999998'"
                    totalRowInRows="= ROW.OID == '-9999999'">
                    
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
                <HEADERROWSTYLE name="textAlign" value="center"/>
				<COLUMN dataField="OID"
                    width="60"
                    type="Char"
                    visible="false"
                    headerText="Oid">
				</COLUMN>
                
				<COLUMN dataField="COD"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="Code"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
				<COLUMN dataField="TXT"
                    type="Char"
                    minWidth="150"
                    maxWidth="300"
                    headerText="SELECT.GROUPBY_LABEL"
                    headerTextCalc="true"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                
                <COLUMN dataField="DATENT" width="70" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date entrée" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATSOR" width="70" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date sortie" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="GMECOD"
                    width="70"
                    type="Char"
                    visible="true"
                    headerText="GME"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="">
				</COLUMN>
              
                <COLUMN dataField="DATDEB" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date début" width="70" textAlign="left" totalFunction="text"/>
				<COLUMN dataField="DATFIN" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" visible="true" headerText="Date fin" width="70" textAlign="left" totalFunction="text"/>
				
				<COLUMN dataField="TYPDMA"
                    width="100"
                    type="Char"
                    visible="true"
                    headerText="Type DMA"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="">
				</COLUMN>
				<COLUMN dataField="TYPFAC"
                    width="100"
                    type="Char"
                    visible="true"
                    headerText="Type FAC"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="">
				</COLUMN>
				
				<COLUMN dataField="NBPJ" type="Number" outputFormat="#" visible="true" headerText="Nb Jours" width="70" textAlign="right"/>

				<COLUMN dataField="PUPJ" type="Number" outputFormat="#,00E" visible="true" headerText="P.U. PJ" width="70" textAlign="right"/>
                <COLUMN dataField="TXPJ" type="Number" outputFormat="#%" visible="true" headerText="Taux PJ" width="70" textAlign="right"/>
				<COLUMN dataField="MTPJ" type="Number" outputFormat="#,00E" visible="true" headerText="Montant PJ" width="100" textAlign="right"/>
				<COLUMN dataField="MTAUT" type="Number" outputFormat="#,00E" visible="true" headerText="Montant Autres" width="100" textAlign="right"/>
				<COLUMN dataField="MTPRE" type="Number" outputFormat="#,00E" visible="true" headerText="Montant Total" width="100" textAlign="right"/>
				<COLUMN dataField="MTMDMA" type="Number" outputFormat="#,00E" visible="true" headerText="Montant 10%" width="100" textAlign="right"/>
				
				<COLUMN dataField="MTDMAX" type="Number" outputFormat="#%" visible="true" headerText="Taux DMA" width="100" textAlign="right"/>
				
				
				<COLUMN dataField="MTDMA" type="Number" outputFormat="#,00E" visible="true" headerText="Montant DMA" width="100" textAlign="right"/>
				
				<COLUMN dataField="MTEDMA" type="Number" outputFormat="#,00E" visible="true" headerText="Ecart DMA" width="100" textAlign="right"/>
				
			</DATAGRID>
		</ONGLET>
        
        <ONGLET excelLabel="Erreurs" label="Erreurs" multiTab="true" queryNumber="2">
           
			
			<DATAGRID title=""
                    total="true"
                    showOthers="true"
                    headerHeight="48"
                    variableRowHeight="true"
                    sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB' || 'COL' == 'COL'"
                    selectRowInRows="= ROW.OID == '-9999997'"
                    otherRowInRows="= ROW.OID == '-9999998'"
                    totalRowInRows="= ROW.OID == '-9999999'">
                    
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
                <HEADERROWSTYLE name="textAlign" value="center"/>
				<COLUMN dataField="OID"
                    width="60"
                    type="Char"
                    visible="false"
                    headerText="Oid">
				</COLUMN>
                
				<COLUMN dataField="COD"
                    width="90"
                    type="Char"
                    visible="true"
                    headerText="Code"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
				<COLUMN dataField="TXT"
                    type="Char"
                    minWidth="150"
                    maxWidth="300"
                    headerText="SELECT.GROUPBY_LABEL"
                    headerTextCalc="true"
                    textAlign="left"
                    totalFunction="text"
                    otherFunction="text"
                    otherComplement="*ROW">
                    <HEADERCELLSTYLE name="textAlign" value="left"/>
				</COLUMN>
                
                <COLUMN dataField="DATENT" width="70" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date entrée" textAlign="right" totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATSOR" width="70" type="Date" inputFormat="AAAA-MM-JJ" outputFormat="DD/MM/YY" fixed="false" headerText="Date sortie" textAlign="right" totalFunction="text">
				</COLUMN>
				
				<COLUMN dataField="ERR"
                    minWidth="100"
                    type="Char"
                    visible="true"
                    headerText="Erreur"
                    textAlign="left"
                    otherFunction="text"
                    totalFunction="text"
                    totalComplement="">
				</COLUMN>
				
			</DATAGRID>
		</ONGLET>
       
	</PRESENTATION>
</VUE>
