<?php
require_once("../../base/php/startSession.php");
require_once("../../base/php//classDatabase.php");
require_once( "../../base/php/Functions.php" );

global $database;

$tableName = getPOST("tableName");
$firstCall = getPOST("firstCall");

if ($tableName == "") {
	$tableName = "t_divers";
}

$database = new Database("iCTI");

$httpString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
$httpString .= "\n<HTTP_SERVICE>";

if ($tableName == "t_divers") {
	$httpString .= getRecords_divers();
}
if ($tableName == "t_categories_socio_professionnelle") {
	$httpString .= getRecords_categories_socio_professionnelle();
}
if ($tableName == "t_codes_emploi") {
	$httpString .= getRecords_codes_emploi();
}
if ($tableName == "t_entreprises") {
	$httpString .= getRecords_entreprises();
}
if ($tableName == "t_etablissements") {
	$httpString .= getRecords_etablissements();
}
if ($tableName == "t_grilles") {
	$httpString .= getRecords_grilles();

}
if ($tableName == "t_grilles_groupes") {
	$httpString .= getRecords_grilles_groupes();
	
}
if ($tableName == "t_groupes_cotisant") {
	$httpString .= getRecords_groupes_cotisant();
	
}
if ($tableName == "t_motifs_arret") {
	$httpString .= getRecords_motifs_arret();
	
}
if ($tableName == "t_motifs_debut_contrat") {
	$httpString .= getRecords_motifs_debut_contrat();
}
if ($tableName == "t_motifs_fin_contrat") {
	$httpString .= getRecords_motifs_fin_contrat();
}
if ($tableName == "t_organismes_cotisation") {
	$httpString .= getRecords_organismes_cotisation();
}
if ($tableName == "t_precisions_motif_arret") {
	$httpString .= getRecords_precisions_motif_arret();
}
if ($tableName == "t_qualifications") {
	$httpString .= getRecords_qualifications();
}
if ($tableName == "t_rubriques") {
	$httpString .= getRecords_rubriques();
}
if ($tableName == "t_sections_analytiques") {
	$httpString .= getRecords_sections_analytiques();
}
if ($tableName == "t_sections_analytiques_paie") {
	$httpString .= getRecords_sections_analytiques_paie();
}
if ($tableName == "t_services") {
	$httpString .= getRecords_services();
}
if ($tableName == "t_situations_famille") {
	$httpString .= getRecords_situations_famille();
}
if ($tableName == "t_societes_interim") {
	$httpString .= getRecords_societes_interim();
	
}
if ($tableName == "t_specialites") {
	$httpString .= getRecords_specialites();
	
}

if ($tableName == "t_statuts") {
	$httpString .= getRecords_statuts();
	
}
if ($tableName == "t_types_contrat") {
	$httpString .= getRecords_types_contrat();
}
if ($tableName == "t_types_horaire") {
	$httpString .= getRecords_types_horaire();
	
}
if ($tableName == "t_types_temps_travail") {
	$httpString .= getRecords_types_temps_travail();
}

if ($tableName == "t_motifs_visite") {
	$httpString .= getRecords_motifs_visite();

}

if ($tableName == "t_accident_circonstance") {
	$httpString .= getRecords_accident_circonstance();
}

if ($tableName == "t_accident_lieu") {
	$httpString .= getRecords_accident_lieu();
 
}

if ($tableName == "t_accident_nature") {
	$httpString .= getRecords_accident_nature();
}

if ($tableName == "t_accident_siege") {
	$httpString .= getRecords_accident_siege();
}

if ($tableName == "t_unite_fonctionnelle") {
	$httpString .= getRecords_unites_fonctionnelle();
}

if ($tableName == "t_lettre_budgetaire") {
	$httpString .= getRecords_lettre_budgetaire();
}

if ($tableName == "t_commission_paritaire") {
	$httpString .= getRecords_commission_paritaire();
}

if ($tableName == "t_categorie_conge") {
	$httpString .= getRecords_categorie_conge();
}

if ($tableName == "t_cadre_emploi") {
	$httpString .= getRecords_cadre_emploi();
}

if ($tableName == "t_filiere") {
	$httpString .= getRecords_filiere();
}

if ($tableName == "t_categorie_statutaire") {
	$httpString .= getRecords_categorie_statutaire();
}

if ($tableName == "t_compte") {
	$httpString .= getRecords_compte();
	
}

if ($tableName == "t_transformation") {
	$httpString .= getRecords_transformation();
	$httpString .= getCombo_transformation();
}

if ($tableName == "t_expert_controle") {
	if ($getOption != "getRefSettings") {
		$httpString .= getRecords_expert_controle();
	}
	else {
		$httpString .= getRecords_expert_controle_refsettings($refPrefix);
	}
}

if ($tableName == "t_planning_service") {
	$httpString .= getRecords_planning_service();
	$httpString .= getCombo_planning_service();
}

if ($tableName == "t_planning_qualification") {
	$httpString .= getRecords_planning_qualification();
	$httpString .= getCombo_planning_qualification();
}

if ($tableName == "t_planning_type_absence") {
	$httpString .= getRecords_planning_type_absence();
}

if ($tableName == "t_data_profile") {
	$httpString .= getRecords_data_profile();
}

$httpString .= "\n</HTTP_SERVICE>";

$httpString = compress64($httpString);

echo "<CTICONTENT>$httpString</CTICONTENT>";



function getRecords_divers() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "	SELECT 
					1::bigint AS div_id, 
					code as div_code, 
					texte as div_texte, 
					valeur as div_valeur, 
					description as div_desc, 
					valeur2 as div_valeur2,
                    CASE WHEN show_info_module THEN 1 ELSE 0 END AS show_info_module
				FROM rh.t_divers
				ORDER BY code ";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = 1;
				$code = toHTML(trim($record['div_code']));
				$texte = toHTML(trim($record['div_texte']));
				$valeur = toHTML(trim($record['div_valeur']));
				$description = toHTML(trim($record['div_desc']));
				$valeur2 = toHTML(trim($record['div_valeur2']));
                $show_info_module = toHTML(trim($record['show_info_module']));
				$nbref = 1;
				
				$httpString .= "\r\n<RECORD
									oid=\"$oid\" 
									code=\"$code\" 
									texte=\"$texte\" 
									valeur=\"$valeur\" 
									description=\"$description\" 
									valeur2=\"$valeur2\" 
                                    show_info_module=\"$show_info_module\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function getRecords_categories_socio_professionnelle() {

global $database;

	$httpString = "";

	$sqlcmd = "	SELECT
					oid as cat_id,
					code as cat_code ,
					code_original as cat_code_original,
					section_code as cat_section_code,
					section_id as cat_section_id,
					section_texte as cat_section_texte,
					texte as cat_texte,
					texte_court as cat_texte_court
				FROM 
					rh.t_categories_socio_professionnelle   
				ORDER BY code ";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = 1;
				$code = toHTML(trim($record['cat_code']));
				$code_original = toHTML(trim($record['cat_code_original']));
				$section_code = toHTML(trim($record['cat_section_code']));
				$section_id = toHTML(trim($record['cat_section_id']));
				$section_texte = toHTML(trim($record['cat_section_texte']));
				$texte = toHTML(trim($record['cat_texte']));
				$texte_court = toHTML(trim($record['cat_texte_court']));
				$nbref = 1;
				
				$httpString .= "\r\n<RECORD 
						oid=\"$oid\"
						code=\"$code\" 
						code_original=\"$code_original\" 
						section_code=\"$section_code\" 
						section_id=\"$section_id\" 
						section_texte=\"$section_texte\" 
						texte=\"$texte\" 
						texte_court=\"$texte_court\"  
						nbref=\"+$nbref\" 
						 />";
			}
		}
	}
	
	
	
	return $httpString;
}

function getRecords_codes_emploi() {

global $database;

	$httpString = "";

	$sqlcmd = "	SELECT 
					code as emp_code,
					code_original as emp_code_original,
					oid as emp_id,
					section_code as emp_section_code,
					section_id as emp_section_id,
					section_texte as emp_section_texte,
					texte as emp_texte,
					texte_court as emp_texte_court
				FROM rh.t_codes_emploi
				ORDER BY code ";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['emp_code']));
				$code_original = toHTML(trim($record['emp_code_original']));
				$oid = 1;
				$section_code = toHTML(trim($record['emp_section_code']));
				$section_id = toHTML(trim($record['emp_section_id']));
				$section_texte = toHTML(trim($record['emp_section_texte']));
                $texte = toHTML(trim($record['emp_texte']));
			    $texte_court = toHTML(trim($record['emp_texte_court']));
				$nbref = 1;
				
				$httpString .= "\r\n<RECORD
									
									code=\"$code\"
									code_original=\"$code_original\"
									oid=\"$oid\"
									section_code=\"$section_code\" 
									section_id=\"$section_id\" 
									section_texte=\"$section_texte\"  									
									texte=\"$texte\"
									texte_court=\"$texte_court\" 									
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function getRecords_entreprises() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "SELECT 
					code as ent_code,
					code_original as ent_code_original,
					oid as ent_id,
					planning_code as ent_planning_code,
					section_code as ent_section_code,
					section_id as ent_section_id,
					section_texte as ent_section_texte,
					texte as ent_texte,
					texte_court as ent_texte_court,
					subview.xmlnodes as xmlnodes  
				FROM rh.t_entreprises 
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['ent_code']));
				$code_original = toHTML(trim($record['ent_code_original']));
				$oid = $record['ent_id'];
				$planning_code = toHTML(trim($record['ent_planning_code']));
				$section_code = toHTML(trim($record['ent_section_code']));
				$section_id = toHTML(trim($record['ent_section_id']));
				$section_texte = toHTML(trim($record['ent_section_texte']));
				$texte = toHTML(trim($record['um_texte']));
				$texte_court = toHTML(trim($record['um_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\" 
									oid=\"$oid\" 
									planning_code=\"$planning_code\" 
									section_code=\"$section_code\" 
									section_id=\"$section_id\" 
									section_texte=\"$section_texte\" 
									texte=\"$texte\" 
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" >
									>
										$xmlHISTO
									\r\n</RECORD>";
			}
		}
	}
	
	
	return $httpString;
}

function getRecords_etablissements() {

global $database;

	$httpString = "";
	
	$sqlcmd = "	SELECT 
					base_calcul_etp as etb_base_calcul_etp,
					code as etb_code,
					code_original as etb_code_original,
					entreprise_id as etb_entreprise_id,
					mode_calcul_etp_paye as etb_mode_calcul_etp_paye, 
					oid as etb_id,
					planning_code as etb_planning_code,
					section_code as etb_section_code,
					section_id as etb_section_id,
					section_texte as etb_section_texte,
					texte as etb_texte,
					texte_court as etb_texte_court,
					subview.xmlnodes as xmlnodes
				FROM rh.t_etablissements 		
				WHERE oid > 0  
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();

			if ($record != FALSE) {
				$ok = TRUE;

				$base_calcul_etp = toHTML(trim($record['etb_base_calcul_etp']));
				$code = toHTML(trim($record['etb_code']));
				$code_original = toHTML(trim($record['etb_code_original']));
				$entreprise_id = toHTML(trim($record['etb_entreprise_id']));
				$mode_calcul_etp_paye = toHTML(trim($record['etb_mode_calcul_etp_paye']));
				$oid = $record['etb_id'];
				$planning_code = toHTML(trim($record['etb_planning_code']));
				$section_code = toHTML(trim($record['etb_section_code']));
				$section_id = toHTML(trim($record['etb_section_id']));
				$section_texte = toHTML(trim($record['etb_section_texte']));
				$texte = toHTML(trim($record['etb_texte']));
				$texte_court = toHTML(trim($record['etb_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
				$httpString .=  
					"\r\n<RECORD 
							base_calcul_etp=\"$base_calcul_etp\"
							code=\"$code\" 
							code_original=\"$code_original\" 
							entreprise_id=\"$entreprise_id\" 
							mode_calcul_etp_paye=\"$mode_calcul_etp_paye\" 
							oid=\"$oid\" 
							planning_code=\"$planning_code\" 
							section_code=\"$section_code\" 
							section_id=\"$section_id\" 
							section_texte=\"$section_texte\" 
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							 >
							$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_grilles() {

global $database;

	$httpString = "";
	
	$sqlcmd = "	SELECT 
					code as gri_code,
					code_original as gri_code_original,
					oid as gri_id,
					section_code as gri_section_code,
					section_id as gri_section_id,
					section_texte as gri_section_texte,
					texte as gri_texte,
					texte_court as gri_texte_court
				FROM rh.t_grilles		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['gri_code']));
				$code_original = toHTML(trim($record['gri_code_original']));
				$oid = floatval($record['gri_id']);
				$section_code = toHTML(trim($record['gri_section_code']));
				$section_id = toHTML(trim($record['gri_section_id']));
				$section_texte = toHTML(trim($record['gri_section_texte']));
				$texte = toHTML(trim($record['gri_texte']));
				$texte_court = toHTML(trim($record['gri_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_grilles_groupes() {

global $database;

	$httpString = "";
	$sqlcmd = "	SELECT 
					code as gri_gro_code,
					code_original as gri_gro_code_original,
					oid as gri_gro_id,
					section_code as gri_gro_section_code,
					section_id as gri_gro_section_id,
					section_texte as gri_gro_section_texte,
					texte as gri_gro_texte,
					texte_court as gri_gro_texte_court
				FROM rh.t_grilles_groupes		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['gri_gro_code']));
				$code_original = toHTML(trim($record['gri_gro_code_original']));
				$oid = floatval($record['gri_gro_id']);
				$section_code = toHTML(trim($record['gri_gro_section_code']));
				$section_id = toHTML(trim($record['gri_gro_section_id']));
				$section_texte = toHTML(trim($record['gri_gro_section_texte']));
				$texte = toHTML(trim($record['gri_gro_texte']));
				$texte_court = toHTML(trim($record['gri_gro_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_groupes_cotisant() {

global $database;

	$httpString = "";

	$sqlcmd = "SELECT 
				
					code as gro_cot_code,
					code_original as gro_cot_code_original,
					oid as gro_cot_id,
					section_code as gro_cot_section_code,
					section_id as gro_cot_section_id,
					section_texte as gro_cot_section_texte,
					texte as gro_cot_texte,
					texte_court as gro_cot_texte_court
				FROM rh.t_groupes_cotisant		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['gro_cot_code']));
				$code_original = toHTML(trim($record['gro_cot_code_original']));
				$oid = floatval($record['gro_cot_id']);
				$section_code = toHTML(trim($record['gro_cot_section_code']));
				$section_id = toHTML(trim($record['gro_cot_section_id']));
				$section_texte = toHTML(trim($record['gro_cot_section_texte']));
				$texte = toHTML(trim($record['gro_cot_texte']));
				$texte_court = toHTML(trim($record['gro_cot_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_motifs_arret() {

global $database;

	$httpString = "";

	$sqlcmd = "
			SELECT
					code as arr_code,
					code_original as arr_code_original,
					oid as arr_id,
					rang_edition as arr_rang_edition,
					section_code as arr_section_code,
					section_id as arr_section_id,
					section_texte as arr_section_texte,
					texte as arr_texte,
					texte_court as arr_texte_court
				FROM rh.t_motifs_arret		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['arr_code']));
				$code_original = toHTML(trim($record['arr_code_original']));
				$oid = floatval($record['arr_id']);
				$rang_edition = toHTML(trim($record['arr_rang_edition']));
				$section_code = toHTML(trim($record['arr_section_code']));
				$section_id = toHTML(trim($record['arr_section_id']));
				$section_texte = toHTML(trim($record['arr_section_texte']));
				$texte = toHTML(trim($record['arr_texte']));
				$texte_court = toHTML(trim($record['arr_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							rang_edition=\"$rang_edition\"
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_motifs_debut_contrat() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "	SELECT
					code as mot_deb_code,
					code_original as mot_deb_code_original,
					oid as mot_deb_id,
					section_code as mot_deb_section_code,
					section_id as mot_deb_section_id,
					section_texte as mot_deb_section_texte,
					texte as mot_deb_texte,
					texte_court as mot_deb_texte_court
				FROM rh.t_motifs_debut_contrat		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['mot_deb_code']));
				$code_original = toHTML(trim($record['mot_deb_code_original']));
				$oid = floatval($record['mot_deb_id']);
				$rang_edition = toHTML(trim($record['mot_deb_rang_edition']));
				$section_code = toHTML(trim($record['mot_deb_section_code']));
				$section_id = toHTML(trim($record['mot_deb_section_id']));
				$section_texte = toHTML(trim($record['mot_deb_section_texte']));
				$texte = toHTML(trim($record['mot_deb_texte']));
				$texte_court = toHTML(trim($record['mot_deb_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_motifs_fin_contrat() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "SELECT
					code as mot_fin_code,
					code_original as mot_fin_code_original,
					oid as mot_fin_id,
					section_code as mot_fin_section_code,
					section_id as mot_fin_section_id,
					section_texte as mot_fin_section_texte,
					texte as mot_fin_texte,
					texte_court as mot_fin_texte_court
				FROM rh.t_motifs_fin_contrat		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['mot_fin_code']));
				$code_original = toHTML(trim($record['mot_fin_code_original']));
				$oid = floatval($record['mot_fin_id']);
				$section_code = toHTML(trim($record['mot_fin_section_code']));
				$section_id = toHTML(trim($record['mot_fin_section_id']));
				$section_texte = toHTML(trim($record['mot_fin_section_texte']));
				$texte = toHTML(trim($record['mot_fin_texte']));
				$texte_court = toHTML(trim($record['mot_fin_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_nationalites() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "	SELECT 
					code as nat_code,
					code_original as nat_code_original,
					oid as nat_id,
					section_code as nat_section_code,
					section_id as nat_section_id,
					section_texte as nat_section_texte,
					texte as nat_texte,
					texte_court as nat_texte_court
				FROM rh.t_nationalites		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['nat_code']));
				$code_original = toHTML(trim($record['nat_code_original']));
				$oid = floatval($record['nat_id']);
				$section_code = toHTML(trim($record['nat_section_code']));
				$section_id = toHTML(trim($record['nat_section_id']));
				$section_texte = toHTML(trim($record['nat_section_texte']));
				$texte = toHTML(trim($record['nat_texte']));
				$texte_court = toHTML(trim($record['nat_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_organismes_cotisation() {

global $database;

	$httpString = "";

	$httpString_tmp = "";
	
	$sqlcmd = "	SELECT 
					code as org_code,
					code_original as org_code_original,
					oid as org_id,
					section_code as org_section_code,
					section_id as org_section_id,
					section_texte as org_section_texte,
					texte as org_texte,
					texte_court as org_texte_court
				FROM rh.t_organismes_cotisation		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['org_code']));
				$code_original = toHTML(trim($record['org_code_original']));
				$oid = floatval($record['org_id']);
				$section_code = toHTML(trim($record['org_section_code']));
				$section_id = toHTML(trim($record['org_section_id']));
				$section_texte = toHTML(trim($record['org_section_texte']));
				$texte = toHTML(trim($record['org_texte']));
				$texte_court = toHTML(trim($record['org_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\" 
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_precisions_motif_arret() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "	SELECT 
					code as pre_mot_code,
					code_original as pre_mot_code_original,
					oid as pre_mot_id,
					rang_edition as pre_mot_rang_edition,
					section_code as pre_mot_section_code,
					section_id as pre_mot_section_id,
					section_texte as pre_mot_section_texte,
					texte as pre_mot_texte,
					texte_court as pre_mot_texte_court
				FROM rh.t_precisions_motif_arret		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['pre_mot_code']));
				$code_original = toHTML(trim($record['pre_mot_code_original']));
				$oid = floatval($record['pre_mot_id']);
				$rang_edition = toHTML(trim($record['pre_mot_rang_edition']));
				$section_code = toHTML(trim($record['pre_mot_section_code']));
				$section_id = toHTML(trim($record['pre_mot_section_id']));
				$section_texte = toHTML(trim($record['pre_mot_section_texte']));
				$texte = toHTML(trim($record['pre_mot_texte']));
				$texte_court = toHTML(trim($record['pre_mot_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\"
							rang_edition=\"$rang_edition\"
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_qualifications() {

global $database;
	
	$httpString = "";
	
	$httpString_tmp = "";
	
	$sqlcmd = "		SELECT 
					code as qua_code,
					code_original as qua_code_original,
					oid as qua_id,
					section_code as qua_section_code,
					section_id as qua_section_id,
					section_texte as qua_section_texte,
					texte as qua_texte,
					texte_court as qua_texte_court
				FROM rh.t_qualifications		
				ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecord();
										

			if ($record != FALSE) {
				$ok = TRUE;

				
				$code = toHTML(trim($record['qua_code']));
				$code_original = toHTML(trim($record['qua_code_original']));
				$oid = floatval($record['qua_id']);
				$section_code = toHTML(trim($record['qua_section_code']));
				$section_id = toHTML(trim($record['qua_section_id']));
				$section_texte = toHTML(trim($record['qua_section_texte']));
				$texte = toHTML(trim($record['qua_texte']));
				$texte_court = toHTML(trim($record['qua_texte_court']));
				$xmlHISTO = trim($record['xmlnodes']);
				$nbref = 0;
				
			
				
				$httpString .= 
					"\r\n<RECORD 
							
							code=\"$code\"
							code_original=\"$code_original\"
							oid=\"$oid\"
							section_code=\"$section_code\"
							section_id=\"$section_id\"  
							section_texte=\"$section_texte\" 							
							texte=\"$texte\" 
							texte_court=\"$texte_court\" 
							nbref=\"+$nbref\" 
							>
						$xmlHISTO
						\r\n</RECORD>";
			}
		}
	}
	return $httpString;
}

function getRecords_rubriques() {

global $database;
	
	$httpString = "";
	
	$httpString_tmp = "";
	
	$sqlcmd = "	SELECT 
					c_avantage_nature as rub_c_avantage_nature,
					c_base as rub_c_base,
					c_brut as rub_c_brut,
					c_cotisation_patronale as rub_c_cotisation_patronale,
					c_cotisation_salarie as rub_c_cotisation_salarie,
					c_frais_imposables as rub_c_frais_imposables,
					c_heures_payees as rub_c_heures_payees,
					c_heures_travaillees as rub_c_heures_travaillees,
					c_masse_salariale as rub_c_masse_salariale,
					c_net_a_payer as rub_c_net_a_payer,
					c_net_imposable as rub_c_net_imposable,
					c_nombre as rub_c_nombre,
					c_od_net_patronale as rub_c_od_net_patronale,
					c_od_net_salarie as rub_c_od_net_salarie,
					chapitre_bulletin as rub_chapitre bulletin,
					code as rub_code,
					code_calcul as rub_code_calcul,
					code_original as rub_code_original,
					coefficient as rub_coefficient,
					coefficient_base as rub_coefficient_base,
					coefficient_nombre as rub_coefficient_nombre,
					coefficient_txp as rub_coefficient_txp,
					coefficient_txs as rub_coefficient_txs,
					heures_payees as rub_heures_payees, 
					oid as rub_id,
					CASE WHEN p_avantage_nature THEN 1 ELSE 0 END AS rub_p_avantage_nature,
					CASE WHEN p_base THEN 1 ELSE 0 END AS rub_p_base,
					CASE WHEN p_brut THEN 1 ELSE 0 END AS rub_p_brut,
					CASE WHEN p_cotisation_patronale THEN 1 ELSE 0 END AS rub_p_cotisation_patronale,
					CASE WHEN p_cotisation_salarie THEN 1 ELSE 0 END AS rub_p_cotisation_salarie,
					CASE WHEN p_cumul THEN 1 ELSE 0 END AS rub_p_cumul,
					CASE WHEN p_detail THEN 1 ELSE 0 END AS rub_p_detail,
					CASE WHEN p_frais_imposables THEN 1 ELSE 0 END AS rub_p_frais_imposables,
					CASE WHEN p_heures_payees THEN 1 ELSE 0 END AS rub_p_heures_payees,
					CASE WHEN p_heures_travaillees THEN 1 ELSE 0 END AS rub_p_heures_travaillees,
					CASE WHEN p_masse_salariale THEN 1 ELSE 0 END AS rub_p_masse_salariale,
					CASE WHEN p_net_a_payer THEN 1 ELSE 0 END AS rub_p_net_a_payer,
					CASE WHEN p_net_imposable THEN 1 ELSE 0 END AS rub_p_net_imposable,
					CASE WHEN p_nombre THEN 1 ELSE 0 END AS rub_p_nombre,
					CASE WHEN p_od_net_patronale THEN 1 ELSE 0 END AS rub_p_od_net_patronale,
					CASE WHEN p_od_net_salarie THEN 1 ELSE 0 END AS rub_p_od_net_salarie,
					rang_edition as rub_rang_edition,
					s_avantage_nature as rub_s_avantage_nature,
					s_base as rub_s_base,
					s_brut as rub_s_brut,
					s_cotisation_patronale as rub_s_cotisation_patronale,
					s_cotisation_salarie as rub_s_cotisation_salarie,
					s_frais_imposables as rub_s_frais_imposables,
					s_heures_payees as rub_s_heures_payees,
					s_heures_travaillees as rub_heures_travaillees,
					s_masse_salariale as rub_s_masse_salariale,
					s_net_a_payer as rub_s_net_a_payer,
					s_net_imposable as rub_s_net_imposable,
					s_nombre as rub_s_nombre,
					s_od_net_patronale as rub_s_od_net_patronale,
					s_od_net_salarie as rub_s_od_net_salarie,
					section_code as rub_section_code,
					section_id as rub_section_id,
					section_texte as rub_section_texte,
					texte as rub_texte,
					texte_court as rub_texte_court,
					unite as rub_unite, 
					CASE WHEN user_modified THEN 1 ELSE 0 END AS rub_user_modified
				FROM 
					rh.t_rubriques 
				ORDER BY code";
				
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$c_avantage_nature=toHTML(trim($record['c_avantage_nature']));
				$c_base=toHTML(trim($record['c_base']));
				$c_brut=toHTML(trim($record['c_brut']));
				$c_cotisation_patronale=toHTML(trim($record['c_cotisation_patronale']));
				$c_cotisation_salarie=toHTML(trim($record['c_cotisation_salarie']));
				$c_frais_imposables=toHTML(trim($record['c_frais_imposables']));
				$c_heures_payees=toHTML(trim($record['c_heures_payees']));
				$c_heures_travaillees=toHTML(trim($record['c_heures_travaillees']));
				$c_masse_salariale=toHTML(trim($record['c_masse_salariale']));
				$c_net_a_payer=toHTML(trim($record['c_net_a_payer']));
				$c_net_imposable=toHTML(trim($record['c_net_imposable']));
				$c_nombre=toHTML(trim($record['c_nombre']));
				$c_od_net_patronale=toHTML(trim($record['c_od_net_patronale']));
				$c_od_net_salarie=toHTML(trim($record['c_od_net_salarie']));
				$chapitre_bulletin=toHTML(trim($record['chapitre_bulletin']));
				$code=toHTML(trim($record['code']));
				$code_calcul=toHTML(trim($record['code_calcul']));
				$code_original=toHTML(trim($record['code_original']));
				$coefficient=toHTML(trim($record['coefficient']));
				$coefficient_base=toHTML(trim($record['coefficient_base']));
				$coefficient_nombre=toHTML(trim($record['coefficient_nombre']));
				$coefficient_txp=toHTML(trim($record['coefficient_txp']));
				$coefficient_txs=toHTML(trim($record['coefficient_txs']));
				$heures_payees=toHTML(trim($record['heures_payees']));
				$oid=toHTML(trim($record['oid']));
				$p_avantage_nature=toHTML(trim($record['p_avantage_nature']));
				$p_base=toHTML(trim($record['p_base']));
				$p_brut=toHTML(trim($record['p_brut']));
				$p_cotisation_patronale=toHTML(trim($record['p_cotisation_patronale']));
				$p_cotisation_salarie=toHTML(trim($record['p_cotisation_salarie']));
				$p_cumul=toHTML(trim($record['p_cumul']));
				$p_detail=toHTML(trim($record['p_detail']));
				$p_frais_imposables=toHTML(trim($record['p_frais_imposables']));
				$p_heures_payees=toHTML(trim($record['p_heures_payees']));
				$p_heures_travaillees=toHTML(trim($record['p_heures_travaillees']));
				$p_masse_salariale=toHTML(trim($record['p_masse_salariale']));
				$p_net_a_payer=toHTML(trim($record['p_net_a_payer']));
				$p_net_imposable=toHTML(trim($record['p_net_imposable']));
				$p_nombre=toHTML(trim($record['p_nombre']));
				$p_od_net_patronale=toHTML(trim($record['p_od_net_patronale']));
				$p_od_net_salarie=toHTML(trim($record['p_od_net_salarie']));
				$rang_edition=toHTML(trim($record['rang_edition']));
				$s_avantage_nature=toHTML(trim($record['s_avantage_nature']));
				$s_base=toHTML(trim($record['s_base']));
				$s_brut=toHTML(trim($record['s_brut']));
				$s_cotisation_patronale=toHTML(trim($record['s_cotisation_patronale']));
				$s_cotisation_salarie=toHTML(trim($record['s_cotisation_salarie']));
				$s_frais_imposables=toHTML(trim($record['s_frais_imposables']));
				$s_heures_payees=toHTML(trim($record['s_heures_payees']));
				$s_heures_travaillees=toHTML(trim($record['s_heures_travaillees']));
				$s_masse_salariale=toHTML(trim($record['s_masse_salariale']));
				$s_net_a_payer=toHTML(trim($record['s_net_a_payer']));
				$s_net_imposable=toHTML(trim($record['s_net_imposable']));
				$s_nombre=toHTML(trim($record['s_nombre']));
				$s_od_net_patronale=toHTML(trim($record['s_od_net_patronale']));
				$s_od_net_salarie=toHTML(trim($record['s_od_net_salarie']));
				$section_code=toHTML(trim($record['section_code']));
				$section_id=toHTML(trim($record['section_id']));
				$section_texte=toHTML(trim($record['section_texte']));
				$texte=toHTML(trim($record['texte']));
				$texte_court=toHTML(trim($record['texte_court']));
				$unite=toHTML(trim($record['unite']));
				$user_modified=toHTML(trim($record['user_modified']));
				$nbref = 0;
				
				
				$httpString_tmp .= "\r\n<RECORD 
										c_avantage_nature=\"$c_avantage_nature\" 
										c_base=\"$c_base\" 
										c_brut=\"$c_brut\" 
										c_cotisation_patronale=\"$c_cotisation_patronale\" 
										c_cotisation_salarie=\"$c_cotisation_salarie\" 
										c_frais_imposables=\"$c_frais_imposables\" 
										c_heures_payees=\"$c_heures_payees\" 
										c_heures_travaillees=\"$c_heures_travaillees\" 
										c_masse_salariale=\"$c_masse_salariale\" 
										c_net_a_payer=\"$c_net_a_payer\" 
										c_net_imposable=\"$c_net_imposable\" 
										c_nombre=\"$c_nombre\" 
										c_od_net_patronale=\"$c_od_net_patronale\" 
										c_od_net_salarie=\"$c_od_net_salarie\" 
										chapitre_bulletin=\"$chapitre_bulletin\" 
										code=\"$code\" 
										code_calcul=\"$code_calcul\" 
										code_original=\"$code_original\" 
										coefficient=\"$coefficient\" 
										coefficient_base=\"$coefficient_base\" 
										coefficient_nombre=\"$coefficient_nombre\" 
										coefficient_txp=\"$coefficient_txp\" 
										coefficient_txs=\"$coefficient_txs\" 
										heures_payees=\"$heures_payees\" 
										oid=\"$oid\" 
										p_avantage_nature=\"$p_avantage_nature\" 
										p_base=\"$p_base\" 
										p_brut=\"$p_brut\"
										p_cotisation_patronale=\"$p_cotisation_patronale\" 
										p_cotisation_salarie=\"$p_cotisation_salarie\" 
										p_cumul=\"$p_cumul\" 
										p_detail=\"$p_detail\" 
										p_frais_imposables=\"$p_frais_imposables\" 
										p_heures_payees=\"$p_heures_payees\" 
										p_heures_travaillees=\"$p_heures_travaillees\" 
										p_masse_salariale=\"$p_masse_salariale\" 
										p_net_a_payer=\"$p_net_a_payer\" 
										p_net_imposable=\"$p_net_imposable\" 
										p_nombre=\"$p_nombre\" 
										p_od_net_patronale=\"$p_od_net_patronale\" 
										p_od_net_salarie=\"$p_od_net_salarie\" 
										rang_edition=\"$rang_edition\" 
										s_avantage_nature=\"$s_avantage_nature\" 
										s_base=\"$s_base\" 
										s_brut=\"$s_brut\" 
										s_cotisation_patronale=\"$s_cotisation_patronale\" 
										s_cotisation_salarie=\"$s_cotisation_salarie\" 
										s_frais_imposables=\"$s_frais_imposables\" 
										s_heures_payees=\"$s_heures_payees\" 
										s_heures_travaillees=\"$s_heures_travaillees\" 
										s_masse_salariale=\"$s_masse_salariale\" 
										s_net_a_payer=\"$s_net_a_payer\" 
										s_net_imposable=\"$s_net_imposable\" 
										s_nombre=\"$s_nombre\" 
										s_od_net_patronale=\"$s_od_net_patronale\" 
										s_od_net_salarie=\"$s_od_net_salarie\" 
										section_code=\"$section_code\" 
										section_id=\"$section_id\" 
										section_texte=\"$section_texte\" 
										texte=\"$texte\" 
										texte_court=\"$texte_court\" 
										unite=\"$unite\" 
										user_modified=\"$user_modified\" 
										nbref=\"+$nbref\" />";
										
									
				
				
			}
		}
	}

	
	return $httpString;
}

function getRecords_sections_analytiques() {

global $database;
	
	$httpString = "";
	
	$sqlcmd = "	SELECT 
					code as sec_ana_code,
					code_original as sec_ana_code_original,
					oid as sec_ana_id,
					section_code as sec_ana_section_code,
					section_id as sec_ana_section_id,
					section_texte as sec_ana_section_texte,
					texte as sec_ana_texte,
					texte_court as sec_ana_texte_court
				FROM 
					rh.t_sections_analytiques 
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['sec_ana_code']));
				$code_original = toHTML(trim($record['sec_ana_code_original']));
				$oid = $record['sec_ana_id'];
				$section_code = toHTML(trim($record['sec_ana_section_code']));
				$section_id = toHTML(trim($record['sec_ana_section_id']));
				$section_texte = toHTML(trim($record['sec_ana_section_texte']));
				$texte = toHTML(trim($record['sec_ana_texte']));
				$texte_court = toHTML(trim($record['sec_ana_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function getRecords_sections_analytiques_paie() {

global $database;

	$httpString = "";
	
	$httpString_tmp = "";

	$sqlcmd = "	SELECT 
					code as sec_pai_code,
					code_original as sec_pai_code_original,
					oid as sec_pai_id,
					section_code as sec_pai_section_code,
					section_id as sec_pai_section_id,
					section_texte as sec_pai_section_texte,
					texte as sec_pai_texte,
					texte_court as sec_pai_texte_court
				FROM 
					rh.t_sections_analytiques_paie 
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['sec_pai_code']));
				$code_original = toHTML(trim($record['sec_pai_code_original']));
				$oid = $record['sec_pai_id'];
				$section_code = toHTML(trim($record['sec_pai_section_code']));
				$section_id = toHTML(trim($record['sec_pai_section_id']));
				$section_texte = toHTML(trim($record['sec_pai_section_texte']));
				$texte = toHTML(trim($record['sec_pai_texte']));
				$texte_court = toHTML(trim($record['sec_pai_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}
					


function getRecords_services() {

global $database;

	$httpString = "";

	$sqlcmd = "
			SELECT
					code as ser_code,
					code_original as ser_code_original,
					oid as ser_id,
					section_code as ser_section_code,
					section_id as ser_section_id,
					section_texte as ser_section_texte,
					texte as ser_texte,
					texte_court as ser_texte_court
				FROM 
					rh.t_services
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['ser_code']));
				$code_original = toHTML(trim($record['ser_code_original']));
				$oid = $record['ser_id'];
				$section_code = toHTML(trim($record['ser_section_code']));
				$section_id = toHTML(trim($record['ser_section_id']));
				$section_texte = toHTML(trim($record['ser_section_texte']));
				$texte = toHTML(trim($record['ser_texte']));
				$texte_court = toHTML(trim($record['ser_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}
				



function getRecords_situations_famille() {

global $database;

	$httpString = "";

	$sqlcmd = "
			SELECT
					code as sit_code,
					code_original as sit_code_original,
					oid as sit_id,
					section_code as sit_section_code,
					section_id as sit_section_id,
					section_texte as sit_section_texte,
					texte as sit_texte,
					texte_court as sit_texte_court
				FROM 
					rh.t_situations_famille
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['sit_code']));
				$code_original = toHTML(trim($record['sit_code_original']));
				$oid = $record['sit_id'];
				$section_code = toHTML(trim($record['sit_section_code']));
				$section_id = toHTML(trim($record['sit_section_id']));
				$section_texte = toHTML(trim($record['sit_section_texte']));
				$texte = toHTML(trim($record['sit_texte']));
				$texte_court = toHTML(trim($record['sit_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}
				

function getRecords_societes_interim() {

global $database;

	$httpString = "";

	$sqlcmd = "SELECT 
					code as soc_code,
					code_original as soc_code_original,
					oid as soc_id,
					section_code as soc_section_code,
					section_id as soc_section_id,
					section_texte as soc_section_texte,
					texte as soc_texte,
					texte_court as soc_texte_court
				FROM 
					rh.t_societes_interim
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['soc_code']));
				$code_original = toHTML(trim($record['soc_code_original']));
				$oid = $record['soc_id'];
				$section_code = toHTML(trim($record['soc_section_code']));
				$section_id = toHTML(trim($record['soc_section_id']));
				$section_texte = toHTML(trim($record['soc_section_texte']));
				$texte = toHTML(trim($record['soc_texte']));
				$texte_court = toHTML(trim($record['soc_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_specialites() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as spe_code,
					code_original as spe_code_original,
					oid as spe_id,
					section_code as spe_section_code,
					section_id as spe_section_id,
					section_texte as spe_section_texte,
					texte as spe_texte,
					texte_court as spe_texte_court
				FROM 
					rh.t_specialites
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['spe_code']));
				$code_original = toHTML(trim($record['spe_code_original']));
				$oid = $record['spe_id'];
				$section_code = toHTML(trim($record['spe_section_code']));
				$section_id = toHTML(trim($record['spe_section_id']));
				$section_texte = toHTML(trim($record['spe_section_texte']));
				$texte = toHTML(trim($record['spe_texte']));
				$texte_court = toHTML(trim($record['spe_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}
               


function getRecords_statuts() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as sta_code,
					code_original as sta_code_original,
					oid as sta_id,
					section_code as sta_section_code,
					section_id as sta_section_id,
					section_texte as sta_section_texte,
					texte as sta_texte,
					texte_court as sta_texte_court
				FROM 
					rh.t_statuts
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['sta_code']));
				$code_original = toHTML(trim($record['sta_code_original']));
				$oid = $record['sta_id'];
				$section_code = toHTML(trim($record['sta_section_code']));
				$section_id = toHTML(trim($record['sta_section_id']));
				$section_texte = toHTML(trim($record['sta_section_texte']));
				$texte = toHTML(trim($record['sta_texte']));
				$texte_court = toHTML(trim($record['sta_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}
               

function getRecords_types_contrat() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as typ_code,
					code_original as typ_code_original,
					oid as typ_id,
					section_code as typ_section_code,
					section_id as typ_section_id,
					section_texte as typ_section_texte,
					texte as typ_texte,
					texte_court as typ_texte_court
				FROM 
					rh.t_types_contrat
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['typ_code']));
				$code_original = toHTML(trim($record['typ_code_original']));
				$oid = $record['typ_id'];
				$section_code = toHTML(trim($record['typ_section_code']));
				$section_id = toHTML(trim($record['typ_section_id']));
				$section_texte = toHTML(trim($record['typ_section_texte']));
				$texte = toHTML(trim($record['typ_texte']));
				$texte_court = toHTML(trim($record['typ_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_types_horaire() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as typ_hor_code,
					code_original as typ_hor_code_original,
					oid as typ_hor_id,
					section_code as typ_hor_section_code,
					section_id as typ_hor_section_id,
					section_texte as typ_hor_section_texte,
					texte as typ_hor_texte,
					texte_court as typ_hor_texte_court
				FROM 
					rh.t_types_horaire
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['typ_hor_code']));
				$code_original = toHTML(trim($record['typ_hor_code_original']));
				$oid = $record['typ_hor_id'];
				$section_code = toHTML(trim($record['typ_hor_section_code']));
				$section_id = toHTML(trim($record['typ_hor_section_id']));
				$section_texte = toHTML(trim($record['typ_hor_section_texte']));
				$texte = toHTML(trim($record['typ_hor_texte']));
				$texte_court = toHTML(trim($record['typ_hor_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}



function getRecords_types_temps_travail() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as typ_tra_code,
					code_original as typ_tra_code_original,
					oid as typ_tra_id,
					section_code as typ_tra_section_code,
					section_id as typ_tra_section_id,
					section_texte as typ_tra_section_texte,
					texte as typ_tra_texte,
					texte_court as typ_tra_texte_court
				FROM 
					rh.t_types_temps_travail
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['typ_tra_code']));
				$code_original = toHTML(trim($record['typ_tra_code_original']));
				$oid = $record['typ_tra_id'];
				$section_code = toHTML(trim($record['typ_tra_section_code']));
				$section_id = toHTML(trim($record['typ_tra_section_id']));
				$section_texte = toHTML(trim($record['typ_tra_section_texte']));
				$texte = toHTML(trim($record['typ_tra_texte']));
				$texte_court = toHTML(trim($record['typ_tra_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_motifs_visite() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as mot_vis_code,
					code_original as mot_vis_code_original,
					oid as mot_vis_id,
					section_code as mot_vis_section_code,
					section_id as mot_vis_section_id,
					section_texte as mot_vis_section_texte,
					texte as mot_vis_texte,
					texte_court as mot_vis_texte_court
				FROM 
					rh.t_motifs_visite
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['mot_vis_code']));
				$code_original = toHTML(trim($record['mot_vis_code_original']));
				$oid = $record['mot_vis_id'];
				$section_code = toHTML(trim($record['mot_vis_section_code']));
				$section_id = toHTML(trim($record['mot_vis_section_id']));
				$section_texte = toHTML(trim($record['mot_vis_section_texte']));
				$texte = toHTML(trim($record['mot_vis_texte']));
				$texte_court = toHTML(trim($record['mot_vis_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_accident_circonstance() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as acc_cir_code,
					code_original as acc_cir_code_original,
					oid as acc_cir_id,
					section_code as acc_cir_section_code,
					section_id as acc_cir_section_id,
					section_texte as acc_cir_section_texte,
					texte as acc_cir_texte,
					texte_court as acc_cir_texte_court
				FROM 
					rh.t_accident_circonstance
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['acc_cir_code']));
				$code_original = toHTML(trim($record['acc_cir_code_original']));
				$oid = $record['acc_cir_id'];
				$section_code = toHTML(trim($record['acc_cir_section_code']));
				$section_id = toHTML(trim($record['acc_cir_section_id']));
				$section_texte = toHTML(trim($record['acc_cir_section_texte']));
				$texte = toHTML(trim($record['acc_cir_texte']));
				$texte_court = toHTML(trim($record['acc_cir_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_accident_lieu() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as acc_lieu_code,
					code_original as acc_lieu_code_original,
					oid as acc_lieu_id,
					section_code as acc_lieu_section_code,
					section_id as acc_lieu_section_id,
					section_texte as acc_lieu_section_texte,
					texte as acc_lieu_texte,
					texte_court as acc_lieu_texte_court
				FROM 
					rh.t_accident_lieu
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['acc_lieu_code']));
				$code_original = toHTML(trim($record['acc_lieu_code_original']));
				$oid = $record['acc_lieu_id'];
				$section_code = toHTML(trim($record['acc_lieu_section_code']));
				$section_id = toHTML(trim($record['acc_lieu_section_id']));
				$section_texte = toHTML(trim($record['acc_lieu_section_texte']));
				$texte = toHTML(trim($record['acc_lieu_texte']));
				$texte_court = toHTML(trim($record['acc_lieu_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_accident_nature() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as acc_nat_code,
					code_original as acc_nat_code_original,
					oid as acc_nat_id,
					section_code as acc_nat_section_code,
					section_id as acc_nat_section_id,
					section_texte as acc_nat_section_texte,
					texte as acc_nat_texte,
					texte_court as acc_nat_texte_court
				FROM 
					rh.t_accident_nature
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['acc_nat_code']));
				$code_original = toHTML(trim($record['acc_nat_code_original']));
				$oid = $record['acc_nat_id'];
				$section_code = toHTML(trim($record['acc_nat_section_code']));
				$section_id = toHTML(trim($record['acc_nat_section_id']));
				$section_texte = toHTML(trim($record['acc_nat_section_texte']));
				$texte = toHTML(trim($record['acc_nat_texte']));
				$texte_court = toHTML(trim($record['acc_nat_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_accident_siege() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as acc_sie_code,
					code_original as acc_sie_code_original,
					oid as acc_sie_id,
					section_code as acc_sie_section_code,
					section_id as acc_sie_section_id,
					section_texte as acc_sie_section_texte,
					texte as acc_sie_texte,
					texte_court as acc_sie_texte_court
				FROM 
					rh.t_accident_siege
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['acc_sie_code']));
				$code_original = toHTML(trim($record['acc_sie_code_original']));
				$oid = $record['acc_sie_id'];
				$section_code = toHTML(trim($record['acc_sie_section_code']));
				$section_id = toHTML(trim($record['acc_sie_section_id']));
				$section_texte = toHTML(trim($record['acc_sie_section_texte']));
				$texte = toHTML(trim($record['acc_sie_texte']));
				$texte_court = toHTML(trim($record['acc_sie_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_unites_fonctionnelle() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as uf_code,
					code_original as uf_code_original,
					oid as uf_id,
					section_code as uf_section_code,
					section_id as uf_section_id,
					section_texte as uf_section_texte,
					texte as uf_texte,
					texte_court as uf_texte_court
				FROM 
					rh.t_unite_fonctionnelle
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['uf_code']));
				$code_original = toHTML(trim($record['uf_code_original']));
				$oid = $record['uf_id'];
				$section_code = toHTML(trim($record['uf_section_code']));
				$section_id = toHTML(trim($record['uf_section_id']));
				$section_texte = toHTML(trim($record['uf_section_texte']));
				$texte = toHTML(trim($record['uf_texte']));
				$texte_court = toHTML(trim($record['uf_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}



function getRecords_lettre_budgetaire() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as bud_code,
					code_original as bud_code_original,
					oid as bud_id,
					section_code as bud_section_code,
					section_id as bud_section_id,
					section_texte as bud_section_texte,
					texte as bud_texte,
					texte_court as bud_texte_court
				FROM 
					rh.t_lettre_budgetaire
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['bud_code']));
				$code_original = toHTML(trim($record['bud_code_original']));
				$oid = $record['bud_id'];
				$section_code = toHTML(trim($record['bud_section_code']));
				$section_id = toHTML(trim($record['bud_section_id']));
				$section_texte = toHTML(trim($record['bud_section_texte']));
				$texte = toHTML(trim($record['bud_texte']));
				$texte_court = toHTML(trim($record['bud_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_commission_paritaire() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as com_code,
					code_original as com_code_original,
					oid as com_id,
					section_code as com_section_code,
					section_id as com_section_id,
					section_texte as com_section_texte,
					texte as com_texte,
					texte_court as com_texte_court
				FROM 
					rh.t_commission_paritaire
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['com_code']));
				$code_original = toHTML(trim($record['com_code_original']));
				$oid = $record['com_id'];
				$section_code = toHTML(trim($record['com_section_code']));
				$section_id = toHTML(trim($record['com_section_id']));
				$section_texte = toHTML(trim($record['com_section_texte']));
				$texte = toHTML(trim($record['com_texte']));
				$texte_court = toHTML(trim($record['com_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}



function getRecords_categorie_conge() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as con_code,
					code_original as con_code_original,
					oid as con_id,
					section_code as con_section_code,
					section_id as con_section_id,
					section_texte as con_section_texte,
					texte as con_texte,
					texte_court as con_texte_court
				FROM 
					rh.t_categorie_conge
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['con_code']));
				$code_original = toHTML(trim($record['con_code_original']));
				$oid = $record['con_id'];
				$section_code = toHTML(trim($record['con_section_code']));
				$section_id = toHTML(trim($record['con_section_id']));
				$section_texte = toHTML(trim($record['con_section_texte']));
				$texte = toHTML(trim($record['con_texte']));
				$texte_court = toHTML(trim($record['con_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_cadre_emploi() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as cad_emp_code,
					code_original as cad_emp_code_original,
					oid as cad_emp_id,
					section_code as cad_emp_section_code,
					section_id as cad_emp_section_id,
					section_texte as cad_emp_section_texte,
					texte as cad_emp_texte,
					texte_court as cad_emp_texte_court
				FROM 
					rh.t_cadre_emploi
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['cad_emp_code']));
				$code_original = toHTML(trim($record['cad_emp_code_original']));
				$oid = $record['cad_emp_id'];
				$section_code = toHTML(trim($record['cad_emp_section_code']));
				$section_id = toHTML(trim($record['cad_emp_section_id']));
				$section_texte = toHTML(trim($record['cad_emp_section_texte']));
				$texte = toHTML(trim($record['cad_emp_texte']));
				$texte_court = toHTML(trim($record['cad_emp_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_filiere() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as fil_code,
					code_original as fil_code_original,
					oid as fil_id,
					section_code as fil_section_code,
					section_id as fil_section_id,
					section_texte as fil_section_texte,
					texte as fil_texte,
					texte_court as fil_texte_court
				FROM 
					rh.t_filiere
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['fil_code']));
				$code_original = toHTML(trim($record['fil_code_original']));
				$oid = $record['fil_id'];
				$section_code = toHTML(trim($record['fil_section_code']));
				$section_id = toHTML(trim($record['fil_section_id']));
				$section_texte = toHTML(trim($record['fil_section_texte']));
				$texte = toHTML(trim($record['fil_texte']));
				$texte_court = toHTML(trim($record['fil_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_categorie_statutaire() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as cat_sta_code,
					code_original as cat_sta_code_original,
					oid as cat_sta_id,
					section_code as cat_sta_section_code,
					section_id as cat_sta_section_id,
					section_texte as cat_sta_section_texte,
					texte as cat_sta_texte,
					texte_court as cat_sta_texte_court
				FROM 
					rh.t_categorie_statutaire
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['cat_sta_code']));
				$code_original = toHTML(trim($record['cat_sta_code_original']));
				$oid = $record['cat_sta_id'];
				$section_code = toHTML(trim($record['cat_sta_section_code']));
				$section_id = toHTML(trim($record['cat_sta_section_id']));
				$section_texte = toHTML(trim($record['cat_sta_section_texte']));
				$texte = toHTML(trim($record['cat_sta_texte']));
				$texte_court = toHTML(trim($record['cat_sta_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}



function getRecords_compte() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as cpt_code,
					code_original as cpt_code_original,
					oid as cpt_id,
					section_code as cpt_section_code,
					section_id as cpt_section_id,
					section_texte as cpt_section_texte,
					texte as cpt_texte,
					texte_court as cpt_texte_court
				FROM 
					rh.t_compte
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['cpt_code']));
				$code_original = toHTML(trim($record['cpt_code_original']));
				$oid = $record['cpt_id'];
				$section_code = toHTML(trim($record['cpt_section_code']));
				$section_id = toHTML(trim($record['cpt_section_id']));
				$section_texte = toHTML(trim($record['cpt_section_texte']));
				$texte = toHTML(trim($record['cpt_texte']));
				$texte_court = toHTML(trim($record['cpt_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}



function getCombo_compte() {

global $database;

	$httpString = "";

	
	$httpString = $httpString . "\r\n<COMBO_CPT>";
	
	$httpString = $httpString . "\r\n<RECORD oid=\"0\" texte=\"\"  />";

	$sqlcmd = "SELECT oid, code || ' ' || texte FROM rh.t_compte WHERE oid > 0 ORDER BY code";
	$result = $database->exec($sqlcmd);
				
	if ($result != false) {
	
		// lignes 
		$ok = TRUE;

		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordInto();
										

			if ($record != FALSE) {
				$ok = TRUE;

				$oid = $record[0];
				$texte = toHTML(trim($record[1]));
			
				$httpString = $httpString . "\r\n<RECORD oid=\"$oid\" texte=\"$texte\"  />";

			}
		}

	
	}

	$httpString = $httpString . "\r\n</COMBO_CPT>";
	
	return $httpString;
	
	

}


function getRecords_transformation() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
				date_debut as tra_date_debut,
				date_fin as tra_date_fin,
				from_qualification_id as tra_from_qualification_id,
				from_service_id as tra_from_service_id,
				oid as tra_id),
				salarie_id as tra_salarie_id,
				texte as tra_texte,
				to_qualification_id as tra_to_qualification_id,
				to_service_id as tra_to_service_id	
				FROM 
					rh.t_transformation
				";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$date_debut = toHTML(trim($record['tra_date_debut']));
				$date_fin = toHTML(trim($record['tra_date_fin']));
				$from_qualification_id = toHTML(trim($record['tra_from_qualification_id']));
				$from_service_id = toHTML(trim($record['tra_from_service_id']));
				$oid = $record['tra_id'];
				$salarie_id = toHTML(trim($record['tra_salarie_id']));				
				$texte = toHTML(trim($record['tra_texte']));	
				$to_qualification_id = toHTML(trim($record['tra_to_qualification_id']));
				$to_service_id = toHTML(trim($record['tra_to_service_id']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									date_debut=\"$date_debut\" 
									date_fin=\"$date_fin\"
									from_qualification_id=\"$from_qualification_id\" 
									from_service_id=\"$from_service_id\"
									oid=\"$oid\"
									salarie_id=\"$salarie_id\"
									texte=\"$texte\"									
									to_qualification_id=\"$to_qualification_id\" 
									to_service_id=\"$to_service_id\"
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function getCombo_transformation(){

    $httpString = "";

    $httpString_sa = "\r\n<COMBO_SAL>";
    $httpString_sa .= "\r\n<RECORD oid=\"-1\" texte=\"Tous les salari�s\" />";
    $sqlcmd = "SELECT oid, nom || ' ' || prenom || ' ('::text || matricule || ')'::text AS texte FROM rh.p_salaries WHERE oid >= 0 ORDER BY 2";
    $result = $db->exec($sqlcmd);
    if ($result != false) {
        $ok = TRUE;
        while ($ok == TRUE) {
            $ok = FALSE;
            $record = $db->nextRecordAssoc();
            if ($record != FALSE) {
                $ok = TRUE;
                $oid = $record["oid"];
                $texte = toHTML(trim($record["texte"]));
                $httpString_sa .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
            }
        }
    }
    $httpString_sa .= "\r\n</COMBO_SAL>";


    $httpString_fs = "\r\n<COMBO_FROMSER>";
    $httpString_fs .= "\r\n<RECORD oid=\"-1\" texte=\"Tous les services\" />";
    $httpString_ts = "\r\n<COMBO_TOSER>";
    $httpString_ts .= "\r\n<RECORD oid=\"-1\" texte=\"Pas de changement\" />";
    $sqlcmd = "SELECT oid, texte || ' ('::text || code || ')'::text AS texte FROM rh.t_services WHERE oid >= 0 ORDER BY 2";
    $result = $db->exec($sqlcmd);
    if ($result != false) {
        $ok = TRUE;
        while ($ok == TRUE) {
            $ok = FALSE;
            $record = $db->nextRecordAssoc();
            if ($record != FALSE) {
                $ok = TRUE;
                $oid = $record["oid"];
                $texte = toHTML(trim($record["texte"]));
                $httpString_fs .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
                $httpString_ts .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
            }
        }
    }
    $httpString_fs .= "\r\n</COMBO_FROMSER>";
    $httpString_ts .= "\r\n</COMBO_TOSER>";

    $httpString_fq = "\r\n<COMBO_FROMQUA>";
    $httpString_fq .= "\r\n<RECORD oid=\"-1\" texte=\"Tous les qualifications\" />";
    $httpString_tq = "\r\n<COMBO_TOQUA>";
    $httpString_tq .= "\r\n<RECORD oid=\"-1\" texte=\"Pas de changement\" />";
    $sqlcmd = "SELECT oid, texte || ' ('::text || code || ')'::text AS texte FROM rh.t_qualifications WHERE oid >= 0 ORDER BY 2";
    $result = $db->exec($sqlcmd);
    if ($result != false) {
        $ok = TRUE;
        while ($ok == TRUE) {
            $ok = FALSE;
            $record = $db->nextRecordAssoc();
            if ($record != FALSE) {
                $ok = TRUE;
                $oid = $record["oid"];
                $texte = toHTML(trim($record["texte"]));
                $httpString_fq .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
                $httpString_tq .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
            }
        }
    }
    $httpString_fq .= "\r\n</COMBO_FROMQUA>";
    $httpString_tq .= "\r\n</COMBO_TOQUA>";

    $httpString_fd = "\r\n<COMBO_FROMDAT>";
    $httpString_fd .= "\r\n<RECORD oid=\"0001-01-01\" texte=\"Depuis le d�but\" />";
    $httpString_td = "\r\n<COMBO_TODAT>";
    $httpString_td .= "\r\n<RECORD oid=\"2099-12-31\" texte=\"Jusqu'� la fin\" />";
    $sqlcmd = "SELECT p_calendrier_annee.date_debut, p_calendrier_annee.date_fin, p_calendrier_annee.texte
				FROM rh.p_chiffrier_production 
					JOIN base.p_calendrier_mois ON (p_chiffrier_production.mois = p_calendrier_mois.mois)
					JOIN base.p_calendrier_mois p_calendrier_annee ON (p_calendrier_annee.annee = p_calendrier_mois.annee)
				GROUP BY 1,2,3
				ORDER BY 1 DESC";
    $result = $db->exec($sqlcmd);
    if ($result != false) {
        $ok = TRUE;
        while ($ok == TRUE) {
            $ok = FALSE;
            $record = $db->nextRecordAssoc();
            if ($record != FALSE) {
                $ok = TRUE;
                $date_debut = $record["date_debut"];
                $date_fin = $record["date_fin"];
                $texte = toHTML(trim($record["texte"]));
                $httpString_fd .= "\r\n<RECORD oid=\"$date_debut\" texte=\"$texte\" />";
                $httpString_td .= "\r\n<RECORD oid=\"$date_fin\" texte=\"$texte\" />";
            }
        }
    }
    $httpString_fd .= "\r\n</COMBO_FROMDAT>";
    $httpString_td .= "\r\n</COMBO_TODAT>";



    return $httpString_sa.$httpString_fs.$httpString_ts.$httpString_fq.$httpString_tq.$httpString_fd.$httpString_td;
}


function getRecords_expert_controle() {

global $database;
	
	$httpString = "";
	$httpString_tmp = "";
	
	// Activation module EXPERT
	$sqlcmd = "
	INSERT INTO rh.t_divers (code, texte, valeur, description)
	SELECT
		'EXPERT_ACTIVE',
		'Module EXPERT activ�',
		'0',
		'1=Activ�'
	WHERE 'EXPERT_ACTIVE' NOT IN (SELECT code FROM rh.t_divers);
	INSERT INTO rh.t_divers (code, texte, valeur, description, valeur_date)
	SELECT
		'EXPERT_DATE_DEBUT',
		'Date données à contrôler',
		'20130101',
		'Date de début des données à contrôler',
		'20130101'
	WHERE 'EXPERT_DATE_DEBUT' NOT IN (SELECT code FROM rh.t_divers);";
	$result = $database->exec($sqlcmd);
	
	// Correction données antérieures
	$sqlcmd = "UPDATE rh.t_expert_controle_rule 
		SET numero = 1 
		WHERE numero NOT IN (1,2,3) OR numero IS NULL;
		
		UPDATE rh.t_expert_controle
		SET gravite_id = 5
		WHERE gravite_id NOT IN (0,5,9) OR gravite_id IS NULL;";
		
	$result = $database->exec($sqlcmd);
	
	// Paramétres généraux
	$EXPERT_ACTIVE = "0";
	$EXPERT_DATE_DEBUT = "2013-01-01";
	
	$sqlcmd = "SELECT code, valeur, to_char(valeur_date,'DD/MM/YYYY')
			FROM rh.t_divers
			WHERE code LIKE 'EXPERT%'";
	$result = $database->exec($sqlcmd);
	if ($result != false) {
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecordInto();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				switch(trim($record[0])) {
					case "EXPERT_ACTIVE" :
						$EXPERT_ACTIVE = trim($record[1]);
						break;
					case "EXPERT_DATE_DEBUT" :
						$EXPERT_DATE_DEBUT = trim($record[2]);
						break;
				}
			}
		}
	}
	
	// Chargement des Prestataires RH
	$sqlcmd = "
			(SELECT 
				-1 as oid, 
				'Tous'::text as texte, 
				0 as tri
			UNION
			SELECT 
				oid, 
				texte, 
				1 as tri 
			FROM base.t_prestataires
			WHERE 'rh' =  ANY (modules) 
			)
			ORDER BY tri,texte";
	$result = $database->exec($sqlcmd);
	
	if ($result !== false) {	
	
		while ($row = pg_fetch_array($result)) {
		
			$oid = $row['oid'];
			$texte = $row['texte'];
			
			$httpString .= "<PRESTATAIRE data=\"$oid\" label=\"$texte\" />" . PHP_EOL; 
		}
	}
	
	$httpString_tmp .= "<GENERAL_SETTINGS 
						EXPERT_ACTIVE=\"$EXPERT_ACTIVE\" 
						EXPERT_DATE_DEBUT=\"$EXPERT_DATE_DEBUT\" 
						/>";
	
	// Liste des controles
	$sqlcmd = "SELECT 
				t_expert_controle.oid as controle_id, 
				t_expert_controle.code as controle_code, 
				t_expert_controle.texte as controle_texte, 
				COALESCE(t_expert_controle.texte_court,t_expert_controle.texte) as controle_texte_court, 
				COALESCE(t_expert_controle.texte_court,t_expert_controle.texte,t_expert_controle.texte_abrege) as controle_texte_abrege, 
				t_expert_controle.description as controle_description,
				t_expert_controle.is_cti as controle_is_cti,
				t_expert_controle.is_hide as controle_is_hide,
				t_expert_controle.gravite_id as controle_gravite,
				t_expert_controle.prestataire_id,
				t_expert_controle.is_active as controle_is_active,
				COALESCE(t_prestataires.texte, 'Tous') as prestataire_texte,
				COALESCE(t_expert_controle_rule_1.oid,0) as rule1_oid,
				COALESCE(t_expert_controle_rule_1.sqlcmd_where) as rule1_sqlcmd_where,
				COALESCE(t_expert_controle_rule_1.sqlcmd_justificatif) as rule1_sqlcmd_justificatif,
				COALESCE(TO_CHAR(t_expert_controle_rule_1.last_execution_date,'DD/MM/YYYY'),'') as rule1_last_execution_date,
				COALESCE(t_expert_controle_rule_1.last_execution_ok) as rule1_last_execution_ok,
				COALESCE(t_expert_controle_rule_1.table_id,0) as rule1_table_id,
				COALESCE(subview.nbref, 0) as nb_ref,
				COALESCE(t_expert_controle.alert_exp,'0') as is_alert				
			FROM rh.t_expert_controle  
				LEFT JOIN base.t_prestataires ON t_prestataires.oid = t_expert_controle.prestataire_id
				LEFT JOIN rh.t_expert_controle_rule t_expert_controle_rule_1 ON t_expert_controle_rule_1.controle_id = t_expert_controle.oid AND t_expert_controle_rule_1.numero = 1
				LEFT JOIN (SELECT controle_id, count(*) AS nbref FROM rh.p_expert_controle GROUP BY 1) subview ON t_expert_controle.oid = subview.controle_id
			WHERE t_expert_controle.oid > 0 AND is_global <> 1
			ORDER BY t_expert_controle.code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
		
			$record = $database->nextRecordAssoc();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				$oid = $record['controle_id'];
				$code = toHTML(trim($record['controle_code']));
				$texte = toHTML(trim($record['controle_texte']));
				$texte_court = toHTML(trim($record['controle_texte_court']));
				$texte_abrege = toHTML(trim($record['controle_texte_abrege']));
				$description = toHTML(trim($record['controle_description']));
				$is_cti = toHTML(trim($record['controle_is_cti']));
				$is_active = toHTML(trim($record['controle_is_active']));
				$is_hide = toHTML(trim($record['controle_is_hide']));
				$gravite = floatval(trim($record['controle_gravite']));
				$rule_oid1 = floatval(trim($record['rule1_oid']));
				$sqlcmd_where1 = toHTML(trim($record['rule1_sqlcmd_where']));
				$sqlcmd_justificatif1 = toHTML(trim($record['rule1_sqlcmd_justificatif']));
				$table1 = floatval(trim($record['rule1_table_id']));
				$nbref = floatval(trim($record['nb_ref']));
				$last_execution_date = trim($record['rule1_last_execution_date']);
				$last_execution_ok = floatval(trim($record['rule1_last_execution_ok']));
				$prestataire_id = floatval(trim($record['prestataire_id']));
				$prestataire_texte = toHTML(trim($record['prestataire_texte']));
				$is_alert = toHTML(trim($record['is_alert']));
				
				if ($last_execution_date == "") {
					$last_execution_date = "jamais exécuté";
					$last_execution_ok = "";
				}
				else {
					if ($last_execution_ok == "1") {
						$last_execution_ok = "OK";
					}
					if ($last_execution_ok == "0") {
						$last_execution_ok = "KO";
					}
				}
				
				$complement = "";
				if ($is_cti == "1") {
					$complement = "$complement CTI";
				}
				else {
					$is_cti = "0";
				}
				if ($is_hide == "1") {
					$complement = "$complement Masqu�";
				}
				else {
					$is_hide = "0";
				}
				if ($is_alert == "1") {
					$complement = "$complement Alerte";
				}
				else {
					$is_alert = "0";
				}
				if ($gravite == 0) {
					$gravite_texte = "INFO";
				}
				else {
					if ($gravite == 9) {
						$gravite_texte = "ERREUR";
					}
					else {
						$gravite_texte = "ATT";
					}
				}
				$is_active_texte = $is_active == "1" ? "Actif" : "Inactif";
				
				$md5_def = refmd5("$code$texte$texte_court$texte_abrege$description$is_cti$prestataire_id");
				$md5_sql = refmd5("$code$sqlcmd_where1$sqlcmd_justificatif1$table1");
				
				$httpString_tmp .= "
				<RECORD 
				selected=\"0\" 
				oid=\"$oid\" 
				code=\"$code\" 
				texte=\"$texte\" 
				texte_court=\"$texte_court\" 
				texte_abrege=\"$texte_abrege\" 
				description=\"$description\" 
				is_cti=\"$is_cti\" 
				is_hide=\"$is_hide\" 
				is_active=\"$is_active\" 
				is_active_texte=\"$is_active_texte\"  
				gravite=\"$gravite\" 
				gravite_texte=\"$gravite_texte\" 
				complement=\"$complement\" 
				rule_oid1=\"$rule_oid1\" 
				sqlcmd_where1=\"$sqlcmd_where1\" 
				sqlcmd_justificatif1=\"$sqlcmd_justificatif1\" 
				table1=\"$table1\"  
				prestataire_id=\"$prestataire_id\" 
				prestataire_texte=\"$prestataire_texte\" 
				nbref=\"$nbref\" 
				last_execution_date=\"$last_execution_date\" 
				last_execution_ok=\"$last_execution_ok\" 
				md5_def=\"$md5_def\"
				md5_sql=\"$md5_sql\"
				is_alert=\"$is_alert\"
				 />";
				
				if (strlen($httpString_tmp) > 64000) {
					$httpString .= $httpString_tmp;
					$httpString_tmp = "";
				}
			}
		}
	}
	
	$httpString .= $httpString_tmp;
	
	// R�f�rence
	$httpString .= getRefSettings("t_expert_controle", $httpString);
	
	return $httpString;
}

function getRecords_expert_controle_refsettings($refPrefix) {

global $database;
	
	$httpString = "";
	$httpString_tmp = "";
	
	// Liste des controles
	$sqlcmd = "SELECT 
				t_expert_controle.oid AS controle_id,
				t_expert_controle.code AS controle_code,
				t_expert_controle.texte AS controle_texte,
				COALESCE(t_expert_controle.texte_court,t_expert_controle.texte) AS controle_texte_court,
				COALESCE(t_expert_controle.texte_court,t_expert_controle.texte,t_expert_controle.texte_abrege) AS controle_texte_abrege,
				t_expert_controle.description AS controle_description,
				t_expert_controle.is_cti AS controle_is_cti,
				t_expert_controle.is_hide AS controle_is_hide,
				t_expert_controle.gravite_id AS controle_gravite,
				t_expert_controle.prestataire_id,
				COALESCE(t_prestataires.texte, 'Tous') as prestataire_texte,
				COALESCE(t_expert_controle_rule_1.oid,0) AS rule1_oid,
				COALESCE(t_expert_controle_rule_1.sqlcmd_where) AS rule1_sqlcmd_where,
				COALESCE(t_expert_controle_rule_1.sqlcmd_justificatif) AS rule1_sqlcmd_justificatif,
				COALESCE(TO_CHAR(t_expert_controle_rule_1.last_execution_date,'DD/MM/YYYY'),'') AS rule1_last_execution_date,
				COALESCE(t_expert_controle_rule_1.last_execution_ok) AS rule1_last_execution_ok,
				COALESCE(t_expert_controle_rule_1.table_id,0) AS rule1_table_id,
				t_expert_controle.alert_exp as is_alert
			FROM rh.t_expert_controle  
				LEFT JOIN base.t_prestataires ON t_prestataires.oid = t_expert_controle.prestataire_id
				LEFT JOIN rh.t_expert_controle_rule t_expert_controle_rule_1 ON t_expert_controle_rule_1.controle_id = t_expert_controle.oid AND t_expert_controle_rule_1.numero = 1
			WHERE t_expert_controle.oid > 0 AND is_global <> 1 AND t_expert_controle.code ILIKE '$refPrefix%'
			ORDER BY t_expert_controle.code";
	$result = $database->exec($sqlcmd);
			
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecordInto();
			
			if ($record != FALSE) {
				$ok = TRUE;

				$oid = $record['controle_id'];
				$code = toHTML(trim($record['controle_code']));
				$texte = toHTML(trim($record['controle_texte']));
				$texte_court = toHTML(trim($record['controle_texte_court']));
				$texte_abrege = toHTML(trim($record['controle_texte_abrege']));
				$description = toHTML(trim($record['controle_description']));
				$is_cti = toHTML(trim($record['controle_is_cti']));
				$is_hide = toHTML(trim($record['controle_is_hide']));
				$gravite = floatval(trim($record['controle_gravite']));
				$rule_oid1 = floatval(trim($record['rule1_oid']));
				$sqlcmd_where1 = toHTML(trim($record['rule1_sqlcmd_where']));
				$sqlcmd_justificatif1 = toHTML(trim($record['rule1_sqlcmd_justificatif']));
				$last_execution_date = toHTML(trim($record['rule1_last_execution_date']));
				$last_execution_ok = toHTML(trim($record['rule1_last_execution_ok']));
				$table1 = floatval(trim($record['rule1_table_id']));
				$prestataire_id = floatval(trim($record['prestataire_id']));
				$prestataire_texte = toHTML(trim($record['prestataire_texte']));
				$is_alert = toHTML(trim($record['is_alert']));
				
				if ($last_execution_date == "") {
					$last_execution_ok = "";
				}
				else {
					if ($last_execution_ok == "1") {
						$last_execution_ok = "OK";
					}
					if ($last_execution_ok == "0") {
						$last_execution_ok = "KO";
					}
				}
				
				$complement = "";
				if ($is_cti == "1") {
					$complement = "$complement CTI";
				}
				else {
					$is_cti = "0";
				}
				if ($is_hide == "1") {
					$complement = "$complement Masqu�";
				}
				else {
					$is_hide = "0";
				}
				if ($gravite == 0) {
					$gravite_texte = "INFO";
				}
				else {
					if ($gravite == 9) {
						$gravite_texte = "ERREUR";
					}
					else {
						$gravite_texte = "ATT";
					}
				}
				$complement = trim($complement);
				
				$md5_def = refmd5("$code$texte$texte_court$texte_abrege$description$is_cti$prestataire_id");
				$md5_sql = refmd5("$code$sqlcmd_where1$sqlcmd_justificatif1$table1");
				
				$httpString_tmp .= "
				<RECORD 
				selected=\"0\" 
				oid=\"$oid\" 
				code=\"$code\" 
				texte=\"$texte\" 
				texte_court=\"$texte_court\" 
				texte_abrege=\"$texte_abrege\" 
				is_cti=\"$is_cti\" 
				is_hide=\"$is_hide\" 
				gravite=\"$gravite\"  
				gravite_texte=\"$gravite_texte\" 
				complement=\"$complement\"
				prestataire_id=\"$prestataire_id\"
				prestataire_texte=\"$prestataire_texte\" 
				md5_def=\"$md5_def\"
				md5_sql=\"$md5_sql\"
				is_alert=\"$is_alert\"
				 />";
				
				if (strlen($httpString_tmp) > 64000) {
					$httpString .= $httpString_tmp;
					$httpString_tmp = "";
				}
			}
		}
	}
	
	$httpString .= $httpString_tmp;
	return $httpString;
}

// recherche des listes de r�ference
function getRefSettings($tableName, $httpString_base) {

	global $getOption;
	
	$httpString = "";
	
	$SETTINGS_file = rootDir() . "settings/settings.XML";
	$SETTINGS_xml = simplexml_load_file($SETTINGS_file);
	$REFSETTINGS_URL = getProperty($SETTINGS_xml, "REFSETTINGS", 'URL');
	$REFSETTINGS_PREFIX = getProperty($SETTINGS_xml, "REFSETTINGS", 'PREFIX');

	if ($REFSETTINGS_URL != "" && extension_loaded('curl')) {
			
		// Recherche des indicateurs de l'environnement de r�f�rence
		$REFSETTINGS_table_url = "$REFSETTINGS_URL/modules/rh/php/RH_getTableRecords.php";
		
		// Recherche http pour indicateurs
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $REFSETTINGS_table_url);
		curl_setopt($ch, CURLOPT_POST, 2);
		curl_setopt($ch, CURLOPT_POSTFIELDS, "tableName=$tableName&getOption=getRefSettings&refPrefix=$REFSETTINGS_PREFIX");
		curl_setopt($ch, CURLOPT_HEADER, 0);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
		$REFSETTINGS_data = @curl_exec($ch);
		curl_close($ch);
		
		if ($REFSETTINGS_data) {
		
			if (substr($REFSETTINGS_data, 0, 12) == "<CTICONTENT>") {
				$REFSETTINGS_data = substr($REFSETTINGS_data, 12, strlen($REFSETTINGS_data) - 25);
			}
			
			$REFSETTINGS_data = uncompress($REFSETTINGS_data);
			$REFSETTINGS_data = str_replace("<RECORD ","<REFRECORD ",$REFSETTINGS_data);
			$REFSETTINGS_data = str_replace("</RECORD>","</REFRECORD>",$REFSETTINGS_data);
			$REFSETTINGS_xml = simplexml_load_string($REFSETTINGS_data);
			if ($REFSETTINGS_xml) {

				foreach ($REFSETTINGS_xml->REFRECORD as $recordNode) {
					$md5_def = trim($recordNode["md5_def"]);
					$md5_sql = trim($recordNode["md5_sql"]);
					$recordNode["ok"] = "";
					if (stripos($httpString_base, $md5_def) === false) {
						$recordNode["ok"] = "D�finition";
					}
					if (stripos($httpString_base, $md5_sql) === false) {
						$recordNode["ok"] = "R�gles";
					}
					//if ($recordNode["ok"] != "") {
						$httpString .= $recordNode->asXML();
					//}
				}
			}
		}
	}
	return $httpString;
}




function getRecords_planning_service() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
				code as pla_code,
				code_original as pla_code_original,
				oid as pla_id,
				section_code as pla_section_code,
				section_id as pla_section_id,
				section_texte as pla_section_texte,
				service_code as pla_service_code,
				service_id as pla_service_id,
				service_section_code as pla_service_section_code,
				service_section_id as pla_service_section_id,
				service_section_texte pla_service_section_texte,
				service_texte as pla_service_texte,
				texte as pla_texte,
				texte_court as pla_texte_court
				FROM 
					rh.t_planning_service
				";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['pla_code']));
				$code_original = toHTML(trim($record['pla_code_original']));
				$oid = $record['tra_id'];
				$section_code = toHTML(trim($record['pla_section_code']));
				$section_id = toHTML(trim($record['pla_section_id']));
				$section_texte = toHTML(trim($record['pla_section_texte']));
				$service_code = toHTML(trim($record['pla_service_code']));
				$service_id = toHTML(trim($record['pla_service_id']));
				$service_section_code = toHTML(trim($record['pla_service_section_code']));
				$service_section_id = toHTML(trim($record['pla_service_section_id']));
				$service_section_texte = toHTML(trim($record['pla_service_section_texte']));
				$service_texte = toHTML(trim($record['pla_service_texte']));		
				$texte = toHTML(trim($record['pla_texte']));
				$texte_court = toHTML(trim($record['pla_texte_court']));								
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\"
									section_code=\"$section_code\" 
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									service_code=\"$service_code\"
									service_id=\"$service_id\"									
									service_section_code=\"$service_section_code\" 
									service_section_id=\"$service_section_id\"
									service_section_texte=\"$service_section_texte\"
									service_texte=\"$service_texte\"
									texte=\"$texte\"
									texte_court=\"$texte_court\"	
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function getCombos_planning_service() {

    $httpString = "\r\n<COMBO_SER>";
    $httpString .= "\r\n<RECORD oid=\"0\" texte=\"Aucun\" />";
    $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM rh.t_services WHERE oid > 0 ORDER BY 2";
    $result = $db->exec($sqlcmd);
    if ($result != false) {
        $ok = TRUE;
        while ($ok == TRUE) {
            $ok = FALSE;
            $record = $db->nextRecordAssoc();
            if ($record != FALSE) {
                $ok = TRUE;
                $oid = $record["oid"];
                $texte = toHTML(trim($record["texte"]));
                $httpString .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
            }
        }
    }
    $httpString .= "\r\n</COMBO_SER>";

    return $httpString;
}


function getRecords_planning_qualification() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
				code as pla_qua_code,
				code_original as pla_qua_code_original,
				oid as pla_qua_id,
				qualification_code as pla_qua_qualification_code,
				qualification_id as pla_qua_qualification_id,
				qualification_section_code as pla_qua_qualification_section_code,
				qualification_section_id as pla_qua_qualification_section_id,
				qualification_section_texte as pla_qua_qualification_section_texte,
				qualification_texte as pla_qua_qualification_texte,
				section_code as pla_qua_section_code,
				section_id as pla_qua_section_id,
				section_texte as pla_qua_section_texte,
				texte as pla_qua_texte,
				texte_court as pla_qua_texte_court
				FROM 
					rh.t_planning_qualification
				";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['pla_qua_code']));
				$code_original = toHTML(trim($record['pla_qua_code_original']));
				$oid = $record['pla_qua_id'];
				$qualification_code = toHTML(trim($record['pla_qua_qualification_code']));
				$qualification_id = toHTML(trim($record['pla_qua_qualification_id']));
				$qualification_section_code = toHTML(trim($record['pla_qua_qualification_section_code']));
				$qualification_section_id = toHTML(trim($record['pla_qua_qualification_section_id']));
				$qualification_section_texte = toHTML(trim($record['pla_qua_qualification_section_texte']));
				$qualification_texte = toHTML(trim($record['pla_qua_qualification_texte']));
				$section_code = toHTML(trim($record['pla_qua_section_code']));
				$section_id = toHTML(trim($record['pla_qua_section_id']));
				$section_texte = toHTML(trim($record['pla_qua_section_texte']));		
				$texte = toHTML(trim($record['pla_qua_texte']));
				$texte_court = toHTML(trim($record['pla_qua_texte_court']));								
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\"
									qualification_code=\"$qualification_code\" 
									qualification_id=\"$qualification_id\"
									qualification_section_code=\"$qualification_section_code\"
									qualification_section_id=\"$qualification_section_id\"
									qualification_section_texte=\"$qualification_section_texte\"									
									qualification_texte=\"$qualification_texte\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"
									texte_court=\"$texte_court\"	
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function getCombos_planning_qualification() {

    $httpString = "\r\n<COMBO_QUA>";
    $httpString .= "\r\n<RECORD oid=\"0\" texte=\"Aucun\" />";
    $sqlcmd = "SELECT oid, code || ' '::text || texte AS texte FROM rh.t_qualifications WHERE oid > 0 ORDER BY 2";
    $result = $db->exec($sqlcmd);
    if ($result != false) {
        $ok = TRUE;
        while ($ok == TRUE) {
            $ok = FALSE;
            $record = $db->nextRecordAssoc();
            if ($record != FALSE) {
                $ok = TRUE;
                $oid = $record["oid"];
                $texte = toHTML(trim($record["texte"]));
                $httpString .= "\r\n<RECORD oid=\"$oid\" texte=\"$texte\" />";
            }
        }
    }
    $httpString .= "\r\n</COMBO_QUA>";

    return $httpString;
}



function getRecords_planning_type_absence() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as pla_abs__code,
					code_original as pla_abs_code_original,
					oid as pla_abs_id,
					section_code as pla_abs_section_code,
					section_id as pla_abs_section_id,
					section_texte as pla_abs_section_texte,
					texte as pla_abs_texte,
					texte_court as pla_abs_texte_court
				FROM 
					rh.t_planning_type_absence
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['pla_abs_code']));
				$code_original = toHTML(trim($record['pla_abs_code_original']));
				$oid = $record['pla_abs_id'];
				$section_code = toHTML(trim($record['pla_abs_section_code']));
				$section_id = toHTML(trim($record['pla_abs_section_id']));
				$section_texte = toHTML(trim($record['pla_abs_section_texte']));
				$texte = toHTML(trim($record['pla_abs_texte']));
				$texte_court = toHTML(trim($record['pla_abs_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									code_original=\"$code_original\"
									oid=\"$oid\" 
									section_code=\"$section_code\"
									section_id=\"$section_id\"
									section_texte=\"$section_texte\"
									texte=\"$texte\"									
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}


function getRecords_data_profile() {

global $database;

	$httpString_tmp = "";

	$sqlcmd = "
			SELECT 
					code as pro_code,
					etablissement_exclus as pro_etablissement_exclus,
					etablissement_id_as pro_etablissement_id,
					etablissement_inclus as pro_etablissement_inclus,
					oid as pro_id,
					service_exclus as pro_service_exclus,
					service_id_as pro_service_id,
					service_inclus as pro_service_inclus,
					statut_exclus as pro_statut_exclus,
					statut_id_as pro_statut_id,
					statut_inclus as pro_statut_inclus,
					texte as pro_texte,
					texte_court as pro_texte_court
				FROM 
					rh.t_data_profile
				ORDER BY code";
	$result = $database->exec($sqlcmd);
	
	if ($result != false) {
		
		// lignes 
		$ok = TRUE;
		
		while ($ok == TRUE) {
			$ok = FALSE;
			
			$record = $database->nextRecord();
			
			if ($record != FALSE) {
				$ok = TRUE;
				
				
				$code = toHTML(trim($record['pro_code']));
				$etablissement_exclus = toHTML(trim($record['pro_etablissement_exclus']));
				$etablissement_id = toHTML(trim($record['pro_etablissement_id']));
				$etablissement_inclus = toHTML(trim($record['pro_etablissement_inclus']));	
				$oid = $record['pro_id'];
				$service_exclus = toHTML(trim($record['pro_service_exclus']));
				$service_id = toHTML(trim($record['pro_service_id']));
				$service_inclus = toHTML(trim($record['pro_service_inclus']));
				$statut_exclus = toHTML(trim($record['pro_statut_exclus']));
				$statut_id = toHTML(trim($record['pro_statut_id']));
				$statut_inclus = toHTML(trim($record['pro_statut_inclus']));
				$texte = toHTML(trim($record['pro_texte']));
				$texte_court = toHTML(trim($record['pro_texte_court']));				
				$nbref = $record['nb_ref'] + 0;
				
				$httpString .= "\r\n<RECORD 
									
									code=\"$code\" 
									etablissement_exclus=\"$etablissement_exclus\"
									etablissement_id=\"$etablissement_id\"
									etablissement_inclus=\"$etablissement_inclus\"
									oid=\"$oid\" 
									service_exclus=\"$service_exclus\"
									service_id=\"$service_id\"
									service_inclus=\"$service_inclus\"
									statut_exclus=\"$statut_exclus\"
									statut_id=\"$statut_id\"
									statut_inclus=\"$statut_inclus\"
									texte=\"$texte\"
									texte_court=\"$texte_court\" 
									nbref=\"+$nbref\" />";
			}
		}
	}
	return $httpString;
}

function refmd5($string) {
	$string = str_replace("\r","",$string);
	$string = str_replace("\n","",$string);
	$string = md5(trim($string));
	return $string;
}
    
?>