<?php
use App\Department;
use App\UserProfilePic;
use App\DepartmentDetail;
use App\UserResume;

$department = Department::find($data);
$tags_details = Department::find($department->id)->alldepartmentDetail;
$departmentstaff = new Department();
$file_details = Department::find($department->id)->alldepartmentFile;

$dataapp = json_decode(json_encode($departmentstaff->departmentWiseActiveStaffWithDes($department->id, 'Associate Professor'), true), true);
$dataap = json_decode(json_encode($departmentstaff->departmentWiseActiveStaffWithDes($department->id, 'Assistant Professor'), true), true);
$datatin = json_decode(json_encode($departmentstaff->departmentWiseActiveStaffWithDes($department->id, 'Teacher-in-Charge'), true), true);
$dataal = json_decode(json_encode($departmentstaff->departmentWiseActiveStaffWithDes($department->id, 'Assistant Librarian'), true), true);
$datala = json_decode(json_encode($departmentstaff->departmentWiseActiveStaffWithDes($department->id, 'Library Assistant'), true), true);
$datata = json_decode(json_encode($departmentstaff->departmentWiseActiveStaffWithDes($department->id, 'Technical Assistant'), true), true);
$dataadmin = json_decode(json_encode($departmentstaff->departmentWiseActiveStaff($department->id), true), true);

//echo $datatin;
//$teacherincharge=json_encode(($department->departmentWiseActiveStaffWithDes($data,"Teacher-in-Charge")));
//echo $teacherincharge['user_name'];
function experience($doj, $exp)
{
    $today = date('Y-m-d');
    $daysdiff = abs(strtotime($today) - strtotime($doj));
    $month = $daysdiff / (30 * 24 * 60 * 60);
    $month = $month + $exp;
    $year = intval($month / 12);
    $month = $month % 12;
    return $year . ' Year ' . $month . ' Months';
    //return $doj;
}
?>
<style>
.img1 {
    height: 120px;
    width: 120px;
    object-fit: contain;
    overflow: hidden;
}

.img2 {
    height: 200px;
    width: 200px;
    object-fit: contain;
    overflow: hidden;
}
</style>
@extends('frontend.mainlayout')
@section('title', 'RERF-Dpartment')
@section('banner')
<section class="p-5 color-white font-1">
    <div class="background-holder overlay overlay-1 background-black "
        style="background-image:url(/frontend/assets/images/1.jpg); opacity: 0.90;"></div>
    <!--/.background-holder-->
    <div class="container">
        @if (count($datatin)>0)
        @foreach ($datatin as $item)
        <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first(); ?>
        <div class="row h-half align-items-center py-4 text-center justify-content-center">
            <div class="col-md-8 col-lg-12">
                <img class="img1 radius-round img-thumbnail"
                    src="/upload/image/staff/{{ $profilepic->profile_pic_link }}">
                <div class="color-white font-1">
                    <h4 class="mb-0">{{ $item['user_name'] }}</h4>
                    <p class="lead mb-0 fw-700">{{ $item['education'] }}<br>
                        <small> Experience:
                            {{ experience($item['date_of_joining'], $item['experience']) }}</small>
                    </p>
                </div>
                <h4 class="font-2 font-italic fw-700">{{ $department->name }}</h4>
            </div>
        </div>
        @endforeach
        @else
        <div class="row h-half align-items-center py-5 text-center justify-content-center">
            <div class="col-md-8 col-lg-12">
                <div class="color-white font-1">

                </div>
                <h4 class="font-2 font-italic fw-700">{{ $department->name }}</h4>
            </div>
        </div>
        @endif
        <!--/.row-->
    </div>
    <!--/.container-->
</section>
<section class="pt-3 pb-0 background-11 text-center">
    <div class="container-fluid">
        <div class="row align-items-center">
            <div class="col">
                <marquee behavior="scroll" direction="left">
                    <p class="mb-0 font-1 fs--1"> Welcome to the department of
                        <samp class="color-warning">
                            <strong> {{ $department->name }}</strong></samp>
                    </p>
                </marquee>

            </div>
            <div class="col-12">
                <hr class="color-9 mb-0">
            </div>
        </div>
        <!--/.row-->
    </div>
    <!--/.container-->
</section>
@endsection
@section('main')
@if (count($tags_details)>0)
<section class="p-2 background-10">
    <div class="container">
        @foreach ($tags_details as $item)
        <div class="row pt-1">
            <div class="col-12">
                <span class="fs-2 font-italic ">{{ $item['tag'] }}</span><br>
                {!! $item['description'] !!}
            </div>
        </div>
        @endforeach
        <!--/.row-->
    </div>
    <!--/.container-->
</section>
@endif
<section class="text-center p-2 background-9">
    <div class="container">
        <div class="row">
            <div class="col-12 text-left">
                <span class="fs-2 font-italic ">Meet our Member</span>
            </div>
        </div>
        <div class="row">
            @foreach ($dataapp as $item)
            <div class="col-sm-6 col-md-4 col-lg-3 p-4 ">
                <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first(); ?>
                @if (empty($profilepic))
                <img src="/upload/image/staff/nanaphoto.png" class="p-1 img2 radius-round img-thumbnail">
                @else
                <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                    class="p-1 img2 radius-round img-thumbnail">
                @endif
                <h5 class="fs-0 mt-3 mb-1">{{ $item['user_name'] }}</h5>
                <div class="fs--1 text-uppercase">
                    {{ $item['education'] }}
                </div>
                <div class="fs--1 text-uppercase">
                    Experience: {{ experience($item['date_of_joining'], $item['experience']) }}
                    @if ($item['activity']!=$item['department_id'])
                    <b>{{(Department::find($item['activity']))['name']}}</b>
                    @endif
                </div>
            </div>
            @endforeach
            @foreach ($dataap as $item)
            <div class="col-sm-6 col-md-4 col-lg-3 p-4 ">
                <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first();
                $resume = UserResume::where('user_resume_id', $item['user_id'])->first();

                ?>
                @if (empty($profilepic))
                <img src="/upload/image/staff/nanaphoto.png" class="p-1 img2 radius-round img-thumbnail">
                @else
                <!-- <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                    class="p-1 img2 radius-round img-thumbnail"> -->

                @if (isset($resume))
                <a href="{{asset('resume/'.$resume->resume)}}" target="_blank"> <img
                        src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                        class="p-1 img2 radius-round img-thumbnail"></a>
                @else
                <a href=""> <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                        class="p-1 img2 radius-round img-thumbnail"></a>
                @endif
                @endif
                <h5 class="fs-0 mt-3 mb-1">{{ $item['user_name'] }}</h5>
                <div class="fs--1 text-uppercase">
                    {{ $item['education'] }}
                </div>
                <div class="fs--1 text-uppercase">
                    Experience: {{ experience($item['date_of_joining'], $item['experience']) }}
                    @if ($item['activity']!=$item['department_id'])
                    <b>{{(Department::find($item['activity']))['name']}}</b>
                    @endif

                </div>
            </div>
            @endforeach
            @foreach ($datata as $item)
            <div class="col-sm-6 col-md-4 col-lg-3 p-4">
                <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first(); ?>
                @if (empty($profilepic))
                <img src="/upload/image/staff/nanaphoto.png" class="p-1 img2 radius-round img-thumbnail">
                @else
                <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                    class="p-1 img2 radius-round img-thumbnail">
                @endif
                <h5 class="fs-0 mt-3 mb-1">{{ $item['user_name'] }}</h5>
                <div class="fs--1 text-uppercase">
                    {{ $item['education'] }}
                </div>
                <div class="fs--1 text-uppercase">
                    Experience: {{ experience($item['date_of_joining'], $item['experience']) }}
                    @if ($item['activity']!=$item['department_id'])
                    <b>{{(Department::find($item['activity']))['name']}}</b>
                    @endif
                </div>
            </div>
            @endforeach
            @foreach ($dataal as $item)
            <div class="col-sm-6 col-md-4 col-lg-3 p-4">
                <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first(); ?>
                @if (empty($profilepic))
                <img src="/upload/image/staff/nanaphoto.png" class="p-1 img2 radius-round img-thumbnail">
                @else
                <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                    class="p-1 img2 radius-round img-thumbnail">
                @endif
                <h5 class="fs-0 mt-3 mb-1">{{ $item['user_name'] }}</h5>
                <div class="fs--1 text-uppercase">
                    {{ $item['education'] }}
                </div>
                <div class="fs--1 text-uppercase">
                    Experience: {{ experience($item['date_of_joining'], $item['experience']) }}
                </div>
            </div>
            @endforeach
            @foreach ($datala as $item)
            <div class="col-sm-6 col-md-4 col-lg-3 p-4">
                <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first(); ?>
                @if (empty($profilepic))
                <img src="/upload/image/staff/nanaphoto.png" class="p-1 img2 radius-round img-thumbnail">
                @else
                <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                    class="p-1 img2 radius-round img-thumbnail">
                @endif
                <h5 class="fs-0 mt-3 mb-1">{{ $item['user_name'] }}</h5>
                <div class="fs--1 text-uppercase">
                    {{ $item['education'] }}
                </div>
                <div class="fs--1 text-uppercase">
                    Experience: {{ experience($item['date_of_joining'], $item['experience']) }}
                </div>
            </div>
            @endforeach
            @if ($department->id==19)
            @foreach ($dataadmin as $item)
            <div class="col-sm-6 col-md-4 col-lg-3 p-4">
                <?php $profilepic = UserProfilePic::where('user_id', $item['user_id'])->first(); ?>
                @if (empty($profilepic))
                <img src="/upload/image/staff/nanaphoto.png" class="p-1 img2 radius-round img-thumbnail">
                @else
                <img src="/upload/image/staff/{{ $profilepic->profile_pic_link }}"
                    class="p-1 img2 radius-round img-thumbnail">
                @endif
                <h5 class="fs-0 mt-3 mb-1">{{ $item['user_name'] }}</h5>
                <div class="fs--1 text-uppercase">
                    {{ $item['education'] }}
                </div>
                <div class="fs--1 text-uppercase">
                    Experience: {{ experience($item['date_of_joining'], $item['experience']) }}
                </div>
            </div>
            @endforeach
            @endif
        </div>
        <div class="row">

            @foreach ($file_details as $item)

            <div class="col-12 text-left">

                <a class="fs-1 font-italic" href="/upload/document/department/{{$item['link']}}"
                    target="_blank">{{$item['link_title']}}</a>
                <hr class="color-9 mb-0">
            </div>
            @endforeach
        </div>
        <!--/.row-->
    </div>
</section>
@endsection