Skip to content

A free open source IT asset/license management system

Implement purchase date

Marcus Moorede5c555af7c0
diff --git a/app/Http/Controllers/Reports/CustomComponentReportController.php b/app/Http/Controllers/Reports/CustomComponentReportController.php
index 92317be569..82b3e2a6b9 100644
--- a/app/Http/Controllers/Reports/CustomComponentReportController.php
+++ b/app/Http/Controllers/Reports/CustomComponentReportController.php
@@ -67,6 +67,10 @@ class CustomComponentReportController extends Controller
'supplier',
]);
+ if ($request->filled(['purchase_start', 'purchase_end'])) {
+ $components->whereBetween('components.purchase_date', [$request->input('purchase_start'), $request->input('purchase_end')]);
+ }
+
$localConstraints = [
'by_model_number' => 'components.model_number',
'by_name' => 'components.name',
diff --git a/resources/views/reports/custom/component.blade.php b/resources/views/reports/custom/component.blade.php
index 0153b739f7..492003fe80 100644
--- a/resources/views/reports/custom/component.blade.php
+++ b/resources/views/reports/custom/component.blade.php
@@ -598,13 +598,13 @@
@section('moar_scripts')
<script>
- // $('.purchase-range .input-daterange').datepicker({
- // clearBtn: true,
- // todayHighlight: true,
- // endDate: '0d',
- // format: 'yyyy-mm-dd',
- // keepEmptyValues: true,
- // });
+ $('.purchase-range .input-daterange').datepicker({
+ clearBtn: true,
+ todayHighlight: true,
+ endDate: '0d',
+ format: 'yyyy-mm-dd',
+ keepEmptyValues: true,
+ });
$("#checkAll").change(function () {
$("#included_fields_wrapper input:checkbox").prop('checked', $(this).prop("checked"));
diff --git a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
index b74ef78c34..fe91ee2186 100644
--- a/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
+++ b/tests/Feature/Reporting/Custom/CustomComponentReportTest.php
@@ -76,6 +76,13 @@ class CustomComponentReportTest extends TestCase
$this->assertTrue($viewTemplateNames->doesntContain('Another User: Component'));
}
+ public function test_custom_component_report_validation()
+ {
+ $this->markTestIncomplete();
+
+ // todo: purchase_start and purchase_end
+ }
+
public function test_custom_component_report_headers()
{
$this->sendRequest([
@@ -334,8 +341,6 @@ class CustomComponentReportTest extends TestCase
public function test_limiting_by_purchase_date()
{
- $this->markTestIncomplete();
-
Component::factory()->create(['name' => 'Component A', 'purchase_date' => '2024-01-15']);
Component::factory()->create(['name' => 'Component B', 'purchase_date' => '2024-06-15']);