add report for road item
This commit is contained in:
@@ -1,73 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Cartables;
|
||||
namespace App\Services\Cartables\RoadItem;
|
||||
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Models\InfoItem;
|
||||
use App\Models\RoadItemsProject;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class RoadItemTableService
|
||||
class ReportService
|
||||
{
|
||||
public function supervisorCartableReport(Request $request, $loadRelations = false)
|
||||
{
|
||||
$allowedFilters = ['*'];
|
||||
$allowedSortings = ['*'];
|
||||
|
||||
$user = auth()->user();
|
||||
$query = null;
|
||||
|
||||
if ($user->hasPermissionTo('show-road-item-supervise-cartable')) {
|
||||
$query = RoadItemsProject::query()
|
||||
->select(['id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng',
|
||||
'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status'])
|
||||
->where('is_new', 1)
|
||||
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-road-item-supervise-cartable-province')) {
|
||||
if (is_null($user->province_id)) {
|
||||
return $this->errorResponse('استانی برای شما در سامانه ثبت نشده است!');
|
||||
}
|
||||
$query = RoadItemsProject::query()
|
||||
->select(['id', 'province_fa', 'edarat_name', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng',
|
||||
'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status'])
|
||||
->where('is_new', 1)
|
||||
->where('province_id', auth()->user()->province_id)
|
||||
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));
|
||||
}
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: $allowedFilters,
|
||||
allowedSortings: $allowedSortings);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function operatorCartableReport(Request $request, $loadRelations = false)
|
||||
{
|
||||
$allowedFilters = ['*'];
|
||||
$allowedSortings = ['*'];
|
||||
|
||||
$query = RoadItemsProject::query()
|
||||
->select(['id', 'province_fa', 'edarat_name', 'supervisor_description', 'item', 'item_fa', 'sub_item', 'sub_item_fa', 'sub_item_data', 'unit_fa', 'start_lat', 'start_lng',
|
||||
'end_lat', 'end_lng', 'activity_date_time', 'created_at', 'status_fa', 'status'])
|
||||
->where('is_new', 1)
|
||||
->where('user_id', auth()->user()->id)
|
||||
->when($loadRelations, fn ($query) => $query->with(['rahdaran:id,name,code', 'cmmsMachines:id,machine_code,car_name,plak_number']));;
|
||||
|
||||
$data = DataTableFacade::run(
|
||||
$query,
|
||||
$request,
|
||||
allowedFilters: $allowedFilters,
|
||||
allowedSortings: $allowedSortings);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function countryActivityPerSubItem(Request $request): array
|
||||
{
|
||||
$fromDate = $request->from_date ? $request->from_date . ' 00:00:00' : now()->startOfDay()->toDateTimeString();
|
||||
Reference in New Issue
Block a user