<?php
// Busca la usuario por id
function info($data,$tabla,$id) {
  global $mysqli;
  $mysqli->query("SET NAMES 'utf8'");
  $row1 = $mysqli->query("SELECT $data FROM $tabla WHERE id='$id'");
  return $row1->fetch_assoc();
}

function sinfo($tabla,$id) {
  global $mysqli;
  $mysqli->query("SET NAMES 'utf8'");
  $row1 = $mysqli->query("SELECT * FROM $tabla WHERE id='$id'");
  return $row1->fetch_assoc();
}


function scinv($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT nombre FROM z_cinversiones WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la usuario por id
function stinv($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_tinversiones WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la usuario por id
function sprod($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_productos WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
function suser($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_usuarios WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la cliente por id
function sclien($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_clientes WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la Proveedor por id
function sprove($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_proveedores WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la rutero por id
function srute($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_ruteros WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la ruta por id
function sruta($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_ruta WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la usuario por id
function seped($code) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_epedidos WHERE code='$code'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la departamento por id
function sdepa($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_departamentos WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la ciudad por id
function scity($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_municipios WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la localidad por id
function sloca($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_localidades WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
// Busca la zona por id
function szona($id) {
  global $server, $user, $pass, $bd, $port;
  $mysqli = new mysqli($server, $user, $pass, $bd, $port);
  if($mysqli->connect_error) {
    $error = str_replace("'", "", $mysqli->connect_error); 
    exit(header("Location:".$r."index.php?error=fallo la conexion (".$error.")"));
  } else {
    $mysqli->query("SET NAMES 'utf8'");
    $row1 = $mysqli->query("SELECT * FROM z_zonas WHERE id='$id'");
    $dato=$row1->fetch_assoc();
    return $dato;
  }
}
?>