Added sticker master get controller production reprint

This commit is contained in:
dhanabalan
2025-07-24 18:03:00 +05:30
parent 5fe2b74174
commit 26ecaf49ef
2 changed files with 125 additions and 0 deletions

View File

@@ -27,6 +27,126 @@ class StickerMasterController extends Controller
// //
} }
public function get_master_type(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);
}
$plantCode = $request->header('plant-code');
$itemCode = $request->header('item-code');
if ($plantCode == null || $plantCode == '')
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant code can't be empty!"
], 400);
}
else if (Str::length($plantCode) < 4 || !is_numeric($plantCode) || !preg_match('/^[1-9]\d{3,}$/', $plantCode))
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Invalid plant code found!"
], 400);
}
else if ($itemCode == null || $itemCode == '')
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code can't be empty!"
], 400);
}
else if (Str::length($itemCode) < 6 || !ctype_alnum($itemCode))
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Invalid item code found!"
], 400);
}
$plant = Plant::where('code', $plantCode)->first();
if (!$plant) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Plant not found!"
], 400);
}
$plantId = $plant->id;
$item = Item::where('code', $itemCode)->first();
if (!$item)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code not found in item table!"
], 404);
}
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
if (!$item)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code not found in item table for the plant : '$plant->name'!"
], 404);
}
$stickerMaster = StickerMaster::where('plant_id', $plantId)->where('item_id', $item->id)->first();
if (!$stickerMaster)
{
return response()->json([
'status_code' => 'ERROR',
'status_description' => "Item Code not found in sticker master table for the plant : '$plant->name'!"
], 404);
}
$serial_number_motor = $stickerMaster->serial_number_motor ?? null;
$serial_number_pump = $stickerMaster->serial_number_pump ?? null;
if ($serial_number_motor != 1 && $serial_number_pump != 1) {
return response()->json([
'status_code' => 'ERROR',
'status_description' => "The Item Code '$itemCode' does not have serial pump or serial motor selected!"
], 400);
}
$serialInfo = [];
if ($serial_number_motor == 1 && $serial_number_pump == 1)
{
$serialInfo[] = 'Serial Pump';
}
else
{
if ($serial_number_motor == 1) {
$serialInfo[] = 'Serial Motor';
}
if ($serial_number_pump == 1) {
$serialInfo[] = 'Serial Pump';
}
}
$output = [
'status_code' => 'SUCCESS',
'status_description' => implode(', ', $serialInfo),
];
return response()->json($output, 200);
}
/** /**
* Display the specified resource. * Display the specified resource.
*/ */

View File

@@ -21,6 +21,7 @@ use App\Http\Controllers\ModuleProductionOrderDataController;
use App\Http\Controllers\ObdController; use App\Http\Controllers\ObdController;
use App\Http\Controllers\PalletController; use App\Http\Controllers\PalletController;
use App\Http\Controllers\PlantController; use App\Http\Controllers\PlantController;
use App\Http\Controllers\ProductionStickerReprintController;
use App\Http\Controllers\StickerMasterController; use App\Http\Controllers\StickerMasterController;
use App\Http\Controllers\TestingPanelController; use App\Http\Controllers\TestingPanelController;
use App\Http\Controllers\UserController; use App\Http\Controllers\UserController;
@@ -77,8 +78,12 @@ Route::get('machine/get-all-data', [MachineController::class, 'get_all_data']);
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']); Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
Route::get('sticker/get-master-type-data', [StickerMasterController::class, 'get_master_type']);
Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrPdf'])->name('download-qr-pdf'); Route::get('/download-qr-pdf/{palletNo}', [PalletController::class, 'downloadQrPdf'])->name('download-qr-pdf');
Route::get('/download-qr1-pdf/{palletNo}', [ProductionStickerReprintController::class, 'downloadQrPdf'])->name('download-qr1-pdf');
//Production Dashboard Controller //Production Dashboard Controller
Route::get('get/module-name/data', [ModuleController::class, 'get_module']); Route::get('get/module-name/data', [ModuleController::class, 'get_module']);