From 7ee300e5d13f2308c98c3e4ed0b4e1b63b4d16c6 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Mon, 15 Oct 2018 12:39:41 +0300 Subject: [PATCH] Signed URL for invoice --- app/Http/Controllers/Customers/Invoices.php | 35 +++ composer.json | 1 + config/app.php | 2 + .../views/customers/invoices/link.blade.php | 219 ++++++++++++++++++ resources/views/layouts/link.blade.php | 16 ++ .../views/partials/link/content.blade.php | 39 ++++ .../views/partials/link/footer.blade.php | 7 + resources/views/partials/link/head.blade.php | 77 ++++++ routes/web.php | 10 + 9 files changed, 406 insertions(+) create mode 100644 resources/views/customers/invoices/link.blade.php create mode 100644 resources/views/layouts/link.blade.php create mode 100644 resources/views/partials/link/content.blade.php create mode 100644 resources/views/partials/link/footer.blade.php create mode 100644 resources/views/partials/link/head.blade.php diff --git a/app/Http/Controllers/Customers/Invoices.php b/app/Http/Controllers/Customers/Invoices.php index aea447a7f..42f4dd6ee 100644 --- a/app/Http/Controllers/Customers/Invoices.php +++ b/app/Http/Controllers/Customers/Invoices.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Events\InvoicePrinting; use App\Models\Banking\Account; use App\Models\Income\Customer; +use App\Models\Income\Revenue; use App\Models\Income\Invoice; use App\Models\Income\InvoiceStatus; use App\Models\Setting\Category; @@ -16,6 +17,7 @@ use App\Traits\DateTime; use App\Traits\Uploads; use App\Utilities\Modules; use File; +use Illuminate\Http\Request; use Image; use Storage; @@ -178,4 +180,37 @@ class Invoices extends Controller return $logo; } + + public function link(Invoice $invoice, Request $request) + { + $paid = 0; + + foreach ($invoice->payments as $item) { + $amount = $item->amount; + + if ($invoice->currency_code != $item->currency_code) { + $item->default_currency_code = $invoice->currency_code; + + $amount = $item->getDynamicConvertedAmount(); + } + + $paid += $amount; + } + + $invoice->paid = $paid; + + $accounts = Account::enabled()->pluck('name', 'id'); + + $currencies = Currency::enabled()->pluck('name', 'code')->toArray(); + + $account_currency_code = Account::where('id', setting('general.default_account'))->pluck('currency_code')->first(); + + $customers = Customer::enabled()->pluck('name', 'id'); + + $categories = Category::enabled()->type('income')->pluck('name', 'id'); + + $payment_methods = Modules::getPaymentMethods(); + + return view('customers.invoices.link', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods')); + } } diff --git a/composer.json b/composer.json index 785330558..bc092a99f 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "akaunting/language": "1.0.*", "akaunting/money": "1.0.*", "akaunting/setting": "1.0.*", + "akaunting/signed-url": "1.0.*", "akaunting/version": "1.0.*", "almasaeed2010/adminlte": "2.3.*", "barryvdh/laravel-debugbar": "2.3.*", diff --git a/config/app.php b/config/app.php index 6bedfcac7..b820e9bd0 100644 --- a/config/app.php +++ b/config/app.php @@ -187,6 +187,7 @@ return [ Akaunting\Language\Provider::class, Akaunting\Money\Provider::class, Akaunting\Setting\Provider::class, + Akaunting\SignedUrl\Provider::class, Akaunting\Version\Provider::class, Barryvdh\DomPDF\ServiceProvider::class, Bkwld\Cloner\ServiceProvider::class, @@ -273,6 +274,7 @@ return [ 'Module' => Nwidart\Modules\Facades\Module::class, 'PDF' => Barryvdh\DomPDF\Facade::class, 'Setting' => Akaunting\Setting\Facade::class, + 'SignedUrl' => Akaunting\SignedUrl\Facade::class, 'Version' => Akaunting\Version\Facade::class, ], diff --git a/resources/views/customers/invoices/link.blade.php b/resources/views/customers/invoices/link.blade.php new file mode 100644 index 000000000..e0624212e --- /dev/null +++ b/resources/views/customers/invoices/link.blade.php @@ -0,0 +1,219 @@ +@extends('layouts.link') + +@section('title', trans_choice('general.invoices', 1) . ': ' . $invoice->invoice_number) + +@section('content') +
+
+
+
+
{{ trans('invoices.status.' . $invoice->status->code) }}
+
+
+ +
+
+ @if (setting('general.invoice_logo')) + + @elseif (setting('general.company_logo')) + + @else + + @endif +
+
+
+ {{ setting('general.company_name') }}
+ {{ setting('general.company_address') }}
+ @if (setting('general.company_tax_number')) + {{ trans('general.tax_number') }}: {{ setting('general.company_tax_number') }}
+ @endif +
+ @if (setting('general.company_phone')) + {{ setting('general.company_phone') }}
+ @endif + {{ setting('general.company_email') }} +
+
+
+ +
+
+ {{ trans('invoices.bill_to') }} +
+ {{ $invoice->customer_name }}
+ {{ $invoice->customer_address }}
+ @if ($invoice->customer_tax_number) + {{ trans('general.tax_number') }}: {{ $invoice->customer_tax_number }}
+ @endif +
+ @if ($invoice->customer_phone) + {{ $invoice->customer_phone }}
+ @endif + {{ $invoice->customer_email }} +
+
+
+
+ + + + + + + @if ($invoice->order_number) + + + + + @endif + + + + + + + + + +
{{ trans('invoices.invoice_number') }}:{{ $invoice->invoice_number }}
{{ trans('invoices.order_number') }}:{{ $invoice->order_number }}
{{ trans('invoices.invoice_date') }}:{{ Date::parse($invoice->invoiced_at)->format($date_format) }}
{{ trans('invoices.payment_due') }}:{{ Date::parse($invoice->due_at)->format($date_format) }}
+
+
+
+ +
+
+ + + + + + + + + @foreach($invoice->items as $item) + + + + + + + @endforeach + +
{{ trans_choice('general.items', 1) }}{{ trans('invoices.quantity') }}{{ trans('invoices.price') }}{{ trans('invoices.total') }}
+ {{ $item->name }} + @if ($item->sku) +
{{ trans('items.sku') }}: {{ $item->sku }} + @endif +
{{ $item->quantity }}@money($item->price, $invoice->currency_code, true)@money($item->total, $invoice->currency_code, true)
+
+
+ +
+
+ @if ($invoice->notes) +

{{ trans_choice('general.notes', 2) }}

+ +

+ {{ $invoice->notes }} +

+ @endif +
+
+
+ + + @foreach($invoice->totals as $total) + @if($total->code != 'total') + + + + + @else + @if ($invoice->paid) + + + + + @endif + + + + + @endif + @endforeach + +
{{ trans($total['name']) }}:@money($total->amount, $invoice->currency_code, true)
{{ trans('invoices.paid') }}:- @money($invoice->paid, $invoice->currency_code, true)
{{ trans($total['name']) }}:@money($total->amount - $invoice->paid, $invoice->currency_code, true)
+
+
+
+ + +
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/layouts/link.blade.php b/resources/views/layouts/link.blade.php new file mode 100644 index 000000000..b49a34515 --- /dev/null +++ b/resources/views/layouts/link.blade.php @@ -0,0 +1,16 @@ + + @include('partials.link.head') + + + @stack('body_start') + + +
+ @include('partials.link.content') + + @include('partials.link.footer') +
+ + @stack('body_end') + + diff --git a/resources/views/partials/link/content.blade.php b/resources/views/partials/link/content.blade.php new file mode 100644 index 000000000..5e8d40141 --- /dev/null +++ b/resources/views/partials/link/content.blade.php @@ -0,0 +1,39 @@ +@stack('content_start') + + +
+ @stack('content_wrapper_start') + + +
+ @stack('content_header_start') + +

+ @yield('title') + @yield('new_button') +

+ + @stack('content_header_end') +
+ + +
+ @include('flash::message') + + @stack('content_content_start') + + @yield('content') + + @stack('content_content_end') +
+ + + @stack('content_wrapper_end') +
+ + + + +@stack('content_end') diff --git a/resources/views/partials/link/footer.blade.php b/resources/views/partials/link/footer.blade.php new file mode 100644 index 000000000..04672845c --- /dev/null +++ b/resources/views/partials/link/footer.blade.php @@ -0,0 +1,7 @@ +@stack('footer_start') + + + +@stack('footer_end') diff --git a/resources/views/partials/link/head.blade.php b/resources/views/partials/link/head.blade.php new file mode 100644 index 000000000..8bef6ff57 --- /dev/null +++ b/resources/views/partials/link/head.blade.php @@ -0,0 +1,77 @@ + + @stack('head_start') + + + + + + + @yield('title') - @setting('general.company_name') + + + + + + + + + + + @if (setting('general.admin_theme', 'skin-green-light') == 'skin-green-light') + + @else + + + @endif + + + + + + + + + + + @stack('css') + + @stack('stylesheet') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @stack('js') + + @stack('scripts') + + @stack('head_end') + diff --git a/routes/web.php b/routes/web.php index 7fb4a61c8..d084481cd 100644 --- a/routes/web.php +++ b/routes/web.php @@ -227,6 +227,16 @@ Route::group(['middleware' => 'language'], function () { }); }); + Route::group(['middleware' => 'signed-url'], function () { + Route::group(['prefix' => 'links'], function () { + Route::get('invoices/{invoice}', 'Customers\Invoices@link'); + Route::get('invoices/{invoice}/print', 'Customers\Invoices@printInvoice'); + Route::get('invoices/{invoice}/pdf', 'Customers\Invoices@pdfInvoice'); + Route::post('invoices/{invoice}/payment', 'Customers\Invoices@payment'); + Route::post('invoices/{invoice}/confirm', 'Customers\Invoices@confirm'); + }); + }); + Route::group(['middleware' => 'guest'], function () { Route::group(['prefix' => 'auth'], function () { Route::get('login', 'Auth\Login@create')->name('login');