diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/SupervisorController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/SupervisorController.php index 240a7219..f6ddb692 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/SupervisorController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/SupervisorController.php @@ -13,15 +13,23 @@ use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Maatwebsite\Excel\Facades\Excel; use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Throwable; class SupervisorController extends Controller { use ApiResponse; + + /** + * @throws Throwable + */ public function index(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): JsonResponse { return response()->json($safetyAndPrivacyTableService->supervisorDataTable($request)); } + /** + * @throws Throwable + */ public function excelReport(Request $request, SafetyAndPrivacyTableService $safetyAndPrivacyTableService): BinaryFileResponse { $name = 'گزارش از نگهداری حریم راه ' . verta()->now()->format('Y-m-d H-i') . '.xlsx'; diff --git a/app/Http/Controllers/V3/NotificationController.php b/app/Http/Controllers/V3/NotificationController.php index 833ba72c..b48536c5 100644 --- a/app/Http/Controllers/V3/NotificationController.php +++ b/app/Http/Controllers/V3/NotificationController.php @@ -91,23 +91,31 @@ class NotificationController extends Controller private function safetyAndPrivacyNotifications(): JsonResponse|array { $user = auth()->user(); - $safety_and_privacy = array(); + $safety_and_privacy = [ + 'supervise_cnt' => 0, + 'step_one' => 0, + 'step_two' => 0, + ]; if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) { - $activity = SafetyAndPrivacy::query() - ->selectRaw('count(*) as cnt, step') - ->groupby('step') - ->orderBy('step') + $supervise = SafetyAndPrivacy::query() + ->selectRaw('count(*) as cnt') + ->where([ + ['is_finished', '=', 1], + ['status', '=', 0], + ]) ->get(); } elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) { throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); - $activity = SafetyAndPrivacy::query() + $supervise = SafetyAndPrivacy::query() ->where('province_id', '=', $user->province_id) - ->selectRaw('count(*) as cnt, step') - ->groupby('step') - ->orderBy('step') + ->selectRaw('count(*) as cnt') + ->where([ + ['is_finished', '=', 1], + ['status', '=', 0], + ]) ->get(); } @@ -120,13 +128,14 @@ class NotificationController extends Controller ->groupby('step') ->orderBy('step') ->get(); - } - $step_one = $activity->where('step', '=', 1)->first(); - $step_two = $activity->where('step', '=', 2)->first(); + $step_one = $activity->where('step', '=', 1)->first(); + $step_two = $activity->where('step', '=', 2)->first(); + } $safety_and_privacy['step_one'] = $step_one->cnt ?? 0; $safety_and_privacy['step_two'] = $step_two->cnt ?? 0; + $safety_and_privacy['supervise_cnt'] = $supervise->cnt ?? 0; return $safety_and_privacy; } diff --git a/app/Models/SafetyAndPrivacy.php b/app/Models/SafetyAndPrivacy.php index 55e0a239..5fbc1126 100644 --- a/app/Models/SafetyAndPrivacy.php +++ b/app/Models/SafetyAndPrivacy.php @@ -42,7 +42,8 @@ class SafetyAndPrivacy extends Model 'is_finished', 'supervisor_description', 'status_fa', - 'need_judiciary' + 'need_judiciary', + 'operator_description' ]; public $table = "safety_and_privacy"; diff --git a/app/Services/Cartables/SafetyAndPrivacyTableService.php b/app/Services/Cartables/SafetyAndPrivacyTableService.php index 89e0ee0f..a9ec577e 100644 --- a/app/Services/Cartables/SafetyAndPrivacyTableService.php +++ b/app/Services/Cartables/SafetyAndPrivacyTableService.php @@ -49,12 +49,12 @@ class SafetyAndPrivacyTableService $user = auth()->user(); $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', + 'id','lat','lon', 'recognize_picture','action_picture','created_at','step', 'final_description', 'province_fa', + 'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', 'edare_shahri_name', 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description' ]; - $query = SafetyAndPrivacy::query()->where('is_finished', '=', 1); + $query = SafetyAndPrivacy::query(); if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {