<?php

include 'conexion.php';
$id=$_GET['id'];
$tipo=$_GET['tipo'];
$start=$_GET['start'];

if(empty($tipo)){
    $tipo = "tipo like '%'";
 }else{
    $tipo = "tipo = $tipo";
 }

if(strlen($id) > 0){
  $id = " and fk_id_activo like '%".$id."%'";
}

$consulta = "SELECT id_log_act,fk_id_activo,fecha_hora,tipo,observacion,nom_pdf, (SELECT COUNT(fk_id_activo) FROM log_activos where $tipo $id) as count_log FROM log_activos where $tipo $id ORDER BY fecha_hora DESC LIMIT $start,50";
$result = $conexion->query($consulta);

//echo $consulta;

while($fila = $result -> fetch_array()){
    $log_activos[] = array_map('utf8_encode', $fila);
}

echo json_encode($log_activos);
$result -> close();

?>