Browse Source

Add invoice print page

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
3cecc606a2
  1. 9
      app/Entities/Invoices/Invoice.php
  2. 5
      app/Http/Controllers/InvoicesController.php
  3. 2
      public/assets/css/app.s.css
  4. 1
      resources/lang/id/app.php
  5. 3
      resources/lang/id/invoice.php
  6. 107
      resources/views/invoices/pdf.blade.php
  7. 12
      resources/views/invoices/show.blade.php
  8. 1
      routes/web/invoices.php

9
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);
}
}

5
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'));
}
}

2
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;

1
resources/lang/id/app.php

@ -38,4 +38,5 @@ return [
'end_date' => 'Tanggal Selesai',
'change_photo' => 'Ganti Foto',
'welcome' => 'Selamat Datang',
'to' => 'Kepada',
];

3
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',
];

107
resources/views/invoices/pdf.blade.php

@ -0,0 +1,107 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{{ trans('invoice.print') }} - {{ $invoice->number }}</title>
<style>
html {
margin: 10px 20px 0px 20px;
}
table.receipt-table {
/*border: 1px solid #aaa;*/
border-collapse: collapse;
/*font-size:14px;*/
max-width: 750px;
}
table.receipt-table th, table.receipt-table td {
padding: 5px;
}
.text-left {
text-align: left;
}
.text-center {
text-align: center;
}
.text-right {
text-align: right;
}
</style>
</head>
<body>
<table class="receipt-table">
<tbody>
<tr>
<td style="width:80px;">
{{ Html::image(url('assets/imgs/logo.png'), '', ['style' => 'width:100%']) }}
</td>
<td style="width:400px">
<div style="width:280px">
<h1 style="margin:0px; border-bottom: 3px; font-size: 21.5px">JasaWebsiteBanjarmasin.com</h1>
<div style="font-size:13px">Jasa Pembuatan Website dan Aplikasi Berbasis Web</div>
</div>
</td>
<td style="width:270px; text-align: center;">
<h3 style="margin: 3px 0; font-size: 24px">{{ trans('invoice.invoice') }}</h3>
<div>{{ trans('invoice.number') }} : INV-{{ $invoice->number }}</div>
<div>{{ trans('app.date') }} : {{ dateId($invoice->created_at->format('Y-m-d')) }}</div>
</td>
</tr>
<tr>
<td colspan="3">
<h4 style="margin: 3px 0;">{{ trans('app.to') }} :</h4>
<p><strong>{{ $invoice->project->customer->name }}</strong></p>
</td>
</tr>
<tr><td colspan="3">{{ trans('project.features') }} :</td></tr>
<tr>
<td colspan="3">
<table border="1" class="receipt-table" style="width: 100%">
<thead style="background-color: #FFC800">
<tr>
<th>{{ trans('app.table_no') }}</th>
<th class="text-left">{{ trans('invoice.item_description') }}</th>
<th>{{ trans('invoice.item_amount') }}</th>
</tr>
</thead>
<tbody>
@foreach ($invoice->items as $key => $item)
<tr>
<td class="text-center">{{ 1 + $key }}</td>
<td>{{ $item['description'] }}</td>
<td class="text-right">{{ formatRp($item['amount']) }}</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th colspan="2" class="text-right">{{ trans('app.total') }}</th>
<th colspan="2" class="text-right">{{ formatRp($invoice->amount) }}</th>
</tr>
</tfoot>
</table>
</td>
</tr>
<tr style="vertical-align: top;">
<td>Terbilang : </td>
<td colspan="2" style="font-weight: bold;">
{{ ucwords(Terbilang::make($invoice->amount)) }} Rupiah
</td>
</tr>
<tr style="vertical-align: top;">
<td colspan="3">
<p>Pembayaran dapat dilakukan melalui transfer ke rekening berikut:</p>
No. Rek : <strong>BCA // 782-0088-543</strong><br>
An. <strong>NAFIES LUTHFI</strong>
<p>Terima kasih atas kerjasamanya.</p>
</td>
</tr>
<tr>
<td colspan="3" class="text-center">
Banjarmasin, {{ dateId($invoice->created_at->format('Y-m-d')) }} <br><br><br><br>
<div style="font-weight: bold;">JasaWebsiteBanjarmasin.com</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>

12
resources/views/invoices/show.blade.php

@ -3,8 +3,10 @@
@section('title', $invoice->number . ' - ' . trans('invoice.detail'))
@section('content')
{{-- <div class="pull-right">{{ link_to_route('invoices.pdf', trans('invoice.invoice_print'), [$invoice->number], ['class' => 'btn btn-info']) }}</div> --}}
<h1 class="page-header">{{ $invoice->number }} <small>{{ trans('invoice.detail') }}</small></h1>
<h1 class="page-header">
<div class="pull-right">{{ link_to_route('invoices.pdf', trans('invoice.print'), [$invoice->number], ['class' => 'btn btn-default']) }}</div>
{{ $invoice->number }} <small>{{ trans('invoice.detail') }}</small>
</h1>
<div class="row">
<div class="col-sm-4">
<div class="panel panel-default">
@ -14,8 +16,8 @@
<tbody>
<tr><td>{{ trans('invoice.number') }}</td><td class="text-primary strong">{{ $invoice->number }}</td></tr>
<tr><td>{{ trans('app.date') }}</td><td>{{ $invoice->created_at->format('Y-m-d') }}</td></tr>
<tr><td>{{ trans('invoice.project') }}</td><td>{{ $invoice->project_id }}</td></tr>
<tr><td>{{ trans('invoice.customer_phone') }}</td><td>{{ $invoice->customer['phone'] }}</td></tr>
<tr><td>{{ trans('invoice.project') }}</td><td>{{ $invoice->project->name }}</td></tr>
<tr><td>{{ trans('invoice.customer') }}</td><td>{{ $invoice->project->customer->name }}</td></tr>
<tr><td>{{ trans('invoice.items_count') }}</td><td>{{ $invoice->items_count }}</td></tr>
<tr><td>{{ trans('invoice.amount') }}</td><td class="text-right strong">{{ formatRp($invoice->amount) }}</td></tr>
</tbody>
@ -47,7 +49,7 @@
<tfoot>
<tr>
<th colspan="2" class="text-right">{{ trans('app.total') }} :</th>
<th class="text-right">{{ formatRp($invoice['total']) }}</th>
<th class="text-right">{{ formatRp($invoice->amount) }}</th>
</tr>
</tfoot>
</table>

1
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']);
});
Loading…
Cancel
Save