Added coil details in pdf controller
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 5m10s
Laravel Larastan / larastan (pull_request) Failing after 6m59s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 5m10s
Laravel Larastan / larastan (pull_request) Failing after 6m59s
This commit is contained in:
@@ -314,6 +314,78 @@ class PdfController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCoilDetails(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!',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$plantCode = $request->header('plant-code');
|
||||||
|
|
||||||
|
$processOrder = $request->header('process-order');
|
||||||
|
|
||||||
|
if (! $plantCode) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Plant Code value can't be empty",
|
||||||
|
], 404);
|
||||||
|
} elseif (! $processOrder) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Process Order cannot be empty!',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!str_contains($processOrder, '-')) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Invalid Process Order",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
|
$plantId = $plant->id;
|
||||||
|
|
||||||
|
if (! $plant) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Plant Code '{$plantCode}' not found!",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$parts = explode('-', $processOrder);
|
||||||
|
$processOrder = $parts[0]; // 261010002154
|
||||||
|
$coilNo = $parts[1]; // 001
|
||||||
|
|
||||||
|
$processOrderExist = ProcessOrder::where('process_order', $processOrder)->where('plant_id', $plantId)->where('coil_number', $coilNo)->first();
|
||||||
|
|
||||||
|
if ($processOrderExist) {
|
||||||
|
$itemId = $processOrderExist->item_id;
|
||||||
|
|
||||||
|
$item = Item::where('id', $itemId)->first();
|
||||||
|
$itemCode = $item->code;
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Process order '$processOrder' with coil number '$coilNo' found against item '$itemCode'",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => "Process order '$processOrder' with coil number '$coilNo' not found'",
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a newly created resource in storage.
|
* Store a newly created resource in storage.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user