A free open source IT asset/license management system
WIP: begin to list assignments
Marcus Moore3c30fd7d4ab6
diff --git a/app/Http/Controllers/Reports/CustomComponentReportController.php b/app/Http/Controllers/Reports/CustomComponentReportController.phpindex f0e68daf47..ea6469a17b 100644--- a/app/Http/Controllers/Reports/CustomComponentReportController.php+++ b/app/Http/Controllers/Reports/CustomComponentReportController.php@@ -69,84 +69,92 @@ class CustomComponentReportController extends Controller$formatter = new EscapeFormula('`');foreach ($components as $component) {- $count++;- $row = [];- if ($request->filled('id')) {- $row[] = $component->id;- }+ foreach ($component->assets as $asset) {- if ($request->filled('company')) {- $row[] = $component?->company?->name;- }+ $count++;+ $row = [];- if ($request->filled('category')) {- $row[] = $component?->category?->name;- }+ if ($request->filled('id')) {+ $row[] = $component->id;+ }- if ($request->filled('component_name')) {- $row[] = $component->name;- }+ if ($request->filled('company')) {+ $row[] = $component?->company?->name;+ }- if ($request->filled('manufacturer')) {- $row[] = $component?->manufacturer?->name;- }+ if ($request->filled('category')) {+ $row[] = $component?->category?->name;+ }- if ($request->filled('model')) {- $row[] = $component->model_number;- }+ if ($request->filled('component_name')) {+ $row[] = $component->name;+ }- // todo: serial- // todo: purchase date- // todo: quantity- // todo: min quantity- // todo: unit cost+ if ($request->filled('manufacturer')) {+ $row[] = $component?->manufacturer?->name;+ }- if ($request->filled('order')) {- $row[] = $component->order_number;- }+ if ($request->filled('model')) {+ $row[] = $component->model_number;+ }- if ($request->filled('supplier')) {- $row[] = $component?->supplier?->name;- }+ if ($request->filled('include_assignments')) {+ $row[] = $asset->name;+ }- if ($request->filled('location')) {- $row[] = $component?->location?->name;- // todo: address- // todo: city- // todo: state- // todo: country- // todo: zip- }+ // todo: serial+ // todo: purchase date+ // todo: quantity+ // todo: min quantity+ // todo: unit cost- // todo: checkout date+ if ($request->filled('order')) {+ $row[] = $component->order_number;+ }- if ($request->filled('created_at')) {- $row[] = $component->created_at;- }+ if ($request->filled('supplier')) {+ $row[] = $component?->supplier?->name;+ }- if ($request->filled('updated_at')) {- $row[] = $component->updated_at;- }+ if ($request->filled('location')) {+ $row[] = $component?->location?->name;+ // todo: address+ // todo: city+ // todo: state+ // todo: country+ // todo: zip+ }- // todo: deleted- // todo: notes+ // todo: checkout date- // todo: checkout to: asset name- // todo: checkout to: asset tag- // todo: checkout to: asset company- // todo: checkout to: asset serial+ if ($request->filled('created_at')) {+ $row[] = $component->created_at;+ }- // CSV_ESCAPE_FORMULAS is set to false in the .env- if (config('app.escape_formulas') === false) {- fputcsv($handle, $row);+ if ($request->filled('updated_at')) {+ $row[] = $component->updated_at;+ }- // CSV_ESCAPE_FORMULAS is set to true or is not set in the .env- } else {- fputcsv($handle, $formatter->escapeRecord($row));- }+ // todo: deleted+ // todo: notes++ // todo: checkout to: asset name+ // todo: checkout to: asset tag+ // todo: checkout to: asset company+ // todo: checkout to: asset serial++ // CSV_ESCAPE_FORMULAS is set to false in the .env+ if (config('app.escape_formulas') === false) {+ fputcsv($handle, $row);++ // CSV_ESCAPE_FORMULAS is set to true or is not set in the .env+ } else {+ fputcsv($handle, $formatter->escapeRecord($row));+ }- Log::debug('-- Record '.$count.' Component ID:'.$component->id.' in '.$this->getExecutionTime());+ Log::debug('-- Record '.$count.' Component ID:'.$component->id.' in '.$this->getExecutionTime());+ }}});@@ -194,6 +202,11 @@ class CustomComponentReportController extends Controller$header[] = trans('general.model_no');}+ if ($request->filled('include_assignments')) {+ // todo:+ $header[] = 'Asset';+ }+if ($request->filled('serial')) {$header[] = trans('general.serial_number');}@@ -285,6 +298,8 @@ class CustomComponentReportController extends Controller'supplier',]);+ $request->whenFilled('include_assignments', fn () => $query->with('assets'));+$query = $this->appendLocalConstraints($query, $request, ['by_model_number' => 'components.model_number','by_name' => 'components.name',diff --git a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php b/tests/Feature/Reporting/Custom/CustomComponentReportTest.phpindex 1e480c644d..101be3bcc9 100644--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php@@ -585,8 +585,6 @@ class CustomComponentReportTest extends TestCasepublic function test_can_include_assignments(){- $this->markTestIncomplete();-[$assetA, $assetB] = Asset::factory()->count(2)->sequence(