<?php

function getSurveyFilter(mysqli $conn): string
{
    $role = $_SESSION['role'] ?? '';

    if ($role === 'admin') {
        return '';
    }

    if ($role === 'zonal_director') {

        $zone = mysqli_real_escape_string(
            $conn,
            $_SESSION['zone_name']
        );

        return " WHERE zone_name = '$zone' ";
    }

    $user = mysqli_real_escape_string(
        $conn,
        $_SESSION['fullname']
    );

    return " WHERE entered_by = '$user' ";
}