10 changed files with 205 additions and 3 deletions
-
4.env.example
-
9app/Http/Controllers/TransactionsController.php
-
6app/Transaction.php
-
4config/app.php
-
7config/store.php
-
67public/css/pdf.css
-
2resources/lang/id/transaction.php
-
18resources/views/layouts/pdf.blade.php
-
86resources/views/transactions/pdf.blade.php
-
5resources/views/transactions/show.blade.php
@ -0,0 +1,7 @@ |
|||||
|
<?php |
||||
|
|
||||
|
return [ |
||||
|
'name' => env('STORE_NAME','Laravel'), |
||||
|
'address' => env('STORE_ADDRESS'), |
||||
|
'phone' => env('STORE_PHONE'), |
||||
|
]; |
||||
@ -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; |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="{{ config('app.locale') }}"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
||||
|
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
|
|
||||
|
<title>@yield('title') | {{ config('app.name', 'Laravel') }}</title> |
||||
|
|
||||
|
{{ Html::style(url('css/pdf.css')) }} |
||||
|
</head> |
||||
|
<body> |
||||
|
<div class="container"> |
||||
|
@yield('content') |
||||
|
</div> |
||||
|
@yield('script') |
||||
|
</body> |
||||
|
</html> |
||||
@ -0,0 +1,86 @@ |
|||||
|
@extends('layouts.pdf') |
||||
|
|
||||
|
@section('title', $transaction->invoice_no . ' - ' . trans('transaction.invoice_print')) |
||||
|
|
||||
|
@section('content') |
||||
|
|
||||
|
<table style="width: 760px; border-collapse: collapse; page-break-inside: avoid; /*border:1px solid #aaa;*/"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td colspan="3"> |
||||
|
<h2 class="text-center">{{ config('store.name') }}</h2> |
||||
|
<p class="text-center">{{ config('store.address') }} | Telp: {{ config('store.phone') }}</p> |
||||
|
<br> |
||||
|
<table style="width:300px;margin: auto;"> |
||||
|
<tbody> |
||||
|
<tr> |
||||
|
<td style="width:90px">{{ trans('transaction.invoice_no') }}</td> |
||||
|
<td>:</td> |
||||
|
<td class="strong">{{ $transaction->invoice_no }}</td> |
||||
|
<td class="text-right">{{ $transaction->created_at->format('d/m/Y') }}</td> |
||||
|
</tr> |
||||
|
<tr><td>{{ trans('transaction.cashier') }}</td><td>:</td><td>{{ $transaction->user->name }}</td><td class="text-right">{{ $transaction->created_at->format('H:i:s') }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.customer') }}</td><td>:</td><td colspan="2">{{ $transaction->customer['name'] }}</td></tr> |
||||
|
<tr><td>{{ trans('transaction.customer_phone') }}</td><td>:</td><td colspan="2">{{ $transaction->customer['phone'] }}</td></tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
<br> |
||||
|
</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<?php $discountTotal = 0; ?>
|
||||
|
@foreach(collect($transaction->items)->chunk(10) as $chunckedItems) |
||||
|
<td style="width:250px;padding-right: 10px"> |
||||
|
<table class="main-table"> |
||||
|
<tbody> |
||||
|
<tr><th colspan="3">@if ($loop->first) {{ trans('product.product') }} @else @endif</th></tr> |
||||
|
<tr> |
||||
|
<th class="">@if ($loop->first) {{ trans('product.item_qty') }} @else @endif</th> |
||||
|
<th class="text-right">@if ($loop->first) {{ trans('product.price') }} ({{ trans('product.item_discount') }}) @else <br> @endif</th> |
||||
|
<th class="text-right" style="width:90px">@if ($loop->first) {{ trans('product.item_subtotal') }} @else @endif</th> |
||||
|
</tr> |
||||
|
@foreach($chunckedItems as $key => $item) |
||||
|
<tr> |
||||
|
<td colspan="3">{{ $key + 1 }}) {{ $item['name'] }} ({{ $item['unit'] }})</td> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<td class="text-center border-bottom">{{ $item['qty'] }}</td> |
||||
|
<td class="text-right border-bottom"> |
||||
|
{{ formatRp($item['price']) }}<br>({{ formatRp($item['item_discount']) }}) |
||||
|
</td> |
||||
|
<td class="text-right border-bottom">{{ formatRp($item['subtotal']) }}</td> |
||||
|
</tr> |
||||
|
<?php $discountTotal += $item['item_discount_subtotal'] ?>
|
||||
|
@endforeach |
||||
|
@if ($loop->last) |
||||
|
<tr> |
||||
|
<th colspan="2" class="text-right">{{ trans('transaction.subtotal') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($transaction['total'] + $discountTotal) }}</th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th colspan="2" class="text-right">{{ trans('transaction.discount_total') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($discountTotal) }}</th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th colspan="2" class="text-right">{{ trans('transaction.total') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($transaction['total']) }}</th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th colspan="2" class="text-right">{{ trans('transaction.payment') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($transaction->payment) }}</th> |
||||
|
</tr> |
||||
|
<tr> |
||||
|
<th colspan="2" class="text-right">{{ trans('transaction.exchange') }} :</th> |
||||
|
<th class="text-right">{{ formatRp($transaction->getExchange()) }}</th> |
||||
|
</tr> |
||||
|
@endif |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</td> |
||||
|
@endforeach |
||||
|
{{-- <td style="width:250px;"> </td> --}} |
||||
|
{{-- <td style="width:250px;"> </td> --}} |
||||
|
</tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
@endsection |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue