Merge pull request #112 from witelgroup/feature/NoProcess
create permission
This commit is contained in:
@@ -54,6 +54,7 @@ class DailyMovingMachineCommand extends Command
|
|||||||
|
|
||||||
MissionViolation::query()->create([
|
MissionViolation::query()->create([
|
||||||
'machine_code' => $code,
|
'machine_code' => $code,
|
||||||
|
'machine_id' => CMMSMachine::query()->firstWhere('machine_code', '=', $code)->id,
|
||||||
'type' => MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
'type' => MissionViolationType::KHOROJ_BEDONE_MOGAVEZ->value,
|
||||||
'request_date' => $date,
|
'request_date' => $date,
|
||||||
'mileage' => $cmm['mileageKM'],
|
'mileage' => $cmm['mileageKM'],
|
||||||
|
|||||||
@@ -204,16 +204,16 @@ class RequestPortalController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function noProcess(NoProcessRequest $request): JsonResponse
|
public function noProcess(NoProcessRequest $request, GetErrorRateService $getErrorRateService): JsonResponse
|
||||||
{
|
{
|
||||||
DB::transaction(function () use ($request) {
|
DB::transaction(function () use ($request, $getErrorRateService) {
|
||||||
$start = Carbon::parse($request->start_date);
|
$start = Carbon::parse($request->start_date);
|
||||||
$end = Carbon::parse($request->end_date);
|
$end = Carbon::parse($request->end_date);
|
||||||
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
$type = $start->diffInMinutes($end) > 480 ? MissionTypes::NO_PROCESS_ROZANE->value : MissionTypes::NO_PROCESS_SAATY->value;
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$zone = $request->zone;
|
$zone = $request->zone;
|
||||||
$state = MissionStates::END_MISSION->value;
|
$state = MissionStates::END_MISSION->value;
|
||||||
$machine = CMMSMachine::query()->where('id', '=', $request->machine_id)->first(['id', 'machine_code']);
|
$machine = CMMSMachine::query()->where('machine_code', '=', $request->machine_code)->first(['id', 'machine_code']);
|
||||||
|
|
||||||
$mission = Mission::query()->create([
|
$mission = Mission::query()->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
@@ -229,6 +229,7 @@ class RequestPortalController extends Controller
|
|||||||
'type' => $type,
|
'type' => $type,
|
||||||
'type_fa' => MissionTypes::name($type),
|
'type_fa' => MissionTypes::name($type),
|
||||||
'start_date' => $request->start_date,
|
'start_date' => $request->start_date,
|
||||||
|
'area' => json_encode($request->area),
|
||||||
'end_date' => $request->end_date,
|
'end_date' => $request->end_date,
|
||||||
'end_point' => $request->end_point,
|
'end_point' => $request->end_point,
|
||||||
'category_id' => $request->category_id,
|
'category_id' => $request->category_id,
|
||||||
@@ -247,6 +248,18 @@ class RequestPortalController extends Controller
|
|||||||
$mission->rahdaran()->sync($request->rahdaran);
|
$mission->rahdaran()->sync($request->rahdaran);
|
||||||
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
$mission->rahdaran()->attach($request->driver, ['is_driver' => true]);
|
||||||
|
|
||||||
|
$getErrorRateService->setInputParameters($mission);
|
||||||
|
$responseData = $getErrorRateService->run();
|
||||||
|
|
||||||
|
$mission->update([
|
||||||
|
'in_area_duration' => $responseData['timeInAreaSeconds'],
|
||||||
|
'first_enter' => $responseData['firstEnter'],
|
||||||
|
'last_exit' => $responseData['lastExit'],
|
||||||
|
'point_number_sent' => $responseData['noOfPointsInMission'],
|
||||||
|
'fms_result_code' => $responseData['resultCode'],
|
||||||
|
'fms_result_message' => FMSResultCode::name($responseData['resultCode']),
|
||||||
|
]);
|
||||||
|
|
||||||
// if ($mission->category_id == 2) {
|
// if ($mission->category_id == 2) {
|
||||||
// $rpc = new OperatorController;
|
// $rpc = new OperatorController;
|
||||||
// $rpc->store($mission);
|
// $rpc->store($mission);
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ class NoProcessRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(): bool
|
public function authorize(): bool
|
||||||
{
|
{
|
||||||
return $this->violation->status === 0 && $this->violation->type === 1;
|
// return $this->violation->status === 0 && $this->violation->type === 1;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -30,9 +31,9 @@ class NoProcessRequest extends FormRequest
|
|||||||
'start_date' => 'required|date',
|
'start_date' => 'required|date',
|
||||||
'end_date' => 'required|date|after:start_date|before:now',
|
'end_date' => 'required|date|after:start_date|before:now',
|
||||||
'end_point' => 'required|string',
|
'end_point' => 'required|string',
|
||||||
// 'area' => 'required|array',
|
'area' => 'array',
|
||||||
// 'area.type' => 'required|string',
|
'area.type' => 'string',
|
||||||
// 'area.coordinates' => 'required|array',
|
'area.coordinates' => 'array',
|
||||||
'category_id' => 'required|in:1,2,3',
|
'category_id' => 'required|in:1,2,3',
|
||||||
'explanation' => 'required|string',
|
'explanation' => 'required|string',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -4,14 +4,21 @@ namespace App\Models;
|
|||||||
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
|
||||||
class MissionViolation extends Model
|
class MissionViolation extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
protected $guarded =[];
|
protected $guarded =[];
|
||||||
|
|
||||||
public function mission()
|
public function mission(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Mission::class);
|
return $this->belongsTo(Mission::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function machine(): HasOne
|
||||||
|
{
|
||||||
|
return $this->hasOne(CMMSMachine::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,26 @@ namespace App\Services\Cartables\Mission;
|
|||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Models\MissionViolation;
|
use App\Models\MissionViolation;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class DailyMoveMachineService
|
class DailyMoveMachineService
|
||||||
{
|
{
|
||||||
public function dataTable(Request $request)
|
public function dataTable(Request $request)
|
||||||
{
|
{
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$query = MissionViolation::query();
|
||||||
|
|
||||||
|
if ($user->hasPermissionTo('manage-violation-station')) {
|
||||||
|
$query->whereRelation('machine', 'station_id', '=', $user->station_id);
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('manage-violation-city')) {
|
||||||
|
$query->whereRelation('machine', 'city_id', '=', $user->city_id);
|
||||||
|
}
|
||||||
|
elseif ($user->hasPermissionTo('manage-violation-province')) {
|
||||||
|
$query->whereRelation('machine', 'province_id', '=', $user->province_id);
|
||||||
|
}
|
||||||
|
|
||||||
return DataTableFacade::run(
|
return DataTableFacade::run(
|
||||||
MissionViolation::query(),
|
MissionViolation::query(),
|
||||||
$request,
|
$request,
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('mission_violations', function (Blueprint $table) {
|
||||||
|
$table->foreignId('machine_id')->constrained('cmms_machines');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('mission_violations', function (Blueprint $table) {
|
||||||
|
$table->dropForeign('mission_violations_machine_id_foreign');
|
||||||
|
$table->dropColumn('machine_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -178,6 +178,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endcan
|
@endcan
|
||||||
|
@canany(['manage-request-portal-city', 'manage-request-portal-province', 'manage-request-portal-country', 'manage-request-portal-station',
|
||||||
|
'manage-transportation-unit-city', 'manage-transportation-unit-province', 'manage-transportation-unit-country', 'manage-transportation-unit-station',
|
||||||
|
'manage-control-unit-city', 'manage-control-unit-province', 'manage-control-unit-country', 'manage-control-unit-station',
|
||||||
|
])
|
||||||
|
<div class="user-actions-topic d-flex align-items-center justify-content-between p-2 text-white rounded mt-2">
|
||||||
|
<a href="/v3/dashboard/" class="">
|
||||||
|
<div><i class="fas fa-shipping-fast mx-2"></i>ماموریت</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
@canany(['add-road-patrol', 'show-road-patrol-supervise-cartable', 'show-road-patrol-supervise-cartable-province'])
|
@canany(['add-road-patrol', 'show-road-patrol-supervise-cartable', 'show-road-patrol-supervise-cartable-province'])
|
||||||
<div class='user-actions-box pt-2'>
|
<div class='user-actions-box pt-2'>
|
||||||
<div class="user-actions-topic d-flex align-items-center justify-content-between p-2 text-white rounded">
|
<div class="user-actions-topic d-flex align-items-center justify-content-between p-2 text-white rounded">
|
||||||
|
|||||||
@@ -523,6 +523,7 @@ Route::prefix('missions')
|
|||||||
});
|
});
|
||||||
Route::prefix('violation_management')
|
Route::prefix('violation_management')
|
||||||
->name('violationManagement.')
|
->name('violationManagement.')
|
||||||
|
->middleware('permission:manage-violation-city|manage-violation-province|manage-violation-country|manage-violation-station')
|
||||||
->controller(ViolationManagementController::class)
|
->controller(ViolationManagementController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::get('/', 'index')->name('index');
|
Route::get('/', 'index')->name('index');
|
||||||
|
|||||||
Reference in New Issue
Block a user