<?php
	$sql = 'SELECT u.*, xrol.libelle AS lib_role, xreg.libelle AS lib_region FROM users u LEFT JOIN x_roles xrol on u.fk_role = xrol.rowid LEFT JOIN x_regions xreg on u.fk_region = xreg.rowid ORDER BY u.libelle, u.prenom;';
	$aModel["users"] = getinfos($sql, "gen");
	
	$sql = 'SELECT rowid, libelle, abreviation FROM x_roles WHERE active=1 ORDER BY libelle;';
	$aModel["roles"] = getinfos($sql, "gen");
	
	$sql = 'SELECT rowid, libelle  FROM x_regions WHERE active=1 ORDER BY libelle;';
	$aModel["regions"] = getinfos($sql, "gen");
	
	$sql = 'SELECT u.rowid, CONCAT(u.prenom, " ", u.libelle, " (", xrol.abreviation, ")") AS lib_parent FROM users u LEFT JOIN x_roles xrol on u.fk_role = xrol.rowid WHERE u.fk_role IN (1,2) ORDER BY lib_parent;';
	$aModel["parents"] = getinfos($sql, "gen");
