Added pdf generate method for sticker validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 16s
Laravel Pint / pint (pull_request) Failing after 2m38s
Laravel Larastan / larastan (pull_request) Failing after 13m18s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 11s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 16s
Laravel Pint / pint (pull_request) Failing after 2m38s
Laravel Larastan / larastan (pull_request) Failing after 13m18s
This commit is contained in:
@@ -913,6 +913,8 @@ class PdfController extends Controller
|
||||
$itemCharacteristicId = $request->query('item_characteristic_id');
|
||||
$stickerId = trim($stickerId);
|
||||
|
||||
//dd($plantId,$itemCharacteristicId,$stickerId);
|
||||
|
||||
// Normalize "empty" or "" to null
|
||||
$plantId = ($plantId && $plantId != 'empty') ? $plantId : null;
|
||||
$itemCharacteristicId = ($itemCharacteristicId && $itemCharacteristicId != 'empty') ? $itemCharacteristicId : null;
|
||||
@@ -956,4 +958,91 @@ class PdfController extends Controller
|
||||
return $pdfService->generate($stickerId, $elements->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public function generatePdf(Request $request, $stickerId)
|
||||
// {
|
||||
// $plantId = $request->query('plant_id');
|
||||
// $itemCharacteristicId = $request->query('item_characteristic_id');
|
||||
// $stickerId = trim($stickerId);
|
||||
|
||||
// //dd($plantId,$itemCharacteristicId,$stickerId);
|
||||
|
||||
// // Normalize "empty" or "" to null
|
||||
// $plantId = ($plantId && $plantId != 'empty') ? $plantId : null;
|
||||
// $itemCharacteristicId = ($itemCharacteristicId && $itemCharacteristicId != 'empty') ? $itemCharacteristicId : null;
|
||||
|
||||
|
||||
// if ($plantId && $itemCharacteristicId)
|
||||
// {
|
||||
// $plantId = $request->query('plant_id');
|
||||
// $itemCharacteristicId = $request->query('item_characteristic_id');
|
||||
|
||||
|
||||
// $sticId = StickerStructureDetail::where('id', $stickerId)->first();
|
||||
|
||||
// $sId = $sticId->id;
|
||||
|
||||
// $stickerId = $sticId->sticker_id;
|
||||
|
||||
// $dynamicElements = StickerDetail::where('sticker_structure_detail_id', $sId)
|
||||
// ->where('element_type', 'Dynamic')
|
||||
// ->get();
|
||||
|
||||
// $itemCharacteristic = null;
|
||||
|
||||
// if ($plantId && $itemCharacteristicId) {
|
||||
// $itemCharacteristic = ItemCharacteristic::where('plant_id', $plantId)
|
||||
// ->where('id', $itemCharacteristicId)
|
||||
// ->first();
|
||||
// }
|
||||
|
||||
// $pdfService = new StickerPdfService();
|
||||
|
||||
// return $pdfService->generatePdf1(
|
||||
// $stickerId,
|
||||
// $dynamicElements,
|
||||
// $itemCharacteristic
|
||||
// );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $elements = StickerStructureDetail::where('sticker_id', $stickerId)
|
||||
// ->first();
|
||||
|
||||
// $pdfService = new StickerPdfService();
|
||||
// return $pdfService->generate($stickerId, $elements->toArray());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public function generatePdf(Request $request, $stickerId)
|
||||
{
|
||||
$plantId = $request->query('plant_id');
|
||||
$itemCharacteristicId = $request->query('item_characteristic_id');
|
||||
$serialNumber = $request->query('serial_number');
|
||||
|
||||
if ($plantId && $itemCharacteristicId) {
|
||||
$structure = StickerStructureDetail::findOrFail($stickerId);
|
||||
|
||||
$dynamicElements = StickerDetail::where(
|
||||
'sticker_structure_detail_id',
|
||||
$structure->id
|
||||
)->where('element_type', 'Dynamic')->get();
|
||||
|
||||
$itemCharacteristic = ItemCharacteristic::where('plant_id', $plantId)
|
||||
->where('id', $itemCharacteristicId)
|
||||
->first();
|
||||
|
||||
return (new StickerPdfService())->generatePdf1(
|
||||
$structure->sticker_id,
|
||||
$dynamicElements,
|
||||
$itemCharacteristic,
|
||||
$serialNumber
|
||||
);
|
||||
}
|
||||
|
||||
return abort(404);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user