From d4b5861120d98a3f3b563b365ebdcdee969725be Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Sat, 2 Feb 2019 14:02:26 +0300 Subject: [PATCH] all media edit and show page --- app/Http/Controllers/Common/Uploads.php | 9 ++- database/seeds/Roles.php | 3 +- resources/views/auth/users/edit.blade.php | 37 +++++----- .../views/common/companies/edit.blade.php | 35 +++++----- resources/views/common/items/edit.blade.php | 37 +++++----- .../views/customers/profile/edit.blade.php | 35 +++++----- resources/views/expenses/bills/edit.blade.php | 29 ++++---- resources/views/expenses/bills/show.blade.php | 19 +----- .../views/expenses/payments/edit.blade.php | 35 +++++----- .../views/expenses/vendors/edit.blade.php | 29 ++++---- .../views/incomes/invoices/edit.blade.php | 3 + .../views/incomes/revenues/edit.blade.php | 35 +++++----- resources/views/partials/media/file.blade.php | 6 +- .../views/partials/media/files.blade.php | 4 +- .../views/settings/settings/edit.blade.php | 68 ++++++++----------- .../views/wizard/companies/edit.blade.php | 30 ++++---- 16 files changed, 196 insertions(+), 218 deletions(-) diff --git a/app/Http/Controllers/Common/Uploads.php b/app/Http/Controllers/Common/Uploads.php index 92a766b20..ae522b7a3 100644 --- a/app/Http/Controllers/Common/Uploads.php +++ b/app/Http/Controllers/Common/Uploads.php @@ -34,9 +34,14 @@ class Uploads extends Controller * @param $id * @return mixed */ - public function show($id) + public function show($id, Request $request) { $file = false; + $column_name = 'attachment'; + + if ($request->has('column_name')) { + $column_name = $request->get('column_name'); + } $media = Media::find($id); @@ -53,7 +58,7 @@ class Uploads extends Controller $file = $media; - $html = view('partials.media.file', compact('file'))->render(); + $html = view('partials.media.file', compact('file', 'column_name'))->render(); return response()->json([ 'success' => true, diff --git a/database/seeds/Roles.php b/database/seeds/Roles.php index 088d369ac..3c7a0b8be 100644 --- a/database/seeds/Roles.php +++ b/database/seeds/Roles.php @@ -36,7 +36,7 @@ class Roles extends Seeder 'common-companies' => 'c,r,u,d', 'common-import' => 'c', 'common-items' => 'c,r,u,d', - 'common-uploads' => 'd', + 'common-uploads' => 'r,d', 'common-notifications' => 'c,r,u,d', 'incomes-invoices' => 'c,r,u,d', 'incomes-revenues' => 'c,r,u,d', @@ -76,6 +76,7 @@ class Roles extends Seeder 'common-companies' => 'c,r,u,d', 'common-import' => 'c', 'common-items' => 'c,r,u,d', + 'common-uploads' => 'r', 'common-notifications' => 'c,r,u,d', 'incomes-invoices' => 'c,r,u,d', 'incomes-revenues' => 'c,r,u,d', diff --git a/resources/views/auth/users/edit.blade.php b/resources/views/auth/users/edit.blade.php index 0b8bd9b5f..d2e081b6f 100644 --- a/resources/views/auth/users/edit.blade.php +++ b/resources/views/auth/users/edit.blade.php @@ -86,31 +86,30 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($user->picture) - placeholder : 'picture->basename; ?>' + placeholder : '{{ $user->picture->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($user->picture) - picture_html = ''; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {{ $user->picture->basename }}'; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}'; - picture_html += ' '; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {!! Form::close() !!}'; - picture_html += ''; - - $('.fancy-file .fake-file').append(picture_html); - - $(document).on('click', '#remove-picture', function (e) { - confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $user->picture->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + $.ajax({ + url: '{{ url('uploads/' . $user->picture->id . '/show') }}', + type: 'GET', + data: {column_name: 'picture'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); + + @permission('delete-common-uploads') + $(document).on('click', '#remove-picture', function (e) { + confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $user->picture->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); + @endpermission @endif @endif diff --git a/resources/views/common/companies/edit.blade.php b/resources/views/common/companies/edit.blade.php index 29defd177..54d424874 100644 --- a/resources/views/common/companies/edit.blade.php +++ b/resources/views/common/companies/edit.blade.php @@ -63,31 +63,30 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($company->company_logo) - placeholder : 'company_logo->basename; ?>' + placeholder : '{{ $company->company_logo->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($company->company_logo) - attachment_html = ''; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {{ $company->company_logo->basename }}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::open(['id' => 'attachment-' . $company->company_logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $company->company_logo->id)], 'style' => 'display:inline']) !!}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::close() !!}'; - attachment_html += ''; + $.ajax({ + url: '{{ url('uploads/' . $company->company_logo->id . '/show') }}', + type: 'GET', + data: {column_name: 'attachment'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); - $('.fancy-file .fake-file').append(attachment_html); - - $(document).on('click', '#remove-attachment', function (e) { - confirmDelete("#attachment-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $company->company_logo->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + @permission('delete-common-uploads') + $(document).on('click', '#remove-attachment', function (e) { + confirmDelete("#attachment-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $company->company_logo->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); + @endpermission @endif }); diff --git a/resources/views/common/items/edit.blade.php b/resources/views/common/items/edit.blade.php index 3ecf81db1..2403c6b27 100644 --- a/resources/views/common/items/edit.blade.php +++ b/resources/views/common/items/edit.blade.php @@ -110,31 +110,30 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($item->picture) - placeholder : 'picture->basename; ?>' + placeholder : '{{ $item->picture->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($item->picture) - picture_html = ''; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {{ $item->picture->basename }}'; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {!! Form::open(['id' => 'picture-' . $item->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $item->picture->id)], 'style' => 'display:inline']) !!}'; - picture_html += ' '; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {!! Form::close() !!}'; - picture_html += ''; - - $('.fancy-file .fake-file').append(picture_html); - - $(document).on('click', '#remove-picture', function (e) { - confirmDelete("#picture-{!! $item->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $item->picture->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + $.ajax({ + url: '{{ url('uploads/' . $item->picture->id . '/show') }}', + type: 'GET', + data: {column_name: 'picture'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); + + @permission('delete-common-uploads') + $(document).on('click', '#remove-picture', function (e) { + confirmDelete("#picture-{!! $item->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $item->picture->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); + @endpermission @endif }); diff --git a/resources/views/customers/profile/edit.blade.php b/resources/views/customers/profile/edit.blade.php index ba5464bcf..1df388a87 100644 --- a/resources/views/customers/profile/edit.blade.php +++ b/resources/views/customers/profile/edit.blade.php @@ -64,31 +64,30 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($user->picture) - placeholder : 'picture->basename; ?>' + placeholder : '{{ $user->picture->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($user->picture) - picture_html = ''; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {{ $user->picture->basename }}'; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}'; - picture_html += ' '; - picture_html += ' '; - picture_html += ' '; - picture_html += ' {!! Form::close() !!}'; - picture_html += ''; + $.ajax({ + url: '{{ url('uploads/' . $user->picture->id . '/show') }}', + type: 'GET', + data: {column_name: 'picture'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); - $('.fancy-file .fake-file').append(picture_html); - - $(document).on('click', '#remove-picture', function (e) { - confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $user->picture->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + @permission('delete-common-uploads') + $(document).on('click', '#remove-picture', function (e) { + confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $user->picture->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); + @endpermission @endif }); diff --git a/resources/views/expenses/bills/edit.blade.php b/resources/views/expenses/bills/edit.blade.php index 736cdf228..c90eaa2a8 100644 --- a/resources/views/expenses/bills/edit.blade.php +++ b/resources/views/expenses/bills/edit.blade.php @@ -257,27 +257,24 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($bill->attachment) - placeholder : 'attachment->basename; ?>' + placeholder : '{{ $bill->attachment->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($bill->attachment) - attachment_html = ''; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {{ $bill->attachment->basename }}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::open(['id' => 'attachment-' . $bill->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $bill->attachment->id)], 'style' => 'display:inline']) !!}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::close() !!}'; - attachment_html += ''; - - $('.fancy-file .fake-file').append(attachment_html); + $.ajax({ + url: '{{ url('uploads/' . $bill->attachment->id . '/show') }}', + type: 'GET', + data: {column_name: 'attachment'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); @endif @if(old('item')) @@ -285,11 +282,13 @@ @endif }); + @permission('delete-common-uploads') @if($bill->attachment) $(document).on('click', '#remove-attachment', function (e) { confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $bill->attachment->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); }); @endif + @endpermission $(document).on('click', '#button-add-item', function (e) { $.ajax({ diff --git a/resources/views/expenses/bills/show.blade.php b/resources/views/expenses/bills/show.blade.php index 489feb93f..772f795aa 100644 --- a/resources/views/expenses/bills/show.blade.php +++ b/resources/views/expenses/bills/show.blade.php @@ -311,23 +311,8 @@ @if($bill->attachment) - - - - {{ $bill->attachment->basename }} - - - {!! Form::open([ - 'id' => 'attachment-' . $bill->attachment->id, - 'method' => 'DELETE', - 'url' => [url('uploads/' . $bill->attachment->id)], - 'style' => 'display:inline' - ]) !!} - - - - {!! Form::close() !!} - + @php $file = $bill->attachment; @endphp + @include('partials.media.file') @endif diff --git a/resources/views/expenses/payments/edit.blade.php b/resources/views/expenses/payments/edit.blade.php index 2f7885ee3..700cb023d 100644 --- a/resources/views/expenses/payments/edit.blade.php +++ b/resources/views/expenses/payments/edit.blade.php @@ -137,31 +137,30 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($payment->attachment) - placeholder : 'attachment->basename; ?>' + placeholder : '{{ $payment->attachment->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($payment->attachment) - attachment_html = ''; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {{ $payment->attachment->basename }}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::open(['id' => 'attachment-' . $payment->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $payment->attachment->id)], 'style' => 'display:inline']) !!}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::close() !!}'; - attachment_html += ''; + $.ajax({ + url: '{{ url('uploads/' . $payment->attachment->id . '/show') }}', + type: 'GET', + data: {column_name: 'attachment'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); - $('.fancy-file .fake-file').append(attachment_html); - - $(document).on('click', '#remove-attachment', function (e) { - confirmDelete("#attachment-{!! $payment->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $payment->attachment->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + @permission('delete-common-uploads') + $(document).on('click', '#remove-attachment', function (e) { + confirmDelete("#attachment-{!! $payment->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $payment->attachment->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); + @endpermission @endif }); diff --git a/resources/views/expenses/vendors/edit.blade.php b/resources/views/expenses/vendors/edit.blade.php index ca9560eea..4993bdd41 100644 --- a/resources/views/expenses/vendors/edit.blade.php +++ b/resources/views/expenses/vendors/edit.blade.php @@ -69,31 +69,30 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($vendor->logo) - placeholder : 'logo->basename; ?>' + placeholder : '{{ $vendor->logo->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($vendor->logo) - logo_html = ''; - - $('.fancy-file .fake-file').append(logo_html); + $.ajax({ + url: '{{ url('uploads/' . $vendor->logo->id . '/show') }}', + type: 'GET', + data: {column_name: 'logo'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); + @permission('delete-common-uploads') $(document).on('click', '#remove-logo', function (e) { confirmDelete("#logo-{!! $vendor->logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $vendor->logo->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); }); + @endpermission @endif }); diff --git a/resources/views/incomes/invoices/edit.blade.php b/resources/views/incomes/invoices/edit.blade.php index dccd5a9de..2805c057a 100644 --- a/resources/views/incomes/invoices/edit.blade.php +++ b/resources/views/incomes/invoices/edit.blade.php @@ -267,6 +267,7 @@ $.ajax({ url: '{{ url('uploads/' . $invoice->attachment->id . '/show') }}', type: 'GET', + data: {column_name: 'attachment'}, dataType: 'JSON', success: function(json) { if (json['success']) { @@ -281,11 +282,13 @@ @endif }); + @permission('delete-common-uploads') @if($invoice->attachment) $(document).on('click', '#remove-attachment', function (e) { confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $invoice->attachment->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); }); @endif + @endpermission $(document).on('click', '#button-add-item', function (e) { $.ajax({ diff --git a/resources/views/incomes/revenues/edit.blade.php b/resources/views/incomes/revenues/edit.blade.php index 197407cc4..f5464d828 100644 --- a/resources/views/incomes/revenues/edit.blade.php +++ b/resources/views/incomes/revenues/edit.blade.php @@ -137,32 +137,31 @@ text : '{{ trans('general.form.select.file') }}', style : 'btn-default', @if($revenue->attachment) - placeholder : 'attachment->basename; ?>' + placeholder : '{{ $revenue->attachment->basename }}' @else placeholder : '{{ trans('general.form.no_file_selected') }}' @endif }); @if($revenue->attachment) - attachment_html = ''; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {{ $revenue->attachment->basename }}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::open(['id' => 'attachment-' . $revenue->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $revenue->attachment->id)], 'style' => 'display:inline']) !!}'; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' '; - attachment_html += ' {!! Form::close() !!}'; - attachment_html += ''; + $.ajax({ + url: '{{ url('uploads/' . $revenue->attachment->id . '/show') }}', + type: 'GET', + data: {column_name: 'attachment'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.fancy-file').after(json['html']); + } + } + }); - $('.fancy-file .fake-file').append(attachment_html); - - $(document).on('click', '#remove-attachment', function (e) { - confirmDelete("#attachment-{!! $revenue->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $revenue->attachment->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + @permission('delete-common-uploads') + $(document).on('click', '#remove-attachment', function (e) { + confirmDelete("#attachment-{!! $revenue->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $revenue->attachment->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); @endif + @endpermission }); $(document).on('change', '#account_id', function (e) { diff --git a/resources/views/partials/media/file.blade.php b/resources/views/partials/media/file.blade.php index 2cb0c306e..960675409 100644 --- a/resources/views/partials/media/file.blade.php +++ b/resources/views/partials/media/file.blade.php @@ -21,14 +21,16 @@ {{ $file->readableSize() }} {!! Form::open([ - 'id' => 'attachment-' . $file->id, + 'id' => $column_name. '-' . $file->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $file->id)], 'style' => 'display:inline' ]) !!} - + @permission('delete-common-uploads') + + @endpermission {!! Form::close() !!} diff --git a/resources/views/partials/media/files.blade.php b/resources/views/partials/media/files.blade.php index e4ae762a2..f1deb107b 100644 --- a/resources/views/partials/media/files.blade.php +++ b/resources/views/partials/media/files.blade.php @@ -27,9 +27,11 @@ 'url' => [url('uploads/' . $file->id)], 'style' => 'display:inline' ]) !!} - + @permission('delete-common-uploads') + + @endpermission {!! Form::close() !!} diff --git a/resources/views/settings/settings/edit.blade.php b/resources/views/settings/settings/edit.blade.php index 1b9757f3a..06c808faa 100644 --- a/resources/views/settings/settings/edit.blade.php +++ b/resources/views/settings/settings/edit.blade.php @@ -246,27 +246,23 @@ }); @if($setting['company_logo']) - company_logo_html = ''; - company_logo_html += ' '; - company_logo_html += ' '; - company_logo_html += ' {!! Form::open(['id' => 'company_logo-' . $setting['company_logo']->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $setting['company_logo']->id)], 'style' => 'display:inline']) !!}'; - company_logo_html += ' '; - company_logo_html += ' '; - company_logo_html += ' '; - company_logo_html += ' '; - company_logo_html += ' {!! Form::close() !!}'; - company_logo_html += ''; - - $('#company .fancy-file .fake-file').append(company_logo_html); - - $(document).on('click', '#remove-company_logo', function (e) { - confirmDelete("#company_logo-{!! $setting['company_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $setting['company_logo']->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); - }); + $.ajax({ + url: '{{ url('uploads/' . $setting['company_logo']->id . '/show') }}', + type: 'GET', + data: {column_name: 'company_logo'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('#company .fancy-file').after(json['html']); + } + } + }); + + @permission('delete-common-uploads') + $(document).on('click', '#remove-company_logo', function (e) { + confirmDelete("#company_logo-{!! $setting['company_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $setting['company_logo']->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); + }); + @endpermission @endif var invoice_file = false; @@ -286,27 +282,23 @@ }); @if($setting['invoice_logo']) - invoice_logo_html = ''; - - $(target + ' .fancy-file .fake-file').append(invoice_logo_html); + $.ajax({ + url: '{{ url('uploads/' . $setting['invoice_logo']->id . '/show') }}', + type: 'GET', + data: {column_name: 'invoice_logo'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $(target + ' .fancy-file').after(json['html']); + } + } + }); + @permission('delete-common-uploads') $(document).on('click', '#remove-invoice_logo', function (e) { confirmDelete("#invoice_logo-{!! $setting['invoice_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $setting['invoice_logo']->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); }); + @endpermission @endif invoice_file = true; diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php index 8322cfcac..b8efd9eed 100644 --- a/resources/views/wizard/companies/edit.blade.php +++ b/resources/views/wizard/companies/edit.blade.php @@ -116,27 +116,23 @@ }); @if($company->company_logo) - company_logo_html = ''; - - $('.form-group.col-md-6 .fancy-file .fake-file').append(company_logo_html); + $.ajax({ + url: '{{ url('uploads/' . $company->company_logo->id . '/show') }}', + type: 'GET', + data: {column_name: 'company_logo'}, + dataType: 'JSON', + success: function(json) { + if (json['success']) { + $('.form-group.col-md-6 .fancy-file').after(json['html']); + } + } + }); + @permission('delete-common-uploads') $(document).on('click', '#remove-company_logo', function (e) { confirmDelete("#company_logo-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $company->company_logo->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); }); + @endpermission @endif });