diff --git a/app/Entities/Invoices/Invoice.php b/app/Entities/Invoices/Invoice.php index 2f35e70..f373d4c 100755 --- a/app/Entities/Invoices/Invoice.php +++ b/app/Entities/Invoices/Invoice.php @@ -25,10 +25,8 @@ class Invoice extends Model { $prefix = date('ym'); - $lastInvoice = $this->orderBy('number', 'desc')->first(); - if (!is_null($lastInvoice)) { $lastInvoiceNo = $lastInvoice->number; if (substr($lastInvoiceNo, 0, 4) == $prefix) { @@ -37,4 +35,11 @@ class Invoice extends Model } return $prefix.'001'; } + + public function getItemsCountAttribute($value) + { + $pcsCount = 0; + + return count($this->items); + } } diff --git a/app/Http/Controllers/InvoicesController.php b/app/Http/Controllers/InvoicesController.php index e13e8f7..cd3029b 100644 --- a/app/Http/Controllers/InvoicesController.php +++ b/app/Http/Controllers/InvoicesController.php @@ -11,4 +11,9 @@ class InvoicesController extends Controller { return view('invoices.show', compact('invoice')); } + + public function pdf(Invoice $invoice) + { + return view('invoices.pdf', compact('invoice')); + } } diff --git a/public/assets/css/app.s.css b/public/assets/css/app.s.css index 80dcef7..6a87081 100644 --- a/public/assets/css/app.s.css +++ b/public/assets/css/app.s.css @@ -248,7 +248,7 @@ html { -webkit-tap-highlight-color: transparent; } body { - font-family: "Liberation Serif", Helvetica, Arial, sans-serif; + font-family: "Trebuchet MS", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.428571429; color: #333333; diff --git a/resources/lang/id/app.php b/resources/lang/id/app.php index e1d4d59..055b39d 100644 --- a/resources/lang/id/app.php +++ b/resources/lang/id/app.php @@ -38,4 +38,5 @@ return [ 'end_date' => 'Tanggal Selesai', 'change_photo' => 'Ganti Foto', 'welcome' => 'Selamat Datang', + 'to' => 'Kepada', ]; \ No newline at end of file diff --git a/resources/lang/id/invoice.php b/resources/lang/id/invoice.php index ff4fb70..2e416ff 100644 --- a/resources/lang/id/invoice.php +++ b/resources/lang/id/invoice.php @@ -24,6 +24,7 @@ return [ 'deleted' => 'Hapus data Invoice telah berhasil.', 'undeleted' => 'Data Invoice gagal dihapus.', 'undeleteable' => 'Data Invoice tidak dapat dihapus.', + 'print' => 'Cetak Invoice', // Attributes 'number' => 'No. Invoice', @@ -31,6 +32,8 @@ return [ 'items' => 'Item Invoice', 'notes' => 'Catatan', 'amount' => 'Tagihan', + 'customer' => 'Customer', 'item_description' => 'Deskripsi', 'item_amount' => 'Biaya', + 'items_count' => 'Jumlah Item', ]; diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php new file mode 100755 index 0000000..ca729bb --- /dev/null +++ b/resources/views/invoices/pdf.blade.php @@ -0,0 +1,107 @@ + + + + + {{ trans('invoice.print') }} - {{ $invoice->number }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {{ Html::image(url('assets/imgs/logo.png'), '', ['style' => 'width:100%']) }} + +
+

JasaWebsiteBanjarmasin.com

+
Jasa Pembuatan Website dan Aplikasi Berbasis Web
+
+
+

{{ trans('invoice.invoice') }}

+
{{ trans('invoice.number') }} : INV-{{ $invoice->number }}
+
{{ trans('app.date') }} : {{ dateId($invoice->created_at->format('Y-m-d')) }}
+
+

{{ trans('app.to') }} :

+

{{ $invoice->project->customer->name }}

+
{{ trans('project.features') }} :
+ + + + + + + + + + @foreach ($invoice->items as $key => $item) + + + + + + @endforeach + + + + + + + +
{{ trans('app.table_no') }}{{ trans('invoice.item_description') }}{{ trans('invoice.item_amount') }}
{{ 1 + $key }}{{ $item['description'] }}{{ formatRp($item['amount']) }}
{{ trans('app.total') }}{{ formatRp($invoice->amount) }}
+
Terbilang : + {{ ucwords(Terbilang::make($invoice->amount)) }} Rupiah +
+

Pembayaran dapat dilakukan melalui transfer ke rekening berikut:

+ No. Rek : BCA // 782-0088-543
+ An. NAFIES LUTHFI +

Terima kasih atas kerjasamanya.

+
+ Banjarmasin, {{ dateId($invoice->created_at->format('Y-m-d')) }}



+
JasaWebsiteBanjarmasin.com
+
+ + \ No newline at end of file diff --git a/resources/views/invoices/show.blade.php b/resources/views/invoices/show.blade.php index 39b77ff..5fc625a 100644 --- a/resources/views/invoices/show.blade.php +++ b/resources/views/invoices/show.blade.php @@ -3,8 +3,10 @@ @section('title', $invoice->number . ' - ' . trans('invoice.detail')) @section('content') -{{--
{{ link_to_route('invoices.pdf', trans('invoice.invoice_print'), [$invoice->number], ['class' => 'btn btn-info']) }}
--}} -

{{ $invoice->number }} {{ trans('invoice.detail') }}

+

+
{{ link_to_route('invoices.pdf', trans('invoice.print'), [$invoice->number], ['class' => 'btn btn-default']) }}
+ {{ $invoice->number }} {{ trans('invoice.detail') }} +

@@ -14,8 +16,8 @@ {{ trans('invoice.number') }}{{ $invoice->number }} {{ trans('app.date') }}{{ $invoice->created_at->format('Y-m-d') }} - {{ trans('invoice.project') }}{{ $invoice->project_id }} - {{ trans('invoice.customer_phone') }}{{ $invoice->customer['phone'] }} + {{ trans('invoice.project') }}{{ $invoice->project->name }} + {{ trans('invoice.customer') }}{{ $invoice->project->customer->name }} {{ trans('invoice.items_count') }}{{ $invoice->items_count }} {{ trans('invoice.amount') }}{{ formatRp($invoice->amount) }} @@ -47,7 +49,7 @@ {{ trans('app.total') }} : - {{ formatRp($invoice['total']) }} + {{ formatRp($invoice->amount) }} diff --git a/routes/web/invoices.php b/routes/web/invoices.php index 4f115c2..a43824f 100644 --- a/routes/web/invoices.php +++ b/routes/web/invoices.php @@ -20,4 +20,5 @@ Route::group(['middleware' => ['web','role:admin']], function() { * Invoices Routes */ Route::get('invoices/{invoice}', ['as' => 'invoices.show', 'uses' => 'InvoicesController@show']); + Route::get('invoices/{invoice}/pdf', ['as' => 'invoices.pdf', 'uses' => 'InvoicesController@pdf']); });