Merge branch 'feature/CHangeStepRahdari' into 'develop'

Feature/c hange step rahdari

See merge request witelgroup/rms_v2!105
This commit is contained in:
2025-04-23 12:02:09 +00:00
13 changed files with 317 additions and 45 deletions

View File

@@ -4,16 +4,16 @@ namespace App\Enums;
enum SafetyAndPrivacyStatus: int
{
case PENDING = 0;
case CONFIRM = 1;
case REJECT = 2;
case PENDING = 3;
public static function name(int $state): string
{
$mapArray = [
0 => 'در حال بررسی',
1 => 'تایید',
2 => 'عدم تایید',
3 => 'در حال بررسی'
];
return $mapArray[$state];

View File

@@ -12,13 +12,13 @@ use Maatwebsite\Excel\Events\AfterSheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class CartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
class OperatorCartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
{
public function __construct(private ?Collection $data){}
public function view(): View
{
return view('v3.Reports.SafetyAndPrivacy.CartableReport', [
return view('v3.Reports.SafetyAndPrivacy.OperatorCartableReport', [
'data' => $this->data,
]);
}

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Exports\V3\SafetyAndPrivacy;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
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\Worksheet\Drawing;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class SupervisorCartableReport implements FromView, WithEvents, ShouldAutoSize, WithDrawings
{
public function __construct(private ?Collection $data){}
public function view(): View
{
return view('v3.Reports.SafetyAndPrivacy.SupervisorCartableReport', [
'data' => $this->data,
]);
}
public function registerEvents(): array
{
return [
AfterSheet::class => function (AfterSheet $event) {
$event->sheet->getDelegate()->setRightToLeft(true);
},
];
}
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('B1');
return [$drawing, $drawing2];
}
public function styles(Worksheet $sheet): array
{
return [
'A:BA' => [
'font' => [
'name' => 'B Nazanin'
]
],
];
}
}

View File

@@ -5,10 +5,13 @@ namespace App\Http\Controllers\V3\Dashboard;
use App\Enums\AxisTypes;
use App\Enums\SafetyAndPrivacyStatus;
use App\Enums\SafetyAndPrivacySteps;
use App\Exports\V3\SafetyAndPrivacy\CartableReport;
use App\Exports\V3\SafetyAndPrivacy\OperatorCartableReport;
use App\Exports\V3\SafetyAndPrivacy\SupervisorCartableReport;
use App\Facades\DataTable\DataTableFacade;
use App\Facades\File\FileFacade;
use App\Http\Controllers\Controller;
use App\Http\Requests\V3\SafetyAndPrivacy\FinishRequest;
use App\Http\Requests\V3\SafetyAndPrivacy\RejectRequest;
use App\Http\Requests\V3\SafetyAndPrivacy\FirstStepStoreRequest;
use App\Http\Requests\V3\SafetyAndPrivacy\SecondStepStoreRequest;
use App\Http\Requests\V3\SafetyAndPrivacy\ThirdStepStoreRequest;
@@ -41,11 +44,11 @@ class SafetyAndPrivacyController extends Controller
/**
* @throws Throwable
*/
public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
public function operatorExcelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
{
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
$data = $safetyAndPrivacyTableService->operatorDatatable($request);
return Excel::download(new CartableReport($data['data']), $name);
return Excel::download(new OperatorCartableReport($data['data']), $name);
}
public function firstStepStore(FirstStepStoreRequest $request, NominatimService $nominatimService): JsonResponse
@@ -60,6 +63,7 @@ class SafetyAndPrivacyController extends Controller
DB::transaction(function () use ($request, $coordinates, $item, $nominatimService, $user)
{
$step = SafetyAndPrivacySteps::SHENASAEI->value;
$safety_and_privacy = SafetyAndPrivacy::query()->create([
'lat' => $coordinates[0],
'lon' => $coordinates[1],
@@ -77,9 +81,9 @@ class SafetyAndPrivacyController extends Controller
'way_id' => $nominatimService->get_way_id_from_nominatim($coordinates[0], $coordinates[1]),
'axis_type_id' => $request->axis_type_id,
'axis_type_name' => AxisTypes::name($request->axis_type_id),
'step' => SafetyAndPrivacySteps::SHENASAEI->value,
'step_fa' => SafetyAndPrivacySteps::name(1),
'is_finished' => false
'step' => $step,
'step_fa' => SafetyAndPrivacySteps::name($step),
'is_finished' => false,
]);
$safety_and_privacy->recognize_picture = $request->has('recognize_picture') ?
@@ -97,17 +101,27 @@ class SafetyAndPrivacyController extends Controller
{
$user = auth()->user();
DB::transaction(function () use ($request, $safetyAndPrivacy, $user)
{
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
$need_judiciary = $request->need_judiciary;
$judiciary_document = [];
foreach ($request->judiciary_document as $index => $file) {
$judiciary_document[] = FileFacade::save($file, "safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document");
if ($need_judiciary) {
foreach ($request->judiciary_document as $index => $file) {
$judiciary_document[] = FileFacade::save(
$file,
"safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document"
);
}
}
$step = SafetyAndPrivacySteps::MOSTANADAT_GAZAEI->value;
$safetyAndPrivacy->update([
'judiciary_document' => serialize($judiciary_document),
'judiciary_document_upload_date' => now(),
'step' => SafetyAndPrivacySteps::MOSTANADAT_GAZAEI->value,
'step_fa' => SafetyAndPrivacySteps::name(2),
'step' => $step,
'step_fa' => SafetyAndPrivacySteps::name($step),
'judiciary_document' => $need_judiciary ? serialize($judiciary_document) : null,
'judiciary_document_upload_date' => $need_judiciary ? now() : null,
'need_judiciary' => $need_judiciary,
]);
$user->addActivityComplete(1135);
@@ -121,13 +135,15 @@ class SafetyAndPrivacyController extends Controller
$user = auth()->user();
DB::transaction(function () use ($request, $safetyAndPrivacy, $user) {
$step = SafetyAndPrivacySteps::BARKHORD->value;
$safetyAndPrivacy->update([
'step' => SafetyAndPrivacySteps::BARKHORD->value,
'step_fa' => SafetyAndPrivacySteps::name(3),
'step' => $step,
'step_fa' => SafetyAndPrivacySteps::name($step),
'action_picture' => FileFacade::save($request->action_picture, "safety_and_privacy/{$safetyAndPrivacy->id}/action_picture"),
'action_picture_document_upload_date' => now(),
'action_date' => $request->action_date,
'is_finished' => true
'is_finished' => true,
'final_description' => 'پیام سیستمی : این عملیات پس از طی تمامی گام ها خاتمه یافت'
]);
$user->addActivityComplete(1136);
@@ -200,32 +216,40 @@ class SafetyAndPrivacyController extends Controller
));
}
public function confirm(Request $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
public function confirm(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
{
$status_id = SafetyAndPrivacyStatus::CONFIRM->value;
$safetyAndPrivacy->update([
'status' => SafetyAndPrivacyStatus::CONFIRM->value,
'status' => $status_id,
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
]);
return $this->successResponse();
}
public function reject(RejectRequest $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
{
$status_id = SafetyAndPrivacyStatus::REJECT->value;
$safetyAndPrivacy->update([
'status' => $status_id,
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
'supervisor_description' => $request->supervisor_description
]);
return $this->successResponse();
}
public function reject(Request $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
public function finish(FinishRequest $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
{
$safetyAndPrivacy->update([
'status' => SafetyAndPrivacyStatus::REJECT->value,
'supervisor_description' => $request->supervisor_description
]);
$status_id = SafetyAndPrivacyStatus::PENDING->value;
return $this->successResponse();
}
public function finish(Request $request, SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
{
$safetyAndPrivacy->update([
'is_finished' => $request->is_finished,
'is_finished' => 1,
'final_description' => $request->final_description,
'status' => SafetyAndPrivacyStatus::PENDING->value,
'status' => $status_id,
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
]);
return $this->successResponse();
@@ -235,4 +259,11 @@ class SafetyAndPrivacyController extends Controller
{
return response()->json($safetyAndPrivacyTableService->supervisorDataTable($request));
}
public function supervisorExcelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse
{
$name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx';
$data = $safetyAndPrivacyTableService->supervisorDataTable($request);
return Excel::download(new SupervisorCartableReport($data['data']), $name);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests\V3\SafetyAndPrivacy;
use Illuminate\Foundation\Http\FormRequest;
class FinishRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'final_description' => 'required|string',
];
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests\V3\SafetyAndPrivacy;
use Illuminate\Foundation\Http\FormRequest;
class RejectRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'supervisor_description' => 'required|string',
];
}
}

View File

@@ -22,6 +22,7 @@ class SecondStepStoreRequest extends FormRequest
public function rules(): array
{
return [
'need_judiciary' => 'required|boolean',
'judiciary_document' => 'required|array',
'judiciary_document.*' => 'file',
];

View File

@@ -40,7 +40,9 @@ class SafetyAndPrivacy extends Model
'status',
'final_description',
'is_finished',
'supervisor_description'
'supervisor_description',
'status_fa',
'need_judiciary'
];
public $table = "safety_and_privacy";

View File

@@ -22,10 +22,10 @@ class SafetyAndPrivacyTableService
{
$user = auth()->user();
$fields = ['id','lat','lon','province_id','province_fa','city_id','city_fa','edare_shahri_id','edare_shahri_name',
'recognize_picture','action_picture','operator_id','operator_name','way_id','created_at','updated_at','step',
'info_id','info_fa','activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date',
'step_fa', 'axis_type_id', 'axis_type_name', 'action_date'
$fields = [
'id','lat','lon', 'recognize_picture','action_picture','created_at','step', 'final_description',
'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date',
'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description'
];
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {

View File

@@ -14,8 +14,12 @@ return new class extends Migration
Schema::table('safety_and_privacy', function (Blueprint $table) {
$table->boolean('is_finished')->nullable();
$table->integer('status')->nullable();
$table->string('status_fa')->nullable();
$table->string('supervisor_description')->nullable();
$table->string('final_description')->nullable();
$table->boolean('need_judiciary')->nullable();
$table->text('judiciary_document')->nullable()->change();
$table->dateTime('judiciary_document_upload_date')->nullable()->change();
});
}
@@ -25,7 +29,9 @@ return new class extends Migration
public function down(): void
{
Schema::table('safety_and_privacy', function (Blueprint $table) {
$table->dropColumn(['status', 'final_description', 'is_finished', 'supervisor_description']);
$table->dropColumn(['status', 'final_description', 'is_finished', 'supervisor_description', 'status_fa', 'need_judiciary']);
$table->text('judiciary_document')->change();
$table->dateTime('judiciary_document_upload_date')->change();
});
}
};

View File

@@ -0,0 +1,99 @@
<!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="10"
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="10"
style="background-color: #DAEEF3;text-align: center;border-right:1px solid black;font-weight:bolder;">
</th>
</tr>
<tr>
<th colspan="10"
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>
</tr>
</thead>
<tbody>
@foreach ($data as $item)
<tr>
<td style="border: 1px solid black;text-align: center;">{{ $item['id'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['info_fa'] ?? '-' }}</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['axis_type_name'] ?? '-' }}</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>
<td style="border: 1px solid black;text-align: center;">{{ $item['activity_date_time'] ? verta($item['activity_date_time'])->format('Y/n/j H:i:s') : '-' }}</td>
<td style="border: 1px solid black;text-align: center;">
{{ $item['judiciary_document_upload_date'] && $item['judiciary_document_upload_date'] != '0000-00-00 00:00:00' ? verta($item['judiciary_document_upload_date'])->format('Y/n/j H:i:s') : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">
{{ $item['action_picture_document_upload_date'] ? verta($item['action_date'])->format('Y/n/j H:i:s') : '-' }}
</td>
<td style="border: 1px solid black;text-align: center;">{{ $item['step_fa'] ?? '-' }}</td>
</tr>
@endforeach
</tbody>
</table>
</body>
</html>

View File

@@ -337,11 +337,16 @@ Route::prefix('safety_and_privacy')
->name('SafetyAndPrivacy.')
->controller(SafetyAndPrivacyController::class)
->group(function () {
Route::get('/', 'operatorIndex')->name('operatorIndex')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
Route::get('/excel_report', 'excelReport')->name('excelReport')->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province|show-safety-and-privacy-operator-cartable-edarate-shahri');
Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')
->middleware(['validate-store-access', 'permission:add-safety-and-privacy']);
Route::get('/operator_index', 'operatorIndex')->name('operatorIndex')
->middleware('permission:show-safety-and-privacy-operator-cartable-edarate-shahri');
Route::get('/supervisor_index', 'supervisorIndex')->name('supervisorIndex')
->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province');
Route::get('/operator_excel_report', 'operatorExcelReport')->name('operatorExcelReport')
->middleware('permission:show-safety-and-privacy-operator-cartable-edarate-shahri');
Route::get('/supervisor_excel_report', 'supervisorExcelReport')->name('supervisorExcelReport')
->middleware('permission:show-safety-and-privacy-operator-cartable|show-safety-and-privacy-operator-cartable-province');
Route::post('/first_step_store', 'firstStepStore')->name('firstStepStore')->middleware(['validate-store-access', 'permission:add-safety-and-privacy']);
Route::get('/sub_items', 'subItems')->name('subItems');
Route::get('/map', 'map')->name('map');
Route::post('/second_step_store/{safetyAndPrivacy}', 'secondStepStore')->name('secondStepStore')->middleware(['validate-store-access','permission:add-safety-and-privacy']);
@@ -350,6 +355,9 @@ Route::prefix('safety_and_privacy')
Route::get('/{safetyAndPrivacy}', 'show')->name('show');
Route::delete('/{safetyAndPrivacy}', 'destroy')->name('destroy')->middleware('permission:delete-safety-and-privacy');
Route::get('/deserialize/{safetyAndPrivacy}', 'deserialize')->name('deserialize');
Route::post('/confirm/{safetyAndPrivacy}', 'confirm')->name('confirm');
Route::post('/reject/{safetyAndPrivacy}', 'reject')->name('reject');
Route::post('/finish/{safetyAndPrivacy}', 'finish')->name('finish');
});
Route::prefix('safety_and_privacy_report')