mirror of
https://github.com/grokability/snipe-it.git
synced 2026-03-12 17:52:00 +08:00
suppliers completely done, rinse and repeat for the other two
This commit is contained in:
@@ -20,26 +20,26 @@ class BulkSuppliersController extends Controller
|
||||
foreach ($request->ids as $id) {
|
||||
$supplier = Supplier::find($id);
|
||||
if (is_null($supplier)) {
|
||||
$errors[] = 'Supplier not found';
|
||||
$errors[] = trans('admin/suppliers/message.delete.not_found');
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
DestroySupplierAction::run(supplier: $supplier);
|
||||
} catch (ModelStillHasAssets $e) {
|
||||
$errors[] = "{$supplier->name} still has assets";
|
||||
$errors[] = trans('admin/suppliers/message.delete.bulk_assoc_assets', ['supplier_name' => $supplier->name]);
|
||||
} catch (ModelStillHasAssetMaintenances $e) {
|
||||
$errors[] = "{$supplier->name} still has asset maintenances";
|
||||
$errors[] = trans('admin/suppliers/message.delete.bulk_assoc_maintenances', ['supplier_name' => $supplier->name]);;
|
||||
} catch (ModelStillHasLicenses $e) {
|
||||
$errors[] = "{$supplier->name} still has licenses";
|
||||
$errors[] = trans('admin/suppliers/message.delete.bulk_assoc_licenses', ['supplier_name' => $supplier->name]);
|
||||
} catch (\Exception $e) {
|
||||
report($e);
|
||||
$errors[] = 'Something went wrong';
|
||||
$errors[] = trans('general.something_went_wrong');
|
||||
}
|
||||
}
|
||||
if (count($errors) > 0) {
|
||||
return redirect()->route('suppliers.index')->with('error', implode(', ', $errors));
|
||||
return redirect()->route('suppliers.index')->with('multi_error_messages', $errors);
|
||||
} else {
|
||||
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.delete.success'));
|
||||
return redirect()->route('suppliers.index')->with('success', trans('admin/suppliers/message.delete.bulk_success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,11 @@ return array(
|
||||
'confirm' => 'Are you sure you wish to delete this supplier?',
|
||||
'error' => 'There was an issue deleting the supplier. Please try again.',
|
||||
'success' => 'Supplier was deleted successfully.',
|
||||
'not_found' => 'Supplier not found.',
|
||||
'bulk_success' => 'Suppliers were deleted successfully.',
|
||||
'bulk_assoc_assets' => ':supplier_name still has associated assets and cannot be deleted. Please update your assets to no longer reference this supplier and try again.',
|
||||
'bulk_assoc_licenses' => ':supplier_name still has associated licenses and cannot be deleted. Please update your licenses to no longer reference this supplier and try again.',
|
||||
'bulk_assoc_maintenances' => ':supplier_name still has associated maintenances and cannot be deleted. Please update your maintenances to no longer reference this supplier and try again.',
|
||||
'assoc_assets' => 'This supplier is currently associated with :asset_count asset(s) and cannot be deleted. Please update your assets to no longer reference this supplier and try again. ',
|
||||
'assoc_licenses' => 'This supplier is currently associated with :licenses_count licences(s) and cannot be deleted. Please update your licenses to no longer reference this supplier and try again. ',
|
||||
'assoc_maintenances' => 'This supplier is currently associated with :asset_maintenances_count asset maintenances(s) and cannot be deleted. Please update your asset maintenances to no longer reference this supplier and try again. ',
|
||||
|
||||
@@ -147,6 +147,21 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($messages = session()->get('multi_error_messages'))
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert alert-danger fade in">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<i class="fas fa-exclamation-triangle faa-pulse animated"></i>
|
||||
<strong>{{ trans('general.notification_error') }}: </strong>
|
||||
@foreach($messages as $key => $message)
|
||||
<ul>
|
||||
<li>{{ $message }}</li>
|
||||
</ul>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
@if ($message = session()->get('warning'))
|
||||
<div class="col-md-12">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<div id="{{ (isset($id_divname)) ? $id_divname : 'supplierBulkEditToolbar' }}" style="min-width:400px">
|
||||
<div id="{{ (isset($id_divname)) ? $id_divname : 'suppliersBulkEditToolbar' }}" style="min-width:400px">
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ route('suppliers.bulk.delete') }}"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@include('partials.supplier-bulk-actions', ['delete_only' => true])
|
||||
@include('partials.supplier-bulk-actions', [])
|
||||
|
||||
<table
|
||||
data-columns="{{ \App\Presenters\SupplierPresenter::dataTableLayout() }}"
|
||||
@@ -38,6 +38,11 @@
|
||||
data-show-refresh="true"
|
||||
data-sort-order="asc"
|
||||
id="suppliersTable"
|
||||
{{-- begin stuff for bulk dropdown --}}
|
||||
data-toolbar="#suppliersBulkEditToolbar"
|
||||
data-bulk-button-id="#bulkSupplierEditButton"
|
||||
data-bulk-form-id="#suppliersBulkForm"
|
||||
{{-- end stuff for bulk dropdown --}}
|
||||
class="table table-striped snipe-table"
|
||||
data-url="{{ route('api.suppliers.index') }}"
|
||||
data-export-options='{
|
||||
|
||||
@@ -47,7 +47,7 @@ Route::group(['middleware' => 'auth'], function () {
|
||||
'parameters' => ['category' => 'category_id'],
|
||||
]);
|
||||
|
||||
Route::delete('categories/bulk/delete', [BulkCategoriesController::class, 'destroy'])->name('categories.bulk.delete');
|
||||
Route::post('categories/bulk/delete', [BulkCategoriesController::class, 'destroy'])->name('categories.bulk.delete');
|
||||
|
||||
/*
|
||||
* Labels
|
||||
@@ -71,14 +71,14 @@ Route::group(['middleware' => 'auth'], function () {
|
||||
|
||||
Route::resource('manufacturers', ManufacturersController::class);
|
||||
|
||||
Route::delete('manufacturers/bulk/delete', [BulkManufacturersController::class, 'destroy'])->name('manufacturers.bulk.delete');
|
||||
Route::post('manufacturers/bulk/delete', [BulkManufacturersController::class, 'destroy'])->name('manufacturers.bulk.delete');
|
||||
|
||||
/*
|
||||
* Suppliers
|
||||
*/
|
||||
Route::resource('suppliers', SuppliersController::class);
|
||||
|
||||
Route::delete('suppliers/bulk/delete', [BulkSuppliersController::class, 'destroy'])->name('suppliers.bulk.delete');
|
||||
Route::post('suppliers/bulk/delete', [BulkSuppliersController::class, 'destroy'])->name('suppliers.bulk.delete');
|
||||
|
||||
/*
|
||||
* Depreciations
|
||||
|
||||
Reference in New Issue
Block a user