<?php
// This script and data application were generated by AppGini 5.81
// Download AppGini for free from https://bigprof.com/appgini/download/

	/* Configuration */
	/*************************************/

		$pcConfig = array(
			'main' => array(
			),
			'dossier_individuel' => array(
				'option_prime' => array(
					'parent-table' => 'gestion_primes',
					'parent-primary-key' => 'idgestion_prime',
					'child-primary-key' => 'iddindividuel',
					'child-primary-key-index' => 0,
					'tab-label' => 'LISTE DU PERSONNEL <span class="hidden child-label-dossier_individuel child-field-caption">(PRIME)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/folder_table.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(2 => 'Matricule', 3 => 'Nom & Pr&#233;nom', 15 => 'Fonction', 18 => 'Categorie', 21 => 'Prime', 24 => 'Compte', 25 => 'Banque'),
					'display-field-names' => array(2 => 'matricule', 3 => 'nom_prenom', 15 => 'fonction', 18 => 'categorie', 21 => 'prime', 24 => 'compte', 25 => 'banque'),
					'sortable-fields' => array(0 => '`dossier_individuel`.`iddindividuel`', 1 => '`gestion_primes1`.`link`', 2 => 3, 3 => 4, 4 => '`dossier_individuel`.`date_naissance`', 5 => '`dossier_individuel`.`age`', 6 => 7, 7 => '`dossier_individuel`.`enfants`', 8 => 9, 9 => 10, 10 => 11, 11 => 12, 12 => '`dossier_individuel`.`date_recrutement`', 13 => '`statuts1`.`statut`', 14 => '`directions1`.`direction`', 15 => '`fonctions1`.`fonction`', 16 => '`services1`.`service`', 17 => '`divisions1`.`division`', 18 => '`categories1`.`categorie`', 19 => '`dossier_individuel`.`anciennete`', 20 => '`dossier_individuel`.`salaire`', 21 => '`categories1`.`prime`', 22 => 23, 23 => '`dossier_individuel`.`total`', 24 => 25, 25 => '`banques1`.`banque`', 26 => 27, 27 => 28, 28 => 29, 29 => 30, 30 => 31),
					'records-per-page' => 10,
					'default-sort-by' => 25,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-dossier_individuel',
					'template-printable' => 'children-dossier_individuel-printable',
					'query' => "SELECT `dossier_individuel`.`iddindividuel` as 'iddindividuel', IF(    CHAR_LENGTH(`gestion_primes1`.`link`), CONCAT_WS('',   `gestion_primes1`.`link`), '') as 'option_prime', `dossier_individuel`.`matricule` as 'matricule', `dossier_individuel`.`nom_prenom` as 'nom_prenom', if(`dossier_individuel`.`date_naissance`,date_format(`dossier_individuel`.`date_naissance`,'%d/%m/%Y'),'') as 'date_naissance', `dossier_individuel`.`age` as 'age', `dossier_individuel`.`matrimoniale` as 'matrimoniale', `dossier_individuel`.`enfants` as 'enfants', `dossier_individuel`.`nni` as 'nni', `dossier_individuel`.`telephone` as 'telephone', `dossier_individuel`.`courriel` as 'courriel', `dossier_individuel`.`postale` as 'postale', if(`dossier_individuel`.`date_recrutement`,date_format(`dossier_individuel`.`date_recrutement`,'%d/%m/%Y'),'') as 'date_recrutement', IF(    CHAR_LENGTH(`statuts1`.`statut`), CONCAT_WS('',   `statuts1`.`statut`), '') as 'statut', IF(    CHAR_LENGTH(`directions1`.`direction`), CONCAT_WS('',   `directions1`.`direction`), '') as 'direction', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction', IF(    CHAR_LENGTH(`services1`.`service`), CONCAT_WS('',   `services1`.`service`), '') as 'service', IF(    CHAR_LENGTH(`divisions1`.`division`), CONCAT_WS('',   `divisions1`.`division`), '') as 'division', IF(    CHAR_LENGTH(`categories1`.`categorie`), CONCAT_WS('',   `categories1`.`categorie`), '') as 'categorie', `dossier_individuel`.`anciennete` as 'anciennete', REPLACE(FORMAT(`dossier_individuel`.`salaire`, 0), ',', ' ') as 'salaire', IF(    CHAR_LENGTH(`categories1`.`prime`), CONCAT_WS('',   `categories1`.`prime`), '') as 'prime', IF(    CHAR_LENGTH(`rythme_prime1`.`rythme`), CONCAT_WS('',   `rythme_prime1`.`rythme`), '') as 'qty', `dossier_individuel`.`total` as 'total', `dossier_individuel`.`compte` as 'compte', IF(    CHAR_LENGTH(`banques1`.`banque`), CONCAT_WS('',   `banques1`.`banque`), '') as 'banque', `dossier_individuel`.`cv` as 'cv', `dossier_individuel`.`dossier` as 'dossier', `dossier_individuel`.`contrat` as 'contrat', `dossier_individuel`.`photo` as 'photo', `dossier_individuel`.`observation` as 'observation' FROM `dossier_individuel` LEFT JOIN `gestion_primes` as gestion_primes1 ON `gestion_primes1`.`idgestion_prime`=`dossier_individuel`.`option_prime` LEFT JOIN `statuts` as statuts1 ON `statuts1`.`idstatut`=`dossier_individuel`.`statut` LEFT JOIN `directions` as directions1 ON `directions1`.`iddirection`=`dossier_individuel`.`direction` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`dossier_individuel`.`fonction` LEFT JOIN `services` as services1 ON `services1`.`idservice`=`dossier_individuel`.`service` LEFT JOIN `divisions` as divisions1 ON `divisions1`.`iddivision`=`dossier_individuel`.`division` LEFT JOIN `categories` as categories1 ON `categories1`.`idcategorie`=`dossier_individuel`.`categorie` LEFT JOIN `banques` as banques1 ON `banques1`.`idbanque`=`dossier_individuel`.`banque` LEFT JOIN `rythme_prime` as rythme_prime1 ON `rythme_prime1`.`idrythme_prime`=`gestion_primes1`.`echeance` "
				),
			),
			'gestion_primes' => array(
			),
			'permissions' => array(
			),
			'conges' => array(
			),
			'pointages' => array(
			),
			'fiche_pointages' => array(
				'from_pointage' => array(
					'parent-table' => 'pointages',
					'parent-primary-key' => 'id_pointages',
					'child-primary-key' => 'id_fiche_pointage',
					'child-primary-key-index' => 0,
					'tab-label' => 'Pointages <span class="hidden child-label-fiche_pointages child-field-caption">(From pointage)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/pointage.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(2 => 'Date', 3 => 'NOM ET PRENOM', 4 => 'Fonction', 5 => 'NNI', 6 => 'HEURE / ARRIVEE', 7 => 'HEURE / DEPART', 8 => 'Emargement'),
					'display-field-names' => array(2 => 'date_fiche_pointage', 3 => 'nom_prenom_fp', 4 => 'fonction_fp', 5 => 'nni_fp', 6 => 'heure_arrive', 7 => 'heure_depart', 8 => 'emargement'),
					'sortable-fields' => array(0 => '`fiche_pointages`.`id_fiche_pointage`', 1 => '`pointages1`.`to_fiche_pointage`', 2 => '`fiche_pointages`.`date_fiche_pointage`', 3 => '`dossier_individuel1`.`nom_prenom`', 4 => 5, 5 => '`dossier_individuel1`.`nni`', 6 => '`fiche_pointages`.`heure_arrive`', 7 => '`fiche_pointages`.`heure_depart`', 8 => 9),
					'records-per-page' => 10,
					'default-sort-by' => 2,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-fiche_pointages',
					'template-printable' => 'children-fiche_pointages-printable',
					'query' => "SELECT `fiche_pointages`.`id_fiche_pointage` as 'id_fiche_pointage', IF(    CHAR_LENGTH(`pointages1`.`to_fiche_pointage`), CONCAT_WS('',   `pointages1`.`to_fiche_pointage`), '') as 'from_pointage', if(`fiche_pointages`.`date_fiche_pointage`,date_format(`fiche_pointages`.`date_fiche_pointage`,'%d/%m/%Y'),'') as 'date_fiche_pointage', IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') as 'nom_prenom_fp', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction_fp', IF(    CHAR_LENGTH(`dossier_individuel1`.`nni`), CONCAT_WS('',   `dossier_individuel1`.`nni`), '') as 'nni_fp', `fiche_pointages`.`heure_arrive` as 'heure_arrive', `fiche_pointages`.`heure_depart` as 'heure_depart', `fiche_pointages`.`emargement` as 'emargement' FROM `fiche_pointages` LEFT JOIN `pointages` as pointages1 ON `pointages1`.`id_pointages`=`fiche_pointages`.`from_pointage` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`fiche_pointages`.`nom_prenom_fp` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`dossier_individuel1`.`fonction` "
				),
				'nom_prenom_fp' => array(
					'parent-table' => 'dossier_individuel',
					'parent-primary-key' => 'iddindividuel',
					'child-primary-key' => 'id_fiche_pointage',
					'child-primary-key-index' => 0,
					'tab-label' => 'Pointages <span class="hidden child-label-fiche_pointages child-field-caption">(NOM ET PRENOM)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/pointage.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(2 => 'Date', 3 => 'NOM ET PRENOM', 4 => 'Fonction', 5 => 'NNI', 6 => 'HEURE / ARRIVEE', 7 => 'HEURE / DEPART', 8 => 'Emargement'),
					'display-field-names' => array(2 => 'date_fiche_pointage', 3 => 'nom_prenom_fp', 4 => 'fonction_fp', 5 => 'nni_fp', 6 => 'heure_arrive', 7 => 'heure_depart', 8 => 'emargement'),
					'sortable-fields' => array(0 => '`fiche_pointages`.`id_fiche_pointage`', 1 => '`pointages1`.`to_fiche_pointage`', 2 => '`fiche_pointages`.`date_fiche_pointage`', 3 => '`dossier_individuel1`.`nom_prenom`', 4 => 5, 5 => '`dossier_individuel1`.`nni`', 6 => '`fiche_pointages`.`heure_arrive`', 7 => '`fiche_pointages`.`heure_depart`', 8 => 9),
					'records-per-page' => 10,
					'default-sort-by' => 2,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-fiche_pointages',
					'template-printable' => 'children-fiche_pointages-printable',
					'query' => "SELECT `fiche_pointages`.`id_fiche_pointage` as 'id_fiche_pointage', IF(    CHAR_LENGTH(`pointages1`.`to_fiche_pointage`), CONCAT_WS('',   `pointages1`.`to_fiche_pointage`), '') as 'from_pointage', if(`fiche_pointages`.`date_fiche_pointage`,date_format(`fiche_pointages`.`date_fiche_pointage`,'%d/%m/%Y'),'') as 'date_fiche_pointage', IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') as 'nom_prenom_fp', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction_fp', IF(    CHAR_LENGTH(`dossier_individuel1`.`nni`), CONCAT_WS('',   `dossier_individuel1`.`nni`), '') as 'nni_fp', `fiche_pointages`.`heure_arrive` as 'heure_arrive', `fiche_pointages`.`heure_depart` as 'heure_depart', `fiche_pointages`.`emargement` as 'emargement' FROM `fiche_pointages` LEFT JOIN `pointages` as pointages1 ON `pointages1`.`id_pointages`=`fiche_pointages`.`from_pointage` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`fiche_pointages`.`nom_prenom_fp` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`dossier_individuel1`.`fonction` "
				),
			),
			'missions' => array(
			),
			'ordres_missions' => array(
				'from_mission' => array(
					'parent-table' => 'missions',
					'parent-primary-key' => 'id_mission',
					'child-primary-key' => 'id_ordre_mission',
					'child-primary-key-index' => 0,
					'tab-label' => 'LISTE ORDRE DE MISSION <span class="hidden child-label-ordres_missions child-field-caption">(From mission)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/folder_edit.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(2 => 'Nom prenom', 3 => 'Fonction', 4 => 'Direction', 5 => 'Service'),
					'display-field-names' => array(2 => 'nom_prenom', 3 => 'fonction', 4 => 'direction', 5 => 'service'),
					'sortable-fields' => array(0 => '`ordres_missions`.`id_ordre_mission`', 1 => '`missions1`.`to_mission`', 2 => '`dossier_individuel1`.`nom_prenom`', 3 => 4, 4 => 5, 5 => 6),
					'records-per-page' => 10,
					'default-sort-by' => 0,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-ordres_missions',
					'template-printable' => 'children-ordres_missions-printable',
					'query' => "SELECT `ordres_missions`.`id_ordre_mission` as 'id_ordre_mission', IF(    CHAR_LENGTH(`missions1`.`to_mission`), CONCAT_WS('',   `missions1`.`to_mission`), '') as 'from_mission', IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') as 'nom_prenom', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction', IF(    CHAR_LENGTH(`directions1`.`direction`), CONCAT_WS('',   `directions1`.`direction`), '') as 'direction', IF(    CHAR_LENGTH(`services1`.`service`), CONCAT_WS('',   `services1`.`service`), '') as 'service' FROM `ordres_missions` LEFT JOIN `missions` as missions1 ON `missions1`.`id_mission`=`ordres_missions`.`from_mission` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`ordres_missions`.`nom_prenom` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`dossier_individuel1`.`fonction` LEFT JOIN `directions` as directions1 ON `directions1`.`iddirection`=`dossier_individuel1`.`direction` LEFT JOIN `services` as services1 ON `services1`.`idservice`=`dossier_individuel1`.`service` "
				),
			),
			'fonctions' => array(
			),
			'directions' => array(
			),
			'services' => array(
			),
			'divisions' => array(
			),
			'categories' => array(
			),
			'statuts' => array(
			),
			'banques' => array(
			),
			'decomptes' => array(
			),
			'details_decompte' => array(
				'to_decomptes' => array(
					'parent-table' => 'decomptes',
					'parent-primary-key' => 'iddecompte',
					'child-primary-key' => 'iddetail_decompte',
					'child-primary-key-index' => 0,
					'tab-label' => 'LISTE DECOMPTE <span class="hidden child-label-details_decompte child-field-caption">(To decomptes)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/folder_page_white.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Tranches', 2 => 'Periodes', 3 => 'Pourcentage', 4 => 'COEFFICIENT DE PONDERATION', 5 => 'Salaire moyen', 6 => 'Montant'),
					'display-field-names' => array(1 => 'tranches', 2 => 'periodes', 3 => 'pourcentage', 4 => 'coef', 5 => 'salaire_moyen', 6 => 'montant'),
					'sortable-fields' => array(0 => '`details_decompte`.`iddetail_decompte`', 1 => 2, 2 => 3, 3 => '`details_decompte`.`pourcentage`', 4 => '`details_decompte`.`coef`', 5 => '`details_decompte`.`salaire_moyen`', 6 => '`details_decompte`.`montant`', 7 => '`details_decompte`.`mois_preavis`', 8 => '`details_decompte`.`mois_conge`', 9 => '`decomptes1`.`iddecompte`'),
					'records-per-page' => 10,
					'default-sort-by' => 0,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-details_decompte',
					'template-printable' => 'children-details_decompte-printable',
					'query' => "SELECT `details_decompte`.`iddetail_decompte` as 'iddetail_decompte', `details_decompte`.`tranches` as 'tranches', `details_decompte`.`periodes` as 'periodes', `details_decompte`.`pourcentage` as 'pourcentage', `details_decompte`.`coef` as 'coef', `details_decompte`.`salaire_moyen` as 'salaire_moyen', `details_decompte`.`montant` as 'montant', `details_decompte`.`mois_preavis` as 'mois_preavis', `details_decompte`.`mois_conge` as 'mois_conge', IF(    CHAR_LENGTH(`decomptes1`.`iddecompte`), CONCAT_WS('',   `decomptes1`.`iddecompte`), '') as 'to_decomptes' FROM `details_decompte` LEFT JOIN `decomptes` as decomptes1 ON `decomptes1`.`iddecompte`=`details_decompte`.`to_decomptes` "
				),
			),
			'informations' => array(
				'matricule' => array(
					'parent-table' => 'dossier_individuel',
					'parent-primary-key' => 'iddindividuel',
					'child-primary-key' => 'idinformation',
					'child-primary-key-index' => 0,
					'tab-label' => 'Exp&#233;riences <span class="hidden child-label-informations child-field-caption">(Matricule)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/chart_pie_alternative.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(2 => 'Matricule', 3 => 'Nom prenom', 5 => 'DIPL&#212;ME PRIMORDIAL', 6 => 'Date', 7 => 'Institution', 8 => 'Lieu', 9 => 'DIPL&#214;ME / CERTIFICAT DE SP&#201;CIALIT&#201;', 10 => 'SP&#201;CIALIT&#201;', 11 => 'Institution ', 12 => 'Lieu ', 15 => 'Fran&#231;ais'),
					'display-field-names' => array(2 => 'matricule', 3 => 'nom_prenom', 5 => 'diplome_primordial', 6 => 'date_diplome', 7 => 'institution', 8 => 'lieu_diplome', 9 => 'diplome_certificat', 10 => 'specialite', 11 => 'institution_specialite', 12 => 'lieu_specialite', 15 => 'francais'),
					'sortable-fields' => array(0 => '`informations`.`idinformation`', 1 => 2, 2 => '`dossier_individuel1`.`matricule`', 3 => '`dossier_individuel1`.`nom_prenom`', 4 => 5, 5 => 6, 6 => '`informations`.`date_diplome`', 7 => 8, 8 => 9, 9 => 10, 10 => 11, 11 => 12, 12 => 13, 13 => 14, 14 => 15, 15 => 16, 16 => 17, 17 => 18, 18 => 19, 19 => 20, 20 => 21, 21 => 22),
					'records-per-page' => 10,
					'default-sort-by' => 0,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-informations',
					'template-printable' => 'children-informations-printable',
					'query' => "SELECT `informations`.`idinformation` as 'idinformation', `informations`.`situation` as 'situation', IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`), '') as 'matricule', IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') as 'nom_prenom', `informations`.`education` as 'education', `informations`.`diplome_primordial` as 'diplome_primordial', if(`informations`.`date_diplome`,date_format(`informations`.`date_diplome`,'%d/%m/%Y'),'') as 'date_diplome', `informations`.`institution` as 'institution', `informations`.`lieu_diplome` as 'lieu_diplome', `informations`.`diplome_certificat` as 'diplome_certificat', `informations`.`specialite` as 'specialite', `informations`.`institution_specialite` as 'institution_specialite', `informations`.`lieu_specialite` as 'lieu_specialite', `informations`.`langues` as 'langues', `informations`.`arabe` as 'arabe', `informations`.`francais` as 'francais', `informations`.`anglais` as 'anglais', `informations`.`autres1` as 'autres1', `informations`.`autres2` as 'autres2', `informations`.`informatique` as 'informatique', `informations`.`utilisation` as 'utilisation', `informations`.`programmation` as 'programmation' FROM `informations` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`informations`.`matricule` "
				),
			),
			'formations' => array(
				'matricule' => array(
					'parent-table' => 'dossier_individuel',
					'parent-primary-key' => 'iddindividuel',
					'child-primary-key' => 'idformation',
					'child-primary-key-index' => 0,
					'tab-label' => 'Formations <span class="hidden child-label-formations child-field-caption">(Matricule)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/books.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Matricule', 2 => 'Nom prenom', 3 => 'Specialisation', 4 => 'Annee', 5 => 'Date', 6 => 'Organisme', 7 => 'Lieu', 8 => 'NATURE FORMATION', 9 => 'DUR&#201;E / JOURS', 10 => 'EFFETS VIS&#201;S', 11 => 'RESULTATS PRODUITS', 12 => 'R / C / P'),
					'display-field-names' => array(1 => 'matricule', 2 => 'nom_prenom', 3 => 'specialisation', 4 => 'annee', 5 => 'date', 6 => 'organisme', 7 => 'lieu', 8 => 'nature', 9 => 'duree', 10 => 'effets', 11 => 'resultat', 12 => 'r_c_p'),
					'sortable-fields' => array(0 => '`formations`.`idformation`', 1 => '`dossier_individuel1`.`matricule`', 2 => '`dossier_individuel1`.`nom_prenom`', 3 => 4, 4 => 5, 5 => '`formations`.`date`', 6 => 7, 7 => 8, 8 => 9, 9 => '`formations`.`duree`', 10 => 11, 11 => 12, 12 => 13),
					'records-per-page' => 10,
					'default-sort-by' => 5,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-formations',
					'template-printable' => 'children-formations-printable',
					'query' => "SELECT `formations`.`idformation` as 'idformation', IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`), '') as 'matricule', IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') as 'nom_prenom', `formations`.`specialisation` as 'specialisation', `formations`.`annee` as 'annee', if(`formations`.`date`,date_format(`formations`.`date`,'%d/%m/%Y'),'') as 'date', `formations`.`organisme` as 'organisme', `formations`.`lieu` as 'lieu', `formations`.`nature` as 'nature', `formations`.`duree` as 'duree', `formations`.`effets` as 'effets', `formations`.`resultat` as 'resultat', `formations`.`r_c_p` as 'r_c_p' FROM `formations` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`formations`.`matricule` "
				),
			),
			'carrieres' => array(
				'matricule' => array(
					'parent-table' => 'dossier_individuel',
					'parent-primary-key' => 'iddindividuel',
					'child-primary-key' => 'idcarriere',
					'child-primary-key-index' => 0,
					'tab-label' => 'Carrieres <span class="hidden child-label-carrieres child-field-caption">(Matricule)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/award_star_silver_2.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Matricule', 2 => 'Direction', 3 => 'Fonction', 4 => 'Division', 5 => 'Service', 6 => 'Date', 7 => 'DESCRIPTION', 8 => 'Statut'),
					'display-field-names' => array(1 => 'matricule', 2 => 'direction', 3 => 'fonction', 4 => 'division', 5 => 'service', 6 => 'date', 7 => 'r_n_m_a_p_d', 8 => 'statut'),
					'sortable-fields' => array(0 => '`carrieres`.`idcarriere`', 1 => '`dossier_individuel1`.`matricule`', 2 => 3, 3 => 4, 4 => 5, 5 => 6, 6 => '`carrieres`.`date`', 7 => 8, 8 => 9, 9 => 10),
					'records-per-page' => 10,
					'default-sort-by' => 6,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-carrieres',
					'template-printable' => 'children-carrieres-printable',
					'query' => "SELECT `carrieres`.`idcarriere` as 'idcarriere', IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`), '') as 'matricule', IF(    CHAR_LENGTH(`directions1`.`direction`), CONCAT_WS('',   `directions1`.`direction`), '') as 'direction', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction', IF(    CHAR_LENGTH(`divisions1`.`division`), CONCAT_WS('',   `divisions1`.`division`), '') as 'division', IF(    CHAR_LENGTH(`services1`.`service`), CONCAT_WS('',   `services1`.`service`), '') as 'service', if(`carrieres`.`date`,date_format(`carrieres`.`date`,'%d/%m/%Y'),'') as 'date', `carrieres`.`r_n_m_a_p_d` as 'r_n_m_a_p_d', `carrieres`.`statut` as 'statut', `carrieres`.`observations` as 'observations' FROM `carrieres` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`carrieres`.`matricule` LEFT JOIN `directions` as directions1 ON `directions1`.`iddirection`=`dossier_individuel1`.`direction` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`dossier_individuel1`.`fonction` LEFT JOIN `divisions` as divisions1 ON `divisions1`.`iddivision`=`dossier_individuel1`.`division` LEFT JOIN `services` as services1 ON `services1`.`idservice`=`dossier_individuel1`.`service` "
				),
			),
			'expenses' => array(
				'matricule' => array(
					'parent-table' => 'dossier_individuel',
					'parent-primary-key' => 'iddindividuel',
					'child-primary-key' => 'idexpense',
					'child-primary-key-index' => 0,
					'tab-label' => 'Cong&#233;s & Permissions <span class="hidden child-label-expenses child-field-caption">(Matricule)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/holiday.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Type', 2 => 'Nature', 3 => 'Date demande', 4 => 'Matricule', 5 => 'Nom & Pr&#233;nom', 6 => 'Date recrutement', 7 => 'Fonction', 8 => 'Division', 9 => 'Service', 10 => 'Direction', 11 => 'Nombre de jour &#224; d&#233;duire', 12 => 'Date de d&#233;part', 13 => 'Date de retour', 18 => 'Observations'),
					'display-field-names' => array(1 => 'type', 2 => 'nature', 3 => 'date_saisie', 4 => 'matricule', 5 => 'client', 6 => 'date_recrutement', 7 => 'fonction', 8 => 'division', 9 => 'service', 10 => 'direction', 11 => 'amount', 12 => 'date_depart', 13 => 'date_retour', 18 => 'observations'),
					'sortable-fields' => array(0 => '`expenses`.`idexpense`', 1 => 2, 2 => 3, 3 => '`expenses`.`date_saisie`', 4 => '`dossier_individuel1`.`matricule`', 5 => '`dossier_individuel1`.`nom_prenom`', 6 => 'date_format(`dossier_individuel1`.`date_recrutement`,\'%d/%m/%Y\')', 7 => 8, 8 => 9, 9 => 10, 10 => 11, 11 => '`expenses`.`amount`', 12 => '`expenses`.`date_depart`', 13 => '`expenses`.`date_retour`', 14 => '`expenses`.`date_depart_derniere`', 15 => 16, 16 => 17, 17 => 18, 18 => 19),
					'records-per-page' => 10,
					'default-sort-by' => 3,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-expenses',
					'template-printable' => 'children-expenses-printable',
					'query' => "SELECT `expenses`.`idexpense` as 'idexpense', `expenses`.`type` as 'type', `expenses`.`nature` as 'nature', if(`expenses`.`date_saisie`,date_format(`expenses`.`date_saisie`,'%d/%m/%Y'),'') as 'date_saisie', IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`), '') as 'matricule', IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') as 'client', IF(    CHAR_LENGTH(if(`dossier_individuel1`.`date_recrutement`,date_format(`dossier_individuel1`.`date_recrutement`,'%d/%m/%Y'),'')), CONCAT_WS('',   if(`dossier_individuel1`.`date_recrutement`,date_format(`dossier_individuel1`.`date_recrutement`,'%d/%m/%Y'),'')), '') as 'date_recrutement', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction', IF(    CHAR_LENGTH(`divisions1`.`division`), CONCAT_WS('',   `divisions1`.`division`), '') as 'division', IF(    CHAR_LENGTH(`services1`.`service`), CONCAT_WS('',   `services1`.`service`), '') as 'service', IF(    CHAR_LENGTH(`directions1`.`direction`), CONCAT_WS('',   `directions1`.`direction`), '') as 'direction', `expenses`.`amount` as 'amount', if(`expenses`.`date_depart`,date_format(`expenses`.`date_depart`,'%d/%m/%Y'),'') as 'date_depart', if(`expenses`.`date_retour`,date_format(`expenses`.`date_retour`,'%d/%m/%Y'),'') as 'date_retour', if(`expenses`.`date_depart_derniere`,date_format(`expenses`.`date_depart_derniere`,'%d/%m/%Y'),'') as 'date_depart_derniere', `expenses`.`adresse_absence` as 'adresse_absence', `expenses`.`departement` as 'departement', `expenses`.`signataire` as 'signataire', `expenses`.`observations` as 'observations' FROM `expenses` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`expenses`.`matricule` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`dossier_individuel1`.`fonction` LEFT JOIN `divisions` as divisions1 ON `divisions1`.`iddivision`=`dossier_individuel1`.`division` LEFT JOIN `services` as services1 ON `services1`.`idservice`=`dossier_individuel1`.`service` LEFT JOIN `directions` as directions1 ON `directions1`.`iddirection`=`dossier_individuel1`.`direction` "
				),
			),
			'rythme_prime' => array(
			),
		);

	/*************************************/
	/* End of configuration */


	$currDir = dirname(__FILE__);
	include("{$currDir}/defaultLang.php");
	include("{$currDir}/language.php");
	include("{$currDir}/lib.php");
	@header('Content-Type: text/html; charset=' . datalist_db_encoding);

	handle_maintenance();

	/**
	* dynamic configuration based on current user's permissions
	* $userPCConfig array is populated only with parent tables where the user has access to
	* at least one child table
	*/
	$userPCConfig = array();
	foreach($pcConfig as $pcChildTable => $ChildrenLookups) {
		$permChild = getTablePermissions($pcChildTable);
		if($permChild[2]) { // user can view records of the child table, so proceed to check children lookups
			foreach($ChildrenLookups as $ChildLookupField => $ChildConfig) {
				$permParent = getTablePermissions($ChildConfig['parent-table']);
				if($permParent[2]) { // user can view records of parent table
					$userPCConfig[$pcChildTable][$ChildLookupField] = $pcConfig[$pcChildTable][$ChildLookupField];
					// show add new only if configured above AND the user has insert permission
					if($permChild[1] && $pcConfig[$pcChildTable][$ChildLookupField]['display-add-new']) {
						$userPCConfig[$pcChildTable][$ChildLookupField]['display-add-new'] = true;
					}else{
						$userPCConfig[$pcChildTable][$ChildLookupField]['display-add-new'] = false;
					}
				}
			}
		}
	}

	/* Receive, UTF-convert, and validate parameters */
	$ParentTable = $_REQUEST['ParentTable']; // needed only with operation=show-children, will be validated in the processing code
	$ChildTable = $_REQUEST['ChildTable'];
		if(!in_array($ChildTable, array_keys($userPCConfig))) {
			/* defaults to first child table in config array if not provided */
			$ChildTable = current(array_keys($userPCConfig));
		}
		if(!$ChildTable) { die('<!-- No tables accessible to current user -->'); }
	$SelectedID = strip_tags($_REQUEST['SelectedID']);
	$ChildLookupField = $_REQUEST['ChildLookupField'];
		if(!in_array($ChildLookupField, array_keys($userPCConfig[$ChildTable]))) {
			/* defaults to first lookup in current child config array if not provided */
			$ChildLookupField = current(array_keys($userPCConfig[$ChildTable]));
		}
	$Page = intval($_REQUEST['Page']);
		if($Page < 1) {
			$Page = 1;
		}
	$SortBy = ($_REQUEST['SortBy'] != '' ? abs(intval($_REQUEST['SortBy'])) : false);
		if(!in_array($SortBy, array_keys($userPCConfig[$ChildTable][$ChildLookupField]['sortable-fields']), true)) {
			$SortBy = $userPCConfig[$ChildTable][$ChildLookupField]['default-sort-by'];
		}
	$SortDirection = strtolower($_REQUEST['SortDirection']);
		if(!in_array($SortDirection, array('asc', 'desc'))) {
			$SortDirection = $userPCConfig[$ChildTable][$ChildLookupField]['default-sort-direction'];
		}
	$Operation = strtolower($_REQUEST['Operation']);
		if(!in_array($Operation, array('get-records', 'show-children', 'get-records-printable', 'show-children-printable'))) {
			$Operation = 'get-records';
		}

	/* process requested operation */
	switch($Operation) {
		/************************************************/
		case 'show-children':
			/* populate HTML and JS content with children tabs */
			$tabLabels = $tabPanels = $tabLoaders = '';
			foreach($userPCConfig as $ChildTable => $childLookups) {
				foreach($childLookups as $ChildLookupField => $childConfig) {
					if($childConfig['parent-table'] == $ParentTable) {
						$TableIcon = ($childConfig['table-icon'] ? "<img src=\"{$childConfig['table-icon']}\" border=\"0\" />" : '');
						$tabLabels .= sprintf('<li%s><a href="#panel_%s-%s" id="tab_%s-%s" data-toggle="tab">%s%s</a></li>' . "\n\t\t\t\t\t",($tabLabels ? '' : ' class="active"'), $ChildTable, $ChildLookupField, $ChildTable, $ChildLookupField, $TableIcon, $childConfig['tab-label']);
						$tabPanels .= sprintf('<div id="panel_%s-%s" class="tab-pane%s"><img src="loading.gif" align="top" />%s</div>' . "\n\t\t\t\t", $ChildTable, $ChildLookupField, ($tabPanels ? '' : ' active'), $Translation['Loading ...']);
						$tabLoaders .= sprintf('post("parent-children.php", { ChildTable: "%s", ChildLookupField: "%s", SelectedID: "%s", Page: 1, SortBy: "", SortDirection: "", Operation: "get-records" }, "panel_%s-%s");' . "\n\t\t\t\t", $ChildTable, $ChildLookupField, addslashes($SelectedID), $ChildTable, $ChildLookupField);
					}
				}
			}

			if(!$tabLabels) { die('<!-- no children of current parent table are accessible to current user -->'); }
			?>
			<div id="children-tabs">
				<ul class="nav nav-tabs">
					<?php echo $tabLabels; ?>
				</ul>
				<span id="pc-loading"></span>
			</div>
			<div class="tab-content"><?php echo $tabPanels; ?></div>

			<script>
				$j(function() {
					/* for iOS, avoid loading child tabs in modals */
					var iOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
					var embedded = ($j('.navbar').length == 0);
					if(iOS && embedded) {
						$j('#children-tabs').next('.tab-content').remove();
						$j('#children-tabs').remove();
						return;
					}

					/* ajax loading of each tab's contents */
					<?php echo $tabLoaders; ?>

					/* show child field caption on tab title in case the same child table appears more than once */
					$j('.child-field-caption').each(function() {
						var clss = $j(this).attr('class').split(/\s+/).reduce(function(rc, cc) {
							return (cc.match(/child-label-.*/) ? '.' + cc : rc);
						}, '');

						// if class occurs more than once, remove .hidden
						if($j(clss).length > 1) $j(clss).removeClass('hidden');
					})
				})
			</script>
			<?php
			break;

		/************************************************/
		case 'show-children-printable':
			/* populate HTML and JS content with children buttons */
			$tabLabels = $tabPanels = $tabLoaders = '';
			foreach($userPCConfig as $ChildTable => $childLookups) {
				foreach($childLookups as $ChildLookupField => $childConfig) {
					if($childConfig['parent-table'] == $ParentTable) {
						$TableIcon = ($childConfig['table-icon'] ? "<img src=\"{$childConfig['table-icon']}\" border=\"0\" />" : '');
						$tabLabels .= sprintf('<button type="button" class="btn btn-default" data-target="#panel_%s-%s" id="tab_%s-%s" data-toggle="collapse">%s %s</button>' . "\n\t\t\t\t\t", $ChildTable, $ChildLookupField, $ChildTable, $ChildLookupField, $TableIcon, $childConfig['tab-label']);
						$tabPanels .= sprintf('<div id="panel_%s-%s" class="collapse"><img src="loading.gif" align="top" />%s</div>' . "\n\t\t\t\t", $ChildTable, $ChildLookupField, $Translation['Loading ...']);
						$tabLoaders .= sprintf('post("parent-children.php", { ChildTable: "%s", ChildLookupField: "%s", SelectedID: "%s", Page: 1, SortBy: "", SortDirection: "", Operation: "get-records-printable" }, "panel_%s-%s");' . "\n\t\t\t\t", $ChildTable, $ChildLookupField, addslashes($SelectedID), $ChildTable, $ChildLookupField);
					}
				}
			}

			if(!$tabLabels) { die('<!-- no children of current parent table are accessible to current user -->'); }
			?>
			<div id="children-tabs" class="hidden-print">
				<div class="btn-group btn-group-lg">
					<?php echo $tabLabels; ?>
				</div>
				<span id="pc-loading"></span>
			</div>
			<div class="vspacer-lg"><?php echo $tabPanels; ?></div>

			<script>
				$j(function() {
					/* for iOS, avoid loading child tabs in modals */
					var iOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
					var embedded = ($j('.navbar').length == 0);
					if(iOS && embedded) {
						$j('#children-tabs').next('.tab-content').remove();
						$j('#children-tabs').remove();
						return;
					}

					/* ajax loading of each tab's contents */
					<?php echo $tabLoaders; ?>
				})
			</script>
			<?php
			break;

		/************************************************/
		case 'get-records-printable':
		default: /* default is 'get-records' */

			if($Operation == 'get-records-printable') {
				$userPCConfig[$ChildTable][$ChildLookupField]['records-per-page'] = 2000;
			}

			// build the user permissions limiter
			$permissionsWhere = $permissionsJoin = '';
			$permChild = getTablePermissions($ChildTable);
			if($permChild[2] == 1) { // user can view only his own records
				$permissionsWhere = "`$ChildTable`.`{$userPCConfig[$ChildTable][$ChildLookupField]['child-primary-key']}`=`membership_userrecords`.`pkValue` AND `membership_userrecords`.`tableName`='$ChildTable' AND LCASE(`membership_userrecords`.`memberID`)='".getLoggedMemberID()."'";
			}elseif($permChild[2] == 2) { // user can view only his group's records
				$permissionsWhere = "`$ChildTable`.`{$userPCConfig[$ChildTable][$ChildLookupField]['child-primary-key']}`=`membership_userrecords`.`pkValue` AND `membership_userrecords`.`tableName`='$ChildTable' AND `membership_userrecords`.`groupID`='".getLoggedGroupID()."'";
			}elseif($permChild[2] == 3) { // user can view all records
				/* that's the only case remaining ... no need to modify the query in this case */
			}
			$permissionsJoin = ($permissionsWhere ? ", `membership_userrecords`" : '');

			// build the count query
			$forcedWhere = $userPCConfig[$ChildTable][$ChildLookupField]['forced-where'];
			$query = 
				preg_replace('/^select .* from /i', 'SELECT count(1) FROM ', $userPCConfig[$ChildTable][$ChildLookupField]['query']) .
				$permissionsJoin . " WHERE " .
				($permissionsWhere ? "( $permissionsWhere )" : "( 1=1 )") . " AND " .
				($forcedWhere ? "( $forcedWhere )" : "( 2=2 )") . " AND " .
				"`$ChildTable`.`$ChildLookupField`='" . makeSafe($SelectedID) . "'";
			$totalMatches = sqlValue($query);

			// make sure $Page is <= max pages
			$maxPage = ceil($totalMatches / $userPCConfig[$ChildTable][$ChildLookupField]['records-per-page']);
			if($Page > $maxPage) { $Page = $maxPage; }

			// initiate output data array
			$data = array(
				'config' => $userPCConfig[$ChildTable][$ChildLookupField],
				'parameters' => array(
					'ChildTable' => $ChildTable,
					'ChildLookupField' => $ChildLookupField,
					'SelectedID' => $SelectedID,
					'Page' => $Page,
					'SortBy' => $SortBy,
					'SortDirection' => $SortDirection,
					'Operation' => $Operation
				),
				'records' => array(),
				'totalMatches' => $totalMatches
			);

			// build the data query
			if($totalMatches) { // if we have at least one record, proceed with fetching data
				$startRecord = $userPCConfig[$ChildTable][$ChildLookupField]['records-per-page'] * ($Page - 1);
				$data['query'] = 
					$userPCConfig[$ChildTable][$ChildLookupField]['query'] .
					$permissionsJoin . " WHERE " .
					($permissionsWhere ? "( $permissionsWhere )" : "( 1=1 )") . " AND " .
					($forcedWhere ? "( $forcedWhere )" : "( 2=2 )") . " AND " .
					"`$ChildTable`.`$ChildLookupField`='" . makeSafe($SelectedID) . "'" . 
					($SortBy !== false && $userPCConfig[$ChildTable][$ChildLookupField]['sortable-fields'][$SortBy] ? " ORDER BY {$userPCConfig[$ChildTable][$ChildLookupField]['sortable-fields'][$SortBy]} $SortDirection" : '') .
					" LIMIT $startRecord, {$userPCConfig[$ChildTable][$ChildLookupField]['records-per-page']}";
				$res = sql($data['query'], $eo);
				while($row = db_fetch_row($res)) {
					$data['records'][$row[$userPCConfig[$ChildTable][$ChildLookupField]['child-primary-key-index']]] = $row;
				}
			}else{ // if no matching records
				$startRecord = 0;
			}

			if($Operation == 'get-records-printable') {
				$response = loadView($userPCConfig[$ChildTable][$ChildLookupField]['template-printable'], $data);
			}else{
				$response = loadView($userPCConfig[$ChildTable][$ChildLookupField]['template'], $data);
			}

			// change name space to ensure uniqueness
			$uniqueNameSpace = $ChildTable.ucfirst($ChildLookupField).'GetRecords';
			echo str_replace("{$ChildTable}GetChildrenRecordsList", $uniqueNameSpace, $response);
		/************************************************/
	}
