<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="ACTI000108" label="Activité. Comptabilisation et en-cours" title="= SELECT.DATA_LABEL + ' (' + SELECT.OPTION2_LABEL + ') par ' + SELECT.GROUPBY_LABEL + ' (' +  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_ACTI000104.HTML"
    helpDokuWIkiDir="activite:comptabilisation_et_en_cours:encours" 
    helpDokuWIkiFile="acti000104" 
>
	<VIEWPROPERTIES componentName="PROPERTIES_PRESTATIONS"/>
	
		
	<VIEWPROPERTIES>
		<PROPERTY name="OPTION2_WHERE">
			<value><![CDATA[[EVAL 
								switch ('[OPTION2]') {
								case 'SOR':
									return "AND montant_encours_sorti <> 0";
									break;
								default:
									return "";
								}
					EVAL]]]></value>
		</PROPERTY>

		<PROPERTY name="DATAVEN">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'MTVEN':
									return 'montant_comptabilise';
									break;
								case 'MTVENENC':
									return 'montant_comptabilise';
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DATAENC">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'MTVARENC':
									return 'montant_encours';
									break;
								case 'MTENC':
									return 'montant_encours';
									break;
								case 'MTVENENC':
									return 'montant_encours';
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="DATAENCR">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								case 'MTVARENC':
									return '0 - montant_encours';
									break;
								case 'MTVENENC':
									return '0 - montant_encours';
									break;
								default:
									return '0';
								}
					EVAL]]]></value>
		</PROPERTY>
		<PROPERTY name="AGG">
			<value><![CDATA[[EVAL 
								switch ('[DATA]') {
								default:
									return 'SUM(';
								}
					EVAL]]]></value>
		</PROPERTY>
		
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
						display = display + 'Source en-cours : #B#' + SELECT.SOURCE_ENCOURS_LABEL + '#/B#';
						
						return display;
						">
		<GROUP label="Période comptable">
			<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>
		<GROUP>
			<FIELD name="GROUPBY" label="Regroupement" UI="combo" default="SER" width="200" tree="true">
				<OPTION label="PRESTATIONS_ENCOURS_GROUPBY" data="" globalListProvider="PRESTATIONS_ENCOURS_GROUPBY"/>
				<OPTION label="Mois d'activité" data="MOIA"/>
				<OPTION label="Mois de sortie" data="MOIS"/>
				<OPTION label="Mois de ventes" data="MOIV"/>
			</FIELD>
			<FIELD name="GROUPBY_TAB" label="Présentation" UI="combo" default="AUTO" visible="= SELECT.GROUPBY_2 != '-1' ">
				<OPTION label="Automatique" data="AUTO"/>
				<OPTION label="Arbre" data="TREE"/>
				<OPTION label="Onglet" data="TAB"/>
			</FIELD>
		</GROUP>
		<GROUP label="">
			<FIELD name="GROUPBY_2" label="" UI="combo" default="-1" width="200" tree="true">
				<OPTION label="" data="-1"/>
				<OPTION label="PRESTATIONS_ENCOURS_GROUPBY" data="" globalListProvider="PRESTATIONS_ENCOURS_GROUPBY"/>
				<OPTION label="Mois d'activité" data="MOIA"/>
				<OPTION label="Mois de sortie" data="MOIS"/>
				<OPTION label="Mois de ventes" data="MOIV"/>
			</FIELD>
		</GROUP>
		<GROUP>
			<FIELD name="DATA" tree="true" label="Données" UI="combo" default="MTVENENC">
				<OPTION label="Ventes + En-cours du mois - Reports mois précédent" treeLevel="1" data="MTVENENC" data2="#" data3=""/>
				<OPTION label="Ventes" treeLevel="1" data="MTVEN" data2="#" data3=""/>
				<OPTION label="En-cours" treeLevel="1" data="MTENC" data2="#" data3=""/>
				<OPTION label="Variation d'En-cours" treeLevel="1" data="MTVARENC" data2="#" data3=""/>
			</FIELD>
		</GROUP>
		<GROUP label="Options">
			<FIELD name="OPTION2" label="" UI="combo" width="200" default="-1" >
				<OPTION label="Présents et Sortis" data="-1"/>
				<OPTION label="Sortis uniquement" data="SOR"/>
			</FIELD>
		</GROUP>
		<GROUP label="Source en-cours">
			<FIELD name="SOURCE_ENCOURS" label="" UI="combo" width="200" default="C" >
				<OPTION label="CTI Santé" data="C"/>
				<OPTION label="Prestataire facturation" data="P"/>
			</FIELD>
		</GROUP>
		 <GROUP visible="false">
			<FIELD name="RUBRIQUE_CA" label="C.A." UI="combo" tree="true" width="200" default="-1"  globalListProvider="RUBRIQUES_CA" showIfNotDefault="true" />
			<FIELD name="RUBRIQUE_CODES" label="Codes" UI="text" width="150" default="" showIfNotDefault="true" visible="= SELECT.RUBRIQUE == 'SAISIECODE' " />
		</GROUP>
		
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_PRESTATIONS_SOUSSELECTIONS"/>
	<SELECTIONS componentName="FILTRES_PRESTATIONS_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_SEJOURS_SELECTIONS"/>
	<QUERIES>
		<QUERY label="">
			<SQL optimizer="V_SEJOURS_X" optimizer2="V_FACTURES_ENCOURS_LIGNES_C_X">
				<select><![CDATA[		
					CTIPREPAR_TREE
					WORKTABLE{ACTI000108_R}
					GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
					GROUPBY1MODE{[GROUPBY_TAB]}
					GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
					SIGNIFDATA{[VIEW.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
					COLUMNBYMONTH{date_comptable,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12}
					INDICATORS{0,,}	
					INDICATORS_COLUMNS{[VIEW.AGG] CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.DATAENC] ELSE NULL END), }
					FROM #V_FACTURES_ENCOURS_LIGNES_C_X#
					WHERE '[VIEW.DATAENC]' <> '0' AND 
						date_trunc('month', date_comptable) BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND
						code_origine = '[SOURCE_ENCOURS]'
						[VIEW.OPTION2_WHERE]
						[VIEW.SEJOURS_SELECT]
						[VIEW.PRESTATIONS_SELECT]
				
				
				]]></select>
			</SQL>
			<SQL optimizer="V_SEJOURS_X" optimizer2="V_FACTURES_ENCOURS_LIGNES_C_X">
				<select><![CDATA[		
					CTIPREPAR_TREE
					WORKTABLE{ACTI000108_E}
					GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
					GROUPBY1MODE{[GROUPBY_TAB]}
					GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
					SIGNIFDATA{[VIEW.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
					COLUMNBYMONTH{date_trunc('month',date_comptable) + interval '1 month',, '[PERIODE]' ,, '[TOPERIODE]' ,, 12}
					INDICATORS{0,,}	
					INDICATORS_COLUMNS{[VIEW.AGG] CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.DATAENCR] ELSE NULL END), }
					FROM #V_FACTURES_ENCOURS_LIGNES_C_X#
					WHERE '[VIEW.DATAENCR]' <> '0' AND
						date_trunc('month',date_comptable) + interval '1 month' BETWEEN '[PERIODE]' AND '[TOPERIODE]' AND
						code_origine = '[SOURCE_ENCOURS]'
						[VIEW.OPTION2_WHERE]
						[VIEW.SEJOURS_SELECT]
						[VIEW.PRESTATIONS_SELECT]
				
				
				]]></select>
			</SQL>
			<SQL optimizer="V_SEJOURS_X" optimizer2="V_FACTURES_LIGNES_C_X">
				<select><![CDATA[		
					CTIPREPAR_TREE
					WORKTABLE{ACTI000108_V}
					GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
					GROUPBY1MODE{[GROUPBY_TAB]}
					GROUPBY2{[VIEW.GROUPBY_2_OID_FIELD],, [VIEW.GROUPBY_2_COD_FIELD],, [VIEW.GROUPBY_2_TXT_FIELD]}
					SIGNIFDATA{[VIEW.ACTIVITE_SIGNIFICATIVE_DATA],, [ACTIVITE_SIGNIFICATIVE_MODE],, [ACTIVITE_SIGNIFICATIVE_NUMBER]}
					COLUMNBYMONTH{date_vente,, '[PERIODE]' ,, '[TOPERIODE]' ,, 12}
					INDICATORS{0,,}	
					INDICATORS_COLUMNS{[VIEW.AGG] CASE WHEN COLUMNCHECKSEQUENCE THEN [VIEW.DATAVEN] ELSE NULL END), }
					FROM #V_FACTURES_LIGNES_C_X#
						JOIN #V_SEJOURS_X# ON v_sejours_1.no_sejour = v_factures_lignes_c_4.no_sejour
					WHERE '[VIEW.DATAVEN]' <> '0' AND
						date_trunc('month', date_vente) BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						[VIEW.SEJOURS_SELECT]
						[VIEW.PRESTATIONS_SELECT]
				
				
				]]></select>
			</SQL>
			<SQL>
				<select><![CDATA[		
					SELECT oidt, labelt, textet, 
						oid1, code1, 
						oid2, code2, 
						oid3, code3, 
						oid, code, texte, level, 
						SUM(indicateurs[1]), 
						SUM(indicateurs[2]), 
						SUM(indicateurs[3]), 
						SUM(indicateurs[4]), 
						SUM(indicateurs[5]), 
						SUM(indicateurs[6]), 
						SUM(indicateurs[7]), 
						SUM(indicateurs[8]), 
						SUM(indicateurs[9]), 
						SUM(indicateurs[10]), 
						SUM(indicateurs[11]), 
						SUM(indicateurs[12]), 
						SUM(indicateurs[13]), 
						SUM(indicateurs[14]), 
						SUM(indicateurs[15]), 
						SUM(indicateurs[16])
					FROM 
						(
						SELECT 
							oidt, labelt, textet, 
							oid1, code1, 
							oid2, code2, 
							oid3, code3, 
							oid, code, texte, level, 
							indicateurs
							FROM ACTI000108_R
						UNION ALL
						SELECT 
							oidt, labelt, textet, 
							oid1, code1, 
							oid2, code2, 
							oid3, code3, 
							oid, code, texte, level, 
							indicateurs
							FROM ACTI000108_E
						UNION ALL
						SELECT 
							oidt, labelt, textet, 
							oid1, code1, 
							oid2, code2, 
							oid3, code3, 
							oid, code, texte, level, 
							indicateurs
							FROM ACTI000108_V
						) subview
					GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13
					ORDER BY labelt,oidt,code1,oid1,code2,oid2,code3,oid3
				
				
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="N"/>
					<FIELD name="N0"/>
					<FIELD name="N1"/>
					<FIELD name="N2"/>
					<FIELD name="N3"/>
					<FIELD name="N4"/>
					<FIELD name="N5"/>
					<FIELD name="N6"/>
					<FIELD name="N7"/>
					<FIELD name="N8"/>
					<FIELD name="N9"/>
					<FIELD name="N10"/>
					<FIELD name="N11"/>
					<FIELD name="N12"/>
				</FIELDS>
			</SQL>
		</QUERY>
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forRows="false">
		</QUERY>
	</QUERIES>
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Liste des séjours" shortLabel="Liste séjours" view="ACTI000107.XML" componentName="PRESTATIONS_BASE_VIEWLINK" component3Name="STANDARD_BASE_VIEWLINK">
				<ARG name="PERIODE" value="	if (COLUMN.NAME == 'N1') {return VIEW.COLD1}
											if (COLUMN.NAME == 'N2') {return VIEW.COLD2}
											if (COLUMN.NAME == 'N3') {return VIEW.COLD3}
											if (COLUMN.NAME == 'N4') {return VIEW.COLD4}
											if (COLUMN.NAME == 'N5') {return VIEW.COLD5}
											if (COLUMN.NAME == 'N6') {return VIEW.COLD6}
											if (COLUMN.NAME == 'N7') {return VIEW.COLD7}
											if (COLUMN.NAME == 'N8') {return VIEW.COLD8}
											if (COLUMN.NAME == 'N9') {return VIEW.COLD9}
											if (COLUMN.NAME == 'N10') {return VIEW.COLD10}
											if (COLUMN.NAME == 'N11') {return VIEW.COLD11}
											if (COLUMN.NAME == 'N12') {return VIEW.COLD12}
											return SELECT.PERIODE"/>
				<ARG name="TOPERIODE" value="	if (COLUMN.NAME == 'N1') {return VIEW.COLF1}
											if (COLUMN.NAME == 'N2') {return VIEW.COLF2}
											if (COLUMN.NAME == 'N3') {return VIEW.COLF3}
											if (COLUMN.NAME == 'N4') {return VIEW.COLF4}
											if (COLUMN.NAME == 'N5') {return VIEW.COLF5}
											if (COLUMN.NAME == 'N6') {return VIEW.COLF6}
											if (COLUMN.NAME == 'N7') {return VIEW.COLF7}
											if (COLUMN.NAME == 'N8') {return VIEW.COLF8}
											if (COLUMN.NAME == 'N9') {return VIEW.COLF9}
											if (COLUMN.NAME == 'N10') {return VIEW.COLF10}
											if (COLUMN.NAME == 'N11') {return VIEW.COLF11}
											if (COLUMN.NAME == 'N12') {return VIEW.COLF12}
											return SELECT.TOPERIODE"/>
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Répartition mensuelle" label="Répartition mensuelle" multiTab="true">
			<CHART title="Evolution (Total)" type="lineChart" serieIsCategory="true" fromTotal="true">
				<CATEGORY field="TXT" type="Char"/>
				<SERIE field="N1" displayName="VIEW.COLH1" displayNameCalc="true" visibleCondition="VIEW.COLH1 != null"/>
				<SERIE field="N2" displayName="VIEW.COLH2" displayNameCalc="true" visibleCondition="VIEW.COLH2 != null"/>
				<SERIE field="N3" displayName="VIEW.COLH3" displayNameCalc="true" visibleCondition="VIEW.COLH3 != null"/>
				<SERIE field="N4" displayName="VIEW.COLH4" displayNameCalc="true" visibleCondition="VIEW.COLH4 != null"/>
				<SERIE field="N5" displayName="VIEW.COLH5" displayNameCalc="true" visibleCondition="VIEW.COLH5 != null"/>
				<SERIE field="N6" displayName="VIEW.COLH6" displayNameCalc="true" visibleCondition="VIEW.COLH6 != null"/>
				<SERIE field="N7" displayName="VIEW.COLH7" displayNameCalc="true" visibleCondition="VIEW.COLH7 != null"/>
				<SERIE field="N8" displayName="VIEW.COLH8" displayNameCalc="true" visibleCondition="VIEW.COLH8 != null"/>
				<SERIE field="N9" displayName="VIEW.COLH9" displayNameCalc="true" visibleCondition="VIEW.COLH9 != null"/>
				<SERIE field="N10" displayName="VIEW.COLH10" displayNameCalc="true" visibleCondition="VIEW.COLH10 != null"/>
				<SERIE field="N11" displayName="VIEW.COLH11" displayNameCalc="true" visibleCondition="VIEW.COLH11 != null"/>
				<SERIE field="N12" displayName="VIEW.COLH12" displayNameCalc="true" visibleCondition="VIEW.COLH12 != null"/>
			</CHART>
			<CHART title="Comparatif (10 premiers)" type="pieChart" maxItems="10" maxItemsSortOn="N" maxItemsSortSeq="D" sortField="TXT" sortSeq="A">
				<CATEGORY field="TXT" type="Char"/>
				<SERIE field="N" displayName="SELECT.DATA_LABEL" displayNameCalc="true"/>
			</CHART>
			<DATAGRID title="" total="true" showOthers="true" headerHeight="36" variableRowHeight="true" sortable="= SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'" selectRowInRows="= ROW.OID == '-9999997'" otherRowInRows="= ROW.OID == '-9999998'" totalRowInRows="= ROW.OID == '-9999999'">
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				<COLUMN dataField="OID" width="60" type="Char" visible="false" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="80" type="Char" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text" totalComplement="TOTAL">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="150" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" otherFunction="text" otherComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="N" width="80" visible="false" type="Number" outputFormat="= SELECT.DATA2" headerText="Total" textAlign="right" totalFunction="sum" otherFunction="sum">
				</COLUMN>
				<COLUMN dataField="N_P" type="Number" headerText="% / Total" width="40" visible="false" outputFormat="0%" textAlign="right" totalFunction="calc" totalComplement="" otherFunction="calc" calc="true">
					<CALC formula="ROW.N / TOTALROW.N * 100"/>
				</COLUMN>
				<COLUMN dataField="NA" width="70" visibleCondition="VIEW.COLH0 != null" type="Number" outputFormat="#" fixed="false" headerText="&lt;&lt;" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N1" width="70" visibleCondition="VIEW.COLH1 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH1" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N2" width="70" visibleCondition="VIEW.COLH2 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH2" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N3" width="70" visibleCondition="VIEW.COLH3 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH3" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N4" width="70" visibleCondition="VIEW.COLH4 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH4" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N5" width="70" visibleCondition="VIEW.COLH5 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH5" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N6" width="70" visibleCondition="VIEW.COLH6 != null" type="Number" selectable="true" outputFormat="#" fixed="false" headerText="VIEW.COLH6" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N7" width="70" visibleCondition="VIEW.COLH7 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH7" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N8" width="70" visibleCondition="VIEW.COLH8 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH8" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N9" width="70" visibleCondition="VIEW.COLH9 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH9" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N10" width="70" visibleCondition="VIEW.COLH10 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH10" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N11" width="70" visibleCondition="VIEW.COLH11 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH11" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
				<COLUMN dataField="N12" width="70" visibleCondition="VIEW.COLH12 != null" type="Number" outputFormat="#" fixed="false" selectable="true" headerText="VIEW.COLH12" headerTextCalc="true" textAlign="right" otherFunction="sum" totalFunction="sum">
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
