<?php
class Reporte {
	private $db;

	public function __construct($db) {
		$this->db = $db;
	}

	public function obtenerTodosPorUsuario($usuario_id) {
		$stmt = $this->db->prepare("
			SELECT r.* FROM reportes r
			INNER JOIN permisos_reportes p ON r.id = p.id_reporte
			WHERE p.id_usuario = ? AND r.activo = 1
		");
		$stmt->bind_param("i", $usuario_id);
		$stmt->execute();
		return $stmt->get_result();
	}

	public function crear($nombre, $url) {
		$stmt = $this->db->prepare("INSERT INTO reportes (fullname, url) VALUES (?, ?)");
		$stmt->bind_param("ss", $nombre, $url);
		return $stmt->execute();
	}
}
