<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="RH000002" 
	label="Chiffrier RH-Paie" 
	database="iCTI" 
	swf="*CTI_view1" 
	globals="RH_globals.XML" 
	softCode="iCTI_rh"
	helpDokuWIkiDir="rh:vues:controles" helpDokuWIkiFile="rh000002"  helpFile=""
>
	<CACHE cachable="false" />
	<VIEWPROPERTIES>
		<PROPERTY dataLink="VIEWPROPERTIES" nameField="name" valueField="value" />
	</VIEWPROPERTIES>
	
	<SELECTIONS label="Période" >
		<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="2010-01-01" globalListProvider="PERIODE_DEBUT">
			</FIELD>
			<FIELD name="TOPERIODE" label="au" UI="combo" tree="true" width="200" default="2010-01-31" globalListProvider="PERIODE_FIN">
			</FIELD>
		</GROUP>
	</SELECTIONS>
	
	<QUERIES>
		<QUERY> 
			<SQL select="SELECT substr(mois, 1, 4) || '-' || substr(mois, 5, 2)  || '-01', 
							sum(nombre_salaries_prod), 
							round(sum(nombre_heures_prod)), 
							round(sum(nombre_heures_od_prod)), 
							round(sum(nombre_heures_prod+nombre_heures_od_prod)),
							round(sum(montant_brut_prod)),
							sum(nombre_salaries_cti), 
							round(sum(nombre_heures_cti)), 
							round(sum(montant_brut_cti))
						FROM
						(
							SELECT
								mois::numeric,
								sum(nombre_salaries) AS nombre_salaries_prod, 
								sum(nombre_heures) AS nombre_heures_prod, 
								sum(nombre_heures_od) AS nombre_heures_od_prod, 
								sum(montant_brut) AS montant_brut_prod,
								0::numeric AS nombre_salaries_cti,
								0::numeric AS nombre_heures_cti,
								0::numeric AS montant_brut_cti
							FROM rh.p_chiffrier_production 
							WHERE (mois || '01')::date BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							GROUP BY p_chiffrier_production.mois  
							UNION
							SELECT 
								mois_paie_code::numeric AS mois, 
								0::numeric AS nombre_salaries_prod,
								0::numeric AS nombre_heures_prod,
								0::numeric AS nombre_heures_od_prod,
								0::numeric AS montant_brut_prod,
								count(DISTINCT ARRAY[rhp_etablissement_id, salarie_id]) AS nombre_salaries_cti, 
								SUM(heures_payees) AS nombre_heures_cti,
								SUM(montant_brut) AS montant_brut_cti
								
							FROM rh.v_historique_paie_1
							WHERE date_paie BETWEEN '[PERIODE]' AND '[TOPERIODE]'
							GROUP BY 1
						) subview
						GROUP BY 1
						ORDER BY 1 DESC " >
				<FIELDS>
					<FIELD name="MOIS" />
					<FIELD name="PNBC" />
					<FIELD name="PNBH" />
					<FIELD name="PNBHO" />
					<FIELD name="PNBHT" />
					<FIELD name="PMTB" />
					<FIELD name="CNBC" />
					<FIELD name="CNBH" />
					<FIELD name="CMTB" />
				</FIELDS>
			</SQL>
		</QUERY>
		
		<QUERY> 
			<SQL select="
						SELECT p_calendrier_mois.annee, 
							sum(nombre_salaries), 
							sum(nombre_heures+nombre_heures_od), 
							sum(montant_brut)
						FROM rh.p_chiffrier_production JOIN base.p_calendrier_mois on (p_chiffrier_production.mois = p_calendrier_mois.mois)
						WHERE (p_chiffrier_production.mois || '01')::date BETWEEN '[PERIODE]' AND '[TOPERIODE]'
						GROUP BY p_calendrier_mois.annee 
						ORDER BY p_calendrier_mois.annee DESC
				 " >
				<FIELDS>
					<FIELD name="ANNEE" />
					<FIELD name="PNBC" />
					<FIELD name="PNBH" />
					<FIELD name="PMTB" />
				</FIELDS>
			</SQL>
			
		</QUERY>
		
	
		<QUERY type="propertiesLink" name="VIEWPROPERTIES" forSelections="false"> 
			
			<SQL>
				<select><![CDATA[
						SELECT 'WITHOD', MAX(CASE WHEN nombre_heures_od <> 0 THEN '1' ELSE '0' END)::text FROM rh.p_chiffrier_production
				]]></select>
				<FIELDS>
					<FIELD name="name" />
					<FIELD name="value" />
				</FIELDS>
			</SQL>
		
			
		</QUERY>
	
	</QUERIES>
	
	<CALCFIELDS>
	</CALCFIELDS>
	
	<PRESENTATION>
	
		
		<ONGLET label="Chiffrier mensuel">
		
					
			<CHART title="[DICT.RH.SALARIE#3]" type="columnChart" subType="stacked" 	
				sortField="MOIS" sortSeq="A" 
				maxItems="24"  maxItemsSortOn="MOIS" maxItemsSortSeq="D"  >
				<CATEGORY field="MOIS" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="PNBC" displayName="Nombre de [DICT.RH.SALARIE#3] ayant eu un bulletin" />
			</CHART>
			<CHART title="Heures" type="columnChart" subType="stacked" 	
				sortField="MOIS" sortSeq="A" 
				maxItems="24"  maxItemsSortOn="MOIS" maxItemsSortSeq="D"  >
				<CATEGORY field="MOIS" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="PNBH" displayName="Nombre d'heures" />
			</CHART>
			<CHART title="Montant brut" type="columnChart" subType="stacked" 	
				sortField="MOIS" sortSeq="A" 
				maxItems="24"  maxItemsSortOn="MOIS" maxItemsSortSeq="D"  >
				<CATEGORY field="MOIS" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="PMTB" displayName="Montant brut" />
			</CHART>
					
			<DATAGRID title="Chiffrier mensuel" headerHeight="48" >
				<COLUMN dataField="MOIS"
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMMM YYYY"
					width="100"
					headerText="Mois"
					textAlign="left" />
				<COLUMN dataField="PNBC" 
					type="Number"
					width="110"
					outputFormat="#"
					headerText="[DICT.RH.SALARIE#3] (production)" 
					textAlign="right" />
				<COLUMN dataField="PNBH" 
					type="Number"
					width="110"
					outputFormat="#h"
					headerText="Heures (production)" 
					textAlign="right" />
				<COLUMN dataField="PNBHO" 
					type="Number"
					width="110"
					outputFormat="#h"
					headerText="Heures (od)" 
					textAlign="right"
					visibleCondition="[VIEW.WITHOD] == '1'"/>
				<COLUMN dataField="PNBHT" 
					type="Number"
					width="110"
					outputFormat="#h"
					headerText="Heures (production+od)" 
					textAlign="right" 
					visibleCondition="[VIEW.WITHOD] == '1'"/>
				<COLUMN dataField="PMTB" 
					type="Number" 
					width="110"
					outputFormat="#E"
					headerText="Montant brut (production)" 
					textAlign="right" 
					largeSeparator="true"/>
				<COLUMN dataField="CNBC" 
					type="Number"
					width="110"
					outputFormat="#"
					headerText="[DICT.RH.SALARIE#3] (cti)" 
					textAlign="right" >
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF6600" 
							condition="ROW.CNBC != ROW.PNBC" />
				</COLUMN>
				<COLUMN dataField="CNBH" 
					type="Number"
					width="110"
					outputFormat="#h"
					headerText="Heures (cti)" 
					textAlign="right" >
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF6600" 
							condition="ROW.CNBH != ROW.PNBHT" />
				</COLUMN>
				<COLUMN dataField="CMTB" 
					type="Number" 
					width="110"
					outputFormat="#E"
					headerText="Montant brut (cti)" 
					textAlign="right" 
					largeSeparator="true">
					<CELLSTYLE name="cellIndicator" value="circle, 5, left top, 0xFF6600" 
							condition="ROW.CMTB != ROW.PMTB" />
				</COLUMN>
				
				
			</DATAGRID>
		
		</ONGLET>
		
		<ONGLET label="Chiffrier annuel" queryNumber="1">
		
			
			<CHART title="Heures" type="columnChart" subType="stacked" 	
				sortField="ANNEE" sortSeq="A" 
				maxItems="24"  maxItemsSortOn="ANNEE" maxItemsSortSeq="D"  >
				<CATEGORY field="ANNEE" 
					type="Number"
					/>
				<SERIE field="PNBH" displayName="Nombre d'heures" />
			</CHART>
			<CHART title="Montant brut" type="columnChart" subType="stacked" 	
				sortField="ANNEE" sortSeq="A" 
				maxItems="24"  maxItemsSortOn="ANNEE" maxItemsSortSeq="D"  >
				<CATEGORY field="ANNEE" 
					type="Date"
					inputFormat="AAAA-MM-JJ"
					outputFormat="MMM YY"
					/>
				<SERIE field="PMTB" displayName="Montant brut" />
			</CHART>
					
			<DATAGRID title="Chiffrier" headerHeight="48" >
				<COLUMN dataField="ANNEE"
					type="Char"
					width="100"
					outputFormat="#"
					headerText="Année"
					textAlign="left" />
				
				<COLUMN dataField="PNBH" 
					type="Number"
					width="110"
					outputFormat="#h"
					headerText="Heures (production)" 
					textAlign="right" />
				<COLUMN dataField="PMTB" 
					type="Number" 
					width="110"
					outputFormat="#E"
					headerText="Montant brut (production)" 
					textAlign="right" 
					largeSeparator="true"/>
			</DATAGRID>
		
		</ONGLET>
		
		
		
		
		
				
	</PRESENTATION>
	
</VUE>

			
