Skip to content

Commit

Permalink
Feat: Filtrar por Fecha el Rendimiento Medico
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenU21 committed May 28, 2023
1 parent 9d69176 commit 0394f72
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 6 deletions.
20 changes: 17 additions & 3 deletions app/Http/Controllers/Admin/ChartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\Models\Appointment;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

Expand All @@ -31,13 +32,26 @@ public function appointments()

public function doctors()
{
return view('charts.doctors');
$now = Carbon::now();
$end = $now->format('Y-m-d');
$start = $now->subYear()->format('Y-m-d');
return view('charts.doctors', compact('end', 'start'));
}

public function doctorsJason(){
public function doctorsJason(Request $request){

$start = $request->input('start');
$end = $request->input('end');

$doctors = User::doctors()
->select('name')
->withCount(['attendedAppointments', 'cancelledAppointments'])
->withCount(['attendedAppointments' => function($query) use ($start, $end){
$query->whereBetween('scheduled_date', [$start, $end]);
}
,'cancelledAppointments' => function($query) use ($start, $end){
$query->whereBetween('scheduled_date', [$start, $end]);
}
])
->orderBy('attended_appointments_count', 'desc')
->take(5)
->get();
Expand Down
19 changes: 18 additions & 1 deletion public/js/charts/doctors.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,39 @@ Highcharts.chart('container', {
series: []
});


let $start, $end;
function fetchData()
{
const $startDate = $start.val();
const $endDate = $end.val();
const $url = `/reportes/doctors/column/data?start=${$startDate}&end=${$endDate}`;
//Fetch API
fetch('/reportes/doctors/column/data')
fetch($url)
.then(function (response) {
return response.json();
})
.then(function (myJason) {
//console.log(data);
chart.xAxis[0].setCategories(myJason.categories);

if(chart.series.length > 0)
{
chart.series[1].remove();
chart.series[0].remove();
}

chart.addSeries(myJason.series[0]);//Citas Atendidas
chart.addSeries(myJason.series[1]);//Citas Canceladas

})
}

$(function(){
$start = $('#startDate');
$end = $('#endDate');
fetchData();

$start.change(fetchData);
$end.change(fetchData);
});
32 changes: 30 additions & 2 deletions resources/views/charts/doctors.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,37 @@
</div>
</div>
<div class="card-body">
<div class="input-daterange datepicker row align-items-center" data-date-format="yyyy-mm-dd">
<div class="col">
<div class="form-group">
<label for="startDate">Fecha de Inicio</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-calendar-grid-58"></i></span>
</div>
<input class="form-control" placeholder="Fecha de Inicio" id="startDate" type="text"
value="{{ $start }}">
</div>
</div>
</div>
<div class="col">
<div class="form-group">
<label for="endDate">Fecha de Finalización</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="ni ni-calendar-grid-58"></i></span>
</div>
<input class="form-control" placeholder="Fecha de Finalización" id="endDate" type="text"
value="{{ $end }}">
</div>
</div>
</div>
</div>

<div id="container">
</div>
</div>

</div>
@endsection

Expand All @@ -21,7 +49,7 @@
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<script src="{{ asset('js/plugins/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js') }}"></script>

<script src="{{ asset('js/charts/doctors.js')}}">
</script>
<script src="{{ asset('js/charts/doctors.js') }}"></script>
@endsection

0 comments on commit 0394f72

Please sign in to comment.