<?php

include('../../../config/config.php');

$task_id = $_POST['task_id'];
$commitee_id = $_POST['commitee_id'];
$user_id = $_POST['user_id'];
$user_type_holder = $_POST['user_type_holder'];

if($user_type_holder == 'admin'){

    $view_penalty = "SELECT * FROM `offenceconclusion` WHERE `TaskID` = '$task_id' AND `CommitteeID` = '$commitee_id' AND `UserID` = '$user_id' ";
    $view_penalty_query = mysqli_query($link, $view_penalty);
    $fetch_penalty_query = mysqli_fetch_assoc($view_penalty_query);
    $rows_penalty_query = mysqli_num_rows($view_penalty_query);

    if($rows_penalty_query > 0){
        $get_penalty_id = $fetch_penalty_query['Penalty'];

        echo '<div class="card">
                <div class="card-body text-center">
                    <b>'.$get_penalty_id.'</b>
                </div>
            </div>';
    }else{
        echo 2;
    }
}elseif($user_type_holder == 'parent' || $user_type_holder == 'teacher' || $user_type_holder == 'student'){

    $view_penalty = "SELECT * FROM `offenceconclusion` WHERE `TaskID` = '$task_id' AND `CommitteeID` = '$commitee_id' AND `UserID` = '$user_id' ";
    $view_penalty_query = mysqli_query($link, $view_penalty);
    $fetch_penalty_query = mysqli_fetch_assoc($view_penalty_query);
    $rows_penalty_query = mysqli_num_rows($view_penalty_query);

    if($rows_penalty_query > 0){
        $get_penalty_id = $fetch_penalty_query['Penalty'];

        echo '<div class="card">
                <div class="card-body text-center">
                    <b>'.$get_penalty_id.'</b>
                </div>
            </div>';
    }else{
        echo 2;
    }
}elseif($user_type_holder == 'schoolhead'){

    $view_penalty = "SELECT * FROM `offenceconclusion` WHERE `TaskID` = '$task_id' AND `CommitteeID` = '$commitee_id' AND `UserID` = '$user_id' ";
    $view_penalty_query = mysqli_query($link, $view_penalty);
    $fetch_penalty_query = mysqli_fetch_assoc($view_penalty_query);
    $rows_penalty_query = mysqli_num_rows($view_penalty_query);

    if($rows_penalty_query > 0){
        $get_penalty_id = $fetch_penalty_query['Penalty'];

        echo '<div class="card">
                <div class="card-body text-center">
                    <b>'.$get_penalty_id.'</b>
                </div>
            </div>';
    }else{
        echo 2;
    }

}else{

}

?>