<?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;
     };


$anio=$_REQUEST['anio'];
$mes=$_REQUEST['mes'];

$sql = $db->query("SELECT id, depreciacion, gps, soat, imp_vehicular, gasto_adm, serv_public, otras_depre, rev_tecnica, otros_gastos, total_cfadm, sueldo_oper, sctr, bono, epps, accesorios_seg, movilidad, alimentacion, otros_gastoscv, total_cfoperaciones, total_cf, total_cfkm, precio_comb, combustible, neuma_km, mtto_prevkmtotal, mtto_prevkm, mtto_correctkmtotal, mtto_correctkm, TotalCostoVariable, KmRecorrido, TotalCostos, TotalTarifa, anio, mes, placa, created_at, updated_at FROM tb_maestra WHERE anio=$anio AND mes=$mes ORDER BY id DESC;");
$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);
?>