<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000122" 
	label="Pointage erreur Expert" 
	database="iCTI" 
	swf="*CTI_view1" 
	softCode="iCTI_RH" 
	softOption="iCTI_expert"
	globals="RH_globals.XML" 
	componentsFile="RH_components.XML">
	
	<CACHE cachable="false" />
	<title><![CDATA[= 
			var title:String = 'Salarié ' + SELECT.NOM + ':';

			if ('[CNT_ID]' != '') {title = title + ' - Contrat n° ' + SELECT.CNT_ID;}
			
			if ('[CNTM_ID]' != '') {title = title + ' - Contrat mois n° ' + SELECT.CNTM_ID;}
						
			return title;
		]]></title>
	<VIEWPROPERTIES>
	
		<PROPERTY name="EXPERT_CONTROLE_UPDATE_SELECT">
			<value><![CDATA[[EVAL 
				
				$mode = substr('[EXPERT_CONTROLE]',0,2);
				$oid = substr('[EXPERT_CONTROLE]',2);
				if ($mode == 'LS') {
                    $section_id = RH_get_section_id('[EXPERT_CONTROLE]');
                    $oid = RH_get_classe_oid('[EXPERT_CONTROLE]');
				}
				$subselect = '';
				
				if ($mode == 'LI') {$subselect = " AND expert_controle_id IN (SELECT to_id FROM RH.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'SL') {$subselect = " AND expert_controle_id NOT IN (SELECT to_id FROM RH.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'LS') {$subselect = " AND expert_controle_id IN (SELECT oid FROM RH.t_expert_controle WHERE $section_id = $oid)";}
				if ($mode == 'C*') {$subselect = " AND expert_controle_id IN (SELECT oid FROM RH.t_expert_controle WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
				if ($mode == 'DT') {$subselect = " AND expert_controle_id = $oid ";}
				
				
				return "$subselect";
				
			EVAL]]]></value>
		</PROPERTY>
		
		<PROPERTY name="EXPERT_CONTROLE_SELECT">
			<value><![CDATA[[EVAL 
				
				$mode = substr('[EXPERT_CONTROLE]',0,2);
				$oid = substr('[EXPERT_CONTROLE]',2);
				if ($mode == 'LS') {
                    $section_id = RH_get_section_id('[EXPERT_CONTROLE]');
                    $oid = RH_get_classe_oid('[EXPERT_CONTROLE]');
				}
				$subselect = '';
				
				if ($mode == 'LI') {$subselect = " AND expert_controle_id IN (SELECT to_id FROM RH.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'SL') {$subselect = " AND expert_controle_id NOT IN (SELECT to_id FROM RH.t_listes_contenu WHERE liste_id = $oid)";}
				if ($mode == 'LS') {$subselect = " AND expert_controle_id IN (SELECT oid FROM RH.t_expert_controle WHERE $section_id = $oid)";}
				if ($mode == 'C*') {$subselect = " AND expert_controle_id IN (SELECT oid FROM RH.t_expert_controle WHERE code ILIKE ANY (base.cti_select_codes('$oid')))";}
				if ($mode == 'DT') {$subselect = " AND expert_controle_id = $oid ";}
				
				
				return "$subselect";
				
			EVAL]]]></value>	
		</PROPERTY>
	
		<PROPERTY name="CNTM_ID_SELECT" >
				<value><![CDATA[
						[EVAL 
						if ('[CNTM_ID]' == '') {return "";}
						
						return "
							AND expert_controle_data.contrat_mois_id 
							= '[CNTM_ID]'";							
					EVAL]
				]]></value>
		</PROPERTY>
		
		<PROPERTY name="CNT_ID_SELECT" >
				<value><![CDATA[
						[EVAL 
						if ('[CNT_ID]' == '') {return "";}
						
						return "
							AND expert_controle_data.contrat_mois_id 
							= ANY (
								SELECT contrat_mois_id FROM rh.v_contrats_mois_1 WHERE contrat_id = '[CNT_ID]'
								)";							
					EVAL]
				]]></value>
		</PROPERTY>
	</VIEWPROPERTIES>
	
	<SELECTIONS>
		<GROUP label="Date ocntrat">
			<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="2014-01-01" globalListProvider="DATE_DEBUT" printable="false" />
			<FIELD name="TOPERIODE" label="à" UI="combo" tree="true" width="200" default="2014-12-31"  globalListProvider="DATE_FIN" printable="false" />
		</GROUP>

		<GROUP label="N° de Contrat mois">
			<FIELD name="CNTM_ID" label="" UI="textArea" width="100" height="20" default="" visible="false" />
			<FIELD name="CNT_ID" label="" UI="textArea" width="100" height="20" default="" visible="false" />
		</GROUP>
		
		<GROUP label="Nom">
			<FIELD name="NOM" label="" UI="textArea" width="550" height="20" default="" visible="false"  />
		</GROUP>
		
		
		<GROUP label="Option">
			<FIELD name="VAL_ACTION" label="" UI="text" width="200">
				<OPTION label="Ignorer cette anomalie" data="I"/>
				<OPTION label="Pointer comme corrigée" data="T"/>
				<OPTION label="Remettre en service" data=""/>
			</FIELD>
		</GROUP>
		<SELECTIONS componentName="FILTRES_EXPERT_SELECTIONS" />
	</SELECTIONS>
	<SELECTIONS componentName="FILTRES_EXPERT_SELECTIONS" />
	<QUERIES>
		<QUERY> 
			<SQL optimizer="V_ALL_X">
				<select><![CDATA[
				
					UPDATE rh.p_expert_controle_data AS expert_controle_data
					SET etat = CASE WHEN '[VAL_ACTION]' IN ('', 'I', 'T') THEN '[VAL_ACTION]' ELSE etat END,
						date_correction = CASE WHEN '[VAL_ACTION]' IN ('I', 'T') THEN date(now()) ELSE '20991231' END
					WHERE 1=1 
						[VIEW.CNTM_ID_SELECT]
						[VIEW.CNT_ID_SELECT]
						[VIEW.EXPERT_CONTROLE_UPDATE_SELECT];
							
					
					SELECT 
						v_contrats_mois_1.contrat_mois_id,
						v_contrats_mois_1.salarie_id,
						v_contrats_mois_1.finess,
						v_contrats_mois_1.nom || ' ' || v_contrats_mois_1.prenom,
						date_debut_contrat,
						date_fin_contrat,
						v_contrats_mois_1.date_naissance,
						expert_controle_data.date_signalement,
						expert_controle_data.etat,
						expert_controle_data.etat_texte,
						expert_controle_data.expert_controle_code,
						expert_controle_data.expert_controle_id,
						expert_controle_data.expert_controle_texte,
						expert_controle_data.expert_controle_gravite_texte,
						expert_controle_data.justificatif
					FROM rh.v_expert_controle_1 AS expert_controle_data
						JOIN rh.v_contrats_mois_1 ON expert_controle_data.contrat_mois_id = v_contrats_mois_1.contrat_mois_id
					WHERE 1=1
						[VIEW.CNTM_ID_SELECT]
						[VIEW.CNT_ID_SELECT]
						[VIEW.EXPERT_CONTROLE_SELECT]
					
						ORDER BY 2
					
		
				;
				
				
						;
							
					]]></select>
				<FIELDS>
					<FIELD name="OID" />
					<FIELD name="SAL" />
					<FIELD name="FIN" />
					<FIELD name="NOM"  ifHideNames="Non autorisé"/>
					<FIELD name="DATE_DEB" />
					<FIELD name="DATE_FIN" />
					<FIELD name="DATE_NAIS" />
					<FIELD name="CXDS"/>
					<FIELD name="CXEC"/>
					<FIELD name="CXE"/>
					<FIELD name="CXC"/>
					<FIELD name="CXI"/>
					<FIELD name="CXT"/>
					<FIELD name="CXG"/>
					<FIELD name="CXJ"/>
				</FIELDS>
			</SQL>
			
			
		</QUERY>
	
	</QUERIES>
	
	<CALCFIELDS>
	</CALCFIELDS>
	
	<PRESENTATION>
	
		<VIEWLINKS>
			<VIEWLINK label="Retour à la liste" shortLabel="Retour à la liste" view="RH000110.XML" rowContext="false">
				<ARG name="_FORCE_UPDATE" value="new Date().milliseconds.toString()" />
			</VIEWLINK>
		</VIEWLINKS>

		
		<ONGLET excelLabel="Pointage" label="Pointage" queryNumber="0">
				
			<DATAGRID title="" total="true" key="RSS" headerHeight="36"  rowHeight="48"
				totalRowInRows="= ROW.OID == '-9999999'"
			>
				<ROWSTYLE name="rowHeight" value="48" />
				<ROWSTYLE name="fontSize" value="11" />
				<FOOTERROWSTYLE name="fontSize" value="11" />
				<COLUMN dataField="OID"
					type="Char"
					visible="true">
				</COLUMN>
					<COLUMN dataField="CXI"
					type="Char"
					visible="false">
				</COLUMN>
				<COLUMN dataField="CXEC"
					type="Char"
					visible="true">
				</COLUMN>
				<COLUMN dataField="FIN"
					width="60"
					type="Char"
					headerText="Finess" 
					textAlign="left" 
					visibleCondition="ENV.CONSOLIDATION == '1'"
					otherFunction="text"
					totalFunction="text" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="SAL"
					width="90"
					type="Char"
					headerText="N° Salarié" 
					textAlign="center" 
					otherFunction="text"
					totalFunction="text" 
					totalComplement="TOTAL">
				</COLUMN>
				<COLUMN dataField="NOM"
					minWidth="100"
					maxWidth="200"
					type="Char"
					headerText="Nom" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="*ROW">
				</COLUMN>
				<COLUMN dataField="DATE_NAIS"
					width="50"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					fixed="false"
					headerText="Date naissance" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATE_DEB"
					width="55"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					fixed="false"
					headerText="Date&#xD;début" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="DATE_FIN"
					width="55"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					fixed="false"
					headerText="Date&#xD;fin" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CXDS"
					width="90"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="DD/MM/YY"
					fixed="false"
					headerText="Date&#xD;signalement" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text">
				</COLUMN>
				<COLUMN dataField="CXG"
					width="60"
					type="Char"
					headerText="Gravité" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXC"
					width="120"
					type="Char"
					outputFormat="#"
					headerText="Code contrôle" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text" 
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXT"
					minWidth="200"
					type="Char"
					headerText="Texte contrôle" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
				<COLUMN dataField="CXJ"
					width="200"
					type="Char"
					headerText="Justificatif contrôle" 
					textAlign="left" 
					otherFunction="text"
					totalFunction="text"
					totalComplement="">
				</COLUMN>
			</DATAGRID>
		
		</ONGLET>
		
		
		
				
	</PRESENTATION>
	
</VUE>

			
