diff --git a/routes/web.php b/routes/web.php index 4925958a..a38a8f15 100644 --- a/routes/web.php +++ b/routes/web.php @@ -97,25 +97,26 @@ Route::get('/products', function (\App\Classes\Modules\Exports\Services\ExportsP })->name('products.random'); Route::get('/fix_bills', function () { -// ini_set('max_execution_time', '1000000'); -// Auth()->login(User::find(1)); -// Transaction::where('type', TransactionType::INVOICE)->chunk(200, function($invoices){ -// foreach ($invoices as $invoice){ -// $invoice->booking->documents()->where('document_type', DocumentType::INVOICE)->delete(); -// $po = $invoice->booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); -// $supplier = Company::find($invoice->receiver); -// $invoice_pdf = LaravelMpdf::loadView('pages.pdfs.invoice', ['invoice_transaction' => $invoice, 'po_order_transaction' => $po, 'supplier' => $supplier]); -// $document_object = new DocumentObject( -// DocumentType::INVOICE, -// [chunk_split('data:application/pdf;base64,'.base64_encode($invoice_pdf->output()))], -// '', -// ApprovalStatus::COMPLETED, -// 'invoices' -// ); -// $document = (App()->make(CreatesDocument::class))->execute($invoice->booking, $document_object); -// (App()->make(CreatesFiles::class))->execute($document, $document_object); -// } -// }); + ini_set('max_execution_time', '1000000'); + Auth()->login(User::find(1)); + $bookings = \App\Models\Booking::whereIn('id', [11257, 11268, 11281, 11287, 11288, 11290, 11292, 11293, 11296, 11298, 11299, 11302, 11303, 11307, 11314, 11324, 11345, 11346])->get(); + foreach ($bookings as $booking){ + $booking->documents()->where('document_type', DocumentType::SUPPLIER_DELIVER_ORDER)->delete(); + $po = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); + $supplier_deliver_order_transaction = $booking->transactions()->where('type', TransactionType::SUPPLIER_DELIVER)->first(); + $supplier = Company::find($booking->transactions()->where('type', TransactionType::BILL)->first()->receiver); + $supplier_order_pdf = LaravelMpdf::loadView('pages.pdfs.supplier_deliver_order', ['supplier_deliver_order_transaction' => $supplier_deliver_order_transaction, 'po_order_transaction' => $po, 'supplier' => $supplier]); + $document_object = new DocumentObject( + DocumentType::SUPPLIER_DELIVER_ORDER, + [chunk_split('data:application/pdf;base64,'.base64_encode($supplier_order_pdf->output()))], + '', + ApprovalStatus::COMPLETED, + 'supplier_delivery_orders' + ); + + $document = (App()->make(CreatesDocument::class))->execute($booking, $document_object); + (App()->make(CreatesFiles::class))->execute($document, $document_object); + } })->name('products.random');