@extends('layout.base')

@section('content')
<?php setlocale(LC_TIME, 'es-CL', 'es') ?>
<div class="row page-heading">
	<div class="col-md-11 h3">Temas Abiertos {{strftime('%d de %B de %Y', \Carbon\Carbon::today(config('app.timezone'))->timestamp)}}</div>
	<div class="col-md-1 h3 text-right"><a href="{{url('', ['p' => 'temas', 'a' => 'add'])}}"><span class="glyphicon glyphicon-plus"></span></a></div>
</div>
<?php $proyecto = 0; $f = \Carbon\Carbon::today(config('app.timezone')) ?>
@foreach ($temas as $tema)
@if ($tema->proyecto_id != $proyecto)
<?php $proyecto = $tema->proyecto_id ?>
<div class="row section-heading">
	<div class="col-md-4 h4">{{$tema->proyecto()->descripcion}}</div>
	<div class="col-md-5 h4">{{$tema->proyecto()->estado()->descripcion}}</div>
</div>
@endif
<div class="row" style="border-bottom: thin solid grey">
	<div class="col-md-2
	@if ($f->diff($tema->inicio())->format('%r%a') > 0)
		bg-success
	@elseif ($f->diff($tema->inicio())->format('%r%a') < -3)
		bg-danger
	@endif
	"
	>
		<div class="row">
			<div class="col-md-6">{{format('shortDate', $tema->inicio)}}</div>
			<div class="col-md-6">
				@if ($tema->cierre()->year != -1)
					{{format('shortDate', $tema->cierre)}}
				@endif
			</div>
		</div>
	</div>
	<div class="col-md-9
	@if ($tema->cierre()->year != -1)
		bg-success
	@endif
	"
	>
		{!!$tema->texto()!!}
		@if ($tema->cierre()->year != -1)
			[Cerrado]
		@endif
	</div>
	<div class="col-md-1">
		<a href="{{url('', ['p' => 'temas', 'a' => 'edit', 'tema' => $tema->id])}}"><span class="glyphicon glyphicon-edit"></span></a>
	@if ($tema->cierre()->year != -1)
		<a href="{{url('', ['p' => 'temas', 'a' => 'abrir', 'tema' => $tema->id])}}"><span class="glyphicon glyphicon-plus"></span></a>
	@else
		<a href="{{url('', ['p' => 'temas', 'a' => 'cerrar', 'tema' => $tema->id])}}"><span class="glyphicon glyphicon-minus"></span></a>
	@endif
	</div>
</div>
@endforeach
@endsection