浏览代码

multilanguage support

1Day 3 年之前
父节点
当前提交
60b310bc0c

+ 1 - 0
app/Http/Controllers/Admin/PaymentController.php

@@ -224,6 +224,7 @@ class PaymentController extends Controller
                     ->pricePerUnit($paypalProduct->price);
 
                 $invoice = Invoice::make()
+                    ->template('controlpanel')
                     ->buyer($customer)
                     ->seller($seller)
                     ->discountByPercent(0)

+ 1 - 1
config/app.php

@@ -81,7 +81,7 @@ return [
     |
     */
 
-    'locale' => 'en',
+    'locale' => env('LOCALE', 'en'),
 
     /*
     |--------------------------------------------------------------------------

+ 29 - 0
resources/lang/de.json

@@ -0,0 +1,29 @@
+{
+    "Invoice": "Rechnung",
+    "Serial No.": "Rechnungsnr.",
+    "Invoice date": "Rechnungsdatum",
+    "Seller": "Verkäufer",
+    "Buyer": "Käufer",
+    "Address": "Adresse",
+    "Code": "Code",
+    "VAT code": "Steuerid",
+    "Phone": "Telefon",
+    "Description": "Beschreibung",
+    "Units": "Einheiten",
+    "Qty": "Menge",
+    "Price": "Preis",
+    "Discount": "Rabatt",
+    "Tax": "Steuer",
+    "Sub total": "Zwischensumme",
+    "Total discount": "Gesamtrabatt",
+    "Taxable amount": "Steuerbetrag",
+    "Total taxes": "Steuerngesamt",
+    "Tax rate": "Steuerrate",
+    "Total amount": "Gesamtbetrag",
+    "Please pay until": "Zahlbar bis",
+    "Amount in words": "Betrag in Worten",
+    "Notes": "Notizen",
+    "Shipping": "Lieferbedingung",
+    "Paid": "Bezahlt",
+    "Due:": "Fällig"
+}

+ 0 - 38
resources/lang/vendor/invoices/de/invoice.php

@@ -1,38 +0,0 @@
-<?php
-
-return [
-    /*
-    |--------------------------------------------------------------------------
-    | Invoice Language Lines
-    |--------------------------------------------------------------------------
-    */
-
-    'invoice'                => 'Rechnung',
-    'serial'                 => 'Rechnung Nr.',
-    'date'                   => 'Rechnungsdatum',
-    'seller'                 => 'Verkäufer',
-    'buyer'                  => 'Käufer',
-    'address'                => 'Adresse',
-    'code'                   => 'Code',
-    'vat'                    => 'Umsatzsteuer ID',
-    'phone'                  => 'Telefon',
-    'description'            => 'Beschreibung',
-    'units'                  => 'Einheit',
-    'quantity'               => 'Menge',
-    'price'                  => 'Preis',
-    'discount'               => 'Rabatt',
-    'tax'                    => 'Steuer',
-    'sub_total'              => 'Zwischensumme',
-    'total_discount'         => 'Gesamtrabatt',
-    'taxable_amount'         => 'Steuerwert',
-    'total_taxes'            => 'Gesamtsteuer',
-    'tax_rate'               => 'Steuerrate',
-    'total_amount'           => 'Gesamtpreis',
-    'pay_until'              => 'Zahlbar bis',
-    'amount_in_words'        => 'Betrag in Worten',
-    'amount_in_words_format' => '%s %s und %s %s',
-    'notes'                  => 'Notizen',
-    'shipping'               => 'Lieferbedingung',
-    'paid'                   => 'Bezahlt',
-    'due'                    => 'fällig',
-];

+ 0 - 38
resources/lang/vendor/invoices/en/invoice.php

@@ -1,38 +0,0 @@
-<?php
-
-return [
-    /*
-    |--------------------------------------------------------------------------
-    | Invoice Language Lines
-    |--------------------------------------------------------------------------
-    */
-
-    'invoice'                => 'Invoice',
-    'serial'                 => 'Serial No.',
-    'date'                   => 'Invoice date',
-    'seller'                 => 'Seller',
-    'buyer'                  => 'Buyer',
-    'address'                => 'Address',
-    'code'                   => 'Code',
-    'vat'                    => 'VAT code',
-    'phone'                  => 'Phone',
-    'description'            => 'Description',
-    'units'                  => 'Units',
-    'quantity'               => 'Qty',
-    'price'                  => 'Price',
-    'discount'               => 'Discount',
-    'tax'                    => 'Tax',
-    'sub_total'              => 'Sub total',
-    'total_discount'         => 'Total discount',
-    'taxable_amount'         => 'Taxable amount',
-    'total_taxes'            => 'Total taxes',
-    'tax_rate'               => 'Tax rate',
-    'total_amount'           => 'Total amount',
-    'pay_until'              => 'Please pay until',
-    'amount_in_words'        => 'Amount in words',
-    'amount_in_words_format' => '%s %s and %s %s',
-    'notes'                  => 'Notes',
-    'shipping'               => 'Shipping',
-    'paid'                   => 'Paid',
-    'due'                    => 'Due',
-];

+ 0 - 38
resources/lang/vendor/invoices/nl/invoice.php

@@ -1,38 +0,0 @@
-<?php
-
-return [
-    /*
-    |--------------------------------------------------------------------------
-    | Factuur Taal Lijnen
-    |--------------------------------------------------------------------------
-    */
-
-    'invoice'                => 'Factuur',
-    'serial'                 => 'Factuurnummer',
-    'date'                   => 'Factuurdatum',
-    'seller'                 => 'Leverancier',
-    'buyer'                  => 'Afnemer',
-    'address'                => 'Adres',
-    'code'                   => 'Code',
-    'vat'                    => 'Btw-identificatienummer',
-    'phone'                  => 'Telefoonnummer',
-    'description'            => 'Omschrijving',
-    'units'                  => 'Eenheid',
-    'quantity'               => 'Aantal',
-    'price'                  => 'Prijs',
-    'discount'               => 'Korting',
-    'tax'                    => 'Belasting',
-    'sub_total'              => 'Subtotaal',
-    'total_discount'         => 'Totale korting',
-    'taxable_amount'         => 'Belastbaar bedrag',
-    'total_taxes'            => 'Totaal belastingen',
-    'tax_rate'               => 'Belastingtarief',
-    'total_amount'           => 'Totaalbedrag',
-    'pay_until'              => 'Gelieve te betalen voor',
-    'amount_in_words'        => 'Totaalbedrag in woorden',
-    'amount_in_words_format' => '%s %s en %s %s',
-    'notes'                  => 'Opmerkingen',
-    'shipping'               => 'Verzending',
-    'paid'                   => 'Betaald',
-    'due'                    => 'Openstaand',
-];

+ 390 - 0
resources/views/vendor/invoices/templates/controlpanel.blade.php

@@ -0,0 +1,390 @@
+<!DOCTYPE html>
+<html lang="en">
+    <head>
+        <title>{{ $invoice->name }}</title>
+        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+        <style type="text/css" media="screen">
+            html {
+                font-family: sans-serif;
+                line-height: 1.15;
+                margin: 0;
+            }
+
+            body {
+                font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
+                font-weight: 400;
+                line-height: 1.5;
+                color: #212529;
+                text-align: left;
+                background-color: #fff;
+                font-size: 10px;
+                margin: 36pt;
+            }
+
+            h4 {
+                margin-top: 0;
+                margin-bottom: 0.5rem;
+            }
+
+            p {
+                margin-top: 0;
+                margin-bottom: 1rem;
+            }
+
+            strong {
+                font-weight: bolder;
+            }
+
+            img {
+                vertical-align: middle;
+                border-style: none;
+            }
+
+            table {
+                border-collapse: collapse;
+            }
+
+            th {
+                text-align: inherit;
+            }
+
+            h4, .h4 {
+                margin-bottom: 0.5rem;
+                font-weight: 500;
+                line-height: 1.2;
+            }
+
+            h4, .h4 {
+                font-size: 1.5rem;
+            }
+
+            .table {
+                width: 100%;
+                margin-bottom: 1rem;
+                color: #212529;
+            }
+
+            .table th,
+            .table td {
+                padding: 0.75rem;
+                vertical-align: top;
+            }
+
+            .table.table-items td {
+                border-top: 1px solid #dee2e6;
+            }
+
+            .table thead th {
+                vertical-align: bottom;
+                border-bottom: 2px solid #dee2e6;
+            }
+
+            .mt-5 {
+                margin-top: 3rem !important;
+            }
+
+            .pr-0,
+            .px-0 {
+                padding-right: 0 !important;
+            }
+
+            .pl-0,
+            .px-0 {
+                padding-left: 0 !important;
+            }
+
+            .text-right {
+                text-align: right !important;
+            }
+
+            .text-center {
+                text-align: center !important;
+            }
+
+            .text-uppercase {
+                text-transform: uppercase !important;
+            }
+            * {
+                font-family: "DejaVu Sans";
+            }
+            body, h1, h2, h3, h4, h5, h6, table, th, tr, td, p, div {
+                line-height: 1.1;
+            }
+            .party-header {
+                font-size: 1.5rem;
+                font-weight: 400;
+            }
+            .total-amount {
+                font-size: 12px;
+                font-weight: 700;
+            }
+            .border-0 {
+                border: none !important;
+            }
+            .cool-gray {
+                color: #6B7280;
+            }
+            .cool-green {
+                color: #308d00;
+            }
+        </style>
+    </head>
+
+    <body>
+        {{-- Header --}}
+        @if($invoice->logo)
+            <img src="{{ $invoice->getLogo() }}" alt="logo" height="100">
+        @endif
+
+        <table class="table mt-5">
+            <tbody>
+                <tr>
+                <tr>
+                    <td class="border-0 pl-0" width="70%">
+                        <h4 class="text-uppercase">
+                            <strong>{{ $invoice->name }} {{$invoice->getSerialNumber()}}</strong>
+                        </h4>
+                    </td>
+                    <td class="border-0 pl-0">
+                        @if($invoice->status)
+                            <h4 class="text-uppercase cool-green">
+                                <strong>{{ $invoice->status }}</strong>
+                            </h4>
+                        @endif
+                        <p>{{ __('Serial No.') }} <strong>{{ $invoice->getSerialNumber() }}</strong></p>
+                        <p>{{ __('Invoice date') }}: <strong>{{ $invoice->getDate() }}</strong></p>
+                    </td>
+                </tr>
+            </tbody>
+        </table>
+
+        {{-- Seller - Buyer --}}
+        <table class="table">
+            <thead>
+                <tr>
+                    <th class="border-0 pl-0 party-header" width="48.5%">
+                        {{ __('Seller') }}
+                    </th>
+                    <th class="border-0" width="3%"></th>
+                    <th class="border-0 pl-0 party-header">
+                        {{ __('Buyer') }}
+                    </th>
+                </tr>
+            </thead>
+            <tbody>
+                <tr>
+                    <td class="px-0">
+                        @if($invoice->seller->name)
+                            <p class="seller-name">
+                                <strong>{{ $invoice->seller->name }}</strong>
+                            </p>
+                        @endif
+
+                        @if($invoice->seller->address)
+                            <p class="seller-address">
+                                {{ __('Adress') }}: {{ $invoice->seller->address }}
+                            </p>
+                        @endif
+
+                        @if($invoice->seller->code)
+                            <p class="seller-code">
+                                {{ __('Code') }}: {{ $invoice->seller->code }}
+                            </p>
+                        @endif
+
+                        @if($invoice->seller->vat)
+                            <p class="seller-vat">
+                                {{ __('VAT Code') }}: {{ $invoice->seller->vat }}
+                            </p>
+                        @endif
+
+                        @if($invoice->seller->phone)
+                            <p class="seller-phone">
+                                {{ __('Phone') }}: {{ $invoice->seller->phone }}
+                            </p>
+                        @endif
+
+                        @foreach($invoice->seller->custom_fields as $key => $value)
+                            <p class="seller-custom-field">
+                                {{ ucfirst($key) }}: {{ $value }}
+                            </p>
+                        @endforeach
+                    </td>
+                    <td class="border-0"></td>
+                    <td class="px-0">
+                        @if($invoice->buyer->name)
+                            <p class="buyer-name">
+                                <strong>{{ $invoice->buyer->name }}</strong>
+                            </p>
+                        @endif
+
+                        @if($invoice->buyer->address)
+                            <p class="buyer-address">
+                                {{ __('Adress') }}: {{ $invoice->buyer->address }}
+                            </p>
+                        @endif
+
+                        @if($invoice->buyer->code)
+                            <p class="buyer-code">
+                                {{ __('Code') }}: {{ $invoice->buyer->code }}
+                            </p>
+                        @endif
+
+                        @if($invoice->buyer->vat)
+                            <p class="buyer-vat">
+                                {{ __('VAT Code') }}: {{ $invoice->buyer->vat }}
+                            </p>
+                        @endif
+
+                        @if($invoice->buyer->phone)
+                            <p class="buyer-phone">
+                                {{ __('Phone') }}: {{ $invoice->buyer->phone }}
+                            </p>
+                        @endif
+
+                        @foreach($invoice->buyer->custom_fields as $key => $value)
+                            <p class="buyer-custom-field">
+                                {{ ucfirst($key) }}: {{ $value }}
+                            </p>
+                        @endforeach
+                    </td>
+                </tr>
+            </tbody>
+        </table>
+
+        {{-- Table --}}
+        <table class="table table-items">
+            <thead>
+                <tr>
+                    <th scope="col" class="border-0 pl-0">{{ __('Description') }}</th>
+                    @if($invoice->hasItemUnits)
+                        <th scope="col" class="text-center border-0">{{ __('Units') }}</th>
+                    @endif
+                    <th scope="col" class="text-center border-0">{{ __('Quantity') }}</th>
+                    <th scope="col" class="text-right border-0">{{ __('Price') }}</th>
+                    @if($invoice->hasItemDiscount)
+                        <th scope="col" class="text-right border-0">{{ __('Discount') }}</th>
+                    @endif
+                    @if($invoice->hasItemTax)
+                        <th scope="col" class="text-right border-0">{{ __('Tax') }}</th>
+                    @endif
+                    <th scope="col" class="text-right border-0 pr-0">{{ __('Subtotal') }}</th>
+                </tr>
+            </thead>
+            <tbody>
+                {{-- Items --}}
+                @foreach($invoice->items as $item)
+                <tr>
+                    <td class="pl-0">
+                        {{ $item->title }}
+
+                        @if($item->description)
+                            <p class="cool-gray">{{ $item->description }}</p>
+                        @endif
+                    </td>
+                    @if($invoice->hasItemUnits)
+                        <td class="text-center">{{ $item->units }}</td>
+                    @endif
+                    <td class="text-center">{{ $item->quantity }}</td>
+                    <td class="text-right">
+                        {{ $invoice->formatCurrency($item->price_per_unit) }}
+                    </td>
+                    @if($invoice->hasItemDiscount)
+                        <td class="text-right">
+                            {{ $invoice->formatCurrency($item->discount) }}
+                        </td>
+                    @endif
+                    @if($invoice->hasItemTax)
+                        <td class="text-right">
+                            {{ $invoice->formatCurrency($item->tax) }}
+                        </td>
+                    @endif
+
+                    <td class="text-right pr-0">
+                        {{ $invoice->formatCurrency($item->sub_total_price) }}
+                    </td>
+                </tr>
+                @endforeach
+                {{-- Summary --}}
+                @if($invoice->hasItemOrInvoiceDiscount())
+                    <tr>
+                        <td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
+                        <td class="text-right pl-0">{{ __('Total Discount') }}</td>
+                        <td class="text-right pr-0">
+                            {{ $invoice->formatCurrency($invoice->total_discount) }}
+                        </td>
+                    </tr>
+                @endif
+                @if($invoice->taxable_amount)
+                    <tr>
+                        <td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
+                        <td class="text-right pl-0">{{ __('Taxable amount') }}</td>
+                        <td class="text-right pr-0">
+                            {{ $invoice->formatCurrency($invoice->taxable_amount) }}
+                        </td>
+                    </tr>
+                @endif
+                @if($invoice->tax_rate)
+                    <tr>
+                        <td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
+                        <td class="text-right pl-0">{{ __('Tax rate') }}</td>
+                        <td class="text-right pr-0">
+                            {{ $invoice->tax_rate }}%
+                        </td>
+                    </tr>
+                @endif
+                @if($invoice->hasItemOrInvoiceTax())
+                    <tr>
+                        <td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
+                        <td class="text-right pl-0">{{ __('Total taxes') }}</td>
+                        <td class="text-right pr-0">
+                            {{ $invoice->formatCurrency($invoice->total_taxes) }}
+                        </td>
+                    </tr>
+                @endif
+                @if($invoice->shipping_amount)
+                    <tr>
+                        <td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
+                        <td class="text-right pl-0">{{ __('Shipping') }}</td>
+                        <td class="text-right pr-0">
+                            {{ $invoice->formatCurrency($invoice->shipping_amount) }}
+                        </td>
+                    </tr>
+                @endif
+                    <tr>
+                        <td colspan="{{ $invoice->table_columns - 2 }}" class="border-0"></td>
+                        <td class="text-right pl-0">{{ __('Total amount') }}</td>
+                        <td class="text-right pr-0 total-amount">
+                            {{ $invoice->formatCurrency($invoice->total_amount) }}
+                        </td>
+                    </tr>
+            </tbody>
+        </table>
+
+        @if($invoice->notes)
+            <p>
+                {{ trans('Notes') }}: {!! $invoice->notes !!}
+            </p>
+        @endif
+
+        <p>
+            {{ trans('Amount in words') }}: {{ $invoice->getTotalAmountInWords() }}
+        </p>
+        <p>
+            {{ trans('Please pay until') }}: {{ $invoice->getPayUntilDate() }}
+        </p>
+
+        <script type="text/php">
+            if (isset($pdf) && $PAGE_COUNT > 1) {
+                $text = "Page {PAGE_NUM} / {PAGE_COUNT}";
+                $size = 10;
+                $font = $fontMetrics->getFont("Verdana");
+                $width = $fontMetrics->get_text_width($text, $font, $size) / 2;
+                $x = ($pdf->get_width() - $width);
+                $y = $pdf->get_height() - 35;
+                $pdf->page_text($x, $y, $text, $font, $size);
+            }
+        </script>
+    </body>
+</html>