create complaints blade
This commit is contained in:
67
app/Exports/V3/RoadObservation/ComplaintsReport.php
Normal file
67
app/Exports/V3/RoadObservation/ComplaintsReport.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\V3\RoadObservation;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithDrawings;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
|
||||
|
||||
class ComplaintsReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
|
||||
{
|
||||
public function __construct(private Collection $data){}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
return view('v3.Reports.RoadObservation.ComplaintsReport', [
|
||||
'data' => $this->data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
$event->sheet->getDelegate()->setRightToLeft(true);
|
||||
$event->sheet->getDelegate()->getStyle('A:U')->getFont()->setName('Arial');
|
||||
$event->sheet->getDelegate()->getStyle('A:U')
|
||||
->getAlignment()
|
||||
->setHorizontal(Alignment::HORIZONTAL_CENTER);
|
||||
|
||||
$event->sheet->getDelegate()->getStyle('A:U')
|
||||
->getAlignment()
|
||||
->setVertical(Alignment::VERTICAL_CENTER);
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
public function drawings(): array
|
||||
{
|
||||
$drawing = new Drawing();
|
||||
$drawing->setName('Logo');
|
||||
$drawing->setDescription('This is my logo');
|
||||
$drawing->setPath(public_path('/dist/logo.png'));
|
||||
$drawing->setWidth(50);
|
||||
$drawing->setHeight(50);
|
||||
$drawing->setOffsetX(5);
|
||||
$drawing->setOffsetY(5);
|
||||
$drawing->setCoordinates('A1');
|
||||
|
||||
$drawing2 = new Drawing();
|
||||
$drawing2->setName('Logo');
|
||||
$drawing2->setDescription('This is my logo');
|
||||
$drawing2->setPath(public_path('/dist/141icon.png'));
|
||||
$drawing2->setWidth(50);
|
||||
$drawing2->setHeight(50);
|
||||
$drawing2->setOffsetX(5);
|
||||
$drawing2->setOffsetY(5);
|
||||
$drawing2->setCoordinates('q1');
|
||||
return [$drawing, $drawing2];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\V3\Dashboard;
|
||||
use App\Exports\V3\RoadObservation\ComplaintsReport;
|
||||
use App\Exports\V3\RoadObservation\OperatorCartableReport;
|
||||
use App\Exports\V3\RoadObservation\SupervisorCartableReport;
|
||||
use App\Facades\File\FileFacade;
|
||||
@@ -11,6 +12,7 @@ use App\Http\Requests\V3\RoadObservation\RestoreRequest;
|
||||
use App\Http\Requests\V3\RoadObservation\VerifyBySupervisorRequest;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateShahri;
|
||||
use App\Models\Province;
|
||||
use App\Models\RoadObservationHistory;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Models\User;
|
||||
@@ -74,9 +76,16 @@ class RoadObservationController extends Controller
|
||||
return Excel::download(new OperatorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
public function complaintsIndex(Request $request, RoadObservationTableService $roadObservationTableservice): JsonResponse
|
||||
public function complaintsIndex(Request $request, RoadObservationTableService $roadObservationTableService): JsonResponse
|
||||
{
|
||||
return response()->json($roadObservationTableservice->complaintsIndex($request));
|
||||
return response()->json($roadObservationTableService->complaintsIndex($request));
|
||||
}
|
||||
|
||||
public function complaintsReport(Request $request, RoadObservationTableService $roadObservationTableService): BinaryFileResponse
|
||||
{
|
||||
$name = 'گزارش از رسیدگی به شکایات واکنش سریع ' . verta()->now()->format('Y-m-d H:i') . '.xlsx';
|
||||
$data = $roadObservationTableService->complaintsIndex($request);
|
||||
return Excel::download(new ComplaintsReport($data['data']), $name);
|
||||
}
|
||||
|
||||
public function register(Request $request, RoadObserved $roadObserved, NikarayanService $nikarayanService): JsonResponse
|
||||
@@ -142,8 +151,7 @@ class RoadObservationController extends Controller
|
||||
|
||||
public function refer(ReferRequest $request, RoadObserved $roadObserved): JsonResponse
|
||||
{
|
||||
RoadObservationHistory::query()->create([
|
||||
'id' => $roadObserved->id,
|
||||
$roadObserved->problemHistories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'action' => 'refer',
|
||||
'description' => $request->refer_description,
|
||||
@@ -165,17 +173,18 @@ class RoadObservationController extends Controller
|
||||
|
||||
public function referList(Request $request, RoadObserved $roadObserved): JsonResponse
|
||||
{
|
||||
$data = RoadObservationHistory::query()
|
||||
->where('id', '=', $roadObserved->id)
|
||||
->where('action', '=', 'refer')
|
||||
->get();
|
||||
$referList = [];
|
||||
$data = $roadObserved->problemHistories()->where('action', '=', 'refer')->get();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$data[$key]->from_edareh = EdarateShahri::find($value->from_edareh)->name_fa;
|
||||
$data[$key]->to_edareh = EdarateShahri::find($value->to_edareh)->name_fa;
|
||||
$user = User::find($value->user_id);
|
||||
$data[$key]->user = $user->first_name . ' ' . $user->last_name;
|
||||
$referList[$key]['from_edareh'] = EdarateShahri::query()->find($value->from_edareh)->name_fa;
|
||||
$referList[$key]['to_edareh'] = EdarateShahri::query()->find($value->to_edareh)->name_fa;
|
||||
$referList[$key]['from_province'] = Province::query()->find($value->from_province)->name_fa;
|
||||
$referList[$key]['to_province'] = Province::query()->find($value->to_province)->name_fa;
|
||||
$user = User::query()->find($value->user_id);
|
||||
$referList[$key]['user'] = $user->first_name . ' ' . $user->last_name;
|
||||
}
|
||||
return $this->successResponse($data);
|
||||
return $this->successResponse($referList);
|
||||
}
|
||||
|
||||
public function restore(RestoreRequest $request, RoadObserved $roadObserved): JsonResponse
|
||||
@@ -200,8 +209,7 @@ class RoadObservationController extends Controller
|
||||
'status_fa' => null,
|
||||
]);
|
||||
|
||||
RoadObservationHistory::query()->create([
|
||||
'id' => $roadObserved->id,
|
||||
$roadObserved->problemHistories()->create([
|
||||
'user_id' => auth()->user()->id,
|
||||
'action' => 'restore',
|
||||
'description' => $request->restore_description,
|
||||
|
||||
@@ -26,7 +26,8 @@ class RoadObservationTableService
|
||||
|
||||
if ($user->hasPermissionTo('supervise-fast-react')) {
|
||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||
->whereNotNull('road_observeds.status');
|
||||
->whereNotNull('road_observeds.status')
|
||||
->select($fields);
|
||||
}
|
||||
elseif ($user->hasPermissionTo('supervise-fast-react-province'))
|
||||
{
|
||||
@@ -37,7 +38,8 @@ class RoadObservationTableService
|
||||
|
||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||
->where('road_observeds.province_id', $user->province_id)
|
||||
->whereNotNull('road_observeds.status');
|
||||
->whereNotNull('road_observeds.status')
|
||||
->select($fields);
|
||||
}
|
||||
|
||||
return DataTableFacade::run(
|
||||
@@ -96,7 +98,10 @@ class RoadObservationTableService
|
||||
if ($user->hasPermissionTo('show-fast-react')) {
|
||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||
->where('rms_status', '=', 0)
|
||||
->whereNotNull('edarate_shahri_id');
|
||||
->whereNotNull('edarate_shahri_id')
|
||||
->selectRaw('fk_RegisteredEventMessage, road_observeds.id, Title, FeatureTypeTitle, MobileForSendEventSms,
|
||||
road_observeds.created_at, rms_last_activity, rms_last_activity_fa, status,
|
||||
status_fa, supervisor_description, rms_description, province_fa, city_fa, Description, edarate_shahri.name_fa as edarate_shahri_name_fa, lat, lng');
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-fast-react-province')) {
|
||||
|
||||
@@ -106,8 +111,11 @@ class RoadObservationTableService
|
||||
|
||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||
->where('rms_status', '=', 0)
|
||||
->whereNotNull('edarate_shahri_id')
|
||||
->where('road_observeds.province_id', '=', $user->province_id);
|
||||
->whereNotNull('road_observeds.province_id')
|
||||
->where('road_observeds.province_id', '=', $user->province_id)
|
||||
->selectRaw('fk_RegisteredEventMessage, road_observeds.id, Title, FeatureTypeTitle, MobileForSendEventSms,
|
||||
road_observeds.created_at, rms_last_activity, rms_last_activity_fa, status,
|
||||
status_fa, supervisor_description, rms_description, province_fa, city_fa, Description, edarate_shahri.name_fa as edarate_shahri_name_fa, lat, lng');
|
||||
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-fast-react-edarate-shahri')) {
|
||||
@@ -119,7 +127,10 @@ class RoadObservationTableService
|
||||
$query = RoadObserved::query()->leftjoin('edarate_shahri', 'road_observeds.edarate_shahri_id', 'edarate_shahri.id')
|
||||
->where('rms_status', '=', 0)
|
||||
->whereNotNull('edarate_shahri_id')
|
||||
->where('edarate_shahri_id', '=', $user->edarate_shahri_id);
|
||||
->where('edarate_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->selectRaw('fk_RegisteredEventMessage, road_observeds.id, Title, FeatureTypeTitle, MobileForSendEventSms,
|
||||
road_observeds.created_at, rms_last_activity, rms_last_activity_fa, status,
|
||||
status_fa, supervisor_description, rms_description, province_fa, city_fa, Description, edarate_shahri.name_fa as edarate_shahri_name_fa, lat, lng');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ class RoadPatrolTableService
|
||||
$query = RoadPatrol::query()
|
||||
->select([
|
||||
'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description',
|
||||
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points,'
|
||||
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points'
|
||||
])
|
||||
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class RoadPatrolTableService
|
||||
$query = RoadPatrol::query()
|
||||
->select([
|
||||
'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description',
|
||||
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points,'
|
||||
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points'
|
||||
])
|
||||
->where('province_id', '=', $user->province_id)
|
||||
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||
@@ -55,7 +55,7 @@ class RoadPatrolTableService
|
||||
$query = RoadPatrol::query()
|
||||
->select([
|
||||
'province_fa', 'province_id', 'id', 'edare_id', 'edare_name', 'start_time', 'end_time', 'created_at', 'description',
|
||||
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points,'
|
||||
'distance', 'vehicle_runtime', 'fuel_consumption', 'stop_points'
|
||||
])
|
||||
->where('operator_id', '=', auth()->user()->id)
|
||||
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>گزارش واکنش سریع</title>
|
||||
|
||||
<style>
|
||||
table,
|
||||
th,
|
||||
td {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body dir="rtl" style="text-align: center;">
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="9"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right: 1px solid black;font-weight:bolder;">
|
||||
تاریخ دریافت گزارش: {{ verta()->now()->format('Y/m/d H:i') }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="9"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="9"
|
||||
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;font-size: 13px;">
|
||||
گزارش رسیدگی به شکایات واکنش سریع
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">کد
|
||||
سوانح</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
استان
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
ادارات شهری
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
موضوع گزارش
|
||||
</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
نوع گزارش</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
توضیح گزارش</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
موقعیت مکانی</th>
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
شماره تماس گیرنده</th>
|
||||
|
||||
<th rowspan="1"
|
||||
style="text-align: center;border: 1px solid black;background-color: #EBF1DE;font-weight: bold;">
|
||||
تاریخ ثبت گزارش</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@foreach ($data as $item)
|
||||
<tr>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['fk_RegisteredEventMessage'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['province_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['edarate_shahri_name_fa'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['Title'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['FeatureTypeTitle'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['Description'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ isset($item['lat']) && isset($item['lng']) ? $item['lat'] . ' ' . $item['lng'] : '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['MobileForSendEventSms'] ?? '-' }}</td>
|
||||
<td style="border: 1px solid black;text-align: center;">{{ $item['created_at'] ? verta($item['created_at'])->format('Y/n/j H:i:s') : '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -298,4 +298,5 @@ Route::prefix('road_observations')
|
||||
Route::post('/restore/{roadObserved}', 'restore')
|
||||
->middleware('permission:restore-fast-react')
|
||||
->name('restore');
|
||||
Route::get('/complaints_report', 'complaintsReport')->name('complaintsReport');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user