410 lines
24 KiB
PHP
410 lines
24 KiB
PHP
@extends('layouts.vertical', ['page_title' => 'Datatables'])
|
|
|
|
@section('css')
|
|
<link href="{{ asset('assets/libs/datatables/datatables.min.css') }}" rel="stylesheet" type="text/css" />
|
|
<link href="{{ asset('assets/libs/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet"
|
|
type="text/css" />
|
|
@endsection
|
|
|
|
@section('content')
|
|
<div class="container-fluid">
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 p-2">
|
|
<h4 class="page-title">{{ $title }}</h4>
|
|
</div>
|
|
<div class="col-md-6 p-2 d-flex justify-content-end align-items-center">
|
|
@php
|
|
// Helper to get all months from July 2025 to current month
|
|
$start = \Carbon\Carbon::create(2025, 7, 1);
|
|
$end = \Carbon\Carbon::now()->startOfMonth();
|
|
$months = [];
|
|
while ($start <= $end) {
|
|
$months[] = $start->format('F Y');
|
|
$start->addMonth();
|
|
}
|
|
$selectedMonth = request()->get('month', \Carbon\Carbon::now()->format('F Y'));
|
|
@endphp
|
|
<form id="month-select-form" class="me-2" method="get" action="">
|
|
<select class="form-select" name="month" id="month-select" style="width:auto; display:inline-block;">
|
|
@foreach(array_reverse($months) as $month)
|
|
<option value="{{ $month }}" {{ $selectedMonth == $month ? 'selected' : '' }}>{{ $month }}</option>
|
|
@endforeach
|
|
</select>
|
|
</form>
|
|
@if (isset($buttons))
|
|
@foreach ($buttons as $button)
|
|
<a href="{{ $button['link'] }}"
|
|
class="btn btn-{{ $button['title'] == 'Add New' ? 'success' : 'dark' }} waves-effect waves-light float-end ms-2"
|
|
id="btn-{{ strtolower(str_replace(' ', '-', $button['title'])) }}">{{ $button['title'] }}</a>
|
|
@endforeach
|
|
@endif
|
|
</div>
|
|
</div>
|
|
@if (session()->has('message'))
|
|
<div class="alert alert-success">
|
|
{{ session()->get('message') }}
|
|
</div>
|
|
@endif
|
|
@if (session()->has('error'))
|
|
<div class="alert alert-danger">
|
|
{{ session()->get('error') }}
|
|
</div>
|
|
@endif
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body ">
|
|
<!-- Monthly Summary Table -->
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">1. Monthly Summary ( {{ $selectedMonth }}
|
|
)
|
|
</h5>
|
|
<a href="/gennovadcreport/export?type=monthsummary&month={{ $selectedMonth }}" class="btn btn-sm btn-primary"> Export
|
|
</a>
|
|
</div>
|
|
<div class="card-body">
|
|
<div style="overflow-x:auto; width:100%;">
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
@foreach ($monthsummary as $col)
|
|
<th>{{ $col['name'] }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($monthsummarysubmission as $row)
|
|
<tr>
|
|
@foreach ($monthsummary as $col)
|
|
@php
|
|
$val = $row->{$col['key']} ?? '';
|
|
@endphp
|
|
<td class="m-2">
|
|
@php
|
|
if (is_numeric($val)) {
|
|
if (floor($val) == $val) {
|
|
echo number_format($val);
|
|
} else {
|
|
echo number_format($val, 2);
|
|
}
|
|
} else {
|
|
echo $val;
|
|
}
|
|
@endphp
|
|
</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
<tr class="table-secondary">
|
|
<td><strong>Total</strong></td>
|
|
@foreach (array_slice($monthsummary, 1) as $col)
|
|
@php
|
|
$key = $col['key'];
|
|
@endphp
|
|
<td><strong>
|
|
@if ($key === 'percent_ach')
|
|
{{ $monthTotals['units_plan'] > 0
|
|
? round(($monthTotals['units_ach'] / $monthTotals['units_plan']) * 100)
|
|
: 0 }}%
|
|
@else
|
|
@php
|
|
$totalVal = $monthTotals[$key] ?? 0;
|
|
if (floor($totalVal) == $totalVal) {
|
|
echo number_format($totalVal);
|
|
} else {
|
|
echo number_format($totalVal, 2);
|
|
}
|
|
@endphp
|
|
@endif
|
|
</strong></td>
|
|
@endforeach
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<!-- Weekly Summary Table -->
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">2. Weekly Summary ( {{ $selectedMonth }} )
|
|
</h5>
|
|
<a href="/gennovadcreport/export?type=weeksummary&month={{ $selectedMonth }}" class="btn btn-sm btn-primary"> Export
|
|
</a>
|
|
</div>
|
|
<div class="card-body">
|
|
<div style="overflow-x:auto; width:100%;">
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
@foreach ($weeklysummary as $col)
|
|
<th>{{ $col['label'] }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($weeklysummarysubmission as $row)
|
|
<tr>
|
|
@foreach ($weeklysummary as $col)
|
|
@php
|
|
$val = $row->{$col['key']} ?? '';
|
|
@endphp
|
|
<td class="m-2">
|
|
@if (is_numeric($val))
|
|
{{ number_format($val) }}
|
|
@else
|
|
{{ $val }}
|
|
@endif
|
|
</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
|
|
@if (count($weeklysummarysubmission) > 0)
|
|
<tr class="table-secondary">
|
|
<td><strong>Total</strong></td>
|
|
|
|
@foreach ($weeklysummary as $col)
|
|
@if ($col['key'] === 'product_name')
|
|
@continue
|
|
@elseif ($col['key'] === 'percent_ach')
|
|
<td>
|
|
<strong>
|
|
{{ $weeklyTotals['month_plan'] > 0
|
|
? number_format(($weeklyTotals['units_ach'] / $weeklyTotals['month_plan']) * 100)
|
|
: 0 }}%
|
|
</strong>
|
|
</td>
|
|
@else
|
|
<td><strong>{{ number_format($weeklyTotals[$col['key']] ?? 0) }}</strong>
|
|
</td>
|
|
@endif
|
|
@endforeach
|
|
</tr>
|
|
@endif
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<!-- Center Summary Table -->
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
|
|
<h5 class="card-title mb-0">3. Center Summary</h5>
|
|
<a href="/gennovadcreport/export?type=centersummary&month={{ $selectedMonth }}" class="btn btn-sm btn-primary"> Export
|
|
</a>
|
|
|
|
</div>
|
|
<div class="card-body">
|
|
<div style="overflow-x:auto; width:100%;">
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
@foreach ($centersummary as $col)
|
|
<th>{{ $col['name'] }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($centersummarysubmission as $row)
|
|
<tr>
|
|
@foreach ($centersummary as $col)
|
|
@php $val = $row->{$col['key']} ?? ''; @endphp
|
|
<td class="m-2">
|
|
@if ($col['key'] === 'percent_ach')
|
|
{{ round($val) }}
|
|
@elseif (is_numeric($val))
|
|
{{ number_format($val) }}
|
|
@else
|
|
{{ $val }}
|
|
@endif
|
|
</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
|
|
@if ($centerTotals)
|
|
<tr class="table-secondary">
|
|
<td><strong>Total</strong></td>
|
|
|
|
@foreach ($centersummary as $index => $col)
|
|
@if ($index === 0)
|
|
{{-- Skip the first column since "Total" text already there --}}
|
|
@continue
|
|
@endif
|
|
|
|
@php
|
|
$key = $col['key'];
|
|
$val = $centerTotals->{$key} ?? 0;
|
|
@endphp
|
|
|
|
@if ($key === 'percent_ach')
|
|
@php
|
|
$plan = $centerTotals->centers_plan ?? 0;
|
|
$ach = $centerTotals->centers_ach ?? 0;
|
|
$percent =
|
|
$plan > 0
|
|
? number_format(($ach / $plan) * 100)
|
|
: 0;
|
|
@endphp
|
|
<td><strong>{{ $percent }}%</strong></td>
|
|
@else
|
|
<td><strong>{{ number_format($val) }}</strong></td>
|
|
@endif
|
|
@endforeach
|
|
</tr>
|
|
@endif
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
|
<!-- Center Trend Summary Table -->
|
|
<div class="card-body">
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
|
|
<h5 class="card-title mb-0">4. Center Trend Summary</h5>
|
|
<a href="/gennovadcreport/export?type=centertrendsummary&month={{ $selectedMonth }}" class="btn btn-sm btn-primary">
|
|
Export </a>
|
|
|
|
</div>
|
|
<div class="card-body">
|
|
<div style="overflow-x:auto; width:100%;">
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
@foreach ($centertrendsummary as $col)
|
|
<th>{{ $col['name'] }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($centertrendsummarysubmission as $row)
|
|
<tr>
|
|
@foreach ($centertrendsummary as $col)
|
|
@php
|
|
$val = $row->{$col['key']} ?? '';
|
|
@endphp
|
|
<td class="m-2">
|
|
{{ is_numeric($val) ? number_format($val) : $val }}</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
|
|
@if (count($centertrendsummarysubmission) > 0)
|
|
<tr class="table-secondary">
|
|
<td><strong>Total</strong></td>
|
|
@foreach (array_slice($centertrendsummary, 1) as $col)
|
|
@php
|
|
$val = $centerTrendTotals[$col['key']] ?? 0;
|
|
@endphp
|
|
<td><strong>{{ number_format($val) }}</strong></td>
|
|
@endforeach
|
|
</tr>
|
|
@endif
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="card">
|
|
<!-- Unit Trend Summary Table -->
|
|
<div class="card-body">
|
|
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
|
|
<h5 class="card-title mb-0">5. Unit Trend Summary</h5>
|
|
<a href="/gennovadcreport/export?type=unittrendsummary&month={{ $selectedMonth }}" class="btn btn-sm btn-primary">
|
|
Export </a>
|
|
|
|
</div>
|
|
<div class="card-body">
|
|
<div style="overflow-x:auto; width:100%;">
|
|
|
|
<table class="table table-centered table-nowrap table-borderless mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
@foreach ($unittrendsummary as $col)
|
|
<th>{{ $col['name'] }}</th>
|
|
@endforeach
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach ($unittrendsummarysubmission as $row)
|
|
<tr>
|
|
@foreach ($unittrendsummary as $col)
|
|
@php
|
|
$val = $row->{$col['key']} ?? '';
|
|
@endphp
|
|
<td class="m-2">
|
|
{{ is_numeric($val) ? number_format($val) : $val }}</td>
|
|
@endforeach
|
|
</tr>
|
|
@endforeach
|
|
|
|
@if (count($unittrendsummarysubmission) > 0)
|
|
<tr class="table-secondary">
|
|
<td><strong>Total</strong></td>
|
|
@foreach (array_slice($unittrendsummary, 1) as $col)
|
|
<td><strong>{{ number_format($unitTrendTotals[$col['key']] ?? 0) }}</strong>
|
|
</td>
|
|
@endforeach
|
|
</tr>
|
|
@endif
|
|
</tbody>
|
|
</table>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<style type="text/css">
|
|
</style>
|
|
@endsection
|
|
|
|
@section('script')
|
|
<script src="{{ asset('assets/libs/datatables/datatables.min.js') }}"></script>
|
|
<script src="{{ asset('assets/libs/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
$('#month-select').on('change', function() {
|
|
$('#month-select-form').submit();
|
|
});
|
|
});
|
|
</script>
|
|
@endsection
|