<?xml version="1.0" encoding="ISO-8859-1"?>
<VUE name="ECO000010" 
	label="ECO. Justificatif mouvements" 
	title="= 'Justificatif des mouvements de ' + SELECT.PERIODE_LABEL + ' à ' + SELECT.TOPERIODE_LABEL " 
	database="iCTI" 
	swf="*CTI_view1" 
	globals="ECO_globals.XML" 
	componentsFile="ECO_components.XML"
	dboptimizer="ECO_dboptimizer.XML"
	softCode="iCTI_eco">
	
	<VIEWPROPERTIES componentName="PROPERTIES_MOUVEMENTS"/>
	<VIEWPROPERTIES componentName="PROPERTIES_GROUPBY"/>
	<VIEWPROPERTIES componentName="PROPERTIES_DATA"/>
	
	<SELECTIONS label="Paramètres de l'analyse" displayText="">
		<GROUP label="Période">
			<FIELD name="ALIAS_PERIODE" label="" UI="combo" width="180" 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>
		<GROUP label="Regroupement">
			<FIELD name="GROUPBY" label="" UI="combo" width="200" default="ART" tree="true">
				<OPTION label="Pas de premier niveau" data="-1"/>
				<OPTION label="Site" data="SIT" treeLevel="1"  globalListProvider="SITE_GROUPBY"/>
				<OPTION label="Article" data="ART" treeLevel="1"  globalListProvider="ARTICLE_GROUPBY"/>
				<OPTION label="Compte" data="CPA" treeLevel="1"  globalListProvider="COMPTE_ARTICLE_GROUPBY"/>
				<OPTION label="Fournisseur" data="FOU" treeLevel="1"  globalListProvider="FOURNISSEUR_GROUPBY"/>
				<OPTION label="Gestionnaire" data="GES" treeLevel="1"  globalListProvider="GESTIONNAIRE_GROUPBY"/>
				<OPTION label="Lieu" data="LIE" treeLevel="1"  globalListProvider="LIEU_GROUPBY"/>
				<OPTION label="Unité fonctionnelle" data="UFO" treeLevel="1"  globalListProvider="UNITE_FONCTIONNELLE_GROUPBY"/>
				<OPTION label="Type de mouvement" data="TYM" treeLevel="1"  globalListProvider="TYPE_MOUVEMENT_GROUPBY"/>
				<OPTION label="Année-Mois mouvement" globalListProvider="DATE_GROUPBY" treeLevel="1"  />
				<OPTION label="Commande" data="CMD" treeLevel="1"  />
				<OPTION label="Séjours" data="SEJ" treeLevel="1"/>
				<OPTION label="Séjours" data="SEJ" treeLevel="2"/>
				<OPTION label="RSS" data="RSS" treeLevel="2"/>
				<OPTION label="Médecins" data="MED" treeLevel="1"/>			
			</FIELD>
			<FIELD name="GROUPBY_TAB" width="100" label="Présentation" UI="combo" default="AUTO" visible="= SELECT.GROUPBY_2 != '-1' " update="= if(SELECT.GROUPBY != '-1') {return 'no_update'} else {return 'AUTO'}">
				<OPTION label="Automatique" data="AUTO"/>
				<OPTION label="Arbre" data="TREE"/>
				<OPTION label="Onglet" data="TAB"/>
			</FIELD>
		</GROUP>
		<GROUP label="Niveau de détail">
			<FIELD name="GROUPBY_2" label="" width="200" UI="combo" default="MVT" tree="true">
				<OPTION label="Mouvement" data="MVT" />
			</FIELD>
		</GROUP>
	</SELECTIONS>
	
	<SELECTIONS componentName="FILTRES_ARTICLE_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_FOURNISSEUR_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_MOUVEMENT_SELECTIONS"/>
	<SELECTIONS componentName="FILTRES_PROVIDER_SELECTIONS"/>
	<SELECTIONS label="Filtre Indicateur" collapsible="true" displayText="= var display:String = '';

					if (SELECT.DATA01  != '-1') {
						display = display + '  #B#Indicateur#/B# = ' + SELECT.DATA01_LABEL;
					}
					return display;">
		
			<GROUP label="">
			<FIELD name="DATA01" label="Indicateur" UI="combo" width="210" default="-1" tree="true" showIfNotDefault="true">
				<OPTION label="" data="-1"/>
				<OPTION label="" data="" globalListProvider="DATA_AP_IND" condition="dataItem.data6 &gt; 10 and dataItem.data6 &lt; 15"/>
			</FIELD>
			
		</GROUP>

		</SELECTIONS>
	
	<QUERIES>
		<QUERY label=""> 
			<SQL optimizer="V_MOUVEMENTS_ARTICLES_X" optimizer2="V_ALL_X">
				<select><![CDATA[		
					
					CTISELECT_TREE
						GROUPBY1{[VIEW.GROUPBY_OID_FIELD],, [VIEW.GROUPBY_COD_FIELD],, [VIEW.GROUPBY_TXT_FIELD]}
						GROUPBY1MODE{[GROUPBY_TAB]}
						GROUPBY2{article_id,, date,, mouvement_texte}
						INDICATORS{
							COUNT(DISTINCT unite_stockage_article_id),,
							SUM(entree_quantite),,
							SUM(sortie_quantite),,
							SUM(entree_quantite) - SUM(sortie_quantite),,
							SUM(entree_montant),,
							SUM(sortie_montant),,
							SUM(entree_montant) - SUM(sortie_montant),,
							AVG(prix_unitaire),,
						}
						INDICATORS_TEXT{
							COUNT(*)::text || ' lignes'::text,,
							'',,
							'',,
							'',,
							'',,
							'',,
							'',,
							'',,
						}	
						INDICATORS_2_TEXT{
							MAX(article_code || ' ' || article_texte)::text,,
							MAX(type_mouvement_code)::text,,
							MAX(lieu_code)::text,,
							MAX(unite_fonctionnelle_code)::text,,
							MAX(gestionnaire_code)::text,,
							MAX(CASE WHEN unite_stockage_article_id <> 0 AND unite_stockage_article_code <> 'UN' THEN unite_stockage_article_texte ELSE '' END)::text,,
							MAX(commande_code),,
							MIN(date_commande),,
						}						
					FROM #V_MOUVEMENTS_ARTICLES_X##V_ALL_X#
					WHERE (date BETWEEN '[PERIODE]' AND '[TOPERIODE]')
						[VIEW.ARTICLE_SELECT]
						[VIEW.FOURNISSEUR_SELECT]
						[VIEW.MOUVEMENT_SELECT]
						[VIEW.PROVIDER_SELECT]
					HAVING ([VIEW.DATASQL_FILTER] != 0)
					AFTER{
						
					}
					
				]]></select>
				<FIELDS>
					<INSERT name="CTISELECT_TREE_FIELDS"/>
					<FIELD name="QUST" />
					<FIELD name="QENT" />
					<FIELD name="QSOR" />
					<FIELD name="QECA" />
					<FIELD name="MENT" />
					<FIELD name="MSOR" />
					<FIELD name="MECA" />
					<FIELD name="PU" />

					<FIELD name="ARTI" />
					<FIELD name="TMVT" />
					<FIELD name="LIEU" />
					<FIELD name="UF" />
					<FIELD name="GEST" />
					<FIELD name="UNIT" />
					<FIELD name="CMD" />
					<FIELD name="DCMD" />
				</FIELDS>
			</SQL>
		</QUERY>
	</QUERIES>
	
	<PRESENTATION>
		<VIEWLINKS>
			<VIEWLINK label="Détail ligne commande" shortLabel="Détail commande" view="ECO000011.XML" componentName="" rowContext="true"
				 visible="= ROW.CMD != ''">
				<ARGS name="ALL" >
					<value><![CDATA[
					
					LINKVARIABLES['NUMERO_COMMANDE'] = ROW.CMD
					LINKVARIABLES['PERIODE'] = ROW.DCMD
					LINKVARIABLES['TOPERIODE'] = ROW.DCMD
					LINKVARIABLES['ARTICLE'] = 'DT' + ROW.OID2
					LINKVARIABLES['GROUPBY'] = 'CMD'
					LINKVARIABLES['GROUPBY_2'] = 'CML'
					return 'OK';
			
					]]></value>
				</ARGS>
			</VIEWLINK>	
			<VIEWLINK label="Détail article" shortLabel="Détail article" view="ECO000069.XML" componentName="ECO_VIEWLINK" component2Name="DATE_EVOL_VIEWLINK" >
				<ARGS name="SPEC" >
					<value><![CDATA[
						LINKVARIABLES['GROUPBY'] = 'AMCMD'
						LINKVARIABLES['GROUPBY_2'] = 'AMMVT'
						LINKVARIABLES['GROUPBY_3'] = 'AMSTO'
						LINKVARIABLES['TAB'] = 'AUTO'
						LINKVARIABLES['ARTICLE'] = 'DT' + ROW.OID2
						return 'OK';
			
					]]></value>
				</ARGS>
			</VIEWLINK>
		</VIEWLINKS>

		<ONGLET label="Onglet" multiTab="true" >

			<DATAGRID 	title="" 
						total="true" 
						headerHeight="40" 
						selectRowInRows="= ROW.OID == '-9999997'" 
						otherRowInRows="= ROW.OID == '-9999998'" 
						totalRowInRows="= ROW.OID == '-9999999'"
						variableRowHeight="true" 
						sortable="= SELECT.GROUPBY == '-1' || SELECT.GROUPBY_2 == '-1' || SELECT.GROUPBY_TAB == 'TAB'"> 
				
				<INSERT name="DATAGRID_MULTITAB_STYLES"/>
				
				<COLUMN dataField="OID"
					type="Number"
					visible="false" />
				<COLUMN dataField="ISAL"
					type="Number"
					visible="false" />
				<COLUMN dataField="COD" 
					type="Char" 
					width="100"
					outputFormat="#"
					headerText="Date" 
					textAlign="left" 
					totalComplement="*ROW">
					<INSERT name="COLUMN_COD_MULTITAB_STYLES"/>
				</COLUMN>
				<COLUMN dataField="TXT" 
					type="Char" 
					minWidth="110"
					headerText="Texte" 
					textAlign="left" 
					totalComplement="*ROW"/>
				
				<COLUMN dataField="ARTI" 
					type="Char" 
					minWidth="110"
					headerText="Article" 
					textAlign="left" 
					totalComplement=""/>
				<COLUMN dataField="TMVT" 
					type="Char" 
					width="40"
					headerText="Mvt" 
					textAlign="left" 
					totalComplement="*ROW"/>
				<COLUMN dataField="LIEU" 
					type="Char" 
					width="50"
					headerText="Lieu" 
					textAlign="left" 
					totalComplement="*ROW"/>
				<COLUMN dataField="UF" 
					type="Char" 
					width="50"
					headerText="U.F." 
					textAlign="left" 
					totalComplement="*ROW"/>
				<COLUMN dataField="GEST" 
					type="Char" 
					width="60"
					headerText="Gest" 
					textAlign="left" 
					totalComplement="*ROW"/>
				<COLUMN dataField="UNIT" 
					type="Char" 
					width="50"
					headerText="Unité" 
					textAlign="left" 
					totalComplement="*ROW"/>	
				<COLUMN dataField="QENT" 
					type="Number" 
					width="80"
					visibleCondition="SELECT.SENS_MOUVEMENT != 'S'"
					outputFormat="#"
					headerText="Entrées" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="MENT" 
					type="Number" 
					width="80"
					outputFormat="#E"
					visibleCondition="SELECT.SENS_MOUVEMENT != 'S'"
					headerText="Montant Entrées" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="QSOR" 
					type="Number" 
					width="80"
					outputFormat="#"
					visibleCondition="SELECT.SENS_MOUVEMENT != 'E'"
					headerText="Sorties" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="MSOR" 
					type="Number" 
					width="80"
					outputFormat="#E"
					visibleCondition="SELECT.SENS_MOUVEMENT != 'E'"
					headerText="Montant Sorties" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="QECA" 
					type="Number" 
					width="80"
					outputFormat="#"
					visibleCondition="SELECT.SENS_MOUVEMENT == '-1'"
					headerText="Ecart" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="MECA" 
					type="Number" 
					width="80"
					outputFormat="#E"
					visibleCondition="SELECT.SENS_MOUVEMENT == '-1'"
					headerText="Montant Ecart" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="PU" 
					type="Number" 
					width="60"
					outputFormat="#E"
					headerText="PU Moyen HT" 
					textAlign="right"
					totalComplement="*ROW" />
				<COLUMN dataField="CMD" 
					type="Char" 
					minWidth="70"
					headerText="Commande" 
					textAlign="left" 
					totalComplement="*ROW"/>
				<COLUMN dataField="DCMD" 
					type="Char" 
					minWidth="110"
					headerText="Date Commande" 
					textAlign="left" 
					totalComplement="*ROW"
					visible="false"/>
				
				
			</DATAGRID>
		</ONGLET>
	</PRESENTATION>
</VUE>

			
