Add estate.generate_pdf route and generatePdf method to EstateController
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -236,6 +236,53 @@ class EstateController extends Controller
|
|||||||
return view('estate.show-team', compact('order', 'members', 'appraisers'));
|
return view('estate.show-team', compact('order', 'members', 'appraisers'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generatePdf($id)
|
||||||
|
{
|
||||||
|
$order = DB::table('estate_orders as o')
|
||||||
|
->selectRaw('o.*, p.uz as purpose, r.uz as region_name, d.uz as district_name, CONCAT_WS(\' \', o.owner_last_name, o.owner_first_name, o.owner_patronymic) as "ownerName"')
|
||||||
|
->leftJoin('purposes as p', 'p.id', '=', 'o.purpose_id')
|
||||||
|
->leftJoin('regions as r', 'r.id', '=', 'o.region')
|
||||||
|
->leftJoin('districts as d', 'd.id', '=', 'o.district')
|
||||||
|
->where('o.id', $id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$order) abort(404);
|
||||||
|
|
||||||
|
$pdf = new \setasign\Fpdi\Fpdi();
|
||||||
|
$pdf->AddPage();
|
||||||
|
$pdf->SetFont('Arial', 'B', 16);
|
||||||
|
$pdf->Cell(0, 10, 'BAXOLASH XULOSASI (KO\'CHMAS MULK)', 0, 1, 'C');
|
||||||
|
$pdf->Ln(10);
|
||||||
|
$pdf->SetFont('Arial', '', 12);
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'Tartib raqami' => $order->number,
|
||||||
|
'Sana' => date('d.m.Y', strtotime($order->created_at)),
|
||||||
|
'Maqsadi' => $order->purpose,
|
||||||
|
'Ob\'yekt nomi' => $order->name_of_object,
|
||||||
|
'Viloyat' => $order->region_name,
|
||||||
|
'Tuman' => $order->district_name,
|
||||||
|
'Manzil' => $order->address,
|
||||||
|
'Egasi' => $order->ownerName,
|
||||||
|
'Baholangan summa'=> number_format($order->object_price ?: 0, 0, '.', ' ') . ' UZS',
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($fields as $label => $value) {
|
||||||
|
$pdf->SetFont('Arial', 'B', 12);
|
||||||
|
$pdf->Cell(60, 10, $label . ':', 0, 0);
|
||||||
|
$pdf->SetFont('Arial', '', 12);
|
||||||
|
$pdf->Cell(0, 10, $value ?: '-', 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pdf->Ln(20);
|
||||||
|
$pdf->SetFont('Arial', 'I', 10);
|
||||||
|
$pdf->Cell(0, 10, 'Ushbu hujjat tizim tomonidan avtomatik generatsiya qilindi.', 0, 1, 'C');
|
||||||
|
|
||||||
|
return response($pdf->Output('S'), 200)
|
||||||
|
->header('Content-Type', 'application/pdf')
|
||||||
|
->header('Content-Disposition', 'attachment; filename="Conclusion_'.$order->number.'.pdf"');
|
||||||
|
}
|
||||||
|
|
||||||
public function showDocuments($order, Request $request)
|
public function showDocuments($order, Request $request)
|
||||||
{
|
{
|
||||||
$order = DB::table('estate_orders')->find($order);
|
$order = DB::table('estate_orders')->find($order);
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ Route::group(['middleware' => ['auth']], function () {
|
|||||||
Route::get('/estate/show-activities/{order}', [EstateController::class, 'showActivities'])->name('estate.show-activities');
|
Route::get('/estate/show-activities/{order}', [EstateController::class, 'showActivities'])->name('estate.show-activities');
|
||||||
Route::get('/estate/show-team/{order}', [EstateController::class, 'showTeam'])->name('estate.show-team');
|
Route::get('/estate/show-team/{order}', [EstateController::class, 'showTeam'])->name('estate.show-team');
|
||||||
Route::get('/estate/show-documents/{order}', [EstateController::class, 'showDocuments'])->name('estate.show-documents');
|
Route::get('/estate/show-documents/{order}', [EstateController::class, 'showDocuments'])->name('estate.show-documents');
|
||||||
|
Route::get('/estate/generate-pdf/{order}', [EstateController::class, 'generatePdf'])->name('estate.generate_pdf');
|
||||||
Route::put('/estate/order-clone/{id}', [EstateController::class, 'orderClone'])->name('estate.clone');
|
Route::put('/estate/order-clone/{id}', [EstateController::class, 'orderClone'])->name('estate.clone');
|
||||||
|
|
||||||
Route::get('/auto', [AutoController::class, 'index'])->name('auto.index');
|
Route::get('/auto', [AutoController::class, 'index'])->name('auto.index');
|
||||||
|
|||||||
Reference in New Issue
Block a user