<?php
require_once('../../../includes/load.php');


//funcion para traer los datos de la base de datos a la tabla listado programa
$convert_utf8 = function ($s) {
         if (!mb_check_encoding($s, 'UTF-8')) {
             $s = utf8_encode($s);
         }
         return $s;
     };
$sql = $db->query("SELECT u.id, u.username, u.name, u.last_name, a.NOMB_AREA, u.cargo, g.NOMB_GER FROM users as u INNER JOIN area as a ON a.id = u.id_area INNER JOIN gerencia AS g ON g.id = a.ID_GER ORDER BY u.id ASC");
$data = array();
while( $rows = mysqli_fetch_assoc($sql) ) {
	$data[] = array_map($convert_utf8, $rows);
}
$results = array(
	"sEcho" => 1,
"iTotalRecords" => count($data),
"iTotalDisplayRecords" => count($data),
  "aaData"=>$data);
echo json_encode($results);
?>