3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 03:06:23 +00:00

FMCS+Location Scoping: Added download CSV to location scope check

This commit is contained in:
snipe
2026-07-30 20:12:46 +01:00
parent 525a3a517f
commit cf7cde65a8
4 changed files with 50 additions and 0 deletions

View File

@ -162,6 +162,38 @@ class SettingsController extends Controller
return redirect()->back()->withInput()->withErrors($setting->getErrors());
}
/**
* Stream a CSV of every location-scoping FMCS mismatch.
*
* This endpoint runs the full walk (artisan=true) and streams
* the same table columns the CLI command prints, as CSV.
*/
public function downloadLocationScopingReport(): \Symfony\Component\HttpFoundation\StreamedResponse
{
$mismatched = Helper::test_locations_fmcs(true);
$filename = 'location-scoping-mismatches-' . date('Y-m-d') . '.csv';
return response()->streamDownload(function () use ($mismatched) {
$out = fopen('php://output', 'w');
fputcsv($out, [
'Type',
'ID',
'Name',
'Checkout Type',
'Company IDs',
'Item Companies',
'Item Location',
'Location Company',
'Location Company ID',
]);
foreach ($mismatched as $row) {
fputcsv($out, $row);
}
fclose($out);
}, $filename, ['Content-Type' => 'text/csv']);
}
/**
* Return a form to allow a super admin to update settings.
*

View File

@ -280,6 +280,7 @@ return [
'scope_locations_fmcs_check_button' => 'Check Compatibility',
'scope_locations_fmcs_test_needed' => 'Please Check Compatibility to enable this',
'scope_locations_fmcs_support_disabled_text' => 'This option is disabled because you have conflicting locations set for :count or more items.',
'scope_locations_fmcs_download_report' => 'Download mismatch report (CSV)',
'null_company_is_floater_text' => 'Treat items and users without company associations as floaters',
'null_company_is_floater_help_text' => 'When disabled, items can only be checked out to targets without a company association if the item also has no company - null is treated as its own pseudo-company. When enabled, items from any company can be checked out to targets with no company assignment.',
'show_in_model_list' => 'Show in Model Dropdowns',

View File

@ -12,4 +12,18 @@
@endif
</p>
<button class="btn btn-sm btn-theme" wire:click.prevent="check_locations">{{ trans('admin/settings/general.scope_locations_fmcs_check_button') }}</button>
{{-- Download-full-report link. Shown only after the enable-check
has run AND found mismatches. The endpoint runs the full walk of
Helper::test_locations_fmcs and streams a CSV, so expect it to
take longer than the enable-check on large datasets since it
doesn't early-bail. --}}
@if ($is_tested && count($mismatched) > 0)
<a href="{{ route('settings.general.location_scoping_report') }}"
class="btn btn-sm btn-default"
style="margin-left: 6px;">
<x-icon type="download"/>
{{ trans('admin/settings/general.scope_locations_fmcs_download_report') }}
</a>
@endif
</div>

View File

@ -230,6 +230,9 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser
Route::post('settings', [SettingsController::class, 'postSettings'])
->name('settings.general.save');
Route::get('settings/location-scoping-report.csv', [SettingsController::class, 'downloadLocationScopingReport'])
->name('settings.general.location_scoping_report');
Route::get('branding', [SettingsController::class, 'getBranding'])
->name('settings.branding.index')
->breadcrumbs(fn (Trail $trail) => $trail->parent('settings.index')