<?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(
			'entete' => array(
			),
			'personnels' => array(
			),
			'clients' => array(
			),
			'suivi_client' => array(
			),
			'rendez_vous' => array(
			),
			'partenaires' => array(
			),
			'packages' => array(
			),
			'oumrah' => array(
			),
			'hajj_oumrah' => array(
			),
			'souscriptions' => array(
				'pelerin' => array(
					'parent-table' => 'hajj_oumrah',
					'parent-primary-key' => 'idhajjoumrah',
					'child-primary-key' => 'idsouscription',
					'child-primary-key-index' => 0,
					'tab-label' => 'Souscriptions <span class="hidden child-label-souscriptions child-field-caption">(HAJJ)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/kaaba.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Date', 2 => 'HAJJ', 3 => 'OUMRAH', 4 => 'Nom du package', 5 => 'MONTANT', 6 => 'REMISE', 7 => 'NET A PAYER', 9 => 'Groupe', 10 => 'Agent'),
					'display-field-names' => array(1 => 'date_enr', 2 => 'pelerin', 3 => 'oumrah', 4 => 'package', 5 => 'prix', 6 => 'remise', 7 => 'net_a_payer', 9 => 'groupe', 10 => 'agent'),
					'sortable-fields' => array(0 => '`souscriptions`.`idsouscription`', 1 => '`souscriptions`.`date_enr`', 2 => 3, 3 => 4, 4 => '`packages1`.`nom`', 5 => '`souscriptions`.`prix`', 6 => '`souscriptions`.`remise`', 7 => '`souscriptions`.`net_a_payer`', 8 => 9, 9 => 10, 10 => 11),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-souscriptions',
					'template-printable' => 'children-souscriptions-printable',
					'query' => "SELECT `souscriptions`.`idsouscription` as 'idsouscription', if(`souscriptions`.`date_enr`,date_format(`souscriptions`.`date_enr`,'%d/%m/%Y'),'') as 'date_enr', IF(    CHAR_LENGTH(`hajj_oumrah1`.`Prenom`) || CHAR_LENGTH(`hajj_oumrah1`.`Nom`), CONCAT_WS('',   `hajj_oumrah1`.`Prenom`, '   ', `hajj_oumrah1`.`Nom`), '') as 'pelerin', IF(    CHAR_LENGTH(`oumrah1`.`Prenom`) || CHAR_LENGTH(`oumrah1`.`Nom`), CONCAT_WS('',   `oumrah1`.`Prenom`, '   ', `oumrah1`.`Nom`), '') as 'oumrah', IF(    CHAR_LENGTH(`packages1`.`nom`), CONCAT_WS('',   `packages1`.`nom`), '') as 'package', REPLACE(FORMAT(`souscriptions`.`prix`, 0), ',', ' ') as 'prix', REPLACE(FORMAT(`souscriptions`.`remise`, 0), ',', ' ') as 'remise', REPLACE(FORMAT(`souscriptions`.`net_a_payer`, 0), ',', ' ') as 'net_a_payer', `souscriptions`.`observations` as 'observations', `souscriptions`.`groupe` as 'groupe', `souscriptions`.`agent` as 'agent' FROM `souscriptions` LEFT JOIN `hajj_oumrah` as hajj_oumrah1 ON `hajj_oumrah1`.`idhajjoumrah`=`souscriptions`.`pelerin` LEFT JOIN `oumrah` as oumrah1 ON `oumrah1`.`idoumrah`=`souscriptions`.`oumrah` LEFT JOIN `packages` as packages1 ON `packages1`.`idpackage`=`souscriptions`.`package` "
				),
				'oumrah' => array(
					'parent-table' => 'oumrah',
					'parent-primary-key' => 'idoumrah',
					'child-primary-key' => 'idsouscription',
					'child-primary-key-index' => 0,
					'tab-label' => 'Souscriptions <span class="hidden child-label-souscriptions child-field-caption">(OUMRAH)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/kaaba.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Date', 2 => 'HAJJ', 3 => 'OUMRAH', 4 => 'Nom du package', 5 => 'MONTANT', 6 => 'REMISE', 7 => 'NET A PAYER', 9 => 'Groupe', 10 => 'Agent'),
					'display-field-names' => array(1 => 'date_enr', 2 => 'pelerin', 3 => 'oumrah', 4 => 'package', 5 => 'prix', 6 => 'remise', 7 => 'net_a_payer', 9 => 'groupe', 10 => 'agent'),
					'sortable-fields' => array(0 => '`souscriptions`.`idsouscription`', 1 => '`souscriptions`.`date_enr`', 2 => 3, 3 => 4, 4 => '`packages1`.`nom`', 5 => '`souscriptions`.`prix`', 6 => '`souscriptions`.`remise`', 7 => '`souscriptions`.`net_a_payer`', 8 => 9, 9 => 10, 10 => 11),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-souscriptions',
					'template-printable' => 'children-souscriptions-printable',
					'query' => "SELECT `souscriptions`.`idsouscription` as 'idsouscription', if(`souscriptions`.`date_enr`,date_format(`souscriptions`.`date_enr`,'%d/%m/%Y'),'') as 'date_enr', IF(    CHAR_LENGTH(`hajj_oumrah1`.`Prenom`) || CHAR_LENGTH(`hajj_oumrah1`.`Nom`), CONCAT_WS('',   `hajj_oumrah1`.`Prenom`, '   ', `hajj_oumrah1`.`Nom`), '') as 'pelerin', IF(    CHAR_LENGTH(`oumrah1`.`Prenom`) || CHAR_LENGTH(`oumrah1`.`Nom`), CONCAT_WS('',   `oumrah1`.`Prenom`, '   ', `oumrah1`.`Nom`), '') as 'oumrah', IF(    CHAR_LENGTH(`packages1`.`nom`), CONCAT_WS('',   `packages1`.`nom`), '') as 'package', REPLACE(FORMAT(`souscriptions`.`prix`, 0), ',', ' ') as 'prix', REPLACE(FORMAT(`souscriptions`.`remise`, 0), ',', ' ') as 'remise', REPLACE(FORMAT(`souscriptions`.`net_a_payer`, 0), ',', ' ') as 'net_a_payer', `souscriptions`.`observations` as 'observations', `souscriptions`.`groupe` as 'groupe', `souscriptions`.`agent` as 'agent' FROM `souscriptions` LEFT JOIN `hajj_oumrah` as hajj_oumrah1 ON `hajj_oumrah1`.`idhajjoumrah`=`souscriptions`.`pelerin` LEFT JOIN `oumrah` as oumrah1 ON `oumrah1`.`idoumrah`=`souscriptions`.`oumrah` LEFT JOIN `packages` as packages1 ON `packages1`.`idpackage`=`souscriptions`.`package` "
				),
			),
			'entrees' => array(
				'client' => array(
					'parent-table' => 'hajj_oumrah',
					'parent-primary-key' => 'idhajjoumrah',
					'child-primary-key' => 'identrees',
					'child-primary-key-index' => 0,
					'tab-label' => 'Packages <span class="hidden child-label-entrees child-field-caption">(Pelerin HAJJ)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/kaaba.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'DATE', 2 => 'Pelerin HAJJ', 3 => 'Pelerin OUMRAH', 4 => 'PACKAGE', 5 => 'MONTANT', 7 => 'Groupe', 8 => 'Agent'),
					'display-field-names' => array(1 => 'date_entree', 2 => 'client', 3 => 'oumrah', 4 => 'description', 5 => 'montant', 7 => 'groupe', 8 => 'agent'),
					'sortable-fields' => array(0 => '`entrees`.`identrees`', 1 => '`entrees`.`date_entree`', 2 => 3, 3 => 4, 4 => '`packages1`.`nom`', 5 => '`entrees`.`montant`', 6 => 7, 7 => 8, 8 => 9),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-entrees',
					'template-printable' => 'children-entrees-printable',
					'query' => "SELECT `entrees`.`identrees` as 'identrees', if(`entrees`.`date_entree`,date_format(`entrees`.`date_entree`,'%d/%m/%Y'),'') as 'date_entree', IF(    CHAR_LENGTH(`hajj_oumrah1`.`Prenom`) || CHAR_LENGTH(`hajj_oumrah1`.`Nom`), CONCAT_WS('',   `hajj_oumrah1`.`Prenom`, '   ', `hajj_oumrah1`.`Nom`), '') as 'client', IF(    CHAR_LENGTH(`oumrah1`.`Prenom`) || CHAR_LENGTH(`oumrah1`.`Nom`), CONCAT_WS('',   `oumrah1`.`Prenom`, '   ', `oumrah1`.`Nom`), '') as 'oumrah', IF(    CHAR_LENGTH(`packages1`.`nom`), CONCAT_WS('',   `packages1`.`nom`), '') as 'description', REPLACE(FORMAT(`entrees`.`montant`, 0), ',', ' ') as 'montant', `entrees`.`observations` as 'observations', `entrees`.`groupe` as 'groupe', `entrees`.`agent` as 'agent' FROM `entrees` LEFT JOIN `hajj_oumrah` as hajj_oumrah1 ON `hajj_oumrah1`.`idhajjoumrah`=`entrees`.`client` LEFT JOIN `oumrah` as oumrah1 ON `oumrah1`.`idoumrah`=`entrees`.`oumrah` LEFT JOIN `packages` as packages1 ON `packages1`.`idpackage`=`entrees`.`description` "
				),
				'oumrah' => array(
					'parent-table' => 'oumrah',
					'parent-primary-key' => 'idoumrah',
					'child-primary-key' => 'identrees',
					'child-primary-key-index' => 0,
					'tab-label' => 'Packages <span class="hidden child-label-entrees child-field-caption">(Pelerin OUMRAH)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/kaaba.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'DATE', 2 => 'Pelerin HAJJ', 3 => 'Pelerin OUMRAH', 4 => 'PACKAGE', 5 => 'MONTANT', 7 => 'Groupe', 8 => 'Agent'),
					'display-field-names' => array(1 => 'date_entree', 2 => 'client', 3 => 'oumrah', 4 => 'description', 5 => 'montant', 7 => 'groupe', 8 => 'agent'),
					'sortable-fields' => array(0 => '`entrees`.`identrees`', 1 => '`entrees`.`date_entree`', 2 => 3, 3 => 4, 4 => '`packages1`.`nom`', 5 => '`entrees`.`montant`', 6 => 7, 7 => 8, 8 => 9),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-entrees',
					'template-printable' => 'children-entrees-printable',
					'query' => "SELECT `entrees`.`identrees` as 'identrees', if(`entrees`.`date_entree`,date_format(`entrees`.`date_entree`,'%d/%m/%Y'),'') as 'date_entree', IF(    CHAR_LENGTH(`hajj_oumrah1`.`Prenom`) || CHAR_LENGTH(`hajj_oumrah1`.`Nom`), CONCAT_WS('',   `hajj_oumrah1`.`Prenom`, '   ', `hajj_oumrah1`.`Nom`), '') as 'client', IF(    CHAR_LENGTH(`oumrah1`.`Prenom`) || CHAR_LENGTH(`oumrah1`.`Nom`), CONCAT_WS('',   `oumrah1`.`Prenom`, '   ', `oumrah1`.`Nom`), '') as 'oumrah', IF(    CHAR_LENGTH(`packages1`.`nom`), CONCAT_WS('',   `packages1`.`nom`), '') as 'description', REPLACE(FORMAT(`entrees`.`montant`, 0), ',', ' ') as 'montant', `entrees`.`observations` as 'observations', `entrees`.`groupe` as 'groupe', `entrees`.`agent` as 'agent' FROM `entrees` LEFT JOIN `hajj_oumrah` as hajj_oumrah1 ON `hajj_oumrah1`.`idhajjoumrah`=`entrees`.`client` LEFT JOIN `oumrah` as oumrah1 ON `oumrah1`.`idoumrah`=`entrees`.`oumrah` LEFT JOIN `packages` as packages1 ON `packages1`.`idpackage`=`entrees`.`description` "
				),
			),
			'sorties' => array(
				'client' => array(
					'parent-table' => 'hajj_oumrah',
					'parent-primary-key' => 'idhajjoumrah',
					'child-primary-key' => 'idsorties',
					'child-primary-key-index' => 0,
					'tab-label' => 'Versements <span class="hidden child-label-sorties child-field-caption">(Pelerin HAJJ)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/kaaba.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'DATE ', 2 => 'Pelerin HAJJ', 3 => 'Pelerin OUMRAH', 4 => 'MONTANT ', 6 => 'Groupe', 7 => 'Agent'),
					'display-field-names' => array(1 => 'date_sortie', 2 => 'client', 3 => 'oumrah', 4 => 'montant', 6 => 'groupe', 7 => 'agent'),
					'sortable-fields' => array(0 => '`sorties`.`idsorties`', 1 => '`sorties`.`date_sortie`', 2 => 3, 3 => 4, 4 => '`sorties`.`montant`', 5 => 6, 6 => 7, 7 => 8),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-sorties',
					'template-printable' => 'children-sorties-printable',
					'query' => "SELECT `sorties`.`idsorties` as 'idsorties', if(`sorties`.`date_sortie`,date_format(`sorties`.`date_sortie`,'%d/%m/%Y'),'') as 'date_sortie', IF(    CHAR_LENGTH(`hajj_oumrah1`.`Prenom`) || CHAR_LENGTH(`hajj_oumrah1`.`Nom`), CONCAT_WS('',   `hajj_oumrah1`.`Prenom`, '   ', `hajj_oumrah1`.`Nom`), '') as 'client', IF(    CHAR_LENGTH(`oumrah1`.`Prenom`) || CHAR_LENGTH(`oumrah1`.`Nom`), CONCAT_WS('',   `oumrah1`.`Prenom`, '   ', `oumrah1`.`Nom`), '') as 'oumrah', REPLACE(FORMAT(`sorties`.`montant`, 0), ',', ' ') as 'montant', `sorties`.`observations` as 'observations', `sorties`.`groupe` as 'groupe', `sorties`.`agent` as 'agent' FROM `sorties` LEFT JOIN `hajj_oumrah` as hajj_oumrah1 ON `hajj_oumrah1`.`idhajjoumrah`=`sorties`.`client` LEFT JOIN `oumrah` as oumrah1 ON `oumrah1`.`idoumrah`=`sorties`.`oumrah` "
				),
				'oumrah' => array(
					'parent-table' => 'oumrah',
					'parent-primary-key' => 'idoumrah',
					'child-primary-key' => 'idsorties',
					'child-primary-key-index' => 0,
					'tab-label' => 'Versements <span class="hidden child-label-sorties child-field-caption">(Pelerin OUMRAH)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/kaaba.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'DATE ', 2 => 'Pelerin HAJJ', 3 => 'Pelerin OUMRAH', 4 => 'MONTANT ', 6 => 'Groupe', 7 => 'Agent'),
					'display-field-names' => array(1 => 'date_sortie', 2 => 'client', 3 => 'oumrah', 4 => 'montant', 6 => 'groupe', 7 => 'agent'),
					'sortable-fields' => array(0 => '`sorties`.`idsorties`', 1 => '`sorties`.`date_sortie`', 2 => 3, 3 => 4, 4 => '`sorties`.`montant`', 5 => 6, 6 => 7, 7 => 8),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-sorties',
					'template-printable' => 'children-sorties-printable',
					'query' => "SELECT `sorties`.`idsorties` as 'idsorties', if(`sorties`.`date_sortie`,date_format(`sorties`.`date_sortie`,'%d/%m/%Y'),'') as 'date_sortie', IF(    CHAR_LENGTH(`hajj_oumrah1`.`Prenom`) || CHAR_LENGTH(`hajj_oumrah1`.`Nom`), CONCAT_WS('',   `hajj_oumrah1`.`Prenom`, '   ', `hajj_oumrah1`.`Nom`), '') as 'client', IF(    CHAR_LENGTH(`oumrah1`.`Prenom`) || CHAR_LENGTH(`oumrah1`.`Nom`), CONCAT_WS('',   `oumrah1`.`Prenom`, '   ', `oumrah1`.`Nom`), '') as 'oumrah', REPLACE(FORMAT(`sorties`.`montant`, 0), ',', ' ') as 'montant', `sorties`.`observations` as 'observations', `sorties`.`groupe` as 'groupe', `sorties`.`agent` as 'agent' FROM `sorties` LEFT JOIN `hajj_oumrah` as hajj_oumrah1 ON `hajj_oumrah1`.`idhajjoumrah`=`sorties`.`client` LEFT JOIN `oumrah` as oumrah1 ON `oumrah1`.`idoumrah`=`sorties`.`oumrah` "
				),
			),
			'agences' => array(
			),
			'gestion_transactions' => array(
			),
			'billeteries' => array(
				'link_out' => array(
					'parent-table' => 'gestion_transactions',
					'parent-primary-key' => 'idgtransaction',
					'child-primary-key' => 'idbilleterie',
					'child-primary-key-index' => 0,
					'tab-label' => 'Transactions <span class="hidden child-label-billeteries child-field-caption">(Link fin)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/document_copies.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(3 => 'Date', 4 => 'Service', 6 => 'GDS', 7 => 'Compagnie', 8 => 'Parcours', 12 => 'PRIX D\'ACHAT', 13 => 'PRIX DE VENTE (prix unitaire)', 14 => 'QTS', 15 => 'COMMISSION', 16 => 'FRAIS DE SERVICE', 17 => 'FRAIS ASSURANCES', 18 => 'Montant TVA', 19 => 'TVA', 20 => 'NET POUR MAREGA VOYAGE', 21 => 'NET COMPAGNIES', 22 => 'NET A PAYER', 23 => 'ACCOMPTE', 24 => 'RESTE A PAYER', 25 => 'Agent', 26 => 'Groupe'),
					'display-field-names' => array(3 => 'date', 4 => 'service', 6 => 'gds', 7 => 'compagnie', 8 => 'parcours', 12 => 'prix_achat', 13 => 'prix_vente', 14 => 'qts', 15 => 'commission', 16 => 'frais_service', 17 => 'frais_assurance', 18 => 'mtva', 19 => 'tva', 20 => 'tht', 21 => 'net_compagnie', 22 => 'net_a_payer', 23 => 'account', 24 => 'reste_a_payer', 25 => 'agent', 26 => 'groupe'),
					'sortable-fields' => array(0 => '`billeteries`.`idbilleterie`', 1 => '`gestion_transactions1`.`link_in`', 2 => 3, 3 => '`billeteries`.`date`', 4 => '`produits_services1`.`produit_service`', 5 => 6, 6 => '`gds1`.`gds`', 7 => 8, 8 => '`items1`.`item`', 9 => '`produits_services2`.`produit_service`', 10 => 11, 11 => 12, 12 => '`billeteries`.`prix_achat`', 13 => '`billeteries`.`prix_vente`', 14 => '`billeteries`.`qts`', 15 => '`billeteries`.`commission`', 16 => '`billeteries`.`frais_service`', 17 => '`billeteries`.`frais_assurance`', 18 => '`billeteries`.`mtva`', 19 => '`billeteries`.`tva`', 20 => '`billeteries`.`tht`', 21 => '`billeteries`.`net_compagnie`', 22 => '`billeteries`.`net_a_payer`', 23 => '`billeteries`.`account`', 24 => '`billeteries`.`reste_a_payer`', 25 => 26, 26 => 27, 27 => 28),
					'records-per-page' => 10,
					'default-sort-by' => 3,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-billeteries',
					'template-printable' => 'children-billeteries-printable',
					'query' => "SELECT `billeteries`.`idbilleterie` as 'idbilleterie', IF(    CHAR_LENGTH(`gestion_transactions1`.`link_in`), CONCAT_WS('',   `gestion_transactions1`.`link_in`), '') as 'link_out', `billeteries`.`facture` as 'facture', if(`billeteries`.`date`,date_format(`billeteries`.`date`,'%d/%m/%Y'),'') as 'date', IF(    CHAR_LENGTH(`produits_services1`.`produit_service`), CONCAT_WS('',   `produits_services1`.`produit_service`), '') as 'service', IF(    CHAR_LENGTH(`clients1`.`prenom`) || CHAR_LENGTH(`clients1`.`nom`), CONCAT_WS('',   `clients1`.`prenom`, '   ', `clients1`.`nom`), '') as 'passager', IF(    CHAR_LENGTH(`gds1`.`gds`), CONCAT_WS('',   `gds1`.`gds`), '') as 'gds', IF(    CHAR_LENGTH(`compagnies1`.`nom_compagnie`) || CHAR_LENGTH(`type_compagnie1`.`type_compangie`), CONCAT_WS('',   `compagnies1`.`nom_compagnie`, '   |   ', `type_compagnie1`.`type_compangie`), '') as 'compagnie', IF(    CHAR_LENGTH(`items1`.`item`), CONCAT_WS('',   `items1`.`item`), '') as 'parcours', IF(    CHAR_LENGTH(`produits_services2`.`produit_service`), CONCAT_WS('',   `produits_services2`.`produit_service`), '') as 'nature_transaction', `billeteries`.`billet` as 'billet', `billeteries`.`dossier` as 'dossier', REPLACE(FORMAT(`billeteries`.`prix_achat`, 0), ',', ' ') as 'prix_achat', REPLACE(FORMAT(`billeteries`.`prix_vente`, 0), ',', ' ') as 'prix_vente', `billeteries`.`qts` as 'qts', REPLACE(FORMAT(`billeteries`.`commission`, 0), ',', ' ') as 'commission', REPLACE(FORMAT(`billeteries`.`frais_service`, 0), ',', ' ') as 'frais_service', REPLACE(FORMAT(`billeteries`.`frais_assurance`, 0), ',', ' ') as 'frais_assurance', `billeteries`.`mtva` as 'mtva', `billeteries`.`tva` as 'tva', `billeteries`.`tht` as 'tht', REPLACE(FORMAT(`billeteries`.`net_compagnie`, 0), ',', ' ') as 'net_compagnie', `billeteries`.`net_a_payer` as 'net_a_payer', `billeteries`.`account` as 'account', `billeteries`.`reste_a_payer` as 'reste_a_payer', `billeteries`.`agent` as 'agent', `billeteries`.`groupe` as 'groupe', `billeteries`.`observations` as 'observations' FROM `billeteries` LEFT JOIN `gestion_transactions` as gestion_transactions1 ON `gestion_transactions1`.`idgtransaction`=`billeteries`.`link_out` LEFT JOIN `produits_services` as produits_services1 ON `produits_services1`.`idps`=`billeteries`.`service` LEFT JOIN `clients` as clients1 ON `clients1`.`idclient`=`billeteries`.`passager` LEFT JOIN `gds` as gds1 ON `gds1`.`idgds`=`billeteries`.`gds` LEFT JOIN `compagnies` as compagnies1 ON `compagnies1`.`idcompagnie`=`billeteries`.`compagnie` LEFT JOIN `type_compagnie` as type_compagnie1 ON `type_compagnie1`.`idtypecompagnie`=`compagnies1`.`type` LEFT JOIN `items` as items1 ON `items1`.`iditem`=`billeteries`.`parcours` LEFT JOIN `produits_services` as produits_services2 ON `produits_services2`.`idps`=`billeteries`.`nature_transaction` "
				),
			),
			'gestion_changes' => array(
			),
			'changes' => array(
				'link_out' => array(
					'parent-table' => 'gestion_changes',
					'parent-primary-key' => 'idgchange',
					'child-primary-key' => 'idchange',
					'child-primary-key-index' => 0,
					'tab-label' => 'Changes <span class="hidden child-label-changes child-field-caption">(Link fin)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/document_copies.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(3 => 'Date', 5 => 'Pi&#232;ce justificatives', 6 => 'Nature des devises', 7 => 'Montant devises', 9 => 'Montant CFA', 21 => 'Groupe', 22 => 'Agent'),
					'display-field-names' => array(3 => 'date', 5 => 'billet', 6 => 'dossier', 7 => 'prix_achat', 9 => 'net_a_payer', 21 => 'groupe', 22 => 'agent'),
					'sortable-fields' => array(0 => '`changes`.`idchange`', 1 => '`gestion_changes1`.`link_in`', 2 => 3, 3 => '`changes`.`date`', 4 => 5, 5 => 6, 6 => 7, 7 => '`changes`.`prix_achat`', 8 => '`changes`.`mtva`', 9 => '`changes`.`net_a_payer`', 10 => '`changes`.`net_compagnie`', 11 => '`changes`.`prix_vente`', 12 => '`changes`.`qts`', 13 => '`changes`.`commission`', 14 => '`changes`.`frais_service`', 15 => '`changes`.`frais_assurance`', 16 => '`changes`.`tva`', 17 => '`changes`.`tht`', 18 => '`changes`.`account`', 19 => '`changes`.`reste_a_payer`', 20 => 21, 21 => 22, 22 => 23),
					'records-per-page' => 10,
					'default-sort-by' => 3,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-changes',
					'template-printable' => 'children-changes-printable',
					'query' => "SELECT `changes`.`idchange` as 'idchange', IF(    CHAR_LENGTH(`gestion_changes1`.`link_in`), CONCAT_WS('',   `gestion_changes1`.`link_in`), '') as 'link_out', `changes`.`facture` as 'facture', if(`changes`.`date`,date_format(`changes`.`date`,'%d/%m/%Y'),'') as 'date', `changes`.`nature_transaction` as 'nature_transaction', `changes`.`billet` as 'billet', `changes`.`dossier` as 'dossier', REPLACE(FORMAT(`changes`.`prix_achat`, 0), ',', ' ') as 'prix_achat', `changes`.`mtva` as 'mtva', `changes`.`net_a_payer` as 'net_a_payer', REPLACE(FORMAT(`changes`.`net_compagnie`, 0), ',', ' ') as 'net_compagnie', REPLACE(FORMAT(`changes`.`prix_vente`, 0), ',', ' ') as 'prix_vente', `changes`.`qts` as 'qts', REPLACE(FORMAT(`changes`.`commission`, 0), ',', ' ') as 'commission', REPLACE(FORMAT(`changes`.`frais_service`, 0), ',', ' ') as 'frais_service', REPLACE(FORMAT(`changes`.`frais_assurance`, 0), ',', ' ') as 'frais_assurance', `changes`.`tva` as 'tva', `changes`.`tht` as 'tht', `changes`.`account` as 'account', `changes`.`reste_a_payer` as 'reste_a_payer', `changes`.`observations` as 'observations', `changes`.`groupe` as 'groupe', `changes`.`agent` as 'agent' FROM `changes` LEFT JOIN `gestion_changes` as gestion_changes1 ON `gestion_changes1`.`idgchange`=`changes`.`link_out` "
				),
			),
			'partages' => array(
			),
			'type_compagnie' => array(
			),
			'compagnies' => array(
			),
			'produits_services' => array(
			),
			'banques' => array(
			),
			'pays' => array(
			),
			'villes' => array(
			),
			'items' => array(
			),
			'type_client' => array(
			),
			'fonctions' => array(
			),
			'activites' => array(
			),
			'postes' => array(
			),
			'annees' => array(
			),
			'gds' => array(
			),
			'objets' => array(
			),
			'type_rapport' => array(
			),
			'fidelite' => array(
			),
			'pointages' => array(
				'nom_prenom' => array(
					'parent-table' => 'personnels',
					'parent-primary-key' => 'idpersonnel',
					'child-primary-key' => 'idpointage',
					'child-primary-key-index' => 0,
					'tab-label' => 'Pointages <span class="hidden child-label-pointages child-field-caption">(Nom prenom)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/timesheet.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Date', 2 => 'Nom prenom', 3 => 'Agence', 4 => 'Fonction', 5 => 'Arrivee', 6 => 'Depart', 8 => 'Groupe', 9 => 'Agent'),
					'display-field-names' => array(1 => 'date', 2 => 'nom_prenom', 3 => 'agence', 4 => 'fonction', 5 => 'arrivee', 6 => 'depart', 8 => 'groupe', 9 => 'agent'),
					'sortable-fields' => array(0 => '`pointages`.`idpointage`', 1 => '`pointages`.`date`', 2 => 3, 3 => 4, 4 => 5, 5 => '`pointages`.`arrivee`', 6 => '`pointages`.`depart`', 7 => 8, 8 => 9, 9 => 10),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'desc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-pointages',
					'template-printable' => 'children-pointages-printable',
					'query' => "SELECT `pointages`.`idpointage` as 'idpointage', if(`pointages`.`date`,date_format(`pointages`.`date`,'%d/%m/%Y'),'') as 'date', IF(    CHAR_LENGTH(`personnels1`.`nom`) || CHAR_LENGTH(`personnels1`.`prenom`), CONCAT_WS('',   `personnels1`.`nom`, '   ', `personnels1`.`prenom`), '') as 'nom_prenom', IF(    CHAR_LENGTH(`agences1`.`agence`), CONCAT_WS('',   `agences1`.`agence`), '') as 'agence', IF(    CHAR_LENGTH(`fonctions1`.`fonction`), CONCAT_WS('',   `fonctions1`.`fonction`), '') as 'fonction', `pointages`.`arrivee` as 'arrivee', `pointages`.`depart` as 'depart', `pointages`.`obs` as 'obs', `pointages`.`groupe` as 'groupe', `pointages`.`agent` as 'agent' FROM `pointages` LEFT JOIN `personnels` as personnels1 ON `personnels1`.`idpersonnel`=`pointages`.`nom_prenom` LEFT JOIN `agences` as agences1 ON `agences1`.`idagence`=`personnels1`.`agence` LEFT JOIN `fonctions` as fonctions1 ON `fonctions1`.`idfonction`=`personnels1`.`fonction` "
				),
			),
			'note_de_service' => array(
			),
			'redactions' => array(
			),
			'rapports_activite' => array(
			),
			'gestion_comptes' => array(
			),
			'gestion_comptes_1' => array(
			),
			'type_comptes' => array(
			),
			'journal' => array(
			),
			'liens' => array(
			),
			'courrier_entrant' => array(
			),
			'courrier_sortant' => array(
			),
			'vitae' => array(
			),
			'reunions' => array(
			),
			'item_reunions' => array(
				'link_out' => array(
					'parent-table' => 'reunions',
					'parent-primary-key' => 'idreunion',
					'child-primary-key' => 'iditemreunion',
					'child-primary-key-index' => 0,
					'tab-label' => 'Reunions <span class="hidden child-label-item_reunions child-field-caption">(Link fin)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/calendar_edit.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(2 => 'Activit&#233;s ou Sujet', 3 => 'Temps allou&#233;', 4 => 'Responsable', 5 => 'Objectif'),
					'display-field-names' => array(2 => 'activite', 3 => 'temps', 4 => 'responsable', 5 => 'objectif'),
					'sortable-fields' => array(0 => '`item_reunions`.`iditemreunion`', 1 => '`reunions1`.`link_in`', 2 => 3, 3 => 4, 4 => 5, 5 => 6, 6 => 7),
					'records-per-page' => 10,
					'default-sort-by' => false,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-item_reunions',
					'template-printable' => 'children-item_reunions-printable',
					'query' => "SELECT `item_reunions`.`iditemreunion` as 'iditemreunion', IF(    CHAR_LENGTH(`reunions1`.`link_in`), CONCAT_WS('',   `reunions1`.`link_in`), '') as 'link_out', `item_reunions`.`activite` as 'activite', `item_reunions`.`temps` as 'temps', `item_reunions`.`responsable` as 'responsable', `item_reunions`.`objectif` as 'objectif', `item_reunions`.`observations` as 'observations' FROM `item_reunions` LEFT JOIN `reunions` as reunions1 ON `reunions1`.`idreunion`=`item_reunions`.`link_out` "
				),
			),
			'statut_partage' => array(
			),
			'chequiers' => array(
			),
			'cheques' => array(
				'chequier' => array(
					'parent-table' => 'chequiers',
					'parent-primary-key' => 'idchequier',
					'child-primary-key' => 'idcheque',
					'child-primary-key-index' => 0,
					'tab-label' => 'Cheques <span class="hidden child-label-cheques child-field-caption">(Chequier)</span>',
					'auto-close' => false,
					'table-icon' => 'resources/table_icons/cheque.png',
					'display-refresh' => true,
					'display-add-new' => true,
					'forced-where' => '',
					'display-fields' => array(1 => 'Num&#233;ro', 3 => 'Groupe', 4 => 'Agent'),
					'display-field-names' => array(1 => 'num', 3 => 'groupe', 4 => 'agent'),
					'sortable-fields' => array(0 => '`cheques`.`idcheque`', 1 => 2, 2 => '`chequiers1`.`idchequier`', 3 => 4, 4 => 5),
					'records-per-page' => 10,
					'default-sort-by' => 1,
					'default-sort-direction' => 'asc',
					'open-detail-view-on-click' => true,
					'display-page-selector' => true,
					'show-page-progress' => true,
					'template' => 'children-cheques',
					'template-printable' => 'children-cheques-printable',
					'query' => "SELECT `cheques`.`idcheque` as 'idcheque', `cheques`.`num` as 'num', IF(    CHAR_LENGTH(`chequiers1`.`idchequier`), CONCAT_WS('',   `chequiers1`.`idchequier`), '') as 'chequier', `cheques`.`groupe` as 'groupe', `cheques`.`agent` as 'agent' FROM `cheques` LEFT JOIN `chequiers` as chequiers1 ON `chequiers1`.`idchequier`=`cheques`.`chequier` "
				),
			),
			'gestion_banques' => array(
			),
			'suivi_banques' => array(
			),
			'charges_fixe' => array(
			),
			'caisse' => array(
			),
			'type_visa' => array(
			),
			'libelle_charges_fixe' => array(
			),
			'desc_suivi_banque' => 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);
		/************************************************/
	}
