diff --git a/app/Http/Controllers/Customers/Invoices.php b/app/Http/Controllers/Customers/Invoices.php index aea447a7f..aff6c3b32 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,8 +17,10 @@ use App\Traits\DateTime; use App\Traits\Uploads; use App\Utilities\Modules; use File; +use Illuminate\Http\Request; use Image; use Storage; +use SignedUrl; class Invoices extends Controller { @@ -178,4 +181,52 @@ class Invoices extends Controller return $logo; } + + public function link(Invoice $invoice, Request $request) + { + session(['company_id' => $invoice->company_id]); + + $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(); + + $payment_actions = []; + + foreach ($payment_methods as $payment_method_key => $payment_method_value) { + $codes = explode('.', $payment_method_key); + + if (!isset($payment_actions[$codes[0]])) { + $payment_actions[$codes[0]] = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/' . $codes[0]), 1); + } + } + + $print_action = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/print'), 1); + $pdf_action = SignedUrl::sign(url('links/invoices/' . $invoice->id . '/pdf'), 1); + + return view('customers.invoices.link', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods', 'payment_actions', 'print_action', 'pdf_action')); + } } diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php index dd97566a2..123a2c621 100644 --- a/app/Http/Controllers/Incomes/Invoices.php +++ b/app/Http/Controllers/Incomes/Invoices.php @@ -36,6 +36,7 @@ use File; use Illuminate\Http\Request as ItemRequest; use Image; use Storage; +use SignedUrl; class Invoices extends Controller { @@ -117,7 +118,9 @@ class Invoices extends Controller $payment_methods = Modules::getPaymentMethods(); - return view('incomes.invoices.show', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods')); + $customer_share = SignedUrl::sign(url('links/invoices/' . $invoice->id)); + + return view('incomes.invoices.show', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods', 'customer_share')); } /** diff --git a/app/Utilities/Modules.php b/app/Utilities/Modules.php index f5495c2f4..eba746c9c 100644 --- a/app/Utilities/Modules.php +++ b/app/Utilities/Modules.php @@ -20,7 +20,11 @@ class Modules $payment_methods = Cache::get($cache_admin); - $customer = auth()->user()->customer; + $customer = true; + + if (auth()->user()) { + $customer = auth()->user()->customer; + } if ($customer && $type != 'all') { $payment_methods = Cache::get($cache_customer); 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/public/css/app.css b/public/css/app.css index 312a63455..2aaad375c 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -736,3 +736,7 @@ input[type="number"] { border-radius: 0px; vertical-align: top; } + +.link .content-wrapper, .link .right-side, .link .main-footer { + margin-left: inherit; +} \ No newline at end of file diff --git a/resources/lang/en-GB/invoices.php b/resources/lang/en-GB/invoices.php index 776cb09b6..e662b7aba 100644 --- a/resources/lang/en-GB/invoices.php +++ b/resources/lang/en-GB/invoices.php @@ -31,6 +31,7 @@ return [ 'mark_sent' => 'Mark Sent', 'download_pdf' => 'Download PDF', 'send_mail' => 'Send Email', + 'all_invoices' => 'Login to for all invoices', 'status' => [ 'draft' => 'Draft', diff --git a/resources/views/customers/invoices/link.blade.php b/resources/views/customers/invoices/link.blade.php new file mode 100644 index 000000000..c1072da9a --- /dev/null +++ b/resources/views/customers/invoices/link.blade.php @@ -0,0 +1,228 @@ +@extends('layouts.link') + +@section('title', trans_choice('general.invoices', 1) . ': ' . $invoice->invoice_number) + +@section('new_button') +  {{ trans('invoices.all_invoices') }} +@endsection + +@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/incomes/invoices/show.blade.php b/resources/views/incomes/invoices/show.blade.php index 6e27c209c..031d1c557 100644 --- a/resources/views/incomes/invoices/show.blade.php +++ b/resources/views/incomes/invoices/show.blade.php @@ -168,6 +168,9 @@   {{ trans('general.print') }} + +   Share +