<?xml version="1.0" encoding="ISO-8859-1"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				xmlns:cti_control="CTI.technique.controls.*"
				xmlns="*"
				creationComplete="creationComplete()"
				resize="resize()"
				styleName="CTIView"
				paddingTop="0"
				paddingBottom="0"
				paddingRight="0"
				paddingLeft="0"
				creationPolicy="all">

	<mx:Script>
		<![CDATA[
			import flash.display.DisplayObjectContainer;
			import mx.containers.Form;
			import mx.containers.FormHeading;
			import mx.containers.FormItem;
			import mx.containers.HBox;
			import mx.containers.TitleWindow;
			import mx.controls.Alert;
			import mx.controls.Button;
			import mx.controls.ButtonLabelPlacement;
			import mx.controls.CheckBox;
			import mx.controls.Menu;
			import mx.collections.ArrayCollection;
			import flash.net.URLVariables;
			import mx.core.IFlexDisplayObject;
			import mx.events.CloseEvent
			import flash.events.*;
			import mx.events.*;
			import flash.external.*;
			import flash.utils.ByteArray;
			import flash.net.FileReference;
			import mx.formatters.DateFormatter;
			import mx.collections.Sort;
			import mx.collections.SortField;
			import mx.managers.PopUpManager;
			
			import CTI.technique.CTI_Utilitaires;
			import CTI.technique.CTI_Base64;
			import CTI.properties.CTI_Properties;
			import CTI.technique.CTI_ArrayCollection;
			
			public var buildComplete:Boolean = false;
			
			[Bindable]
			public var title:String = "Import des fichiers RSS / RSF";
			
			[Bindable]
			public var hasHelp:Boolean = false;
			
			[Bindable]
			public var imports_list:ArrayCollection = new ArrayCollection();
			
			[Bindable]
			public var jobsHistory_list:CTI_ArrayCollection = new CTI_ArrayCollection();
			[Bindable]
			public var jobsHistory_length:Number;
			
			[Bindable]
			private var download_menu_GUI:Menu = new Menu();
			[Bindable]
			private var download_menu_items:ArrayCollection = new ArrayCollection();
			private var download_menu_current_data_type:String;
			
						
			[Bindable]
			private var importEnabled:Boolean = false;
			
			[Bindable]
			public var importStarted:Boolean = false;

			
			[Bindable]
			private var validationStatus:String;
			
			[Bindable]
			private var sendFilesStatus:String;
			
			[Bindable]
			private var controleStatus:String;
			
			[Bindable]
			private var new_import_version:Boolean = true;
			
			[Bindable]
			private var new_imports_month_provider:XMLList;
			
			[Bindable]
			private var new_imports_files_provider:XMLList;
			
			[Bindable]
			private var new_imports_files_statusCode:String = "";
			
			[Bindable]
			private var new_imports_files_statusText:String = "";

			
			[Bindable]
			private var new_import_fileToUpload:FileReference = new FileReference();
			
			private var importResult:String;
			private var import_id:Number = 0;

			private var setContents_currentFileIndex:int
			private var setContents_interval:Number;

			[Bindable]
			private var selected_import_item:Object;

			[Bindable]
			private var uploadFilesResult:XML = new XML();

			private var uploadBlockLen:int = 0;

			[Bindable]
			private var http_config_ok:Boolean = false

			public function creationComplete():void
			{

				if (application.currentHelpFile != "")
				{
					hasHelp = true;
				}

				if (application.name == "CTI")
				{
				}
				if (application.name == "CTI_1")
				{
					GUI_titleBar.height = 0
				}

				tabNavigator_GUI.selectedIndex = 0

				// Pop up menu
				var item:Object = new Object()
				item.label = "RSS"
				item.data = "RSS"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "RSF"
				item.data = "RSF"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "RSS IN.ZIP"
				item.data = "ZIN"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "RSS OUT.ZIP"
				item.data = "ZOU"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "RSF IN.ZIP"
				item.data = "ZIF"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "FICHCOMP (ex DG)"
				item.data = "FCP"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "Médecins"
				item.data = "MED"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "RSS - Médecins"
				item.data = "RSSMED"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "Noms RSS"
				item.data = "RSSNOM"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "Actes - Médecins"
				item.data = "ACTMED"
				download_menu_items.addItem(item)

				item = new Object()
				item.label = "Valorisation séjours"
				item.data = "VSJ"
				download_menu_items.addItem(item)

				item = new Object();
				item.label = "Valorisation ACE";
				item.data = "VSE";
				download_menu_items.addItem(item);

				item = new Object();
				item.label = "FICHSUP transports";
				item.data = "TSP";
				download_menu_items.addItem(item);

				download_menu_items.filterFunction = download_menu_items_filterFunction

				download_menu_GUI.dataProvider = download_menu_items;
				download_menu_GUI.selectedIndex = 0;
				download_menu_current_data_type = "";

				download_menu_GUI.addEventListener("itemClick", download_menu_itemClick);

				download_popup_GUI.label = "Télécharger fichier";


				checkFiles();

				getData()
			}

			private function newFile(type:String, label:String):Object
			{
				var file:Object = new Object()
				file.type = type
				file.label = label
				file.path = ""
				file.size = 0
				file.content = ""
				file.sizeD = ""
				file.date = ""
				file.status = ""

				file.uploadType = ""
				file.uploadPath = ""
				file.uploadSize = 0

				file.OK = false
				return file;
			}

			private function download_menu_itemClick(event:MenuEvent):void
			{

				download_popup_GUI.label = "Télécharger " + event.item.label
				download_menu_current_data_type = event.item.data;
				download_popup_GUI.close();
				download_menu_GUI.selectedIndex = event.index;

				if (tabNavigator_GUI.selectedIndex == 0)
				{
					if (imports_list_GUI.selectedItem != null)
					{
						downloadFile();
					}
				}

				if (tabNavigator_GUI.selectedIndex == 1)
				{
					downloadFile();
				}

			}

			public function eventDispatcher(eventCode:String):Boolean
			{
				return true
			}

			public function getData():void
			{

				var urlVariables:URLVariables

				imports_list.removeAll();

				CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_getImports.php", urlVariables, exec, true, this.parentApplication)

				function exec(resultatService:XML):void
				{

					// Options serveur apache
					http_config_ok = true
					for each (var apacheNode:XML in resultatService.APACHEPHP) {
						if (Number(apacheNode.@post_max_size.toString()) < 128) {
							http_config_ok = false
						}
						if (Number(apacheNode.@upload_max_filesize.toString()) < 128) {
							http_config_ok = false
						}
					}

					// suite

					var initDft:Boolean = false;

					jobsHistory_length = resultatService.JOB.length()
					jobsHistory_list.loadXMLList(resultatService.JOB)

					var _sort:Sort = new Sort()
					_sort.fields = [new SortField("start", true, true, false)];
					jobsHistory_list.sort = _sort;
					jobsHistory_list.refresh()



					for each (var importNode:XML in resultatService.IMPORT)
					{

						var import_item:Object = new Object();
						import_item.oid = Number(importNode.@oid.toString())
						import_item.texte = importNode.@texte.toString()
						import_item.date_import = importNode.@date_import.toString()
						import_item.etat = importNode.@etat.toString()
						import_item.etat_en_cours = importNode.@etat_en_cours.toString()
						import_item.traitement_a_faire = importNode.@traitement_a_faire.toString()
						import_item.finess = importNode.@finess.toString()
						import_item.date_debut = importNode.@date_debut.toString()
						import_item.date_fin = importNode.@date_fin.toString()
						import_item.nb_rss = Number(importNode.@nb_rss.toString())
						import_item.nb_rum = Number(importNode.@nb_rum.toString())
						import_item.nb_rsf = Number(importNode.@nb_rsf.toString())
						import_item.nb_erreurs = Number(importNode.@nb_erreurs.toString())
						import_item.nb_avertissements = Number(importNode.@nb_avertissements.toString())

						import_item.rss_file_path = importNode.@rss_file_path.toString()
						import_item.rss_data_size = Number(importNode.@rss_data_size.toString())
						import_item.rsf_file_path = importNode.@rsf_file_path.toString()
						import_item.rsf_data_size = Number(importNode.@rsf_data_size.toString())
						import_item.fcp_file_path = importNode.@fcp_file_path.toString()
						import_item.fcp_data_size = Number(importNode.@fcp_data_size.toString())
						import_item.med_file_path = importNode.@med_file_path.toString()
						import_item.med_data_size = Number(importNode.@med_data_size.toString())
						import_item.rssmed_file_path = importNode.@rssmed_file_path.toString()
						import_item.rssmed_data_size = Number(importNode.@rssmed_data_size.toString())
						import_item.rssnom_file_path = importNode.@rssnom_file_path.toString()
						import_item.rssnom_data_size = Number(importNode.@rssnom_data_size.toString())
						import_item.actmed_file_path = importNode.@actmed_file_path.toString()
						import_item.actmed_data_size = Number(importNode.@actmed_data_size.toString())
						import_item.vsj_file_path = importNode.@vsj_file_path.toString();
						import_item.vsj_data_size = Number(importNode.@vsj_data_size.toString());
						import_item.vse_file_path = importNode.@vse_file_path.toString();
						import_item.vse_data_size = Number(importNode.@vse_data_size.toString());
						import_item.tsp_file_path = importNode.@tsp_file_path.toString();
						import_item.tsp_data_size = Number(importNode.@tsp_data_size.toString());

						import_item.zin_file_path = importNode.@zin_file_path.toString()
						import_item.zin_data_size = Number(importNode.@zin_data_size.toString())
						import_item.zou_file_path = importNode.@zou_file_path.toString()
						import_item.zou_data_size = Number(importNode.@zou_data_size.toString())
						import_item.zif_file_path = importNode.@zif_file_path.toString()
						import_item.zif_data_size = Number(importNode.@zif_data_size.toString())

						import_item.etat_texte = "";
						if (import_item.etat == "I")
						{
							import_item.etat_texte = "Importés";
						}
						if (import_item.etat == "C")
						{
							import_item.etat_texte = "Controlé";
						}
						if (import_item.etat == "G")
						{
							import_item.etat_texte = "Généré";
						}

						if (import_item.traitement_a_faire == "")
						{
							if (import_item.etat_en_cours == "I")
							{
								import_item.etat_texte = import_item.etat_texte + ", Import en cours";
							}
							if (import_item.etat_en_cours == "C")
							{
								import_item.etat_texte = import_item.etat_texte + ", Contrôle en cours";
							}
							if (import_item.etat_en_cours == "G")
							{
								import_item.etat_texte = import_item.etat_texte + ", Génération en cours";
							}
						}
						else
						{
							if (import_item.traitement_a_faire == "C")
							{
								import_item.etat_texte = import_item.etat_texte + ", Contrôle en attente";
							}
							if (import_item.traitement_a_faire == "G")
							{
								import_item.etat_texte = import_item.etat_texte + ", Génération en attente";
							}
						}

						imports_list.addItem(import_item);
					}

					checkFiles();

					var encours_node:XML = resultatService.ENCOURS[0];

					if (encours_node.@licence_activite == "true")
					{
						encours_pmsi_box_GUI.enabled = true

						encours_pmsi_description_GUI.htmlText = "La récupération des <B>dossiers PMSI non expédiés</B> permet de compléter la base de données issue des fichiers RSS/RSF envoyés à ePMSI avec les dossiers <B>groupés</B> de la base de production qui ne sont pas présents dans ces fichiers RSS/RSF envoyés à ePMSI."
						encours_pmsi_description_GUI.htmlText = encours_pmsi_description_GUI.htmlText + "<BR><B>ATTENTION</B>"
						encours_pmsi_description_GUI.htmlText = encours_pmsi_description_GUI.htmlText + "<BR>Ce traitement peut s'exécuter automatiquement toutes les nuits"
						encours_pmsi_description_GUI.htmlText = encours_pmsi_description_GUI.htmlText + "<BR>Si vous souhaitez néanmoins le lancer, il s'exécutera en <B>batch</B> et durera quelques minutes."
						//encours_pmsi_description_GUI.htmlText = encours_pmsi_description_GUI.htmlText + "<BR>Durant le temps de synchronisation, les dossiers non expédiés précédemment importés ne seront pas disponibles dans les tableaux."

						encours_pmsi_last_import_GUI.text = encours_node.@last_encours_active.toString()
						if (encours_pmsi_last_import_GUI.text == "")
						{
							encours_pmsi_last_import_GUI.text = encours_node.@last_encours_endded.toString()
						}
					}

					setTimeout(setBuildComplete, 1000);

				}

			}

			private function setBuildComplete():void
			{

				buildComplete = true;
			}

			private function resize():void
			{

			}



			private function selectImportLine():void
			{

				download_menu_items.refresh()

				download_menu_GUI.selectedIndex = 0
				download_menu_current_data_type = "";
				download_popup_GUI.label = "Télécharger fichier";

				this.validateNow();

			}

			public function download_menu_items_filterFunction(item:Object):Boolean
			{

				if (imports_list_GUI.selectedItem == null)
				{
					return false;
				}

				if (imports_list_GUI.selectedItem.zin_data_size == 0 && item.data == "ZIN")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.zou_data_size == 0 && item.data == "ZOU")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.zif_data_size == 0 && item.data == "ZIF")
				{
					return false;
				}

				if (imports_list_GUI.selectedItem.rss_data_size == 0 && item.data == "RSS")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.rsf_data_size == 0 && item.data == "RSF")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.fcp_data_size == 0 && item.data == "FCP")
				{
					return false;
				}

				if (imports_list_GUI.selectedItem.med_data_size == 0 && item.data == "MED")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.rssmed_data_size == 0 && item.data == "RSSMED")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.rssnom_data_size == 0 && item.data == "RSSNOM")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.actmed_data_size == 0 && item.data == "ACTMED")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.vsj_data_size == 0 && item.data == "VSJ")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.vse_data_size == 0 && item.data == "VSE")
				{
					return false;
				}
				if (imports_list_GUI.selectedItem.tsp_data_size == 0 && item.data == "TSP")
				{
					return false;
				}

				return true;
			}

			private function on_tabNavigator_change():void
			{
				if (tabNavigator_GUI.selectedIndex == 1 && new_import_version == true)
				{
					new_import_getFiles()
				}

			}



			private function askImportFiles():void
			{

				CTI_Utilitaires.question_yesNo("Import RSS RSF", "Confirmez vous le traitement des fichiers choisis ?", responseFunction)

				function responseFunction(event:CloseEvent):void
				{

					if (event.detail != Alert.YES)
					{
						return;
					}


					new_import_filesValidation()


				}
			}





			public function displayRapport():void
			{

				if (imports_list_GUI.selectedItem != null)
				{
					var urlRequest:URLRequest = new URLRequest();
					urlRequest.url = "modules/pmsi/php/PMSI_getImportRapport.php"
					var urlVariables:URLVariables = new URLVariables()
					urlVariables.import_id = imports_list_GUI.selectedItem.oid
					urlRequest.data = urlVariables
					urlRequest.method = "POST";

					navigateToURL(urlRequest, "importRapport")
					return;
				}

				Alert.show("Aucun import à afficher")
			}

			public function controlImport():void
			{

				var urlVariables:URLVariables = new URLVariables()
				urlVariables.option = "C";

				if (imports_list_GUI.selectedItem != null)
				{
					urlVariables.import_id = imports_list_GUI.selectedItem.oid
					CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_execImport.php", urlVariables, exec, true, this.parentApplication)
					return;
				}

				Alert.show("Aucun import sélectionné")

				function exec(resultatService:XML):void
				{

					displayRapport();
					getData();

				}

			}

			/**
			 * Si l'utilisateur qui lance la génération est 'cti', on affiche une fenêtre d'options dans laquelle
			 * on pourra choisir de lancer ou non les contrôles expert et la génération des essentiels
			 */
			public function generateImport():void
			{

				if (application.sessionProperties.properties.CONNECTEDUSER != 'cti') {
					CTI_Utilitaires.question_yesNo("Import RSS RSF", "Confirmez vous la génération dans la base de données ?", responseFunction)
				}
				else {

					var ti:TitleWindow = new TitleWindow();
					ti.title = "Génération des données";
					ti.setStyle("horizontalAlign", "center");

					// Case à cocher pour l'exécution des contrôles expert
					var cbExpert:CheckBox = new CheckBox();
					cbExpert.selected = true;
					cbExpert.name = "CBEXPERT";
					cbExpert.label = "Lancer les contrôles expert";
					cbExpert.labelPlacement = ButtonLabelPlacement.RIGHT;

					// Case à cocher pour le lancement du calcul des essentiels
					var cbEssentiels:CheckBox = new CheckBox();
					cbEssentiels.selected = true;
					cbEssentiels.name = "CBESSENTIELS";
					cbEssentiels.label = "Calculer les essentiels";
					cbEssentiels.labelPlacement = ButtonLabelPlacement.RIGHT;

					// Case à cocher pour le traitement des informations complémentaires
					var cbComplements:CheckBox = new CheckBox();
					cbComplements.selected = true;
					cbComplements.name = "CBCOMPLEMENTS";
					cbComplements.label = "Données complémentaires";
					cbComplements.labelPlacement = ButtonLabelPlacement.RIGHT;

					var form:Form = new Form();

					var formHeading:FormHeading = new FormHeading();
					formHeading.label = "Options de génération";
					form.addChild(formHeading);

					var formItem:FormItem;

					formItem = new FormItem();
					formItem.addChild(cbExpert);
					form.addChild(formItem);

					formItem = new FormItem();
					formItem.addChild(cbEssentiels);
					form.addChild(formItem);

					formItem = new FormItem();
					formItem.addChild(cbComplements);
					form.addChild(formItem);

					var okButton:Button = new Button();
					okButton.label = "Générer";
					okButton.name = "OK";

					var cancelButton:Button = new Button();
					cancelButton.label = "Annuler";
					cancelButton.name = "CANCEL";

					var hbox:HBox = new HBox();
					hbox.addChild(okButton);
					hbox.addChild(cancelButton);

					ti.addChild(form);
					ti.addChild(hbox);

					ti.addEventListener(MouseEvent.CLICK, ctiGenerate);

					PopUpManager.addPopUp(ti, this, true);
					PopUpManager.centerPopUp(ti);

				}
				function responseFunction(event:CloseEvent):void
				{

					if (event.detail != Alert.YES)
					{
						return;
					}

					var urlVariables:URLVariables = new URLVariables()
					urlVariables.option = "G";

					if (imports_list_GUI.selectedItem != null)
					{
						urlVariables.import_id = imports_list_GUI.selectedItem.oid
						CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_execImport.php", urlVariables, handleGenerate, true, this.parentApplication)
						return;
					}
					else {
						Alert.show("Aucun import sélectionné");
					}

				}
			}

			private function ctiGenerate(event:Event):void {
				if ((event.target is Button) && !(event.target is CheckBox)) {
					PopUpManager.removePopUp(event.currentTarget as IFlexDisplayObject);
					event.currentTarget.removeEventListener(MouseEvent.CLICK, ctiGenerate);
					if (event.target.name == "OK") {
						var cbEss:CheckBox = findChild(event.currentTarget as DisplayObjectContainer, "CBESSENTIELS") as CheckBox;
						var cbExp:CheckBox = findChild(event.currentTarget as DisplayObjectContainer, "CBEXPERT") as CheckBox;
						var cbCmp:CheckBox = findChild(event.currentTarget as DisplayObjectContainer, "CBCOMPLEMENTS") as CheckBox;
						var urlVariables:URLVariables = new URLVariables();
						urlVariables.option = "G";
						urlVariables.option_essentiels = cbEss.selected.toString();
						urlVariables.option_expert = cbExp.selected.toString();
						urlVariables.option_complements = cbCmp.selected.toString();
						if (imports_list_GUI.selectedItem != null) {
							urlVariables.import_id = imports_list_GUI.selectedItem.oid
							CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_execImport.php", urlVariables, handleGenerate, true, this.parentApplication)
							return;
						}
						else {
							Alert.show("Aucun import sélectionné");
						}
					}
				}
			}

			/**
			 * Méthode qui s'exécute dès que la fonction PHP de lancement de l'import des données renvoie quelque chose
			 * @param	resultatService	XML de retour de la fonction PHP
			 */
			private function handleGenerate(resultatService:XML):void {
				if (resultatService.@returnCode.toString() == "KO")
				{
					CTI_Utilitaires.alert_error("Import RSS RSF", resultatService.@returnTexte.toString());
				}
				else
				{
					CTI_Utilitaires.alert_info("Import RSS RSF", "Génération démarrée en batch sur le serveur");
					getData();
				}
			}

			/**
			 * Fonction qui cherche un displayObject par son nom dans toute l'arboresence d'un
			 * container. Cette fonction supplante la fonction getChildByName dans le sens où elle
			 * ne se cantonne pas au premier niveau de l'arboresence mais inspecte tous les niveaux
			 *
			 * @param	container	Container dans lequel chercher l'enfant
			 * @param	childname	Nom de l'enfant à chercher
			 * @return	L'élement trouvé dans l'arborescence
			 */
			private function findChild(container:DisplayObjectContainer, childname:String ):DisplayObject {
				if (container == null) {
					container = this;
				}

				for (var j:int = 0; j < container.numChildren; ++j) {

					var obj:DisplayObject = container.getChildAt(j) as DisplayObject;
					if (obj.name == childname) {
						return obj;
					}
					if (obj is DisplayObjectContainer) {
						var doc:DisplayObjectContainer = obj as DisplayObjectContainer;
						if (doc.numChildren > 0) {
							var ret:DisplayObject = findChild( doc, childname );
							if (ret != null) {
								return ret;
							}
						}
					}
				}
				return null;
			}

			private function deleteImport():void
			{
				CTI_Utilitaires.question_yesNo("Import RSS RSF", "Confirmez vous la suppression de l'import ?", responseFunction)

				function responseFunction(event:CloseEvent):void
				{

					if (event.detail != Alert.YES)
					{
						return;
					}

					var urlVariables:URLVariables = new URLVariables()
					urlVariables.option = "D";

					if (imports_list_GUI.selectedItem != null)
					{
						urlVariables.import_id = imports_list_GUI.selectedItem.oid
						CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_execImport.php", urlVariables, exec, true, this.parentApplication)
						return;
					}

					Alert.show("Aucun import sélectionné")

					function exec(resultatService:XML):void
					{

						getData();

					}

				}
			}

			public function downloadFile():void
			{

				if (imports_list_GUI.selectedItem != null)
				{
					if (download_menu_current_data_type != "")
					{
						var urlRequest:URLRequest = new URLRequest();
						urlRequest.url = "modules/pmsi/php/PMSI_getFile.php"
						var urlVariables:URLVariables = new URLVariables()
						urlVariables.import_id = imports_list_GUI.selectedItem.oid
						urlVariables.data_type = download_menu_current_data_type
						urlRequest.data = urlVariables
						urlRequest.method = "POST";

						navigateToURL(urlRequest, "getFile")
					}
					else
					{
						Alert.show("Choisir d'abord un fichier à télécharger")
					}

					return;
				}

				Alert.show("Aucun import sélectionné")

			}

			private function importEncours():void
			{

				CTI_Utilitaires.question_yesNo("Import RSS RSF", "Confirmez vous la récupération des dossiers PMSI non expédiés ?", responseFunction)

				function responseFunction(event:CloseEvent):void
				{

					if (event.detail != Alert.YES)
					{
						return;
					}

					var urlVariables:URLVariables = new URLVariables()
					urlVariables.option = "encours";

					CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_execImport.php", urlVariables, exec, true, this.parentApplication)

					function exec(resultatService:XML):void
					{
						if (resultatService.@returnCode.toString() == "KO")
						{
							CTI_Utilitaires.alert_error("Import RSS RSF", resultatService.@returnTexte.toString());
						}
						else
						{
							CTI_Utilitaires.alert_info("Import RSS RSF", "Récupération démarrée en batch sur le serveur");
							getData();
						}
					}

				}
			}

			private function displayLog():void
			{

				var job:Object;

				if (historique_UI.selectedIndex < 0)
				{
					return
				}
				job = historique_UI.selectedItem;

				if (job.logFile.toString() == "")
				{
					return;
				}

				var urlVariables:URLVariables = new URLVariables();
				urlVariables.longfile = job.logFile.toString();

				CTI_Utilitaires.openURL("modules/outils/php/getLogFile.php", urlVariables, "iCTI_logFile")

			}

			public function vitalia_prepar():void
			{
				CTI_Utilitaires.openWebURL("modules/vitalia/iCTI_VITALIA_E" + application.environmentProperties.properties.FINESS + "E_prepa4cirque.exe")
			}



			private function vedici_synchronize():void
			{

				var urlVariables:URLVariables = new URLVariables();

				CTI_Utilitaires.startRequestHTTP("modules/vedici/php/VEDICI_PMSI_send2central.php", urlVariables, exec, true, this.parentApplication)

				function exec(resultatService:XML):void
				{

					if (resultatService.@returnCode.toString() == "OK")
					{
						CTI_Utilitaires.alert_info("Synchronisation VEDICI", "Synchronisation terminée : " + resultatService.@returnTexte.toString())
					}
					else
					{
						CTI_Utilitaires.alert_error("Synchronisation VEDICI", "Synchronisation non effectué : " + resultatService.@returnTexte.toString())
					}

				}
			}

			private function checkFiles():void {
				importEnabled = true;

				if (importTexte_GUI.text == "")
				{
					importTexte_GUI.setStyle("backgroundColor", "#ffd393")
					importTexte_GUI.setStyle("color", "#0B333C")
					importEnabled = false
				}
				else
				{
					importTexte_GUI.setStyle("backgroundColor", "#FFFFFF")
					importTexte_GUI.setStyle("color", "#0B333C")
				}

				if (new_imports_files_statusCode != "OK" && new_imports_files_statusCode != "ATT") {
					importEnabled = false
				}


			}



			public function new_import_upload():void
			{

				new_import_fileToUpload.addEventListener(Event.SELECT, new_import_fileToUpload_onSelect);

				new_import_fileToUpload.browse();

			}

			private function new_import_fileToUpload_onSelect(event:Event):void
			{

				try
				{
					new_import_fileUpload()
				}
				catch (err:Error)
				{
				}

			}

			public function new_import_removeFile(file:String="*ALL"):void
			{

				if (file == "*ALL") {
					CTI_Utilitaires.question_yesNo("Import RSS RSF", "Confirmez vous la suppression de tous les fichiers ?", responseFunction)
				}
				else {
					responseFunction()
				}

				function responseFunction(event:CloseEvent = null):void
				{


					if (event != null && event.detail != Alert.YES)
					{
						return;
					}

					var urlVariables:URLVariables = new URLVariables();
					urlVariables.file = file

					CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/httpservice_PMSI_rssUpload_removeFile.php", urlVariables, exec, true, this.parentApplication)
					function exec(resultatService:XML):void
					{

						if (resultatService.@returnCode.toString() == "OK")
						{
							new_import_getFiles()
						}
					}
				}
			}

			private function new_import_getFiles():void
			{

				var urlVariables:URLVariables = new URLVariables();

				new_imports_files_statusCode = ""
				new_imports_files_statusText = ""
				new_imports_files_statusText_GUI.setStyle("backgroundColor", 0xFFFFFF)

				CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/httpservice_PMSI_rssUpload_getFiles.php", urlVariables, exec, true, this.parentApplication)
				function exec(resultatService:XML):void
				{
					if (resultatService.@returnCode.toString() == "OK")
					{
						new_imports_files_provider = resultatService.FILE

						new_imports_files_statusCode = resultatService.STATUS[0].@statusCode
						new_imports_files_statusText = resultatService.STATUS[0].@statusText

						if (new_imports_files_statusCode != "OK") {
							new_imports_files_statusText_GUI.setStyle("backgroundColor", 0xffd393)
						}

						checkFiles()
					}
				}
			}


			private function new_import_fileUpload():void
			{


				var urlVariables:URLVariables = new URLVariables();
				urlVariables.importFile = new_import_fileToUpload.name;
				urlVariables.importFileDate = new_import_fileToUpload.modificationDate.getTime().toString().substr(0,10)

				CTI_Utilitaires.startUploadHTTP(new_import_fileToUpload, "modules/pmsi/php/httpservice_PMSI_rssUpload_upload.php", urlVariables, exec, true, this.parentApplication)

				function exec(resultatService:XML):void
				{

					if (resultatService.@returnCode.toString() == "OK")
					{

					}
					else
					{
						CTI_Utilitaires.alert_error("Envoi fichiers RSS/RSF au serveur", resultatService.@returnTexte.toString())
					}
					new_import_getFiles()

				}
			}

			private function new_import_filesValidation():void
			{


				importStarted = true;

				sendFilesStatus = "Terminé"

				validationStatus = "En cours";
				status_bar_GUI.label = "Validation de l'import sur le serveur";
				status_bar_GUI.setProgress(0, 2)

				var urlVariables:URLVariables = new URLVariables();
				urlVariables.import_texte = importTexte_GUI.text;

				CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/httpservice_PMSI_rssUpload_valideFiles.php", urlVariables, exec, true, this.parentApplication)

				function exec(resultatService:XML):void
				{

					if (resultatService.@returnCode.toString() == "OK")
					{
						import_id = Number(resultatService.@import_id.toString());
						validationStatus = "Validation par le serveur terminée : n° " + import_id + " attribué."
						status_bar_GUI.setProgress(1, 2)

						new_import_fileControle()
					}
					else
					{
						importResult = "QUIT";
						validationStatus = "ERREUR. Validation par le serveur non effectuée : " + resultatService.@returnTexte.toString();
						controleStatus = "";
						status_bar_GUI.setProgress(2, 2)
						importStarted = false;
						CTI_Utilitaires.alert_error("Import PMSI", "Validation par le serveur non effectuée : " + resultatService.@returnTexte.toString())
					}

				}
			}

			private function new_import_fileControle():void
			{

				importStarted = true;

				controleStatus = "En cours";
				status_bar_GUI.label = "Contrôle sur le serveur";

				var urlVariables:URLVariables = new URLVariables();
				urlVariables.import_id = import_id;

				CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/httpservice_PMSI_rssUpload_controlImport.php", urlVariables, exec, true, this.parentApplication)

				function exec(resultatService:XML):void
				{

					var urlRequest:URLRequest = new URLRequest();
					urlRequest.url = "modules/pmsi/php/PMSI_getImportRapport.php"
					var urlVariables:URLVariables = new URLVariables()
					urlVariables.import_id = import_id
					urlRequest.data = urlVariables
					urlRequest.method = "POST";
					navigateToURL(urlRequest, "importRapport")

					status_bar_GUI.setProgress(2, 2)
					importStarted = false;

					if (resultatService.@returnCode.toString() == "OK" || resultatService.@returnCode.toString() == "ATT")
					{
						controleStatus = "Contrôle par le serveur terminé : " + resultatService.@returnTexte.toString();
						CTI_Utilitaires.alert_info("Import PMSI", "Traitement par le serveur terminé : " + resultatService.@returnTexte.toString(),demandeGeneration)
					}
					else
					{
						controleStatus = "ERREUR. Contrôle par le serveur en erreur : " + resultatService.@returnTexte.toString();
						CTI_Utilitaires.alert_error("Import PMSI", "Le contrôle a détecté une erreur grave : " + resultatService.@returnTexte.toString(),demandeGeneration)
					}

					function demandeGeneration(event:CloseEvent):void {

						CTI_Utilitaires.question_yesNo("Import PMSI", "Controle terminé : " + resultatService.@returnTexte.toString() + ". Désirez vous générer la base de données ?", responseFunction)

						function responseFunction(event:CloseEvent):void {

							if (event.detail != Alert.YES) {
								return;
							}

							var urlVariables:URLVariables = new URLVariables()
							urlVariables.option = "G";
							urlVariables.import_id = import_id
							CTI_Utilitaires.startRequestHTTP("modules/pmsi/php/PMSI_execImport.php",urlVariables,exec,true)
							function exec(resultatService:XML):void {
								if (resultatService.@returnCode.toString() == "KO") {
									CTI_Utilitaires.alert_error("Import RSS RSF", resultatService.@returnTexte.toString());
								}
								else {
									CTI_Utilitaires.alert_info("Import RSS RSF", "Génération démarrée en batch sur le serveur");
								}
							}
						}

					}

					getData();
				}
			}



			private function exec_config_http():void {

				CTI_Utilitaires.question_yesNo("Import PMSI", "Confirmez vous la configuration du serveur HTTP ?", responseFunction)

				function responseFunction(event:CloseEvent):void {

					if (event.detail != Alert.YES) {
						return;
					}

					var urlVariables:URLVariables = new URLVariables()

					CTI_Utilitaires.startRequestHTTP("modules/outils/php/httpService_wampManager_configure.php",urlVariables,exec,true,this.parentApplication)

					function exec(resultatService:XML):void {

						var returnCode:String = resultatService.RETURN[0].@code.toString()
						var returnMessage:String = resultatService.RETURN[0].@message.toString()

						if (returnCode == "OK") {
							config_http_button.label = config_http_button.label + " (FAIT. Patientez 20 secondes)"
							config_http_button.enabled = false
							setTimeout(getData, 20000);
						}
						else {
							Alert.show(returnMessage)
						}

					}

				}

			}

		]]>
	</mx:Script>


	<mx:VBox width="100%"
			 height="100%">

		<cti_control:CTIViewTitle id="GUI_titleBar"
								  label="{title}"
								  width="100%"
								  height="25" />

		<mx:Canvas width="100%"
				   height="48">
			<mx:Canvas width="100%"
					   height="100%"
					   visible="{tabNavigator_GUI.selectedIndex != 1 &amp;&amp; tabNavigator_GUI.selectedIndex != 2 &amp;&amp; tabNavigator_GUI.selectedIndex != 3}">
				<mx:HBox width="100%">
					<mx:Button height="28"
							   width="28"
							   toolTip="Réafficher"
							   icon="@Embed('../../base/swf/CTI/images/24/view-refresh.png')"
							   labelPlacement="right"
							   click="getData()" />
					<mx:Button height="28"
							   width="140"
							   label="Dernier rapport"
							   toolTip="Afficher le dernier rapport"
							   icon="@Embed('../../base/swf/CTI/images/24/document-open.png')"
							   labelPlacement="right"
							   click="displayRapport()"
							   enabled="{imports_list_GUI.selectedIndex >= 0}" />
					<mx:Button height="28"
							   width="120"
							   label="Recontrôler"
							   toolTip="Lancer un nouveau contrôle"
							   icon="@Embed('../../base/swf/CTI/images/24/preferences-desktop-peripherals-directory.png')"
							   labelPlacement="right"
							   click="controlImport()"
							   enabled="{imports_list_GUI.selectedIndex >= 0}" />
					<mx:Button height="28"
							   width="100"
							   label="Générer"
							   toolTip="Lancer la génération de la base de données"
							   icon="@Embed('../../base/swf/CTI/images/24/system-upgrade.png')"
							   labelPlacement="right"
							   click="generateImport()"
							   enabled="{imports_list_GUI.selectedIndex >= 0}" />
					<mx:PopUpButton id="download_popup_GUI"
									enabled="{imports_list_GUI.selectedIndex >= 0}"
									height="28"
									width="200"
									toolTip="Télécharger un des fichiers importés"
									popUp="{download_menu_GUI}"
									icon="@Embed('../../base/swf/CTI/images/24/document-save-all.png')"
									labelPlacement="right"
									click="downloadFile()" />
					<mx:Button height="28"
							   width="120"
							   label="Synchroniser"
							   toolTip="Synchroniser les imports avec le serveur VEDICI"
							   icon="@Embed('../../base/swf/CTI/images/vedici24.jpg')"
							   labelPlacement="right"
							   click="vedici_synchronize()"
							   visible="{application.environmentProperties.properties.LOCALKEYS == 'VEDICI-E'}" />
					<mx:Button height="28"
							   width="28"
							   toolTip="Supprimer l'import"
							   icon="@Embed('../../base/swf/CTI/images/24/user-trash.png')"
							   labelPlacement="right"
							   click="deleteImport()"
							   enabled="{imports_list_GUI.selectedIndex >= 0}" />
					<mx:Spacer />
					<mx:Button height="28"
							   width="28"
							   toolTip="Aide"
							   icon="@Embed('../../base/swf/CTI/images/24/help.png')"
							   labelPlacement="right"
							   click="application.displayHelp()"
							   visible="{hasHelp}" />
					<mx:Button height="28"
							   width="28"
							   toolTip="A propos"
							   icon="@Embed('../../base/swf/CTI/images/24/information.png')"
							   labelPlacement="right"
							   click="application.showApropos_view()" />
				</mx:HBox>
			</mx:Canvas>
			<mx:Canvas width="100%"
					   height="100%"
					   visible="{tabNavigator_GUI.selectedIndex == 1}">
				<mx:HBox width="100%">
					<mx:Button height="28"
							   label="Lancer l'import"
							   icon="@Embed('../../base/swf/CTI/images/24/run.png')"
							   labelPlacement="right"
							   click="askImportFiles()"
							   enabled="{importEnabled &amp;&amp; importTexte_GUI.text != '' &amp;&amp; !importStarted &amp;&amp; http_config_ok == true}" />
					<mx:Spacer />
					<mx:Button height="28"
							   width="28"
							   toolTip="Aide"
							   icon="@Embed('../../base/swf/CTI/images/24/help.png')"
							   labelPlacement="right"
							   click="application.displayHelp()"
							   visible="{hasHelp}" />
					<mx:Button height="28"
							   width="28"
							   toolTip="A propos"
							   icon="@Embed('../../base/swf/CTI/images/24/information.png')"
							   labelPlacement="right"
							   click="application.showApropos_view()" />
				</mx:HBox>
			</mx:Canvas>
			<mx:Canvas width="100%"
					   height="100%"
					   visible="{tabNavigator_GUI.selectedIndex == 2}">
				<mx:HBox width="100%">
					<mx:Button height="28"
							   label="Lancer l'import"
							   icon="@Embed('../../base/swf/CTI/images/24/run.png')"
							   labelPlacement="right"
							   click="importEncours()" />
					<mx:Spacer />
					<mx:Button height="28"
							   width="28"
							   toolTip="Aide"
							   icon="@Embed('../../base/swf/CTI/images/24/help.png')"
							   labelPlacement="right"
							   click="application.displayHelp()"
							   visible="{hasHelp}" />
					<mx:Button height="28"
							   width="28"
							   toolTip="A propos"
							   icon="@Embed('../../base/swf/CTI/images/24/information.png')"
							   labelPlacement="right"
							   click="application.showApropos_view()" />
				</mx:HBox>
			</mx:Canvas>
			<mx:Canvas width="100%"
					   height="100%"
					   visible="{tabNavigator_GUI.selectedIndex == 3}">
				<mx:HBox width="100%">
					<mx:Button height="28"
							   width="28"
							   toolTip="Réafficher"
							   icon="@Embed('../../base/swf/CTI/images/24/view-refresh.png')"
							   labelPlacement="right"
							   click="getData()" />
					<mx:Button height="28"
							   label="Afficher le fichier log"
							   toolTip="Afficher le fichier log"
							   icon="@Embed('../../base/swf/CTI/images/24/document-open.png')"
							   labelPlacement="right"
							   click="displayLog()" />
					<mx:Spacer />
					<mx:Button height="28"
							   width="28"
							   toolTip="Aide"
							   icon="@Embed('../../base/swf/CTI/images/24/help.png')"
							   labelPlacement="right"
							   click="application.displayHelp()"
							   visible="{hasHelp}" />
					<mx:Button height="28"
							   width="28"
							   toolTip="A propos"
							   icon="@Embed('../../base/swf/CTI/images/24/information.png')"
							   labelPlacement="right"
							   click="application.showApropos_view()" />
				</mx:HBox>
			</mx:Canvas>


		</mx:Canvas>

		<mx:TabNavigator id="tabNavigator_GUI"
						 width="100%"
						 height="100%"
						 change="on_tabNavigator_change()">

			<mx:VBox width="100%"
					 height="100%"
					 label="Etat des imports"
					 backgroundColor="0xF0F0F0">

				<mx:DataGrid id="imports_list_GUI"
							 rowHeight="20"
							 headerHeight="40"
							 rowCount="{imports_list.length + 1}"
							 height="100%"
							 width="100%"
							 wordWrap="true"
							 dataProvider="{imports_list}"
							 fontFamily="tahoma"
							 editable="false"
							 itemClick="selectImportLine();">
					<mx:columns>
						<mx:DataGridColumn dataField="oid"
										   headerText="N°"
										   width="40"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="texte"
										   headerText="Texte"
										   width="200"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="date_import"
										   headerText="Date import"
										   width="90"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="etat_texte"
										   headerText="Etat"
										   width="200"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="finess"
										   headerText="Finess"
										   width="80"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="date_debut"
										   headerText="Date début"
										   width="90"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="date_fin"
										   headerText="Date fin"
										   width="90"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="nb_rss"
										   headerText="RSS"
										   width="60"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="nb_rum"
										   headerText="RUM"
										   width="60"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="nb_rsf"
										   headerText="RSF"
										   width="60"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="nb_erreurs"
										   headerText="Erreurs"
										   width="60"
										   resizable="true"
										   editable="false" />
						<mx:DataGridColumn dataField="nb_avertissements"
										   headerText="Avertissements"
										   width="60"
										   resizable="true"
										   editable="false" />
					</mx:columns>
				</mx:DataGrid>

			</mx:VBox>

			<mx:VBox width="100%"
					 height="100%"
					 label="Nouvel import"
					 backgroundColor="0xF0F0F0">



						<mx:Panel width="100%"
								  height="100%"
								  title="Fichiers locaux à importer" backgroundColor="0xF0F0F0" borderStyle="none">
							<mx:Canvas width="100%" visible="{http_config_ok == true}" includeInLayout="{http_config_ok == true}" >
								<mx:Button height="20"
										   label="Rechercher"
										   color="0x0B333C"
										   toolTip="Choisir le fichier"
										   icon="@Embed('../../base/swf/CTI/images/16/folder.png')"
										   labelPlacement="right"
										   click="new_import_upload()"
										   visible="{! importStarted &amp;&amp; application.environmentProperties.properties.LOCALKEYS != 'VITALIA'}" />
								<mx:HBox visible="{application.environmentProperties.properties.LOCALKEYS == 'VITALIA'}">
									<mx:Button height="20"
											   label="1. Préparer le fichier"
											   toolTip="Préparer le fichier"
											   icon="@Embed('../../base/swf/CTI/images/16/system-upgrade.png')"
											   labelPlacement="right"
											   click="vitalia_prepar()"
											   visible="{! importStarted}" />
									<mx:Button height="20"
											   label="2. Choisir le fichier préparé"
											   toolTip="Choisir le fichier"
											   icon="@Embed('../../base/swf/CTI/images/16/folder.png')"
											   labelPlacement="right"
											   click="new_import_upload()"
											   visible="{! importStarted}" />
									<mx:Button height="20"
											   label="3. Lancer l'import"
											   icon="@Embed('../../base/swf/CTI/images/16/run.png')"
											   labelPlacement="right"
											   click="askImportFiles()"
											   visible="{! importStarted}"
											   enabled="{importEnabled &amp;&amp; importTexte_GUI.text != '' &amp;&amp; !importStarted}" />
								</mx:HBox>
							</mx:Canvas>
							<mx:Canvas width="100%" visible="{http_config_ok != true}" includeInLayout="{http_config_ok != true}">
								<mx:Button height="24" width="100%"
										   id="config_http_button"
										   label="La configuration du serveur HTTP doit être modifiée. Cliquer sur ce bouton."
										   icon="@Embed('../../base/swf/CTI/images/configurer24.png')"
										   labelPlacement="right"
										   click="exec_config_http()"
										   visible="{! importStarted &amp;&amp; application.environmentProperties.properties.LOCALKEYS != 'VITALIA'}" />
							</mx:Canvas>
							<mx:HBox width="100%">
								<mx:Label width="175"
										  text="Description" />
								<mx:TextInput id="importTexte_GUI"
											  width="100%"
											  fontWeight="bold"
											  change="{checkFiles()}" />
							</mx:HBox>
							<mx:Canvas width="100%" height="100%">
								<mx:VBox width="100%" height="100%">
									<mx:DataGrid id="new_imports_files_GUI"
										    rowCount="8"
											rowHeight="20"
											headerHeight="24"
											width="100%"
											wordWrap="true"
											dataProvider="{new_imports_files_provider}"
											editable="false">
										<mx:columns>
											
											<mx:DataGridColumn 
												   headerText=""
												   minWidth="24"
												   width="24"
												   resizable="false"
												   editable="false"
												   sortable="false" >	
												<mx:itemRenderer>
													<mx:Component >
														<mx:Button height="20"
															   width="20"
															   toolTip="Effacer le fichier"
															   icon="@Embed('../../base/swf/CTI/images/16/window-close.png')"
															   labelPlacement="right"
															   click="outerDocument.new_import_removeFile(data.@fullname)"
															   visible="{data.@name != ''}" 
															   />
													</mx:Component>
												</mx:itemRenderer>
											</mx:DataGridColumn>

											<mx:DataGridColumn dataField="@typeTexte"
															   headerText="Type"
															   minWidth="220"
															   resizable="false"
															   editable="false"
															   sortable="false" />
											<mx:DataGridColumn dataField="@mois"
															   headerText="Mois"
															   minWidth="100"
															   resizable="false"
															   editable="false"
															   sortable="false" />
											<mx:DataGridColumn dataField="@name"
															   headerText="Fichier"
															   minWidth="100"
															   resizable="true"
															   editable="false"
															   sortable="false" />
											<mx:DataGridColumn dataField="@date"
															   headerText="Date"
															   minWidth="130"
															   resizable="false"
															   editable="false"
															   sortable="false" />
											<mx:DataGridColumn dataField="@size"
															   headerText="Taille"
															   minWidth="100"
															   resizable="false"
															   editable="false"
															   sortable="false" />
										</mx:columns>
									</mx:DataGrid>
									<mx:HBox width="100%">
										<mx:TextArea id="new_imports_files_statusText_GUI" 
											visible="{new_imports_files_statusCode != 'OK'}"
											includeInLayout="{new_imports_files_statusCode != 'OK'}"
											width="100%" height="40" htmlText="{new_imports_files_statusText}" editable="false" 
											textAlign="center" fontSize="14" fontWeight="bold" />
									</mx:HBox>
								</mx:VBox>
								
								
							</mx:Canvas>
						</mx:Panel>

						<mx:Panel width="100%"
								  visible="{importStarted}" 
								  includeInLayout="{importStarted}" 
								  title="ETAT DU TRAITEMENT"
								  borderStyle="none">
							<mx:HBox width="100%">
								<mx:Label width="150"
										  text="Avancement"
										  fontWeight="bold" />
								<mx:ProgressBar id="status_bar_GUI"
												labelPlacement="center"
												themeColor="0x00CCCC"
												minimum="0"
												maximum="100"
												label=""
												direction="right"
												mode="manual"
												width="100%" />
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label width="150"
										  text="Envoi fichiers" />
								<mx:Label width="100%"
										  text="{sendFilesStatus}"
										  fontWeight="bold" />
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label width="150"
										  text="Validation" />
								<mx:Label width="100%"
										  text="{validationStatus}"
										  fontWeight="bold" />
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label width="150"
										  text="Contrôles" />
								<mx:Label width="100%"
										  text="{controleStatus}"
										  fontWeight="bold" />
							</mx:HBox>
						</mx:Panel>


			</mx:VBox>

			<mx:VBox width="100%"
					 height="100%"
					 id="encours_pmsi_box_GUI"
					 label="Dossier non expédiés"
					 enabled="false"
					 backgroundColor="0xF0F0F0">


				<mx:Panel width="100%"
						  height="100%"
						  title="Import des dossiers non expédiés"
							borderStyle="none">
					<mx:Spacer height="3" />
					<mx:Label width="100%"
							  id="encours_pmsi_last_import_GUI"
							  text="" />
					<mx:Spacer height="3" />
					<mx:Button height="28"
							   width="100%"
							   label="Lancer l'import des dossiers PMSI non expédiés "
							   icon="@Embed('../../base/swf/CTI/images/24/run.png')"
							   labelPlacement="right"
							   click="importEncours()" />
					<mx:Spacer height="3" />
					<mx:TextArea id="encours_pmsi_description_GUI"
								 width="100%"
								 height="100%"
								 htmlText=""
								 editable="false"
								 selectable="false"
								 borderStyle="none" />

				</mx:Panel>



			</mx:VBox>


			<mx:VBox width="100%"
					 height="100%"
					 label="Historique des travaux"
					 backgroundColor="0xF0F0F0">

				<mx:DataGrid id="historique_UI"
							 rowCount="{jobsHistory_length + 1}"
							 height="100%"
							 width="100%"
							 rowHeight="24"
							 wordWrap="false"
							 dataProvider="{jobsHistory_list}">
					<mx:columns>
						<mx:DataGridColumn dataField="name"
										   headerText="Nom"
										   width="200" />
						<mx:DataGridColumn dataField="title"
										   headerText="Titre"
										   width="250"
										   editable="false" />
						<mx:DataGridColumn dataField="start"
										   headerText="Démarré"
										   width="120"
										   editable="false" />
						<mx:DataGridColumn dataField="end"
										   headerText="Terminé"
										   width="120"
										   editable="false" />
						<mx:DataGridColumn dataField="endStatus"
										   headerText="Statut"
										   width="60"
										   editable="false" />
						<mx:DataGridColumn dataField="duration"
										   headerText="Durée"
										   width="60"
										   editable="false" />
					</mx:columns>
				</mx:DataGrid>

			</mx:VBox>

		</mx:TabNavigator>

	</mx:VBox>


</mx:Application>
