<?php

  $debugin        = $decoded['debug'];
  $usr_id         = $decoded['usr_id'];

  if( $usr_id ){

    //User
    $Query = "
      SELECT
        usr.id
      FROM usuarios_app usr
      WHERE
        usr.id = '$usr_id'
        AND usr.activo = '1'
    ";
    $Result = mysqli_query($mysqli, $Query);
    $Usr = mysqli_fetch_assoc($Result);
    if( $Usr[id] ){

      //Marcas
      $Query = "
        SELECT
          mar.id, mar.nombre
        FROM marcas mar
        WHERE mar.activo = '1'
      ";
      $Mars = $mysqli->query($Query);
      mysqli_data_seek($Mars, 0);
      while($Mar = mysqli_fetch_array($Mars)) {

        $Marcas[] = array(
          'marca_id'  => $Mar[id],
          'nombre'    => $Mar[nombre]
        );

      }

      $Data = array(
        'marcas'   => $Marcas
      );
      echo json_encode($Data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

    }else{

      //Error
      $Query = "
        SELECT
          err.Id, err.error, err.msn
        FROM api_errores err
        WHERE err.error = 'uv-1'
      ";
      $Result = mysqli_query($mysqli, $Query);
      $Error = mysqli_fetch_assoc($Result);

      $Data = array(
        'action'      => 'error',
        'error'       => $Error[error],
        'error_msn'   => $Error[msn]
      );
      echo json_encode($Data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

    }

  }

?>
