Contents of the file: /payment-report-system/payment-report-system/backend/controllers/ReportController.php

<?php
require_once 'models/Report.php';

class ReportController {
    private $db;

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

    public function getReport($id) {
        $report = new Report($this->db);
        return $report->find($id);
    }

    public function getReports() {
        $report = new Report($this->db);
        return $report->all();
    }

    public function createReport($data) {
        $report = new Report($this->db);
        return $report->save($data);
    }

    public function deleteReport($id) {
        $report = new Report($this->db);
        return $report->delete($id);
    }
}

Contents of the file: /payment-report-system/payment-report-system/backend/models/Report.php

<?php
class Report {
    private $db;
    private $table = 'reports';

    public $id;
    public $amount;
    public $date;
    public $status;

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

    public function find($id) {
        $stmt = $this->db->prepare("SELECT * FROM " . $this->table . " WHERE id = :id");
        $stmt->bindParam(':id', $id);
        $stmt->execute();
        return $stmt->fetch(PDO::FETCH_ASSOC);
    }

    public function all() {
        $stmt = $this->db->prepare("SELECT * FROM " . $this->table);
        $stmt->execute();
        return $stmt->fetchAll(PDO::FETCH_ASSOC);
    }

    public function save($data) {
        $stmt = $this->db->prepare("INSERT INTO " . $this->table . " (amount, date, status) VALUES (:amount, :date, :status)");
        $stmt->bindParam(':amount', $data['amount']);
        $stmt->bindParam(':date', $data['date']);
        $stmt->bindParam(':status', $data['status']);
        return $stmt->execute();
    }

    public function delete($id) {
        $stmt = $this->db->prepare("DELETE FROM " . $this->table . " WHERE id = :id");
        $stmt->bindParam(':id', $id);
        return $stmt->execute();
    }
}

Contents of the file: /payment-report-system/payment-report-system/backend/routes/api.php

<?php
require_once '../controllers/ReportController.php';

$database = new Database();
$db = $database->getConnection();
$reportController = new ReportController($db);

$requestMethod = $_SERVER["REQUEST_METHOD"];

switch ($requestMethod) {
    case 'GET':
        if (isset($_GET['id'])) {
            $report = $reportController->getReport($_GET['id']);
            echo json_encode($report);
        } else {
            $reports = $reportController->getReports();
            echo json_encode($reports);
        }
        break;
    case 'POST':
        $data = json_decode(file_get_contents("php://input"), true);
        $reportController->createReport($data);
        break;
    case 'DELETE':
        if (isset($_GET['id'])) {
            $reportController->deleteReport($_GET['id']);
        }
        break;
    default:
        header("HTTP/1.0 405 Method Not Allowed");
        break;
}

Contents of the file: /payment-report-system/payment-report-system/frontend/views/index.html

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../css/styles.css">
    <title>Sistema de Reportes de Pago</title>
</head>
<body>
    <h1>Sistema de Reportes de Pago</h1>
    <h2>Crear Reporte</h2>
    <form id="reportForm">
        <input type="number" name="amount" placeholder="Monto" required>
        <input type="date" name="date" required>
        <select name="status" required>
            <option value="pendiente">Pendiente</option>
            <option value="completado">Completado</option>
        </select>
        <button type="submit">Crear Reporte</button>
    </form>
    <h2>Reportes Existentes</h2>
    <div id="reportsList"></div>
    <script src="../js/scripts.js"></script>
</body>
</html>