<?xml version="1.0" encoding="ISO-8859-15"?>
<VUE name="ACTI000128" 
	label="Activité Expert. Contrôles" 
	title="= 'Contrôles Expert' +  ' par ' +  SELECT.GROUPBY_LABEL + ' (' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL + ')'" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_activite" 
	softOption="iCTI_expert" 
	globals="ACTI_globals.XML" 
	componentsFile="ACTI_components.XML" 
    helpFile="iCTI_ACTI_ACTI000128.HTML"
    helpDokuWIkiDir="activite:qualite:expert" 
    helpDokuWIkiFile="acti000128" 
>
	<CACHE cachable="false" />
	<VIEWPROPERTIES componentName="PROPERTIES_OCCUPATION" />
	<VIEWPROPERTIES>
		
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value"/>
		<PROPERTY name="EXPERT_CONTROLE_SELECT">
			<value><![CDATA[[EVAL 
				
				$mode = substr('[EXPERT_CONTROLE]',0,2);
				$oid = substr('[EXPERT_CONTROLE]',2);
				if ($mode == 'LS') {
                    $section_id = ACTI_get_section_id('[EXPERT_CONTROLE]');
                    $oid = ACTI_get_classe_oid('[EXPERT_CONTROLE]');
				}
				$subselect = '';
				
				if ($mode == 'LI') {$subselect = " AND expert_controle_id IN (SELECT to_id FROM activite.t_listes_contenu WHERE liste_id = $oid) ";}
				if ($mode == 'SL') {$subselect = " AND expert_controle_id NOT IN (SELECT to_id FROM activite.t_listes_contenu WHERE liste_id = $oid) ";}
				if ($mode == 'LS') {$subselect = " AND expert_controle_id IN (SELECT oid FROM activite.t_expert_controle WHERE $section_id = $oid) ";}
				if ($mode == 'C*') {$subselect = " AND expert_controle_id IN (SELECT oid FROM activite.t_expert_controle WHERE code ILIKE ANY (base.cti_select_codes('$oid'))) ";}
				if ($mode == 'DT') {$subselect = " AND expert_controle_id = $oid ";}
				
				
				$mode = substr('[EXPERT_CONTROLE_GRAVITE]',0,2);
				$oid = substr('[EXPERT_CONTROLE_GRAVITE]',2);
				if ($mode == 'DT') {$subselect .= " AND expert_controle_gravite_id = $oid ";}
				if ($mode == 'LI' && $oid == "59") {$subselect .= " AND expert_controle_gravite_id IN (5,9) ";}
                    
                $mode = substr('[EXPERT_CONTROLE_GRAVITE_ALERTES]',0,2);
                $oid = substr('[EXPERT_CONTROLE_GRAVITE_ALERTES]',2);
                if ($mode == 'D2' && $oid == "99") {$subselect = "$subselect AND alert_exp = '1'";}

				$subselect .= " AND expert_controle_is_active = '1' ";
				
				return "$subselect";
				
			EVAL]]]></value>
		</PROPERTY>
		
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="= var display:String = '';
					if (SELECT.EXPERT_CONTROLE != '-1') {display = display + '#B#Controle#/B# : #B#' + SELECT.EXPERT_CONTROLE_LABEL + '#/B#'}
					if (SELECT.EXPERT_CONTROLE_GRAVITE != '-1') {display = display + ' #B#(' + SELECT.EXPERT_CONTROLE_GRAVITE_LABEL + ')#/B#'}
					if (SELECT.EXPERT_CONTROLE_GRAVITE_ALERTES == 'D299') {display += ' #B#(' + 'Alertes' + ')#/B#'}

					
					if (display != '') {
						display = 'Filtre controles : ' + display;
					}
					return display;
					">
		<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="" UI="combo" tree="true" width="200" default="2009-01-01" globalListProvider="DATE_DEBUT"  />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2009-12-31" globalListProvider="DATE_FIN"  />
		</GROUP>
		<GROUP label="Controle Expert">
			<FIELD name="EXPERT_CONTROLE" label="" UI="combo" tree="true" width="400" default="-1" globalListProvider="EXC" showIfNotDefault="true">
			</FIELD>
		</GROUP>
		
		<GROUP label="Gravité">
			<FIELD name="EXPERT_CONTROLE_GRAVITE" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de sélection" data="-1" aliasData="1" treeLevel="1"  />
				<OPTION label="Informations" data="DT0" treeLevel="1"  />
				<OPTION label="Avertissements" data="DT5" treeLevel="1"  />
				<OPTION label="Erreurs" data="DT9" treeLevel="1"  />
				<OPTION label="Avertissements et Erreurs" data="LI59" treeLevel="1"  />
			</FIELD>
		</GROUP>

		<GROUP label="Alertes expert">
            <FIELD name="EXPERT_CONTROLE_GRAVITE_ALERTES" label="Alertes" UI="check" selectedValue="D299" unselectedValue="" default="" showIfNotDefault="true" />
        </GROUP>
		
		<GROUP label="Regroupements">
			<FIELD name="GROUPBY" width="220" label="Regroupements" UI="combo" default="EXC" tree="true">
				<OPTION label="Controle Expert" data="EXC" treeLevel="1" />
				<OPTION label="Séjour" data="SEJOUR" treeLevel="1" />
				<OPTION dataLink="EXC_CLASSES" treeLevelField="lvl" dataField="cod" labelField="txt" />
				<OPTION label="Options" data="" globalListProvider="OCCUPATION_GROUPBY" />
			</FIELD>
			<FIELD name="GROUPBY_TAB" width="100" 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" width="220" label="" UI="combo" default="-1" tree="true">
				<OPTION label="Pas de second niveau" data="-1" treeLevel="1" />
				<OPTION label="Controle Expert" data="EXC"  treeLevel="1" />
				<OPTION label="Séjour" data="SEJOUR" treeLevel="1" />
				<OPTION dataLink="EXC_CLASSES" treeLevelField="lvl" dataField="cod" labelField="txt" />
				<OPTION label="Options" data="" globalListProvider="OCCUPATION_GROUPBY" />
			</FIELD>
		</GROUP>
		
	</SELECTIONS>
	
	<SELECTIONS componentName="FILTRES_SEJOURS_SELECTIONS" />
	<SELECTIONS componentName="FILTRES_PASSAGES_SELECTIONS" />
	
	<QUERIES>
		<QUERY label="">
		
			<SQL optimizer="V_SEJOURS_X">
				<select><![CDATA[	
														
					CTISELECT_TREE
						WORKTABLE{ACTI000128}
						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]}
						
					INDICATORS{
						COUNT(DISTINCT v_sejours_1.sejour_id),,
						COUNT(*),,
						COUNT(DISTINCT CASE WHEN expert_controle_gravite_id = 0 THEN v_sejours_1.sejour_id ELSE NULL END),,
						COUNT(DISTINCT CASE WHEN expert_controle_gravite_id BETWEEN 1 AND 5 THEN v_sejours_1.sejour_id ELSE NULL END),,
						COUNT(DISTINCT CASE WHEN expert_controle_gravite_id BETWEEN 6 AND 9 THEN v_sejours_1.sejour_id ELSE NULL END)
					}
					FROM activite.v_expert_sejour_controle_1 
						JOIN #V_SEJOURS_X# ON v_expert_sejour_controle_1.sejour_id = v_sejours_1.sejour_id
					WHERE (date_sortie >= '[PERIODE]' OR code_sorti <> '1') AND date_entree <= '[TOPERIODE]'
						[VIEW.SEJOURS_SELECT]
						[VIEW.EXPERT_CONTROLE_SELECT]
						[VIEW.PASSAGES_SELECT]
					
					
						
				
						
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="NB_SEJ"/>
					<FIELD name="NB_ERR"/>
					<FIELD name="NB_SEJ_I"/>
					<FIELD name="NB_SEJ_A"/>
					<FIELD name="NB_SEJ_E"/>
				</FIELDS>
			</SQL>
		</QUERY>
		
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false">
			
		</QUERY>
	</QUERIES>
	
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Justificatif par Séjour" shortLabel="Justificatif Séjour" view="ACTI000129.XML" 
					visible="= SELECT.GROUPBY != 'SEJOUR' || SELECT.GROUPBY_2 != 'SEJOUR' || SELECT.GROUPBY_2 != '-1'"
					enabled="= (SELECT.GROUPBY != 'SEJOUR' &amp;&amp; ROW.OID2 &lt; 0) || (SELECT.GROUPBY_2 != 'SEJOUR' &amp;&amp; ROW.OID2 &gt;= 0)"
					componentName="STANDARD_BASE_VIEWLINK" >
					<ARG name="EXPERT_CONTROLE_GRAVITE" 
						value="if (COLUMN.NAME == 'NB_SEJ_I') {return 'DT0'}
							if (COLUMN.NAME == 'NB_SEJ_A') {return 'DT5'}
							if (COLUMN.NAME == 'NB_SEJ_E') {return 'DT9'}
							return SELECT.EXPERT_CONTROLE_GRAVITE"/>
			</VIEWLINK>
			<VIEWLINK label="Détail Séjour" shortLabel="Détail Séjour" view="ACTI000020.XML"
				visible="= SELECT.GROUPBY == 'SEJOUR' || SELECT.GROUPBY_2 == 'SEJOUR'"
				enabled="= (SELECT.GROUPBY == 'SEJOUR' &amp;&amp; ROW.OID2 &lt; 0) || (SELECT.GROUPBY_2 == 'SEJOUR' &amp;&amp; ROW.OID2 &gt;= 0)">
				<ARG name="SEJOUR" value="ROW.COD" />
			</VIEWLINK>
		</VIEWLINKS>
		<ONGLET excelLabel="Controle" label="Controle" 
			multiTab="true" multiTabBreakField="TABD" multiTabBreakLabelField="TABDL" multiTabBreakLonglabelField="TABDLL">
			
			<DATAGRID title="" total="true" showOthers="true" headerHeight="48" 
				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" frozen="left" width="60" type="Char" visible="true" headerText="Oid">
				</COLUMN>
				<COLUMN dataField="COD" width="120" type="Char" visible="true" headerText="Code" textAlign="left" otherFunction="text" totalFunction="text">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" type="Char" minWidth="150" headerText="SELECT.GROUPBY_LABEL" headerTextCalc="true" textAlign="left" totalFunction="text" totalComplement="TOTAL" otherFunction="text" otherComplement="Autres">
				</COLUMN>
				<COLUMN dataField="NB_SEJ" type="Number" width="110" outputFormat="#"
					visibleCondition="SELECT.EXPERT_CONTROLE_GRAVITE == '-1'  || SELECT.EXPERT_CONTROLE_GRAVITE == 'LI59'" 
					headerText="Nb séjours@LF@signalés" totalFunction="text" otherFunction="text" otherComplement="">
				</COLUMN>
				<COLUMN dataField="NB_SEJ_I" type="Number" width="110" outputFormat="#" 
					selectable="true"
					visibleCondition="SELECT.EXPERT_CONTROLE_GRAVITE == '-1' || SELECT.EXPERT_CONTROLE_GRAVITE == 'DT0'" 
					headerText="Informations" totalFunction="text" otherFunction="text" otherComplement="">
					<CELLSTYLE name="color" value="0x75a0eb" />
					<CELLSTYLE name="fontWeight" value="bold" />
				</COLUMN>
				<COLUMN dataField="NB_SEJ_A" type="Number" width="110" outputFormat="#"
					selectable="true"
					visibleCondition="(SELECT.EXPERT_CONTROLE_GRAVITE == '-1' || SELECT.EXPERT_CONTROLE_GRAVITE == 'DT5' || SELECT.EXPERT_CONTROLE_GRAVITE == 'LI59')" 
					headerText="Avertissements" totalFunction="text" otherFunction="text" otherComplement="">
					<CELLSTYLE name="color" value="0xFFA500" />
					<CELLSTYLE name="fontWeight" value="bold" />
				</COLUMN>
				<COLUMN dataField="NB_SEJ_E" type="Number" width="110" outputFormat="#"
					selectable="true"
					visibleCondition="(SELECT.EXPERT_CONTROLE_GRAVITE == '-1' || SELECT.EXPERT_CONTROLE_GRAVITE == 'DT9' || SELECT.EXPERT_CONTROLE_GRAVITE == 'LI59')" 
					headerText="Erreurs" totalFunction="text" otherFunction="text" otherComplement="">
					<CELLSTYLE name="color" value="0xD63E00" />
					<CELLSTYLE name="fontWeight" value="bold" />
				</COLUMN>
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>
