|
|
@@ -68,6 +68,7 @@ class ReclamationController extends Controller
|
|
|
public function index(Request $request)
|
|
|
{
|
|
|
session(['gp_reclamations' => $request->all()]);
|
|
|
+ $nav = $this->startNavigationContext($request);
|
|
|
$model = new ReclamationView();
|
|
|
// fill filters
|
|
|
$this->createFilters($model, 'user_name', 'status_name');
|
|
|
@@ -89,6 +90,7 @@ class ReclamationController extends Controller
|
|
|
|
|
|
$this->applyStableSorting($q);
|
|
|
$this->data['reclamations'] = $q->paginate($this->data['per_page'])->withQueryString();
|
|
|
+ $this->data['nav'] = $nav;
|
|
|
|
|
|
return view('reclamations.index', $this->data);
|
|
|
}
|
|
|
@@ -128,6 +130,7 @@ class ReclamationController extends Controller
|
|
|
|
|
|
public function create(CreateReclamationRequest $request, Order $order, NotificationService $notificationService)
|
|
|
{
|
|
|
+ $nav = $this->resolveNavToken($request);
|
|
|
$reclamation = Reclamation::query()->create([
|
|
|
'order_id' => $order->id,
|
|
|
'user_id' => $request->user()->id,
|
|
|
@@ -138,7 +141,7 @@ class ReclamationController extends Controller
|
|
|
$skus = $request->validated('skus');
|
|
|
$reclamation->skus()->attach($skus);
|
|
|
$notificationService->notifyReclamationCreated($reclamation->fresh(['order', 'status']), auth()->user());
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => url()->previous()]);
|
|
|
+ return redirect()->route('reclamations.show', $this->withNav(['reclamation' => $reclamation], $nav));
|
|
|
}
|
|
|
|
|
|
public function show(Request $request, Reclamation $reclamation)
|
|
|
@@ -172,9 +175,12 @@ class ReclamationController extends Controller
|
|
|
$this->data['chatResponsibleUserIds'] = $responsibleUserIds;
|
|
|
$this->data['chatManagerUserId'] = $reclamation->user_id ? (int) $reclamation->user_id : null;
|
|
|
$this->data['chatBrigadierUserId'] = $reclamation->brigadier_id ? (int) $reclamation->brigadier_id : null;
|
|
|
- $this->data['previous_url'] = $this->resolvePreviousUrl(
|
|
|
+ $nav = $this->resolveNavToken($request);
|
|
|
+ $this->rememberNavigation($request, $nav);
|
|
|
+ $this->data['nav'] = $nav;
|
|
|
+ $this->data['back_url'] = $this->navigationBackUrl(
|
|
|
$request,
|
|
|
- 'previous_url_reclamations',
|
|
|
+ $nav,
|
|
|
route('reclamations.index', session('gp_reclamations'))
|
|
|
);
|
|
|
return view('reclamations.edit', $this->data);
|
|
|
@@ -190,15 +196,13 @@ class ReclamationController extends Controller
|
|
|
$notificationService->notifyReclamationStatusChanged($reclamation->fresh(['order', 'status']), auth()->user());
|
|
|
}
|
|
|
|
|
|
- $previousUrl = $this->previousUrlForRedirect($request, 'previous_url_reclamations');
|
|
|
- if (!empty($previousUrl)) {
|
|
|
- return redirect()->route('reclamations.show', [
|
|
|
- 'reclamation' => $reclamation,
|
|
|
- 'previous_url' => $previousUrl,
|
|
|
- ]);
|
|
|
+ $nav = $this->resolveNavToken($request);
|
|
|
+
|
|
|
+ if ($request->ajax()) {
|
|
|
+ return response()->noContent();
|
|
|
}
|
|
|
|
|
|
- return redirect()->route('reclamations.show', $reclamation->id);
|
|
|
+ return redirect()->route('reclamations.show', $this->withNav(['reclamation' => $reclamation], $nav));
|
|
|
}
|
|
|
|
|
|
public function updateStatus(Request $request, Reclamation $reclamation, NotificationService $notificationService)
|
|
|
@@ -240,11 +244,11 @@ class ReclamationController extends Controller
|
|
|
$reclamation->photos_before()->syncWithoutDetaching($f);
|
|
|
} catch (Throwable $e) {
|
|
|
report($e);
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['error' => 'Ошибка загрузки фотографий проблемы. Проверьте имя файла и повторите попытку.']);
|
|
|
}
|
|
|
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Фотографии проблемы успешно загружены!']);
|
|
|
}
|
|
|
|
|
|
@@ -264,11 +268,11 @@ class ReclamationController extends Controller
|
|
|
$reclamation->photos_after()->syncWithoutDetaching($f);
|
|
|
} catch (Throwable $e) {
|
|
|
report($e);
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['error' => 'Ошибка загрузки фотографий после устранения. Проверьте имя файла и повторите попытку.']);
|
|
|
}
|
|
|
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Фотографии после устранения успешно загружены!']);
|
|
|
}
|
|
|
|
|
|
@@ -280,7 +284,7 @@ class ReclamationController extends Controller
|
|
|
$reclamation->photos_before()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation);
|
|
|
}
|
|
|
|
|
|
public function deletePhotoAfter(Request $request, Reclamation $reclamation, File $file, FileService $fileService)
|
|
|
@@ -291,7 +295,7 @@ class ReclamationController extends Controller
|
|
|
$reclamation->photos_after()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation);
|
|
|
}
|
|
|
|
|
|
public function uploadDocument(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
|
@@ -313,11 +317,11 @@ class ReclamationController extends Controller
|
|
|
$reclamation->documents()->syncWithoutDetaching($f);
|
|
|
} catch (Throwable $e) {
|
|
|
report($e);
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['error' => 'Ошибка загрузки документов рекламации. Проверьте имя файла и повторите попытку.']);
|
|
|
}
|
|
|
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Документы рекламации успешно загружены!']);
|
|
|
}
|
|
|
|
|
|
@@ -329,7 +333,7 @@ class ReclamationController extends Controller
|
|
|
$reclamation->documents()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation);
|
|
|
}
|
|
|
|
|
|
public function uploadAct(Request $request, Reclamation $reclamation, FileService $fileService)
|
|
|
@@ -351,11 +355,11 @@ class ReclamationController extends Controller
|
|
|
$reclamation->acts()->syncWithoutDetaching($f);
|
|
|
} catch (Throwable $e) {
|
|
|
report($e);
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['error' => 'Ошибка загрузки актов. Проверьте имя файла и повторите попытку.']);
|
|
|
}
|
|
|
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Акты успешно загружены!']);
|
|
|
}
|
|
|
|
|
|
@@ -367,7 +371,7 @@ class ReclamationController extends Controller
|
|
|
$reclamation->acts()->detach($file);
|
|
|
Storage::disk('public')->delete($file->path);
|
|
|
$file->delete();
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation);
|
|
|
}
|
|
|
|
|
|
public function updateDetails(StoreReclamationDetailsRequest $request, Reclamation $reclamation)
|
|
|
@@ -467,7 +471,7 @@ class ReclamationController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation);
|
|
|
}
|
|
|
|
|
|
public function updateSpareParts(StoreReclamationSparePartsRequest $request, Reclamation $reclamation)
|
|
|
@@ -553,34 +557,34 @@ class ReclamationController extends Controller
|
|
|
// Синхронизируем (заменяем все старые привязки новыми)
|
|
|
$reclamation->spareParts()->sync($newSpareParts);
|
|
|
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')]);
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation);
|
|
|
}
|
|
|
|
|
|
public function generateReclamationPack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
|
GenerateReclamationPack::dispatch($reclamation, auth()->user()->id);
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Задача генерации документов создана!']);
|
|
|
}
|
|
|
|
|
|
public function generateReclamationPaymentPack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
|
GenerateReclamationPaymentPack::dispatch($reclamation, auth()->user()->id);
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Задача генерации пакета документов на оплату создана!']);
|
|
|
}
|
|
|
|
|
|
public function generatePhotosBeforePack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
|
GenerateFilesPack::dispatch($reclamation, $reclamation->photos_before, auth()->user()->id, 'Фото проблемы');
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Задача архивации создана!']);
|
|
|
}
|
|
|
|
|
|
public function generatePhotosAfterPack(Request $request, Reclamation $reclamation)
|
|
|
{
|
|
|
GenerateFilesPack::dispatch($reclamation, $reclamation->photos_after, auth()->user()->id, 'Фото после');
|
|
|
- return redirect()->route('reclamations.show', ['reclamation' => $reclamation, 'previous_url' => $request->get('previous_url')])
|
|
|
+ return $this->redirectToReclamationShow($request, $reclamation)
|
|
|
->with(['success' => 'Задача архивации создана!']);
|
|
|
}
|
|
|
|
|
|
@@ -612,4 +616,11 @@ class ReclamationController extends Controller
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function redirectToReclamationShow(Request $request, Reclamation $reclamation)
|
|
|
+ {
|
|
|
+ $nav = $this->resolveNavToken($request);
|
|
|
+
|
|
|
+ return redirect()->route('reclamations.show', $this->withNav(['reclamation' => $reclamation], $nav));
|
|
|
+ }
|
|
|
+
|
|
|
}
|