<?php
 error_reporting(E_ALL);
 ini_set('display_errors', 1);

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

$campus = $_POST["campus"];

 $slect_all_committee = " SELECT * FROM `boardmember` WHERE `CampusID` IN (0, $campus) AND DeleteStatus = 0";
 $ekene_query_link_class = mysqli_query($link, $slect_all_committee);
 $ekene_get_details_subject = mysqli_fetch_assoc($ekene_query_link_class);
 $ekene_row_cnt_ekene = mysqli_num_rows($ekene_query_link_class);
 if ($ekene_row_cnt_ekene > 0)
 {
    echo ' <div class="row">';
     
    do{
        $Committeename = $ekene_get_details_subject['Committeename'];
        $Datecreated = $ekene_get_details_subject['Datecreated'];
        $CommitteeID = $ekene_get_details_subject['CommitteeID'];
        $CampusID = $ekene_get_details_subject['CampusID'];

        $firstLetter = substr($Committeename, 0, 1);

        $slect_all_member = "SELECT * FROM `member` WHERE `CommitteeID`= '$CommitteeID' AND Deletestatus = 0";
        $ekene_query_link_member = mysqli_query($link, $slect_all_member);
        $ekene_get_details_subjectmember = mysqli_fetch_assoc($ekene_query_link_member);
        $ekene_row_cnt_ekenemember = mysqli_num_rows($ekene_query_link_member);

            echo'
            <div class="col-md-12 col-lg-6"><small class="text-secondary" style="font-size:9px;"></small><div class="card mb-3" style="max-width: 540px; border:2px dashed #007ffb;">
                <div class="row g-0">
                    <div class="col-md-4">
                        <span class="btn btn-sm btn-icon fw-bold p-0" style="cursor:pointer;background-color:#F1F5F9;color:#007bff;font-size:60px;width:100%;height:100%;justify-content: center; display: flex; align-items: center;">
                            '.$firstLetter.'
                        </span>
                    </div>
                    <div class="col-md-8">
                        <div class="card-body text-secondary">
                            <div class="row">
                                <div class="col-lg-7 col-md-12">
                                    <h6 class="card-title mt-2">'. $Committeename.'<br><small style="font-size:11px;">'.$Datecreated.'</small></h6>
                                </div>
                                <div class="col-lg-5 col-md-12">';
                                    if($ekene_row_cnt_ekenemember == '0' || $ekene_row_cnt_ekenemember == '1'){
                                        echo '<span class="badge bg-danger mx-2 float-end">'.$ekene_row_cnt_ekenemember.' Member</span>';  
                                    }else{
                                        echo '<span class="badge bg-danger mx-2 float-end">'.$ekene_row_cnt_ekenemember.' Members</span>';
                                    }
                                    echo '
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-lg-12 col-md-12">
                                    <div class="collapse" id="collapseExample1921">
                                        <div class="card card-body"><small style="font-size:11px;">No C.A has been attached</small></div>
                                    </div>
                                </div>
                            </div>

                            <span class="abba_tooltip">
                                <button type="button" class="btn btn-sm text-white float-end m-1  rounded-3 btn-primary mb-2" data-committee="'.$CommitteeID.'" data-cam="'.$campus.'"    id="ekene_view_fullassignment"    data-bs-toggle="modal" data-bs-target="#ekene_save_change"  style="font-size: 11px;">
                                    <i class="fa fa-eye" style="color: white; cursor: pointer;" aria-hidden="true"></i>
                                </button>
                                <span class="abba_tooltiptext">View Member</span>
                            </span>
                            &nbsp;';
                                            
                            if ($ekene_row_cnt_ekenemember == 0){
                                echo'<span class="abba_tooltip">
                                            <button type="button"  class="btn btn-sm text-white float-end m-1 open_assign_task_modal rounded-3 btn-success mb-2"  data-cam="'.$CampusID.'"  data-committee="'.$CommitteeID.'" data-bs-toggle="modal" data-bs-target="#ekene_assigning_of_task" id="ekene_task_fullassignmenttwo" style="font-size: 11px;" disabled>
                                                <i class="fas fa-tasks"></i>
                                            </button>
                                            <span class="abba_tooltiptext"> Assign Task</span>
                                        </span>
                                    &nbsp;';
                                }else{

                                echo'<span class="abba_tooltip">
                                            <button type="button"  class="btn btn-sm text-white float-end m-1 open_assign_task_modal rounded-3 btn-success mb-2"  data-cam="'.$CampusID.'"  data-committee="'.$CommitteeID.'" data-bs-toggle="modal" data-bs-target="#ekene_assigning_of_task" id="ekene_task_fullassignmenttwo" style="font-size: 11px;">
                                                <i class="fas fa-tasks"></i>
                                            </button>
                                            <span class="abba_tooltiptext"> Assign Task</span>
                                        </span>
                                    &nbsp;';
                            }
                            echo'     </div>
                        </div>
                    </div>
                </div>
            </div>
            ';

    }while($ekene_get_details_subject = mysqli_fetch_assoc($ekene_query_link_class));
    echo '</div>';
 }else{
    $select_for_no_record_found = "SELECT * FROM `defaultimages` WHERE `ImageName` = 'abba-no-record-found-image2' ";
    $query_for_no_record_found = mysqli_query($link, $select_for_no_record_found);
    $fetch_for_no_record_found = mysqli_fetch_assoc($query_for_no_record_found);
    $rows_for_no_record_found = mysqli_num_rows($query_for_no_record_found);

    if($rows_for_no_record_found > 0){
        
        $get_image = $fetch_for_no_record_found['BaseSixtyFour'];
        echo '<div align="center">
                <img src="'.$get_image.'" alt="" style="width:150px">
                <p class="p-1">No Commitee Found</p>
            </div>';
    }else{

    }
 }

 ?>