From 5fe2b7417480d002d2a3b32ef7a3d368487988d6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 22 Jul 2025 11:11:26 +0530 Subject: [PATCH] Aded filter list api for invoice --- .../ModuleInvoiceTypeController.php | 57 +++++++++++++++++++ routes/api.php | 2 + 2 files changed, 59 insertions(+) diff --git a/app/Http/Controllers/ModuleInvoiceTypeController.php b/app/Http/Controllers/ModuleInvoiceTypeController.php index 52699da..60ff6bc 100644 --- a/app/Http/Controllers/ModuleInvoiceTypeController.php +++ b/app/Http/Controllers/ModuleInvoiceTypeController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Models\InvoiceValidation; +use App\Models\ModuleList; use App\Models\Plant; use Illuminate\Http\Request; @@ -16,6 +17,62 @@ class ModuleInvoiceTypeController extends Controller // } + public function get_invoiceFilter(Request $request) + { + $expectedUser = env('API_AUTH_USER'); + $expectedPw = env('API_AUTH_PW'); + + $header_auth = $request->header('Authorization'); + $expectedToken = $expectedUser . ':' . $expectedPw; + + if ("Bearer " . $expectedToken != $header_auth) + { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Invalid authorization token!' + ], 403); + } + + $filterName = $request->header('filter-name'); + + if (empty($filterName)) + { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Filter Name can't be empty!" + ], 404); + } + + $headerValue = $request->header('filter-name'); + + if ($headerValue != 'Filter List') { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => "Invalid value for 'module-name' header!" + ], 404); + } + + $uniqueModules = ModuleList::select('filter_name', 'created_at') + ->orderBy('created_at', 'asc') + ->get() + ->unique('filter_name') + ->pluck('filter_name') + ->values(); + + if ($uniqueModules->isEmpty()) { + return response()->json([ + 'status_code' => 'ERROR', + 'status_description' => 'Filter names not found' + ], 404); + } + + + return response()->json([ + 'status_code' => 'SUCCESS', + 'status_description' => $uniqueModules + ], 200); + } + // public function get_invoiceCountData(Request $request) // { // $expectedUser = env('API_AUTH_USER'); diff --git a/routes/api.php b/routes/api.php index 0e65825..91e3724 100644 --- a/routes/api.php +++ b/routes/api.php @@ -105,6 +105,8 @@ Route::get('get/module-production-linestop/data', [ModuleProductionLineStopContr Route::get('get/module-invoice-type/data', [ModuleInvoiceDataController::class, 'get_invoiceData']); +Route::get('get/module-invoice-filter/data', [ModuleInvoiceTypeController::class, 'get_invoiceFilter']); + Route::get('get/module-invoice-count/data', [ModuleInvoiceTypeController::class, 'get_invoiceCountData']); Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);