Skip to content

A free open source IT asset/license management system

Few more translations

snipe179748012852
diff --git a/app/Http/Controllers/LocationsController.php b/app/Http/Controllers/LocationsController.php
index 7a4b47b385..dad1d0b241 100755
--- a/app/Http/Controllers/LocationsController.php
+++ b/app/Http/Controllers/LocationsController.php
@@ -8,6 +8,7 @@ use App\Models\Location;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Storage;
+use Illuminate\Http\Request;
/**
* This controller handles all actions related to Locations for
@@ -238,7 +239,7 @@ class LocationsController extends Controller
* @author [A. Gianotto] [<[email protected]>]
* @param int $locationId
* @since [v6.0.14]
- * @return View
+ * @return \Illuminate\Contracts\View\View
*/
public function getClone($locationId = null)
{
@@ -272,8 +273,92 @@ class LocationsController extends Controller
}
return redirect()->route('locations.index')->with('error', trans('admin/locations/message.does_not_exist'));
+ }
+
+
+ /**
+ * Returns a view that allows the user to bulk delete locations
+ *
+ * @author [A. Gianotto] [<[email protected]>]
+ * @since [v6.3.1]
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function postBulkDelete(Request $request)
+ {
+ $locations_raw_array = $request->input('ids');
+
+ // Make sure some IDs have been selected
+ if ((is_array($locations_raw_array)) && (count($locations_raw_array) > 0)) {
+ $locations = Location::whereIn('id', $locations_raw_array)->get();
+
+ $valid_count = 0;
+ foreach ($locations as $location) {
+ if ($location->isDeletable()) {
+ $valid_count++;
+ }
+ }
+ return view('locations/bulk-delete', compact('locations'))->with('valid_count', $valid_count);
+ }
+
+ return redirect()->route('models.index')
+ ->with('error', 'You must select at least one model to edit.');
+ }
+
+ /**
+ * Checks that locations can be deleted and deletes them if they can
+ *
+ * @author [A. Gianotto] [<[email protected]>]
+ * @since [v6.3.1]
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function postBulkDeleteStore(Request $request) {
+ $locations_raw_array = $request->input('ids');
+
+ if ((is_array($locations_raw_array)) && (count($locations_raw_array) > 0)) {
+ $locations = Location::whereIn('id', $locations_raw_array)->get();
+
+ $success_count = 0;
+ $error_count = 0;
+
+ foreach ($locations as $location) {
+
+ // Can we delete this location?
+ if ($location->isDeletable()) {
+ $location->delete();
+ $success_count++;
+ } else {
+ $error_count++;
+ }
+ }
+
+ \Log::debug('Success count: '.$success_count);
+ \Log::debug('Error count: '.$error_count);
+ // Complete success
+ if ($success_count == count($locations_raw_array)) {
+ return redirect()
+ ->route('locations.index')
+ ->with('success', trans_choice('general.bulk.delete.success', $success_count,
+ ['object_type' => trans_choice('general.location_plural', $success_count), 'count' => $success_count]
+ ));
+ }
+
+ // Partial success
+ if ($error_count > 0) {
+ return redirect()
+ ->route('locations.index')
+ ->with('warning', trans('general.bulk.partial_success',
+ ['success' => $success_count, 'error' => $error_count, 'object_type' => trans('general.locations')]
+ ));
+ }
+ }
+ // Nothing was selected - return to the index
+ return redirect()
+ ->route('locations.index')
+ ->with('error', trans('general.bulk.nothing_selected',
+ ['object_type' => trans('general.locations')]
+ ));
}
}
diff --git a/resources/lang/en-US/general.php b/resources/lang/en-US/general.php
index 69627a37aa..6e1663b590 100644
--- a/resources/lang/en-US/general.php
+++ b/resources/lang/en-US/general.php
@@ -510,8 +510,9 @@ return [
'warn' => 'You are about to delete one :object_type|You are about to delete :count :object_type',
'success' => ':object_type successfully deleted|Successfully deleted :count :object_type',
'error' => 'Could not delete :object_type',
+ 'nothing_selected' => 'No :object_type selected - nothing to do',
+ 'partial' => 'Deleted :success_count :object_type, but :error_count :object_type could not be deleted',
],
-
],
];