<?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 mx.collections.ArrayCollection;
			import mx.controls.Alert;
			import mx.collections.XMLListCollection;
			import mx.events.CloseEvent
			import mx.collections.Sort;
            import mx.collections.SortField;
			
			import CTI.technique.CTI_Utilitaires;
			import CTI.technique.CTI_ExcelUtilitaires;
			import CTI.print.CTI_Print;
			import CTI.technique.CTI_ExcelUtilitaires;
			import CTI.technique.CTI_PDFUtilitaires;
			import CTI.technique.CTI_ArrayCollection;
			
			public var buildComplete:Boolean = false;
			
			[Embed(source="../../base/swf/CTI/images/24/print.png")]
			public var button_print24:Class;
			
			[Embed(source="../../base/swf/CTI/images/32/help.png")]
            public static var question_class:Class;
			
			// Variables CTI
			public static var softCode:String = "iCTI_eco";
			
			[Bindable]
			public var title:String = "Tables Comptabilité";
			public var titlePrint:String = "Tables Comptabilité";
			
			[Bindable]
			public var hasHelp:Boolean = false;
			
			private var viewName:String;
			private var tableName:String;
			
			[Bindable]
			private var tableCode:String;
			
			[Bindable]
			private var list_collection:XMLListCollection = new XMLListCollection();
			
			public var list_collection_search_mots:Array = new Array();
			
			public var a_regrouper_search_mots:Array = new Array();
			
			[Bindable]
			private var recordUpdated:Boolean = false;
			
			[Bindable]
			private var currendRecordItem:XML = null;
			
			private var tableList:Object = new Object();
			
			[Bindable]
			private var column_visible_code:Boolean = true;
			
			[Bindable]
			private var column_visible_texte_court:Boolean = true;
			
			[Bindable]
			private var column_visible_complement:Boolean = true;
			
			[Bindable]
			private var column_visible_code_original:Boolean = true;
			
			[Bindable]
			private var column_visible_nbref:Boolean = true;
			
			[Bindable]
			private var column_visible_rfoids:Boolean = false;
			
			[Bindable]
			private var new_import_fileToUpload:FileReference = new FileReference();
			
			[Bindable]
			private var TYA_defaut_selon:ArrayCollection = new ArrayCollection(
				[	{label:"", data:""},
					{label:"Compte", data:"CPT"},
					{label:"Catégorie", data:"CAT"}
				]
			);
			
			[Bindable]
			private var TYM_inverser_signe:ArrayCollection = new ArrayCollection(
				[	{label:"Non", data:0},
					{label:"Oui", data:1}
				]
			);
            
            [Bindable]
			private var TYM_sens_force:ArrayCollection = new ArrayCollection(
				[	{label:"Aucun forcage", data:""},
                    {label:"Entrée", data:"E"},
					{label:"Sortie", data:"S"}
				]
			);
			
			private var ART_ARRAY_RA1_XML:XML;
			private var ART_ARRAY_RA9_XML:XML;
			
			private var FOU_ARRAY_RF1_XML:XML;
			private var FOU_ARRAY_RF9_XML:XML;
			
			// FONCTIONS
			public function creationComplete():void {
				if (application.currentHelpFile != "") {
					hasHelp = true;
				}
				if (application.name == "CTI") {
				}
				if (application.name == "CTI_1") {
					GUI_titleBar.height = 0
				}
				
				viewName = application.currentViewName;
				tableCode = application.currentSwfData;
                
                tableList["SIT"] = ["t_sites","Gestion sites","Sites"];
				
				tableList["ART"] = ["t_articles","Gestion articles","Articles"];
				tableList["TYA"] = ["t_types_articles","Gestion types d'articles","Types d'articles"];
				tableList["TAR"] = ["t_type_article_cti_rule","Gestion règles types articles CTI","Règles types articles CTI"];
				tableList["FAA"] = ["t_familles_articles","Gestion familles d'articles","Familles d'articles"];
				tableList["SFA"] = ["t_sous_familles_articles","Gestion sous-familles d'articles","Sous-familles d'articles"];
				tableList["CAA"] = ["t_categories_articles","Gestion catégories d'articles","Catégories d'articles"];
				tableList["SCA"] = ["t_sous_categories_articles","Gestion sous-catégories d'articles","Sous-catégories d'articles"];
				tableList["UNI"] = ["t_unites","Gestion unités","Unités"];
				
				tableList["FOU"] = ["t_fournisseurs","Gestion fournisseurs","Fournisseurs"];
				tableList["TYF"] = ["t_types_fournisseurs","Gestion types de fournisseurs","Types de fournisseurs"];
				
				tableList["GES"] = ["t_gestionnaires","Gestion gestionnaires","Gestionnaires"];
				tableList["LIE"] = ["t_lieux","Gestion lieux","Lieux"];
				tableList["UFO"] = ["t_unites_fonctionnelles","Gestion unites_fonctionnelles","Unites fonctionnelles"];
				tableList["TYM"] = ["t_types_mouvements","Gestion types de mouvements","Types de mouvements"];
				
				tableList["RIN"] = ["t_reference_input","Import Référentiel","Référentiel"];
				
				tableList["RA1"] = ["t_article_reference_cacic","Gestion Référentiel article CACIC","Articles CACIC"];
				tableList["RF1"] = ["t_fournisseur_reference_cacic","Gestion Référentiel fournisseur CACIC","Fournisseurs CACIC"];
				
				tableList["RA9"] = ["t_article_reference_cti","Gestion Référentiel article CTI","Articles CTI"];
				tableList["RF9"] = ["t_fournisseur_reference_cti","Gestion Référentiel fournisseur CTI","Fournisseurs CTI"];
				
				tableList["DIV"] = ["t_divers","Eléments divers","Divers"];
				
				if (tableCode == "RIN") {
					column_visible_texte_court = false;
					column_visible_code_original = false;
					column_visible_nbref = false;
				}
                if (tableCode == "SIT") {
					column_visible_nbref = false;
                    column_visible_complement = false;
				}
				if (tableCode == "UNI") {
					column_visible_nbref = false;
				}
				if (tableCode == "GES") {
					column_visible_nbref = false;
				}
				if (tableCode == "LIE") {
					column_visible_nbref = false;
				}
				if (tableCode == "UFO") {
					column_visible_nbref = false;
				}
				if (tableCode == "TYM") {
					column_visible_nbref = false;
				}
				
				if (tableCode == "RA1") {
					column_visible_texte_court = false;
					column_visible_code_original = false;
				}
				if (tableCode == "RA9") {
					column_visible_texte_court = false;
					column_visible_code_original = false;
					column_visible_complement = false;
					column_visible_rfoids = true
				}
				if (tableCode == "RF1") {
					column_visible_texte_court = false;
					column_visible_code_original = false;
					column_visible_complement = false;
				}
				if (tableCode == "RF9") {
					column_visible_texte_court = false;
					column_visible_code_original = false;
					column_visible_complement = false;
					column_visible_rfoids = true
				}
				
				if (tableCode == "DIV") {
					column_visible_texte_court = false;
					column_visible_code_original = false;
					column_visible_nbref = false;
				}
				
				if (tableCode == "TAR") {
					column_visible_code = false;
					column_visible_texte_court = false;
					column_visible_complement = false;
					column_visible_code_original = false;
					column_visible_nbref = false;
				}
			

				tableName = tableList[tableCode][0];
				title = tableList[tableCode][1];
				titlePrint = tableList[tableCode][2];
				
				getData(true);
			}
			
			public function eventDispatcher(eventCode:String):Boolean {
				return true;
			}
			
			public function getData(firstCall:Boolean = false, updatedOids:String = ""):void {
				// Tri en cours
				var currentSort:Sort = null
				if (list_collection != null) {
					currentSort = list_collection.sort
                } 
			
				// Demande au serveur
				var urlVariables:URLVariables = new URLVariables();
				urlVariables.tableName = tableName;
				if (firstCall) {
					urlVariables.firstCall = "1";
				}
				else {
					urlVariables.firstCall = "0"
				}
				urlVariables.updatedOids = updatedOids
				urlVariables.softCode = softCode;
				CTI_Utilitaires.startRequestHTTP("modules/eco/php/httpService_tablesManager_getData.php",urlVariables,exec,true,this.parentApplication);
				
				function exec(resultatService:XML):void {
					if (list_collection != null) {
						list_collection.filterFunction = null;
						list_collection.refresh();
					}
					
					if (updatedOids == "") {
						list_collection = new XMLListCollection(resultatService.RECORD);
					
						if (currentSort != null) {
							list_collection.sort = currentSort
						}
					}
					else {
						for each (var updateItem:XML in resultatService.RECORD) {
							for each (var item:XML in list_collection) {
								if (item.@oid.toString() == updateItem.@oid.toString()) {
									for each (var attributeNode:XML in updateItem.@*) {
										var attributeName:String = attributeNode.name().toString()
										if (attributeName != "oid") {
											var attributeValue:String = attributeNode.toString()
											item['@'+attributeName] = attributeValue
										}
									}
									break;
								}
							}
						}
					
					}
					
					if (firstCall) {

						if (tableCode == "ART") {
							ART_ARRAY_RA1_XML = new XML(resultatService.ARRAY_RA1[0]);
							ART_ARRAY_RA9_XML = new XML(resultatService.ARRAY_RA9[0]);
						}
						
						if (tableCode == "FOU") {
							FOU_ARRAY_RF1_XML = new XML(resultatService.ARRAY_RF1[0]);
							FOU_ARRAY_RF9_XML = new XML(resultatService.ARRAY_RF9[0]);
							FOU_fusionner_vers_fournisseur_id_GUI.dataProvider = new CTI_ArrayCollection();
							FOU_fusionner_vers_fournisseur_id_GUI.dataProvider.loadXMLList(resultatService.COMBO_FOU.RECORD);
							
						}
						
						if (tableCode == "RA9") {
							RXX_regroupes_GUI.dataProvider = new XMLListCollection(resultatService.LIST_ART.RECORD)
							RXX_a_regrouper_GUI.dataProvider = new XMLListCollection(resultatService.LIST_ART.RECORD)
							
							RXX_a_regrouper_searchChange()
						}
						if (tableCode == "RF9") {
							RXX_regroupes_GUI.dataProvider = new XMLListCollection(resultatService.LIST_FOU.RECORD)
							RXX_a_regrouper_GUI.dataProvider = new XMLListCollection(resultatService.LIST_FOU.RECORD)
							
							RXX_a_regrouper_searchChange()
						}
						
						if (tableCode == "TAR") {
							TAR_type_article_cti_id_GUI.dataProvider = new CTI_ArrayCollection();
							TAR_type_article_cti_id_GUI.dataProvider.loadXMLList(resultatService.COMBO_TAA.RECORD);
						}
					}
					
					
					searchChange();
					setTimeout(setBuildComplete, 1000);
						

					
					
				}
			}
			
			private function setBuildComplete():void {
				buildComplete = true;
			}
					
			private function resize():void {
			}
			
			private function searchChange():void {

				list_collection_search_mots = getMots(textSearch_GUI.text)

				if (list_collection.filterFunction == null) {
					list_collection.filterFunction = filterFunction;
				}
				list_collection.refresh();
			}
			
			public function getMots(fromText:String):Array {
				var toMotsArray:Array = new Array()
				
				if (fromText != "") {
					var fromUpperText:String = toUpperCaseWithoutAccent(fromText)
					var mot:String = "";
					
					for (var i:Number = 0; i < fromUpperText.length; i++) { 
						var char:String = fromUpperText.substr(i,1)
						if (char != ' ') {
							mot = mot + char
						}
						else {
							if (mot != "") {
								toMotsArray.push(mot)
								mot = ""
							}
						}
					} 
					if (mot != "") {
						toMotsArray.push(mot)
						mot = ""
					}
				}
				return toMotsArray;
			}
			
			public static function toUpperCaseWithoutAccent(string:String):String {
				
				return noAccent(string).toUpperCase()
				
			}
			
			public static function noAccent(source:String):String {
				source = source.replace(/[àáâãäå]/g, "a");
				source = source.replace(/[ÀÁÂÃÄÅ]/g, "A");
				source = source.replace(/[èéêë]/gi, "e");
				source = source.replace(/[ËÉÊÈ]/g, "E");
				source = source.replace(/[ìíîï]/g, "i");
				source = source.replace(/[ÌÍÎÏ]/g, "I");
				source = source.replace(/[ðòóôõöø]/g, "o");
				source = source.replace(/[ÐÒÓÔÕÖØ]/g, "O");
				source = source.replace(/[ùúûü]/g, "u");
				source = source.replace(/[ÙÚÛÜ]/g, "U");
				source = source.replace(/[ýýÿ]/g, "y");
				source = source.replace(/[ÝÝŸ]/g, "Y");
				source = source.replace(/[ç]/g, "c");
				source = source.replace(/[Ç]/g, "C");
				source = source.replace(/[ñ]/g, "n");
				source = source.replace(/[Ñ]/g, "N");
				source = source.replace(/[š]/g, "s");
				source = source.replace(/[Š]/g, "S");
				source = source.replace(/[ž]/g, "z");
				source = source.replace(/[Ž]/g, "Z");
				source = source.replace(/[æ]/g, "ae");
				source = source.replace(/[Æ]/g, "AE");
				source = source.replace(/[œ]/g, "oe");
				source = source.replace(/[Œ]/g, "OE");
				
				source = source.replace(/Ã©Ã¨/gi, "e");

				return source;
			}

			public function filterFunction(item:XML):Boolean { 
				var result:Boolean = true; 

				if (Number(item.@oid) >= 0) {
					result = filterListItem(item, list_collection_search_mots)
					
					if (result == true) {
						if (refSearch_GUI.selected == true) {
							if (item.hasOwnProperty("@nbref")) {
								if (Number(item.@nbref.toString()) <= 0) {
									if (item.hasOwnProperty("@nbref2")) {
										if (Number(item.@nbref2.toString()) <= 0) {
											result = false;
										}
									}
									else {
										result = false;
									}	
								}
							}

						}
					}
				}
				return result; 
			} 
			
			public function filterListItem(item:XML, mots:Array):Boolean { 
				var result:Boolean = true; 

				if (mots.length > 0) {
					result = false
					
					var fullText:String = ""
					for each (var attributeNode:XML in item.@*) {
						var attributeName:String = attributeNode.name().toString()
						var attributeValue:String = attributeNode.toString()
						if (attributeName != "oid" && attributeValue.toString() != "") {
							fullText = fullText + ' ' + attributeValue.toUpperCase()
						}
					}

					var resultMot:Boolean = true
					for each (var mot:String in mots) {
						if (fullText.indexOf(mot) < 0) {
							resultMot = false
							break;
						}
					}
					if (resultMot) {
						result = true
					}
					
				}

			
				return result; 
			} 
			
			public function getRecord():void {
				if (recordUpdated == true) {
					return;
				}
				if (list_GUI.selectedIndex < 0) {
					return;
				}
				currendRecordItem = list_GUI.selectedItem as XML;
				showDetail();
			}
			
			public function addRecord():void {
			
				if (currendRecordItem == null) {
					if (tableCode == "TAR") {
						currendRecordItem = new XML(<RECORD />)
						currendRecordItem.@oid = "-1"
						currendRecordItem.@texte = ""
						currendRecordItem.@priorite = "5000"
						currendRecordItem.@type_article_cti = "0"
						currendRecordItem.@liste_compte = ""
						currendRecordItem.@liste_type_article = ""
						currendRecordItem.@liste_famille = ""
						currendRecordItem.@liste_sous_famille = ""
						currendRecordItem.@liste_categorie = ""
						currendRecordItem.@liste_sous_categorie = ""
						currendRecordItem.@liste_article = ""
						showDetail()
					}
				}
			}
			
			public function showDetail():void {
				var i:Number;
				var item:XML;
				if (currendRecordItem == null) {
					return;
				}
				oid_GUI.text = currendRecordItem.@oid.toString();
				nbref_GUI.text = currendRecordItem.@nbref.toString();
				code_GUI.text = currendRecordItem.@code.toString();
				texte_GUI.text = currendRecordItem.@texte.toString();
				texte_court_GUI.text = currendRecordItem.@texte_court.toString();
				complement_GUI.text = currendRecordItem.@complement.toString();
				code_original_GUI.text = currendRecordItem.@code_original.toString();
				
				if (tableCode == 'TYA') {
					TYA_defaut_selon_GUI.selectedIndex = 0;
                    if (currendRecordItem.@defaut_selon.toString() == 'CPT') {
                        TYA_defaut_selon_GUI.selectedIndex = 1
                    }
                    if (currendRecordItem.@defaut_selon.toString() == 'CAT') {
                        TYA_defaut_selon_GUI.selectedIndex = 2
                    }
					TYA_defaut_selon_codes_GUI.text = currendRecordItem.@defaut_selon_codes.toString()
				}
				if (tableCode == 'TYM') {
					TYM_particularite_inverser_signe_GUI.selectedIndex = (currendRecordItem.@particularite_inverser_signe.toString() == '1') ? 1 : 0;
                    TYM_sens_force_GUI.selectedIndex = 0
                    if (currendRecordItem.@sens_force.toString() == 'E') {
                        TYM_sens_force_GUI.selectedIndex = 1
                    }
                    if (currendRecordItem.@sens_force.toString() == 'S') {
                        TYM_sens_force_GUI.selectedIndex = 2
                    }
				}
				if (tableCode == 'ART') {
					if (currendRecordItem.@gere_en_stock.toString() == '0') {
						ART_gere_en_stock_GUI.selected = false
					}
					else {
						ART_gere_en_stock_GUI.selected = true
					}
					
					var ART_cacic_XML:XMLList = ART_ARRAY_RA1_XML.RECORD.(@oid == currendRecordItem.@cacic_id.toString());
					if (ART_cacic_XML.length() > 0) {
						ART_cacic_code_GUI.text = ART_cacic_XML[0].@code;
						ART_cacic_texte_GUI.text = ART_cacic_XML[0].@texte;
						ART_cacic_id_GUI.text = ART_cacic_XML[0].@oid;
					}
					else {
						ART_cacic_code_GUI.text = "";
						ART_cacic_texte_GUI.text = "?";
						ART_cacic_id_GUI.text = "0";
					}
					
					var ART_rfcti_XML:XMLList = ART_ARRAY_RA9_XML.RECORD.(@oid == currendRecordItem.@rfcti_id.toString());
					if (ART_rfcti_XML.length() > 0) {
						ART_rfcti_code_GUI.text = ART_rfcti_XML[0].@code;
						ART_rfcti_texte_GUI.text = ART_rfcti_XML[0].@texte;
						ART_rfcti_id_GUI.text = ART_rfcti_XML[0].@oid;
					}
					else {
						ART_rfcti_code_GUI.text = "";
						ART_rfcti_texte_GUI.text = "?";
						ART_rfcti_id_GUI.text = "0";
					}	
					ART_rfcti_id_GUI.text = currendRecordItem.@rfcti_id.toString()
				}
				
				if (tableCode == 'FOU') {
				
					setSelectedIndex(FOU_fusionner_vers_fournisseur_id_GUI, currendRecordItem.@fusionner_vers_fournisseur_id.toString(), 'oid');
					
					var FOU_cacic_XML:XMLList = FOU_ARRAY_RF1_XML.RECORD.(@oid == currendRecordItem.@cacic_id.toString());
					if (FOU_cacic_XML.length() > 0) {
						FOU_cacic_code_GUI.text = FOU_cacic_XML[0].@code;
						FOU_cacic_texte_GUI.text = FOU_cacic_XML[0].@texte;
						FOU_cacic_id_GUI.text = FOU_cacic_XML[0].@oid;
					}
					else {
						FOU_cacic_code_GUI.text = "";
						FOU_cacic_texte_GUI.text = "?";
						FOU_cacic_id_GUI.text = "0";
					}	
					
					var FOU_rfcti_XML:XMLList = FOU_ARRAY_RF9_XML.RECORD.(@oid == currendRecordItem.@rfcti_id.toString());
					if (FOU_rfcti_XML.length() > 0) {
						FOU_rfcti_code_GUI.text = FOU_rfcti_XML[0].@code;
						FOU_rfcti_texte_GUI.text = FOU_rfcti_XML[0].@texte;
						FOU_rfcti_id_GUI.text = FOU_rfcti_XML[0].@oid;
					}
					else {
						FOU_rfcti_code_GUI.text = "";
						FOU_rfcti_texte_GUI.text = "?";
						FOU_rfcti_id_GUI.text = "0";
					}	
				}
				
				if (tableCode == 'RA9' || tableCode == 'RF9') {
					RXX_regroupes_oids_GUI.text = currendRecordItem.@rfoids.toString();

					if (RXX_a_regrouper_GUI.dataProvider != null) {
						RXX_a_regrouper_GUI.dataProvider.filterFunction = null
						RXX_a_regrouper_GUI.dataProvider.refresh()
					}
					
					RXX_a_regrouper_textSearch_GUI.text = texte_GUI.text.substr(0,5);
					if (RXX_regroupes_GUI.dataProvider.filterFunction == null) {
						RXX_regroupes_GUI.dataProvider.filterFunction = RXX_regroupes_filterFunction
					}
					RXX_regroupes_GUI.dataProvider.refresh();
					RXX_a_regrouper_searchChange()
				}
				
				if (tableCode == "DIV") {
					valeur_GUI.text = currendRecordItem.@valeur.toString();
                    show_info_module_GUI.selected = (currendRecordItem.show_info_module.toString() == "1");
                }
				
				if (tableCode == 'TAR') {
					TAR_priorite_GUI.text = currendRecordItem.@priorite.toString();
					setSelectedIndex(TAR_type_article_cti_id_GUI, currendRecordItem.@type_article_cti_id.toString(), 'oid');
					
					TAR_liste_type_article_GUI.text = currendRecordItem.@liste_type_article.toString();
					TAR_liste_compte_GUI.text = currendRecordItem.@liste_compte.toString();
					TAR_liste_famille_GUI.text = currendRecordItem.@liste_famille.toString();
					TAR_liste_sous_famille_GUI.text = currendRecordItem.@liste_sous_famille.toString();
					TAR_liste_categorie_GUI.text = currendRecordItem.@liste_categorie.toString();
					TAR_liste_sous_categorie_GUI.text = currendRecordItem.@liste_sous_categorie.toString();
					TAR_liste_article_GUI.text = currendRecordItem.@liste_article.toString();
					
					TAR_Qliste_type_article_GUI.selected = TAR_liste_type_article_GUI.text != "" ? true : false;
					TAR_Qliste_compte_GUI.selected = TAR_liste_compte_GUI.text != "" ? true : false;
					TAR_Qliste_famille_GUI.selected = TAR_liste_famille_GUI.text != "" ? true : false;
					TAR_Qliste_sous_famille_GUI.selected = TAR_liste_sous_famille_GUI.text != "" ? true : false;
					TAR_Qliste_categorie_GUI.selected = TAR_liste_categorie_GUI.text != "" ? true : false;
					TAR_Qliste_sous_categorie_GUI.selected = TAR_liste_sous_categorie_GUI.text != "" ? true : false;
					TAR_Qliste_article_GUI.selected = TAR_liste_article_GUI.text != "" ? true : false;
					
				}
				
				
				recordUpdated = false;
				detailBox_GUI.visible = true;
				detailBox_GUI.includeInLayout = true;
			}
			
			private function askCancel():void {
				if (recordUpdated == false) {
					hideRecord();
					return;
				}
				Alert.yesLabel = "OUI";
                Alert.noLabel = "NON";
	            var alert:Alert = Alert.show("Les données ont été changées, désirez vous les annuler ?", title, 3, this, alertClickHandler, question_class);
				
	            function alertClickHandler(event:CloseEvent):void {
	                if (event.detail==Alert.YES) {
						hideRecord();
					}
	            }
			}
			
			private function hideRecord():void {
				detailBox_GUI.visible = false;
				detailBox_GUI.includeInLayout = false;
				currendRecordItem = null;
				recordUpdated = false;
			}

			private function askDelete():void {
				Alert.yesLabel = "OUI";
                Alert.noLabel = "NON";
	            var alert:Alert = Alert.show("Désirez vous vraiment supprimer " + texte_GUI.text + " ?", title, 3, this, alertClickHandler, question_class);
				
				
	            function alertClickHandler(event:CloseEvent):void {
	                if (event.detail==Alert.YES) {
						deleteRecord()
					}
	            }
			}
			
			public function deleteRecord():void {
				updateRecord("delete");
			}
			
			public function copyRecord():void {
				updateRecord("copy");
			}
			
			public function saveRecord():void {
				updateRecord("save");
			}
			
			public function updateRecord(action:String):void {
				var urlVariables:URLVariables = new URLVariables()
				urlVariables.tableName = tableName;
				urlVariables.action = action;
				urlVariables.softCode = softCode;
				var recordNode:XML = new XML(<RECORD />);
				recordNode.@oid = oid_GUI.text;
				recordNode.@code = code_GUI.text;
				recordNode.@texte = texte_GUI.text;
				recordNode.@texte_court = texte_court_GUI.text;
				recordNode.@code_original = code_original_GUI.text;
				recordNode.@show_info_module = (show_info_module_GUI.selected ? "1" : "0");
				recordNode.@valeur = valeur_GUI.text;
				recordNode.@description = complement_GUI.text;
				
				if (tableCode == 'ART') {
					if (ART_gere_en_stock_GUI.selected == true) {
						recordNode.@gere_en_stock = "1";
					}
					else {
						recordNode.@gere_en_stock = "0";
					}
					recordNode.@cacic_id = ART_cacic_id_GUI.text;
					recordNode.@rfcti_id = ART_rfcti_id_GUI.text;
				}
				if (tableCode == 'FOU') {
					recordNode.@fusionner_vers_fournisseur_id = FOU_fusionner_vers_fournisseur_id_GUI.selectedItem.oid;
					recordNode.@cacic_id = FOU_cacic_id_GUI.text;
					recordNode.@rfcti_id = FOU_rfcti_id_GUI.text;
				}
				
				if (tableCode == 'RA9') {
					recordNode.@rfoids = RXX_regroupes_oids_GUI.text;
				}
				if (tableCode == 'RF9') {
					recordNode.@rfoids = RXX_regroupes_oids_GUI.text;
				}
				if (tableCode == 'TYM') {
					recordNode.@particularite_inverser_signe = TYM_particularite_inverser_signe_GUI.selectedIndex.toString();
                    recordNode.@sens_force = TYM_sens_force_GUI.selectedItem.data;
				}
				if (tableCode == 'TYA') {
                    recordNode.@defaut_selon = TYA_defaut_selon_GUI.selectedItem.data;
					recordNode.@defaut_selon_codes = TYA_defaut_selon_codes_GUI.text
				}
				
				if (tableCode == 'TAR') {
					recordNode.@priorite = TAR_priorite_GUI.text
					recordNode.@type_article_cti_id = TAR_type_article_cti_id_GUI.selectedItem.oid;
					
					recordNode.@liste_type_article = TAR_liste_type_article_GUI.text 
					recordNode.@liste_compte = TAR_liste_compte_GUI.text 
					recordNode.@liste_famille = TAR_liste_famille_GUI.text 
					recordNode.@liste_sous_famille = TAR_liste_sous_famille_GUI.text 
					recordNode.@liste_categorie = TAR_liste_categorie_GUI.text  
					recordNode.@liste_sous_categorie = TAR_liste_sous_categorie_GUI.text 
					recordNode.@liste_article = TAR_liste_article_GUI.text  
				}
				
				
				urlVariables.recordNode = recordNode.toXMLString();
				CTI_Utilitaires.startRequestHTTP("modules/eco/php/httpService_tablesManager_setData.php",urlVariables,exec,true,this.parentApplication)	
				function exec(resultatService:XML):void {
				
					var returnCode:String = resultatService.@returnCode;
					var returnTexte:String = resultatService.@returnTexte;
					if (returnCode == "KO") {
						CTI_Utilitaires.alert_error("Mise à jour", "Mise à jour non effeectuée : " + returnTexte);
					}
					else {
						var updatedOids:String = resultatService.@updatedOids.toString();
						
						getData(false,updatedOids);
						
						currendRecordItem = null;
						recordUpdated = false;
						detailBox_GUI.visible = false;
						detailBox_GUI.includeInLayout = false;
					}
					
				}
			}
			
			
			public function TAR_execute_rules():void {
				var urlVariables:URLVariables = new URLVariables()
				urlVariables.tableName = tableName;
				urlVariables.action = "exec";
				urlVariables.softCode = softCode;
				var recordNode:XML = new XML(<RECORD />);
				urlVariables.recordNode = recordNode.toXMLString();
				CTI_Utilitaires.startRequestHTTP("modules/eco/php/httpService_tablesManager_setData.php",urlVariables,exec,true,this.parentApplication)	
				function exec(resultatService:XML):void {
				
					var returnCode:String = resultatService.@returnCode;
					var returnTexte:String = resultatService.@returnTexte;
					if (returnCode == "KO") {
						CTI_Utilitaires.alert_error("Mise à jour", "Mise à jour non effeectuée : " + returnTexte);
					}
					else {
						
					}
					
				}
			}
			
			public function print():void {
				var printReport:CTI_Print = new CTI_Print();
				if (printReport.start("ECO_TablesManager", titlePrint) == false) {
					return;
				}
				printReport.addDataGrid(list_GUI)
				printReport.print();
			}
			
			public function exportExcel():void {
				var xml:XML = new XML(<EXCELEXPORT />);
				var ongletNode:XML;
				var similiTabNode:XML;
				var selectionsNode:XML;
				var datagridNode:XML;
				var columnNode:XML;
				var dataNode:XML;
				var rowNode:XML;
				xml.@viewName = this.viewName;
				xml.@title = this.title;
				selectionsNode = new XML(<SELECTIONS />);
				selectionsNode.displayText = "";
				if (refSearch_GUI.selected == true) {
					selectionsNode.@displayText = selectionsNode.displayText + "Uniquement les codes référencés. ";
				}
				if (textSearch_GUI.text != "") {
					selectionsNode.@displayText = selectionsNode.displayText + "(Filtre : " + textSearch_GUI.text + ")  ";
				}
				xml.appendChild(selectionsNode);
				ongletNode = new XML(<ONGLET />);
				ongletNode.@excelLabel = tableCode;
				xml.appendChild(ongletNode);
				similiTabNode = new XML(<SIMILITAB />);
				similiTabNode.@excelLabel = "Liste";
				ongletNode.appendChild(similiTabNode);
				datagridNode = new XML(<DATAGRID />);
				datagridNode.@total = "false";
				ongletNode.appendChild(datagridNode);
				for each (var column:DataGridColumn in list_GUI.columns) {
					columnNode = new XML(<COLUMN />);
					columnNode.@dataField = column.dataField;
					columnNode.@headerText = column.headerText;
					columnNode.@type = "Char";
					columnNode.@textAlign = column.getStyle("textAlign");
					datagridNode.appendChild(columnNode);
				}
				dataNode = new XML(<DATA />);
				similiTabNode.appendChild(dataNode);
				for each (var itemNode:XML in list_collection) {
					if (itemNode.@oid != "-1") {
						rowNode = new XML(<ROW />)
						var c:int = 0;
						for each (column in list_GUI.columns) {
							c++;
							rowNode.@["c" + c.toString()] = itemNode[column.dataField]
						}
						dataNode.appendChild(rowNode);
					}
				}
				CTI_ExcelUtilitaires.exportExcel(xml);
			}
			
			public function exportPDF():void {
				var xml:XML = new XML(<PDFEXPORT />);
				var ongletNode:XML;
				var selectionsNode:XML;
				var datagridNode:XML;
				var columnNode:XML;
				var dataNode:XML;
				var rowNode:XML;
				xml.@viewName = this.viewName;
				xml.@title = this.title;
				selectionsNode = new XML(<SELECTIONS />);
				selectionsNode.displayText = "";
				if (refSearch_GUI.selected == true) {
					selectionsNode.displayText = selectionsNode.displayText + "Uniquement les codes référencés. ";
				}
				if (textSearch_GUI.text != "") {
					selectionsNode.displayText = selectionsNode.displayText + "(Filtre : " + textSearch_GUI.text + ")  ";
				}
				xml.appendChild(selectionsNode);
				ongletNode = new XML(<ONGLET />);
				ongletNode.@excelLabel = tableCode;
				xml.appendChild(ongletNode);
				datagridNode = new XML(<DATAGRID />);
				datagridNode.@total = "false";
				ongletNode.appendChild(datagridNode);
				for each (var column:DataGridColumn in list_GUI.columns) {
					columnNode = new XML(<COLUMN />);
					columnNode.@dataField = column.dataField;
					columnNode.@headerText = column.headerText;
					columnNode.@type = "Char";
					columnNode.@textAlign = column.getStyle("textAlign");
					datagridNode.appendChild(columnNode);
				}
				dataNode = new XML(<DATA />);
				ongletNode.appendChild(dataNode);
				for each (var itemNode:XML in list_collection) {
					if (itemNode.@oid != "-1") {
						rowNode = new XML(<ROW />)
						var c:int = 0;
						for each (column in list_GUI.columns) {
							c++;
							rowNode.@["c" + c.toString()] = itemNode[column.dataField]
						}
						dataNode.appendChild(rowNode);
					}
				}
				CTI_PDFUtilitaires.exportPDF(xml);
				xml = null;
			}
			
			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)
				{
				}

			}
			
			private function new_import_fileUpload():void
			{
				
				
				var urlVariables:URLVariables = new URLVariables();
				urlVariables.tableName = tableName;
				urlVariables.action = "upload";
				var recordNode:XML = new XML(<RECORD />);
				recordNode.@oid = oid_GUI.text;
				recordNode.@code = code_GUI.text;
				recordNode.@texte = texte_GUI.text;
				recordNode.@texte_court = texte_court_GUI.text;
				recordNode.@code_original = code_original_GUI.text;
				urlVariables.recordNode = recordNode.toXMLString();
				urlVariables.importFile = new_import_fileToUpload.name;
				
				CTI_Utilitaires.startUploadHTTP(new_import_fileToUpload, "modules/eco/php/httpService_tablesManager_setData.php", urlVariables, exec, true, this.parentApplication)
				
				function exec(resultatService:XML):void
				{
					if (resultatService.@returnCode.toString() == "OK")
					{
						getData();
						detailBox_GUI.visible = false;
						detailBox_GUI.includeInLayout = false;
						currendRecordItem = null;
						recordUpdated = false;
					}
					else
					{
						CTI_Utilitaires.alert_error("Envoi fichier " + new_import_fileToUpload.name + " au serveur", resultatService.@returnTexte.toString())
					}
				
				}
			}
			
			private function ART_cacic_changeEvent(event:*):void {
				
				recordUpdated = true;
				var ART_cacic_XML:XMLList = ART_ARRAY_RA1_XML.RECORD.(@code == ART_cacic_code_GUI.text);
				if (ART_cacic_XML.length() > 0) {
					ART_cacic_texte_GUI.text = ART_cacic_XML[0].@texte;
					ART_cacic_id_GUI.text = ART_cacic_XML[0].@oid;
				}
				else {
					ART_cacic_texte_GUI.text = "?";
					ART_cacic_id_GUI.text = "0";
				}	
			}
			
			private function ART_rfcti_changeEvent(event:*):void {
				
				recordUpdated = true;
				var ART_rfcti_XML:XMLList = ART_ARRAY_RA9_XML.RECORD.(@code == ART_rfcti_code_GUI.text);
				if (ART_rfcti_XML.length() > 0) {
					ART_rfcti_texte_GUI.text = ART_rfcti_XML[0].@texte;
					ART_rfcti_id_GUI.text = ART_rfcti_XML[0].@oid;
				}
				else {
					ART_rfcti_texte_GUI.text = "?";
					ART_rfcti_id_GUI.text = "0";
				}	
			}
			
			private function FOU_cacic_changeEvent(event:*):void {
				
				recordUpdated = true;
				var FOU_cacic_XML:XMLList = FOU_ARRAY_RF1_XML.RECORD.(@code == FOU_cacic_code_GUI.text);
				if (FOU_cacic_XML.length() > 0) {
					FOU_cacic_texte_GUI.text = FOU_cacic_XML[0].@texte;
					FOU_cacic_id_GUI.text = FOU_cacic_XML[0].@oid;
				}
				else {
					FOU_cacic_texte_GUI.text = "?";
					FOU_cacic_id_GUI.text = "0";
				}	
			}
			
			private function FOU_rfcti_changeEvent(event:*):void {
				
				recordUpdated = true;
				var FOU_rfcti_XML:XMLList = FOU_ARRAY_RF9_XML.RECORD.(@code == FOU_rfcti_code_GUI.text);
				if (FOU_rfcti_XML.length() > 0) {
					FOU_rfcti_texte_GUI.text = FOU_rfcti_XML[0].@texte;
					FOU_rfcti_id_GUI.text = FOU_rfcti_XML[0].@oid;
				}
				else {
					FOU_rfcti_texte_GUI.text = "?";
					FOU_rfcti_id_GUI.text = "0";
				}	
			}
			
			// Regroupement des fournisseurs reference CTI
			private function RXX_a_regrouper_searchChange():void {
				
				a_regrouper_search_mots = getMots(RXX_a_regrouper_textSearch_GUI.text)
				
				if (RXX_a_regrouper_GUI.dataProvider.filterFunction == null) {
					RXX_a_regrouper_GUI.dataProvider.filterFunction = RXX_a_regrouper_filterFunction
				}

				RXX_a_regrouper_GUI.dataProvider.refresh()
			}
			
			
			// Filter function 
			public function RXX_a_regrouper_filterFunction(item:XML):Boolean 
			{ 
				var result:Boolean = true; 
				
				result = filterListItem(item, a_regrouper_search_mots)

				if (result == true && currendRecordItem != null) {
					if (item.@oid.toString() == currendRecordItem.@oid.toString()) {
						result=false;
					}
				}
				if (result == true) {
					if (RXX_regroupes_oids_GUI.text.indexOf("," + item.@oid.toString() + ",") >= 0) {
						result=false; 
					}
				}
				
				return result; 
			} 
			
			public function RXX_regroupes_filterFunction(item:XML):Boolean 
			{ 
				var result:Boolean = true; 
				
				
				if (result == true) {
					if (RXX_regroupes_oids_GUI.text.indexOf("," + item.@oid.toString() + ",") < 0) {
						result=false; 
					}
				}
				
				return result; 
			} 
			// Ajout dans regroupes
			private function RXX_regroupes_add():void {
				
				for each (var item:XML in RXX_a_regrouper_GUI.selectedItems) {
					RXX_regroupes_oids_GUI.text = RXX_regroupes_oids_GUI.text + item.@oid + "," 
				}

				RXX_a_regrouper_searchChange()
				RXX_regroupes_GUI.dataProvider.refresh();
				
				recordUpdated = true
			}
			
			// enlever dans regroupes
			private function RXX_regroupes_remove():void {
				for each (var item:XML in RXX_regroupes_GUI.selectedItems) {
					var regexp:RegExp = new RegExp("," + item.@oid + ",", "g");
					RXX_regroupes_oids_GUI.text = RXX_regroupes_oids_GUI.text.replace(regexp,  ",");
				}
				 
					
				RXX_a_regrouper_searchChange()
				RXX_regroupes_GUI.dataProvider.refresh();
				
				recordUpdated = true
			}
			
			private function setSelectedIndex(cb:Object, str:String, field:String='data'):void {
				cb.selectedIndex = 0
				for (var idx:int = 0, len:int = cb.dataProvider.length; idx < len; idx++) {
					if (cb.dataProvider.getItemAt(idx)[field] == str) {
						cb.selectedIndex = idx;
					}
				}
			}
			
        ]]>
    </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="28" >
			<mx:HBox id="GUI_buttonBar" width="100%">
				<mx:Button height="28" width="28"
					visible="{detailBox_GUI.visible == false}"
					toolTip="Imprimer" icon="@Embed('../../base/swf/CTI/images/24/print.png')" labelPlacement="right" click="print()"/>
				<mx:Button height="28" width="28" 
					visible="{detailBox_GUI.visible == false}"
					toolTip="Réafficher" icon="@Embed('../../base/swf/CTI/images/24/view-refresh.png')" labelPlacement="right" click="getData()" />
				<mx:Button height="28" width="28" 
					visible="{detailBox_GUI.visible == false}"
					toolTip="Exporter vers Excel" icon="@Embed('../../base/swf/CTI/images/24/excel.png')" labelPlacement="right" click="exportExcel()"/>
				<mx:Spacer />
				<mx:Button height="28" width="28" toolTip="Ajouter" icon="@Embed('../../base/swf/CTI/images/24/list-add.png')" labelPlacement="right" click="addRecord()" visible="{currendRecordItem == null &amp;&amp; tableCode == 'TAR'}" />
				<mx:Spacer />
				<mx:Button height="28" width="160" toolTip="Exécuter les règles" icon="@Embed('../../base/swf/CTI/images/24/system-software-installer.png')" label="Exécuter les règles" labelPlacement="right" click="TAR_execute_rules()" enabled="{!recordUpdated}" visible="{currendRecordItem == null &amp;&amp; tableCode == 'TAR'}" includeInLayout="{currendRecordItem == null &amp;&amp; tableCode == 'TAR'}" />
				<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:Spacer width="100%" />
				<mx:HBox  >
					<mx:Label text="Filtre" />
					<mx:TextArea width="100%" height="18" id="textSearch_GUI" change="searchChange()"/>
					<mx:Spacer width="10" />
					<mx:Label text="Référencés Uniquement" visible="{column_visible_nbref}"/>
					<mx:CheckBox id="refSearch_GUI" change="searchChange()" visible="{column_visible_nbref}"/>
				</mx:HBox>
			</mx:HBox>
		</mx:Canvas>
		<mx:Canvas width="100%" height="100%">
			<mx:VDividedBox id="mainBox" width="100%" height="100%" visible="true">
				<mx:DataGrid id="list_GUI" rowHeight="20" headerHeight="40"
					rowCount="{list_collection.length + 1}" height="100%" width="100%"
					wordWrap="false" dataProvider="{list_collection}"
					fontFamily="tahoma" fontSize="11"
					itemClick="getRecord()"
					selectable="{!recordUpdated}">
					<mx:columns>
						<mx:DataGridColumn dataField="@code" headerText="Code" width="100"  editable="false" headerWordWrap="true" visible="{column_visible_code}"/>
						<mx:DataGridColumn dataField="@priorite" headerText="Priorité" width="100"  editable="false" headerWordWrap="true" visible="{tableCode == 'TAR'}"/>
						<mx:DataGridColumn dataField="@texte" headerText="Texte" minWidth="200"  editable="false" headerWordWrap="true"/>
						<mx:DataGridColumn dataField="@type_article_cti_texte" headerText="Type CTI" width="200"  editable="false" headerWordWrap="true" visible="{tableCode == 'TAR'}"/>
						<mx:DataGridColumn dataField="@rule_texte" headerText="Règle" minWidth="400"  editable="false" headerWordWrap="true" visible="{tableCode == 'TAR'}"/>
						<mx:DataGridColumn dataField="@texte_court" headerText="Texte court" width="100"  editable="false" headerWordWrap="true" visible="{column_visible_texte_court}"/>
						<mx:DataGridColumn dataField="@complement" headerText="Complément" width="200"  editable="false" headerWordWrap="true" visible="{column_visible_complement}"/>
						<mx:DataGridColumn dataField="@code_original" headerText="Code original" width="100"  editable="false" headerWordWrap="true" visible="{column_visible_code_original}"/>
						<mx:DataGridColumn dataField="@nbref" headerText="Réf." width="50"  editable="false" headerWordWrap="true" visible="{column_visible_nbref}"/>
						<mx:DataGridColumn dataField="@valeur" headerText="Valeur" width="100"  editable="false" headerWordWrap="true" visible="{tableCode == 'DIV'}"/>
						<mx:DataGridColumn dataField="@valeur_date" headerText="Valeur date" width="100"  editable="false" headerWordWrap="true" visible="{tableCode == 'DIV'}"/>
						<mx:DataGridColumn dataField="@description" headerText="Description" width="100"  editable="false" headerWordWrap="true" visible="{tableCode == 'DIV'}"/>
                        <mx:DataGridColumn dataField="@show_info_module" headerText="Info Module" width="100"  editable="false" headerWordWrap="true" visible="{tableCode == 'DIV'}"/>
					</mx:columns>
				</mx:DataGrid>
				<mx:VBox id="detailBox_GUI" width="100%" 
					visible="false"
					includeInLayout="false"
					height="400" backgroundColor="0xFFFFFF">
					<mx:HBox>
						<mx:Canvas>
							<mx:Button height="28" label="Annuler" toolTip="Annuler les modifications" icon="@Embed('../../base/swf/CTI/images/24/window-close.png')" labelPlacement="right" click="askCancel()" visible="{recordUpdated == true}" />
							<mx:Button height="28" label="Masquer" toolTip="Masquer la fiche" icon="@Embed('../../base/swf/CTI/images/24/go-up.png')" labelPlacement="right" click="hideRecord()" visible="{recordUpdated == false}" />
						</mx:Canvas>
						<mx:Canvas>
							<mx:Button height="28" label="Enregistrer" toolTip="Enregistrer les modifications" icon="@Embed('../../base/swf/CTI/images/valider24.png')" labelPlacement="right" click="saveRecord()" visible="{recordUpdated == true &amp;&amp; (code_GUI.text != '' || column_visible_code == false)}" />
						</mx:Canvas>
					</mx:HBox>
					<mx:HBox width="100%" height="100%" >
						<mx:VBox width="100%" height="100%" >
							<mx:HBox visible="{column_visible_code}" includeInLayout="{column_visible_code}">
								<mx:Label width="150" text="Code" />
								<mx:TextArea width="100" height="18" id="code_GUI" change="recordUpdated = true" editable="false"/>
							</mx:HBox>
							<mx:HBox visible="{column_visible_code_original}" includeInLayout="{column_visible_code_original}">
								<mx:Label width="150" text="Code original" />
								<mx:TextArea width="300" height="18" id="code_original_GUI" change="recordUpdated = true" editable="false"/>
							</mx:HBox>
							<mx:HBox width="100%">
								<mx:Label width="150" text="Texte" />
								<mx:TextArea width="100%" height="18" id="texte_GUI" change="recordUpdated = true" fontWeight="bold" editable="{tableCode != 'RIN'}"/>
							</mx:HBox>
							<mx:HBox visible="{column_visible_texte_court}" includeInLayout="{column_visible_texte_court}">
								<mx:Label width="150" text="Texte_court" />
								<mx:TextArea width="300" height="18" id="texte_court_GUI" change="recordUpdated = true" fontWeight="bold"/>
							</mx:HBox>
							<mx:HBox visible="{column_visible_complement &amp;&amp; tableCode != 'RF9'}" includeInLayout="{column_visible_complement &amp;&amp; !column_visible_rfoids}">
								<mx:Label width="150" text="Complément" />
								<mx:TextArea width="500" height="60" id="complement_GUI" change="recordUpdated = true" editable="{tableCode == 'DIV'}"/>
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'TYM'}" includeInLayout="{tableCode == 'TYM'}">
								<mx:Label width="150" text="Inverser signe" />
								<mx:ComboBox id="TYM_particularite_inverser_signe_GUI" dataProvider="{TYM_inverser_signe}" change="recordUpdated = true" />
							</mx:HBox>
                            <mx:HBox visible="{tableCode == 'TYM'}" includeInLayout="{tableCode == 'TYM'}">
								<mx:Label width="150" text="Forcer sens" />
								<mx:ComboBox id="TYM_sens_force_GUI" dataProvider="{TYM_sens_force}" change="recordUpdated = true" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'TYA'}" includeInLayout="{tableCode == 'TYA'}">
								<mx:Label width="150" text="Valeur par défaut selon" />
								<mx:ComboBox id="TYA_defaut_selon_GUI" dataProvider="{TYA_defaut_selon}" change="recordUpdated = true" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'TYA'}" includeInLayout="{tableCode == 'TYA'}" width="100%" height="100%">
								<mx:Label width="150" text="     codes" />
								<mx:TextArea width="100%" height="100%" id="TYA_defaut_selon_codes_GUI" change="recordUpdated = true" editable="{TYA_defaut_selon_GUI.selectedIndex != 0}"/>
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'ART'}" includeInLayout="{tableCode == 'ART'}">
								<mx:Label width="150" text="Géré en stock" />
								<mx:CheckBox id="ART_gere_en_stock_GUI" change="recordUpdated = true" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'ART'}" includeInLayout="{tableCode == 'ART'}">
								<mx:Label width="150" text="Référence CACIC" />
								<mx:TextArea width="100" height="18" id="ART_cacic_code_GUI" change="ART_cacic_changeEvent(event)" fontWeight="bold" />
								<mx:TextArea width="500" height="18" id="ART_cacic_texte_GUI" change="recordUpdated = true" fontWeight="bold" editable="false"/>
								<mx:TextArea width="50" height="18" id="ART_cacic_id_GUI" change="recordUpdated = true" fontWeight="bold" enabled="false" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'ART'}" includeInLayout="{tableCode == 'ART'}">
								<mx:Label width="150" text="Référence CTI" />
								<mx:TextArea width="100" height="18" id="ART_rfcti_code_GUI" change="ART_rfcti_changeEvent(event)" fontWeight="bold" />
								<mx:TextArea width="500" height="18" id="ART_rfcti_texte_GUI" change="recordUpdated = true" fontWeight="bold" editable="false"/>
								<mx:TextArea width="50" height="18" id="ART_rfcti_id_GUI" change="recordUpdated = true" fontWeight="bold" enabled="false" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'FOU'}" includeInLayout="{tableCode == 'FOU'}">
								<mx:Label width="150" text="Fusionner vers" />
								<mx:ComboBox id="FOU_fusionner_vers_fournisseur_id_GUI" width="500" labelField="texte" change="recordUpdated = true"/>
							</mx:HBox>
							<mx:HBox verticalAlign="middle" visible="{tableCode == 'DIV'}" includeInLayout="{tableCode == 'DIV'}" >
								<mx:Label width="150" text="Valeur" />
								<mx:TextArea width="300" height="18" id="valeur_GUI" change="recordUpdated = true" fontWeight="bold" />
							</mx:HBox>
							<mx:HBox verticalAlign="middle" visible="{tableCode == 'DIV'}" includeInLayout="{tableCode == 'DIV'}">
							    <mx:Label width="150" text="Info Module" />
								<mx:CheckBox width="300" height="18" id="show_info_module_GUI" change="recordUpdated = true" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'FOU'}" includeInLayout="{tableCode == 'FOU'}">
								<mx:Label width="150" text="Référence CACIC" />
								<mx:TextArea width="100" height="18" id="FOU_cacic_code_GUI" change="FOU_cacic_changeEvent(event)" fontWeight="bold" />
								<mx:TextArea width="500" height="18" id="FOU_cacic_texte_GUI" change="recordUpdated = true" fontWeight="bold" editable="false"/>
								<mx:TextArea width="50" height="18" id="FOU_cacic_id_GUI" change="recordUpdated = true" fontWeight="bold" enabled="false" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'FOU'}" includeInLayout="{tableCode == 'FOU'}">
								<mx:Label width="150" text="Référence CTI" />
								<mx:TextArea width="100" height="18" id="FOU_rfcti_code_GUI" change="FOU_rfcti_changeEvent(event)" fontWeight="bold" />
								<mx:TextArea width="500" height="18" id="FOU_rfcti_texte_GUI" change="recordUpdated = true" fontWeight="bold" editable="false"/>
								<mx:TextArea width="50" height="18" id="FOU_rfcti_id_GUI" change="recordUpdated = true" fontWeight="bold" enabled="false" />
							</mx:HBox>
							
							<mx:HBox visible="{tableCode == 'RIN'}" includeInLayout="{tableCode == 'RIN'}">
								<cti_control:CTIButton2 id="browseButton" height="28" width="300" label="Importer un nouveau fichier" toolTip="Importer un nouveau fichier" icon="@Embed('../../base/swf/CTI/images/24/document-save-as.png')" labelPlacement="right" click="new_import_upload()" visible="{recordUpdated == false}" />
							</mx:HBox>
							<mx:HBox visible="false" includeInLayout="false">
								<mx:Label width="150" text="Oid" />
								<mx:TextArea width="300" height="18" id="oid_GUI" change="recordUpdated = true" editable="false"/>
							</mx:HBox>
							<mx:HBox visible="{column_visible_nbref}" includeInLayout="{column_visible_nbref}">
								<mx:Label width="150" text="Nombre références" />
								<mx:TextArea width="300" height="18" id="nbref_GUI" change="recordUpdated = true" editable="false"/>
							</mx:HBox>
							
							<mx:HBox visible="{tableCode == 'TAR'}" includeInLayout="{tableCode == 'TAR'}" >
								<mx:Label width="150" text="Priorité" />
								<mx:TextArea width="100" height="18" id="TAR_priorite_GUI" change="recordUpdated = true" fontWeight="bold" />
							</mx:HBox>
							<mx:HBox visible="{tableCode == 'TAR'}" includeInLayout="{tableCode == 'TAR'}">
								<mx:Label width="150" text="Type CTI" />
								<mx:ComboBox id="TAR_type_article_cti_id_GUI" width="500" labelField="texte" change="recordUpdated = true"/>
							</mx:HBox>
							
							<mx:VBox width="100%"  height="100%" visible="{tableCode == 'TAR'}" includeInLayout="{tableCode == 'TAR'}">
								<mx:HBox width="100%">
									<mx:Label width="150" text="Listes de codes" />
									<mx:CheckBox id="TAR_Qliste_type_article_GUI" label="Types article source" 
											enabled="{TAR_liste_type_article_GUI.text == ''}" />
									<mx:CheckBox id="TAR_Qliste_compte_GUI" label="Comptes" 
											enabled="{TAR_liste_compte_GUI.text == ''}" />
									<mx:CheckBox id="TAR_Qliste_famille_GUI" label="Familles" 
											enabled="{TAR_liste_famille_GUI.text == ''}" />
									<mx:CheckBox id="TAR_Qliste_sous_famille_GUI" label="Sous-familles" 
											enabled="{TAR_liste_sous_famille_GUI.text == ''}" />
									<mx:CheckBox id="TAR_Qliste_categorie_GUI" label="Catégories" 
											enabled="{TAR_liste_categorie_GUI.text == ''}" />
									<mx:CheckBox id="TAR_Qliste_sous_categorie_GUI" label="Sous-catégories" 
											enabled="{TAR_liste_sous_categorie_GUI.text == ''}" />
									<mx:CheckBox id="TAR_Qliste_article_GUI" label="Articles" 
											enabled="{TAR_liste_article_GUI.text == ''}" />
								</mx:HBox>

								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_type_article_GUI.selected}" 
									includeInLayout="{TAR_Qliste_type_article_GUI.selected}">
									<mx:Label width="150" text="Types d'article source" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_type_article_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
								
								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_compte_GUI.selected}" 
									includeInLayout="{TAR_Qliste_compte_GUI.selected}">
									<mx:Label width="150" text="Comptes" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_compte_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
								
								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_famille_GUI.selected}" 
									includeInLayout="{TAR_Qliste_famille_GUI.selected}">
									<mx:Label width="150" text="Familles" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_famille_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
								
								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_sous_famille_GUI.selected}" 
									includeInLayout="{TAR_Qliste_sous_famille_GUI.selected}">
									<mx:Label width="150" text="Sous-familles" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_sous_famille_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
								
								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_categorie_GUI.selected}" 
									includeInLayout="{TAR_Qliste_categorie_GUI.selected}">
									<mx:Label width="150" text="Catégories" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_categorie_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
							
								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_sous_categorie_GUI.selected}" 
									includeInLayout="{TAR_Qliste_sous_categorie_GUI.selected}">
									<mx:Label width="150" text="Sous-catégories" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_sous_categorie_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
								
								<mx:HBox width="100%" height="100%"
									visible="{TAR_Qliste_article_GUI.selected}" 
									includeInLayout="{TAR_Qliste_article_GUI.selected}">
									<mx:Label width="150" text="Articles" />
									<mx:TextArea width="100%" height="100%" id="TAR_liste_article_GUI" change="recordUpdated = true" fontWeight="bold" />
								</mx:HBox>
							</mx:VBox>	
						</mx:VBox>
						
						
						<mx:VBox width="100%" height="100%" visible="{column_visible_rfoids}" includeInLayout="{column_visible_rfoids}">
							<mx:Label width="100%" text="Eléments production associés" />
							<mx:HBox width="100%" visible="false" includeInLayout="false" >
								<mx:Label width="120" text="oids regroupés" />
								<mx:TextArea id="RXX_regroupes_oids_GUI" width="100%"  editable="false"/>
							</mx:HBox>
							<mx:DataGrid id="RXX_regroupes_GUI" rowHeight="20" 
								height="50%" width="100%" allowMultipleSelection="true" doubleClickEnabled="true" 
								wordWrap="false" doubleClick="RXX_regroupes_remove()"
								fontFamily="tahoma">
								<mx:columns>
									<mx:DataGridColumn dataField="@texte" headerText="Nom" minWidth="100"  editable="false"/>
									<mx:DataGridColumn dataField="@lppucd" headerText="LPP/UCD" width="100"  editable="false"
										visible="{tableCode == 'RA9'}"/>
									<mx:DataGridColumn dataField="@code" headerText="Code" width="100"  editable="false"/>
								</mx:columns>
							</mx:DataGrid>
							<mx:HBox width="100%" >
								<mx:Button height="20" width="20" label="Ajouter" toolTip="Ajouter" icon="@Embed('../../base/swf/CTI/images/16/list-add.png')" labelPlacement="right" click="RXX_regroupes_add()" />
								<mx:Button height="20" width="20" label="Enlever" toolTip="Enlever" icon="@Embed('../../base/swf/CTI/images/16/list-remove.png')" labelPlacement="right" click="RXX_regroupes_remove()"  />
								<mx:Spacer width="20" />
								<mx:HBox width="100%">
									<mx:Label text="Recherche" width="70"/>
									<mx:TextArea id="RXX_a_regrouper_textSearch_GUI" width="100%" height="18"  change="RXX_a_regrouper_searchChange()" />
								</mx:HBox>
							</mx:HBox>
							<mx:DataGrid id="RXX_a_regrouper_GUI" rowHeight="20" 
								height="50%" width="100%" allowMultipleSelection="true" doubleClickEnabled="true" 
								wordWrap="false" doubleClick="RXX_regroupes_add()"
								fontFamily="tahoma">
								<mx:columns>
									<mx:DataGridColumn dataField="@texte" headerText="Nom" minWidth="100"  editable="false"/>
									<mx:DataGridColumn dataField="@lppucd" headerText="LPP/UCD" width="100"  editable="false"
										visible="{tableCode == 'RA9'}"/>
									<mx:DataGridColumn dataField="@code" headerText="Code" width="100"  editable="false"/>
								</mx:columns>
							</mx:DataGrid>
						</mx:VBox>
						
					</mx:HBox>
					
				</mx:VBox>
			</mx:VDividedBox>
		</mx:Canvas>
	</mx:VBox>
</mx:Application>