Commit 64853b3e authored by alissonalbuquerque's avatar alissonalbuquerque
Browse files

add alterações de layout de calendário de horas semanais

parent 5e6aeadc
...@@ -29,6 +29,7 @@ use App\Models\Tabelas\Pesquisa\PesquisaLideranca; ...@@ -29,6 +29,7 @@ use App\Models\Tabelas\Pesquisa\PesquisaLideranca;
use App\Models\Tabelas\Pesquisa\PesquisaOrientacao; use App\Models\Tabelas\Pesquisa\PesquisaOrientacao;
use App\Models\Tabelas\Pesquisa\PesquisaOutros; use App\Models\Tabelas\Pesquisa\PesquisaOutros;
use App\Rules\ValidationLimitTime; use App\Rules\ValidationLimitTime;
use Carbon\Carbon;
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
...@@ -378,6 +379,14 @@ class TaskTime extends Model ...@@ -378,6 +379,14 @@ class TaskTime extends Model
return $dateTime->format($format); return $dateTime->format($format);
} }
public function formatStartTime() {
return Carbon::createFromFormat('H:i:s', $this->start_time)->format('H:i');
}
public function formatEndTime() {
return Carbon::createFromFormat('H:i:s', $this->end_time)->format('H:i');
}
/** /**
* STATIC METHODS * STATIC METHODS
*/ */
......
...@@ -71,13 +71,13 @@ ...@@ -71,13 +71,13 @@
</div> </div>
</div> </div>
{{-- <div class="card mx-2" style="width: 10rem;"> --}} <div class="card mx-2" style="width: 10rem;">
{{-- <div class="card-body"> <div class="card-body">
<h2 class="text-center"> <i class="bi bi-clock"></i> </h2> <h2 class="text-center"> <i class="bi bi-clock"></i> </h2>
<h3 class="text-center">Horário</h3> <h3 class="text-center">Horário</h3>
<a class="stretched-link btn-pad-horario" href="{{ route('task_time_index', ['user_pad_id' => $user_pad_id]) }}"></a> <a class="stretched-link btn-pad-horario" href="{{ route('task_time_index', ['user_pad_id' => $user_pad_id]) }}"></a>
</div> --}} </div>
{{-- </div> --}} </div>
<div class="card mx-2" style="width: 10rem;"> <div class="card mx-2" style="width: 10rem;">
<div class="card-body"> <div class="card-body">
......
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
tarefa_id.val(_tarefa_id) tarefa_id.val(_tarefa_id)
$.ajax({ $.ajax({
url: '{{ route("TaskTimeSearchTask") }}', url: '{{ route("task_time_search") }}',
type: 'GET', type: 'GET',
data: { data: {
tarefa_id: _tarefa_id, tarefa_id: _tarefa_id,
......
...@@ -27,50 +27,29 @@ ...@@ -27,50 +27,29 @@
@php @php
use App\Models\TaskTime; use App\Models\TaskTime;
// $hours = ['07:30', '08:20', '09:10', '10:00', '10:50', '11:40', '12:30', '13:30', '14:30', '15:30', '16:30', '17:30', '19:00', '19:45', '20:30', '21:15'];
$rangeHours = [
['07:30', '08:20'],
['08:20', '09:10'],
['09:10', '10:00'],
['10:00', '10:50'],
['10:50', '11:40'],
['11:40', '12:30'],
['12:30', '13:30'],
['13:30', '14:30'],
['14:30', '15:30'],
['15:30', '16:30'],
['16:30', '17:30'],
['17:30', '19:00'],
['19:00', '19:45'],
['19:45', '20:30'],
['20:30', '21:15'],
['21:15', '21:15'],
];
$calendar = []; $calendar = [];
$row = []; $weekColumns = [];
foreach ($rangeHours as $rangeHour)
{
$start_time = $rangeHour[0];
$end_time = $rangeHour[1];
$row[0] = $start_time; $max_len_column = 0;
foreach (array_keys(TaskTime::listWeekDays()) as $weekday) {
foreach (array_keys(TaskTime::listWeekDays()) as $weekday) $weekColumns[$weekday] =
{ TaskTime::whereWeekday($weekday)
$row[$weekday] = ->orderBy('start_time', 'ASC')
TaskTime::where('user_pad_id', '=', $user_pad_id) ->get();
->where('weekday', '=', $weekday)
->where(function($query) use ($rangeHour) {
$query->orWhereBetween('start_time', $rangeHour)->orWhereBetween('end_time', $rangeHour);
})->first();
$row[$weekday] = $row[$weekday] ? $row[$weekday] : ''; if(count($weekColumns[$weekday]) > $max_len_column) {
$max_len_column = count($weekColumns[$weekday]);
} }
}
foreach (range(0, $max_len_column-1) as $i) {
$row = [];
foreach (array_keys(TaskTime::listWeekDays()) as $weekday) {
isset($weekColumns[$weekday][$i]) ? array_push($row, $weekColumns[$weekday][$i]) : array_push($row, null);
}
$calendar[] = $row; $calendar[] = $row;
} }
@endphp @endphp
...@@ -80,25 +59,33 @@ ...@@ -80,25 +59,33 @@
<table class="table table-hover"> <table class="table table-hover">
<thead> <thead>
<tr> <tr>
@foreach(TaskTime::listWeekDaysTable() as $key => $weekday) @foreach(TaskTime::listWeekDays() as $key => $weekday)
<th scope="col">{{$weekday}}</th> <th scope="col" class="text-center">{{$weekday}}</th>
@endforeach @endforeach
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($calendar as $rowHour) @foreach($calendar as $row)
<tr> <tr>
@foreach ($rowHour as $model) @foreach ($row as $model)
@if(gettype($model) == 'string')
<th scope="col">{{ $model }}</th>
@endif
@if(gettype($model) == 'object') @if($model !== null)
<td> <td>
<div class="card">
<div class="card-header">
<p class="text-center"> <i class="bi bi-clock"></i> {{ $model->formatStartTime() }} </p>
</div>
<div class="card-body">
<div class="text-center">
<a href="#modal" class="btn btn-edit_task" id="{{ $model->id }}"> <a href="#modal" class="btn btn-edit_task" id="{{ $model->id }}">
{{ "{$model->getCode()} : {$model->getName()}" }} {{ "{$model->getCode()} : {$model->getName()}" }} <i class="bi bi-pencil"></i>
</a> </a>
</div>
</div>
<div class="card-header">
<p class="text-center"> <i class="bi bi-clock-fill"></i> {{ $model->formatEndTime() }} </p>
</div>
</div>
</td> </td>
@endif @endif
...@@ -130,28 +117,3 @@ ...@@ -130,28 +117,3 @@
]) ])
@endsection @endsection
\ No newline at end of file
{{-- @include('components.buttons.btn-edit', [
'route' => route('task_time_edit', ['id' => $model->id])
])
@include('components.buttons.btn-delete', [
'id' => $model->id,
'route' => route('task_time_delete', ['id' => $model->id])
]) --}}
{{-- @foreach($listTaskTime as $key => $taskTimes)
<tr>
@foreach($taskTimes as $model)
@if(gettype($model) == 'string')
<th>{{ $model }}</th>
@endif
@if(gettype($model) == 'object')
@endif
@endforeach
</tr>
@endforeach --}}
\ No newline at end of file
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
tarefa_id.val(_tarefa_id) tarefa_id.val(_tarefa_id)
$.ajax({ $.ajax({
url: '{{ route("TaskTimeSearchTask") }}', url: '{{ route("task_time_search") }}',
type: 'GET', type: 'GET',
data: { data: {
tarefa_id: _tarefa_id, tarefa_id: _tarefa_id,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment