Aded filter list api for invoice
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\InvoiceValidation;
|
use App\Models\InvoiceValidation;
|
||||||
|
use App\Models\ModuleList;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use Illuminate\Http\Request;
|
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)
|
// public function get_invoiceCountData(Request $request)
|
||||||
// {
|
// {
|
||||||
// $expectedUser = env('API_AUTH_USER');
|
// $expectedUser = env('API_AUTH_USER');
|
||||||
|
|||||||
@@ -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-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-count/data', [ModuleInvoiceTypeController::class, 'get_invoiceCountData']);
|
||||||
|
|
||||||
Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);
|
Route::get('get/module-invoice-quantity/data', [ModuleInvoiceQuantityController::class, 'get_invoiceQuantityData']);
|
||||||
|
|||||||
Reference in New Issue
Block a user