add notification count for supervise
This commit is contained in:
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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'))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user