diff --git a/.env.example b/.env.example index 668c06f..a05039c 100644 --- a/.env.example +++ b/.env.example @@ -31,3 +31,7 @@ MAIL_ENCRYPTION=null PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= + +STORE_NAME= +STORE_ADDRESS= +STORE_PHONE= diff --git a/app/Http/Controllers/TransactionsController.php b/app/Http/Controllers/TransactionsController.php index 29d9628..98ed225 100644 --- a/app/Http/Controllers/TransactionsController.php +++ b/app/Http/Controllers/TransactionsController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Transaction; use Illuminate\Http\Request; +use PDF; class TransactionsController extends Controller { @@ -18,4 +19,12 @@ class TransactionsController extends Controller { return view('transactions.show', compact('transaction')); } + + public function pdf(Transaction $transaction) + { + // return view('transactions.pdf', compact('transaction')); + $pdf = PDF::loadView('transactions.pdf', compact('transaction')); + return $pdf->stream($transaction->invoice_no.'.faktur.pdf'); + + } } diff --git a/app/Transaction.php b/app/Transaction.php index 24c7e31..ba3b812 100644 --- a/app/Transaction.php +++ b/app/Transaction.php @@ -2,6 +2,7 @@ namespace App; +use App\User; use Illuminate\Database\Eloquent\Model; class Transaction extends Model @@ -30,4 +31,9 @@ class Transaction extends Model { return $this->payment - $this->total; } + + public function user() + { + return $this->belongsTo(User::class); + } } diff --git a/config/app.php b/config/app.php index 83a6333..ff7a3ae 100644 --- a/config/app.php +++ b/config/app.php @@ -168,6 +168,7 @@ return [ */ BackupManager\Laravel\Laravel5ServiceProvider::class, Barryvdh\Debugbar\ServiceProvider::class, + Barryvdh\DomPDF\ServiceProvider::class, Laracasts\Flash\FlashServiceProvider::class, Luthfi\FormField\FormFieldServiceProvider::class, @@ -230,8 +231,9 @@ return [ 'View' => Illuminate\Support\Facades\View::class, 'Form' => Collective\Html\FormFacade::class, - 'Html' => Collective\Html\HtmlFacade::class, 'FormField' => Luthfi\FormField\FormFieldFacade::class, + 'PDF' => Barryvdh\DomPDF\Facade::class, + 'Html' => Collective\Html\HtmlFacade::class, ], ]; diff --git a/config/store.php b/config/store.php new file mode 100644 index 0000000..0622266 --- /dev/null +++ b/config/store.php @@ -0,0 +1,7 @@ + env('STORE_NAME','Laravel'), + 'address' => env('STORE_ADDRESS'), + 'phone' => env('STORE_PHONE'), +]; \ No newline at end of file diff --git a/public/css/pdf.css b/public/css/pdf.css new file mode 100755 index 0000000..f7b9027 --- /dev/null +++ b/public/css/pdf.css @@ -0,0 +1,67 @@ +html { + margin: 25px; +} + +body { + font-family: 'Arial', sans-serif; + font-size:12px; +} + +table { + border-spacing: 1px; +} + +td, th { + padding: 0px; +} + +td { + vertical-align: top; +} + +table.main-table { + width: 100%; + border-collapse: collapse; +} + +table.main-table td, table.main-table th { + padding: 5px 3px; +} + +h1, h2, h3, h4 { + margin: 0; +} + +h2 { font-size: 20px; margin-bottom: 16px } + +.text-center { + text-align: center; + vertical-align:middle; +} + +.text-right { + text-align: right; +} + +.text-left { + text-align: left; +} + +p { + margin: 0 0 3px 0; +} + +div { + margin: 0; + padding: 0; +} + +.strong { font-weight: bold; } + +.border-bottom { + border-bottom: 1px solid #333; +} + +.page-break { + page-break-after: always; +} diff --git a/resources/lang/id/transaction.php b/resources/lang/id/transaction.php index 24dfc59..64b53d9 100644 --- a/resources/lang/id/transaction.php +++ b/resources/lang/id/transaction.php @@ -21,6 +21,7 @@ return [ 'draft_destroyed' => 'Seluruh Draft transaksi telah dihapus.', 'draft_not_found' => 'Draft transaksi tidak ditemukan.', 'items_count' => 'Jumlah Item', + 'cashier' => 'Kasir', // Actions 'proccess' => 'Proses Transaksi', @@ -28,6 +29,7 @@ return [ 'item_list_empty' => 'Masukkan setidaknya 1 item produk.', 'save' => 'Simpan Transaksi', 'created' => 'Transaksi berhasil disimpan, No. Invoice: :invoice_no', + 'invoice_print' => 'Cetak Invoice', // Attributes 'invoice_no' => 'No. Invoice', diff --git a/resources/views/layouts/pdf.blade.php b/resources/views/layouts/pdf.blade.php new file mode 100644 index 0000000..e486b45 --- /dev/null +++ b/resources/views/layouts/pdf.blade.php @@ -0,0 +1,18 @@ + + +
+ + + + +
+ {{ config('store.name') }}+{{ config('store.address') }} | Telp: {{ config('store.phone') }} ++
+ |
+ |||||||||||||||||||||||||||||
+
|
+ @endforeach
+ {{-- --}} + {{-- | --}} + | |||||||||||||||||||||||||||