Rapport-Laravel/resources/views/revesmartlaunchdrive/report.blade.php

374 lines
19 KiB
PHP

@extends('layouts.vertical-individual', ['page_title' => $title ?? 'Revesmart-Launch-Drive'])
@section('css')
<style>
body .account-pages > .container {
max-width: 100%;
padding-left: 0;
padding-right: 0;
}
.revesmart-launch-drive-page .row {
--bs-gutter-x: 0;
margin-left: 0;
margin-right: 0;
}
.revesmart-launch-drive-page .card {
border-left: 0;
border-right: 0;
border-radius: 0;
margin-bottom: 0;
}
.revesmart-launch-drive-page .card-body {
padding-left: 0;
padding-right: 0;
}
.revesmart-launch-drive-page .page-header {
padding-left: 12px;
padding-right: 12px;
}
.revesmart-launch-drive-scroll {
overflow-x: auto;
}
.revesmart-launch-drive-table {
width: 100%;
border-collapse: collapse;
font-size: 12px;
}
.revesmart-launch-drive-table th,
.revesmart-launch-drive-table td {
white-space: nowrap;
vertical-align: middle;
border: 1px solid #c5c9ce;
padding: 6px 8px;
text-align: center;
}
.revesmart-launch-drive-table thead th {
font-weight: 700;
background: #eef1f4;
}
.revesmart-launch-drive-table .group-status {
background: #c8e6c9;
}
.revesmart-launch-drive-table .group-yesterday {
background: #ffe0b2;
}
.revesmart-launch-drive-table .group-mtd {
background: #c8e6c9;
}
.revesmart-launch-drive-table .group-chest {
background: #bbdefb;
}
.revesmart-launch-drive-table .name-col {
text-align: left;
min-width: 140px;
}
.revesmart-launch-drive-table tr.zbm-row td {
background: #e8f5e9;
font-weight: 700;
}
.revesmart-launch-drive-table tr.zbm-row .name-col {
background: #e8f5e9;
}
.revesmart-launch-drive-table tr.rbm-row .name-col {
padding-left: 22px;
font-weight: 500;
}
.revesmart-launch-drive-table tr.grand-total-row td {
background: #2e7d32;
color: #fff;
font-weight: 700;
}
.revesmart-launch-drive-table tr.grand-total-row .name-col {
background: #2e7d32;
color: #fff;
}
.month-form {
display: flex;
gap: 8px;
align-items: center;
flex-wrap: wrap;
padding: 0 12px 12px;
}
.month-form .form-control {
max-width: 220px;
}
</style>
@endsection
@section('content')
@php
$v = function ($obj, $key, $default = 0) {
if (!is_object($obj) && !is_array($obj)) {
return $default;
}
if (is_array($obj)) {
return $obj[$key] ?? $default;
}
return $obj->{$key} ?? $default;
};
$pct = function ($value) {
if ($value === null || $value === '') {
return '-';
}
return rtrim(rtrim(number_format((float) $value, 2, '.', ''), '0'), '.') . '%';
};
$num = function ($value) {
if ($value === null || $value === '') {
return 0;
}
return is_numeric($value) ? (0 + $value) : $value;
};
$showYesterday = !empty($currentMonth);
$statusCols = 4;
$dayCols = 8;
$mtdCols = 8;
$chestCols = 7;
@endphp
<div class="account-pages revesmart-launch-drive-page">
<div class="container">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="page-header d-flex justify-content-between align-items-center flex-wrap gap-2 mb-2">
<h4 class="page-title mb-0">{{ $title }}</h4>
<a href="{{ $base_url }}/export?{{ http_build_query(array_filter(['token' => $token ?? null, 'month' => $month ?? null, 'form_id' => $formId ?? null])) }}"
class="btn btn-dark btn-sm">
Export Excel
</a>
</div>
<form method="GET" action="{{ $base_url }}/report" class="month-form" id="revesmart-month-form">
@if(!empty($token))
<input type="hidden" name="token" value="{{ $token }}">
@endif
@if(!empty($formId))
<input type="hidden" name="form_id" value="{{ $formId }}">
@endif
<label for="month" class="mb-0">Month</label>
<select class="form-control form-control-sm" id="month" name="month" onchange="this.form.submit()">
@foreach(($monthOptions ?? []) as $monthOption)
<option value="{{ $monthOption }}" {{ ($month ?? '') === $monthOption ? 'selected' : '' }}>
{{ $monthOption }}
</option>
@endforeach
</select>
</form>
<div class="revesmart-launch-drive-scroll">
<table class="revesmart-launch-drive-table">
<thead>
<tr>
<th class="group-status name-col" colspan="{{ $statusCols }}">Revesmart Launch Status</th>
@if($showYesterday)
<th class="group-yesterday" colspan="{{ $dayCols }}">{{ $yesterdayLabel }}</th>
@endif
<th class="group-mtd" colspan="{{ $mtdCols }}">{{ $mtdLabel }}</th>
<th class="group-chest" colspan="{{ $chestCols }}">{{ $chestLabel ?? 'MTD Chest' }}</th>
</tr>
<tr>
<th class="name-col">RBM/ZBM</th>
<th>MNP</th>
<th>Participation</th>
<th>% Participation</th>
@if($showYesterday)
<th>Count of Doctor</th>
<th>Launch to HCPs</th>
<th>Handwriting Activity</th>
<th>Dr Converted</th>
<th>No of Dr Rx</th>
<th>No of Foracort Rx</th>
<th>No of Chemist availability</th>
<th>POB I Units</th>
@endif
<th>Count of Doctor</th>
<th>Launch to HCPs</th>
<th>Handwriting Activity</th>
<th>Dr Converted</th>
<th>No of Dr Rx</th>
<th>No of Foracort Rx</th>
<th>No of Chemist availability</th>
<th>POB I Units</th>
<th>Count of Doctor</th>
<th>Launch to HCPs</th>
<th>Handwriting Activity</th>
<th>Dr Converted</th>
<th>No of Dr Rx</th>
<th>No of Foracort Rx</th>
<th>% Chest Launch</th>
</tr>
</thead>
<tbody>
@forelse($zbmReport as $zbm)
@php
$zbmObj = is_object($zbm) ? $zbm : (object) $zbm;
$yesterday = $zbmObj->yesterday ?? (object) [];
$mtd = $zbmObj->mtd ?? (object) [];
$mtdChest = $zbmObj->mtdChest ?? (object) [];
$rbms = is_array($zbmObj->rbms ?? null) ? $zbmObj->rbms : [];
@endphp
<tr class="zbm-row">
<td class="name-col">{{ $zbmObj->zbm ?? '-' }}</td>
<td>{{ $num($zbmObj->mnp ?? 0) }}</td>
<td>{{ $num($zbmObj->participation ?? 0) }}</td>
<td>{{ $pct($zbmObj->participation_percentage ?? null) }}</td>
@if($showYesterday)
<td>{{ $num($v($yesterday, 'countOfDoctor')) }}</td>
<td>{{ $num($v($yesterday, 'launchToHcps')) }}</td>
<td>{{ $num($v($yesterday, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($yesterday, 'doctorConverted')) }}</td>
<td>{{ $num($v($yesterday, 'doctorRx')) }}</td>
<td>{{ $num($v($yesterday, 'noOfRxForacort')) }}</td>
<td>{{ $num($v($yesterday, 'chemistAvailability')) }}</td>
<td>{{ $num($v($yesterday, 'pobUnits')) }}</td>
@endif
<td>{{ $num($v($mtd, 'countOfDoctor')) }}</td>
<td>{{ $num($v($mtd, 'launchToHcps')) }}</td>
<td>{{ $num($v($mtd, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($mtd, 'doctorConverted')) }}</td>
<td>{{ $num($v($mtd, 'doctorRx')) }}</td>
<td>{{ $num($v($mtd, 'noOfRxForacort')) }}</td>
<td>{{ $num($v($mtd, 'chemistAvailability')) }}</td>
<td>{{ $num($v($mtd, 'pobUnits')) }}</td>
<td>{{ $num($v($mtdChest, 'countOfDoctor')) }}</td>
<td>{{ $num($v($mtdChest, 'launchToHcps')) }}</td>
<td>{{ $num($v($mtdChest, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($mtdChest, 'doctorConverted')) }}</td>
<td>{{ $num($v($mtdChest, 'doctorRx')) }}</td>
<td>{{ $num($v($mtdChest, 'noOfRxForacort')) }}</td>
<td>{{ $pct($v($mtdChest, 'chestLaunchPercentage', null)) }}</td>
</tr>
@foreach($rbms as $rbm)
@php
$rbmObj = is_object($rbm) ? $rbm : (object) $rbm;
$ry = $rbmObj->yesterday ?? (object) [];
$rm = $rbmObj->mtd ?? (object) [];
$rc = $rbmObj->mtdChest ?? (object) [];
@endphp
<tr class="rbm-row">
<td class="name-col">{{ $rbmObj->rbm ?? '-' }}</td>
<td>{{ $num($rbmObj->mnp ?? 0) }}</td>
<td>{{ $num($rbmObj->participation ?? 0) }}</td>
<td>{{ $pct($rbmObj->participation_percentage ?? null) }}</td>
@if($showYesterday)
<td>{{ $num($v($ry, 'countOfDoctor')) }}</td>
<td>{{ $num($v($ry, 'launchToHcps')) }}</td>
<td>{{ $num($v($ry, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($ry, 'doctorConverted')) }}</td>
<td>{{ $num($v($ry, 'doctorRx')) }}</td>
<td>{{ $num($v($ry, 'noOfRxForacort')) }}</td>
<td>{{ $num($v($ry, 'chemistAvailability')) }}</td>
<td>{{ $num($v($ry, 'pobUnits')) }}</td>
@endif
<td>{{ $num($v($rm, 'countOfDoctor')) }}</td>
<td>{{ $num($v($rm, 'launchToHcps')) }}</td>
<td>{{ $num($v($rm, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($rm, 'doctorConverted')) }}</td>
<td>{{ $num($v($rm, 'doctorRx')) }}</td>
<td>{{ $num($v($rm, 'noOfRxForacort')) }}</td>
<td>{{ $num($v($rm, 'chemistAvailability')) }}</td>
<td>{{ $num($v($rm, 'pobUnits')) }}</td>
<td>{{ $num($v($rc, 'countOfDoctor')) }}</td>
<td>{{ $num($v($rc, 'launchToHcps')) }}</td>
<td>{{ $num($v($rc, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($rc, 'doctorConverted')) }}</td>
<td>{{ $num($v($rc, 'doctorRx')) }}</td>
<td>{{ $num($v($rc, 'noOfRxForacort')) }}</td>
<td>{{ $pct($v($rc, 'chestLaunchPercentage', null)) }}</td>
</tr>
@endforeach
@empty
<tr>
<td colspan="{{ $statusCols + ($showYesterday ? $dayCols : 0) + $mtdCols + $chestCols }}">
No report data found for {{ $month }}.
</td>
</tr>
@endforelse
@if(!empty($grandTotal))
@php
$gt = is_object($grandTotal) ? $grandTotal : (object) $grandTotal;
$gy = $gt->yesterday ?? (object) [];
$gm = $gt->mtd ?? (object) [];
$gc = $gt->mtdChest ?? (object) [];
@endphp
<tr class="grand-total-row">
<td class="name-col">{{ $gt->zbm ?? 'Grand Total' }}</td>
<td>{{ $num($gt->mnp ?? 0) }}</td>
<td>{{ $num($gt->participation ?? 0) }}</td>
<td>{{ $pct($gt->participation_percentage ?? null) }}</td>
@if($showYesterday)
<td>{{ $num($v($gy, 'countOfDoctor')) }}</td>
<td>{{ $num($v($gy, 'launchToHcps')) }}</td>
<td>{{ $num($v($gy, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($gy, 'doctorConverted')) }}</td>
<td>{{ $num($v($gy, 'doctorRx')) }}</td>
<td>{{ $num($v($gy, 'noOfRxForacort')) }}</td>
<td>{{ $num($v($gy, 'chemistAvailability')) }}</td>
<td>{{ $num($v($gy, 'pobUnits')) }}</td>
@endif
<td>{{ $num($v($gm, 'countOfDoctor')) }}</td>
<td>{{ $num($v($gm, 'launchToHcps')) }}</td>
<td>{{ $num($v($gm, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($gm, 'doctorConverted')) }}</td>
<td>{{ $num($v($gm, 'doctorRx')) }}</td>
<td>{{ $num($v($gm, 'noOfRxForacort')) }}</td>
<td>{{ $num($v($gm, 'chemistAvailability')) }}</td>
<td>{{ $num($v($gm, 'pobUnits')) }}</td>
<td>{{ $num($v($gc, 'countOfDoctor')) }}</td>
<td>{{ $num($v($gc, 'launchToHcps')) }}</td>
<td>{{ $num($v($gc, 'revesmartHandwritingActivity')) }}</td>
<td>{{ $num($v($gc, 'doctorConverted')) }}</td>
<td>{{ $num($v($gc, 'doctorRx')) }}</td>
<td>{{ $num($v($gc, 'noOfRxForacort')) }}</td>
<td>{{ $pct($v($gc, 'chestLaunchPercentage', null)) }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection