@extends('adminlte::page')

@section('content_header')
<h1>Dashboard</h1>
@endsection

@section('css')
<link rel="stylesheet" href="/css/calendaricon.css">

@endsection

@section('content')

<div class="row">
@can('conti')

    <div class="col-lg-3 col-md-8 draggable">
        <div class="info-box bg-success">
            <span class="info-box-icon"><i class="far fa-thumbs-up"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Entrate {{ date('Y') }}</span>
                <span class="info-box-number">{{ $entrate }}</span>
                <!--<div class="progress">
                <div class="progress-bar" style="width: 70%"></div>
                </div>-->
                <span class="progress-description"></span>
            </div>
        </div>
    </div>

    <div class="col-lg-3 col-md-8 draggable">
        <div class="info-box bg-warning">
            <span class="info-box-icon"><i class="far fa-thumbs-down"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Uscite {{ date('Y') }}</span>
                <span class="info-box-number">{{ $uscite }}</span>
                <!--<div class="progress">
                <div class="progress-bar" style="width: 70%"></div>
                </div>-->
                <span class="progress-description"></span>
            </div>
        </div>
    </div>

    <div class="col-lg-3 col-md-8 draggable">
        <div class="info-box bg-primary">
            <span class="info-box-icon"><i class="far fa-thumbs-down"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Saldo anno {{ date('Y') }}</span>
                <span class="info-box-number">{{ $entrate - $uscite }}</span>
                <!--<div class="progress">
                <div class="progress-bar" style="width: 70%"></div>
                </div>-->
                <span class="progress-description"></span>
            </div>
        </div>
    </div>

    <div class="col-lg-3 col-md-8 draggable">
        <div class="info-box bg-secondary">
            <span class="info-box-icon"><i class="far fa-thumbs-down"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Saldo negli anni</span>
                <span class="info-box-number">{{ $saldo }}</span>
                <!--<div class="progress">
                <div class="progress-bar" style="width: 70%"></div>
                </div>-->
                <span class="progress-description"></span>
            </div>
        </div>
    </div>
	@endcan
</div>

@can('tasks')
<!-- Se ha i permessi task -->
<div class="row">
    <div class="col-lg-6 col-md-8 draggable">
        @foreach($mieitask as $task)
	<div class ="row">
		<div class="card-comment">
			<div class ="row p-2">
				<div class="col-xs p-2">
					<time datetime="{{ date_format(date_create($task->termine_il),'Y-m-d') }}" class="icon">
						<em>{{ __('app.'.date_format(date_create($task->termine_il),'l')) }}</em>
						<strong>{{ __('app.'.date_format(date_create($task->termine_il),'F'))}}</strong>
						<span>{{date_format(date_create($task->termine_il),'d') }}</span>
					</time>
				</div>
				<div class="col-xs p-2">
					<img class="img-circle img-sm" src="{{ Gravatar::get(App\Models\User::getUserById($task->assegnato_a)->email )}}" alt="User Image">
				</div>
				<div class="col">
					<div class="row">
						<div class="comment-text">
							<span class="username">
								<b>{{ $task->titolo}}</b><br>
							</span>
							{{ $task->descrizione }}<br>
						</div>
					</div>
					<div class="row text-muted">
						Creato il: {{ date_format(date_create($task->creato_il),'d/m/Y')}} da {{App\Models\User::getUserById($task->assegnato_a)->name }}
					</div>
				</div>
			</div>
		</div>
	</div>
	@endforeach
</div>
<div class="col-lg-6 col-md-8 draggable ">
    <div class="card-footer card-comment draggable">
        @foreach($avvisi as $avviso)
        <div class="card-comment">
            <div class="row">
                <div class="col-xs">
                    <time datetime="{{ date_format(date_create($avviso->creato_il),'Y-m-d') }}" class="icon">
                        <em>{{ __('app.'.date_format(date_create($avviso->creato_il),'l')) }}</em>
                        <strong>{{ __('app.'.date_format(date_create($avviso->creato_il),'F'))}}</strong>
                        <span>{{date_format(date_create($avviso->creato_il),'d') }}</span>
                    </time>
                </div>
                <div class="col">
                    <div class="comment-text">
                        <span class="username">
                            &nbsp;
                            <span class="text-muted float-right">
                            <img class="img-circle img-sm" src="{{ Gravatar::get(App\Models\User::getUserById($avviso->creato_da)->email)}}" alt="User Image">

                            </span>
                        </span>
                    </div>
                <p>{{ $avviso->avviso }}</p>
                </div>
            </div>
        </div>
        @endforeach
    </div>
    <div class="panel-footer">
        <form action="{{ Route('newAvviso') }}" method="POST">
            @csrf
            <label for="avviso" class="form-label">Nuovo Avviso:</label>
            <textarea class="form-control" name="avviso"></textarea>
            <input type="hidden" name="creato_da" value="{{ Auth::user()->id }}">
            <input type="submit" name="submit" class="button btn-primary">
        </form>
    </div>
</div>



<div class="row">
    <div class="col-lg-3 col-md-8 draggable">
        <div class="panel panel-yellow">
            <div class="panel-heading">
                <div class="row">Notizie</div>
            </div>
            <div class="panel-body">
               <!--<ul class="contenuto">


               </ul>-->
            </div>
            <div class=panel-footer></div>
        </div>
    </div>
</div>
@endcan
<div class="row">
    <div class="col">

    </div>
    <div class="col">

    </div>
</div>
@endsection

@section('js')
<script src="js/app/dashboard.js"></script>

@endsection
