-- Retrieving data for a specific passenger complaint:
SELECT
    c.id AS complaint_id,
    r.id AS ride_id,
    p.id AS passenger_id,
    p.first_name,
    p.last_name,
    p.phone,
    p.email,
    c.complaint_type,
    c.description,
    c.date_filed,
    c.statusComplaint AS complaint_status,
    c.resolution,
    c.date_resolved
FROM
    complaint c
JOIN ride r ON
    c.ride_id = r.id
JOIN `passengers` p ON
    c.passenger_id = p.id
WHERE
    c.complaint_type = 'Passenger' AND c.passenger_id = '100393163265770158312';

    -- Admin panel dashboard

    SELECT
        (
        SELECT
            COUNT(`email`)
        FROM
            `passengers`
    ) AS countPassengers,
    (
        SELECT
            COUNT(`email`)
        FROM
            `driver`
    ) AS countDriver,
    (
    SELECT
        COUNT(`id`)
    FROM
        `ride`
    ) AS countRide,
    (
        SELECT
            COUNT(`id`)
        FROM
            `passengers`
        WHERE
            `passengers`.`created_at` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
    ) AS countPassengersThisMonth,
    (
        SELECT
            COUNT(`id`)
        FROM
            `ride`
        WHERE
            `ride`.`created_at` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
    ) AS countRideThisMonth,
    (
        SELECT
            COUNT(`id`)
        FROM
            `driver`
        WHERE
            `driver`.`created_at` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
    ) AS countDriverThisMonth,
    (
        SELECT
            COUNT(`id`)
        FROM
            `CarRegistration`
        WHERE
            `CarRegistration`.`created_at` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
    ) AS countCarRegistrationThisMonth,
    (
        SELECT
            COUNT(`id`)
        FROM
            `complaint`
        WHERE
            `complaint`.`date_filed` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
    ) AS countComplaintThisMonth,
    (
        SELECT
            COUNT(`id`)
        FROM
            `complaint`
        WHERE
            `complaint`.`date_filed` BETWEEN DATE_FORMAT(
                DATE_SUB(
                    CURRENT_DATE,
                    INTERVAL WEEKDAY(CURRENT_DATE) DAY
                ),
                '%Y-%m-%d'
            ) AND DATE_FORMAT(
                DATE_ADD(
                    DATE_SUB(
                        CURRENT_DATE,
                        INTERVAL WEEKDAY(CURRENT_DATE) DAY
                    ),
                    INTERVAL 6 DAY
                ),
                '%Y-%m-%d'
            )
    ) AS countComplaintThisWeek,
    (
        SELECT
            COUNT(`id`)
        FROM
            `complaint`
        WHERE
            `complaint`.`date_filed` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-%d') AND DATE_FORMAT(CURRENT_DATE, '%Y-%m-%d')
    ) AS countComplaintToday,
    (
        SELECT
            SUM(`payments`.`amount`)
        FROM
            `payments` WHERE
            `payments`.`created_at` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
        AND
            `payments`.`payment_method` IN('visa-in',
            'visa',
            'visaRide',
            'TransferFrom',
            'payout',
            'TransferTo')
    ) AS payments,
    (
        SELECT
            SUM(`driverWallet`.`amount`)
        FROM
            `driverWallet`
        WHERE
            `driverWallet`.`dateCreated` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
        AND
            `driverWallet`.`paymentMethod` IN('visa', '')
    ) AS driverWallet,
    (
        SELECT
            SUM(`passengerWallet`.`balance`)
        FROM
            `passengerWallet`
        WHERE
            `passengerWallet`.`created_at` BETWEEN DATE_FORMAT(CURRENT_DATE, '%Y-%m-01') AND LAST_DAY(CURRENT_DATE)
    ) AS passengerWallet
    FROM
        `passengers`
    LIMIT 1