all media edit and show page

This commit is contained in:
cuneytsenturk 2019-02-02 14:02:26 +03:00
parent 18e381f095
commit d4b5861120
16 changed files with 196 additions and 218 deletions

View File

@ -34,9 +34,14 @@ class Uploads extends Controller
* @param $id * @param $id
* @return mixed * @return mixed
*/ */
public function show($id) public function show($id, Request $request)
{ {
$file = false; $file = false;
$column_name = 'attachment';
if ($request->has('column_name')) {
$column_name = $request->get('column_name');
}
$media = Media::find($id); $media = Media::find($id);
@ -53,7 +58,7 @@ class Uploads extends Controller
$file = $media; $file = $media;
$html = view('partials.media.file', compact('file'))->render(); $html = view('partials.media.file', compact('file', 'column_name'))->render();
return response()->json([ return response()->json([
'success' => true, 'success' => true,

View File

@ -36,7 +36,7 @@ class Roles extends Seeder
'common-companies' => 'c,r,u,d', 'common-companies' => 'c,r,u,d',
'common-import' => 'c', 'common-import' => 'c',
'common-items' => 'c,r,u,d', 'common-items' => 'c,r,u,d',
'common-uploads' => 'd', 'common-uploads' => 'r,d',
'common-notifications' => 'c,r,u,d', 'common-notifications' => 'c,r,u,d',
'incomes-invoices' => 'c,r,u,d', 'incomes-invoices' => 'c,r,u,d',
'incomes-revenues' => '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-companies' => 'c,r,u,d',
'common-import' => 'c', 'common-import' => 'c',
'common-items' => 'c,r,u,d', 'common-items' => 'c,r,u,d',
'common-uploads' => 'r',
'common-notifications' => 'c,r,u,d', 'common-notifications' => 'c,r,u,d',
'incomes-invoices' => 'c,r,u,d', 'incomes-invoices' => 'c,r,u,d',
'incomes-revenues' => 'c,r,u,d', 'incomes-revenues' => 'c,r,u,d',

View File

@ -86,31 +86,30 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($user->picture) @if($user->picture)
placeholder : '<?php echo $user->picture->basename; ?>' placeholder : '{{ $user->picture->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($user->picture) @if($user->picture)
picture_html = '<span class="picture">'; $.ajax({
picture_html += ' <a href="{{ url('uploads/' . $user->picture->id . '/download') }}">'; url: '{{ url('uploads/' . $user->picture->id . '/show') }}',
picture_html += ' <span id="download-picture" class="text-primary">'; type: 'GET',
picture_html += ' <i class="fa fa-file-{{ $user->picture->aggregate_type }}-o"></i> {{ $user->picture->basename }}'; data: {column_name: 'picture'},
picture_html += ' </span>'; dataType: 'JSON',
picture_html += ' </a>'; success: function(json) {
picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
picture_html += ' <a id="remove-picture" href="javascript:void();">'; $('.fancy-file').after(json['html']);
picture_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
picture_html += ' </a>'; }
picture_html += ' {!! Form::close() !!}'; });
picture_html += '</span>';
@permission('delete-common-uploads')
$('.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' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
$(document).on('click', '#remove-picture', function (e) { });
confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); @endpermission
});
@endif @endif
@endif @endif

View File

@ -63,31 +63,30 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($company->company_logo) @if($company->company_logo)
placeholder : '<?php echo $company->company_logo->basename; ?>' placeholder : '{{ $company->company_logo->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($company->company_logo) @if($company->company_logo)
attachment_html = '<span class="attachment">'; $.ajax({
attachment_html += ' <a href="{{ url('uploads/' . $company->company_logo->id . '/download') }}">'; url: '{{ url('uploads/' . $company->company_logo->id . '/show') }}',
attachment_html += ' <span id="download-attachment" class="text-primary">'; type: 'GET',
attachment_html += ' <i class="fa fa-file-{{ $company->company_logo->aggregate_type }}-o"></i> {{ $company->company_logo->basename }}'; data: {column_name: 'attachment'},
attachment_html += ' </span>'; dataType: 'JSON',
attachment_html += ' </a>'; success: function(json) {
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $company->company_logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $company->company_logo->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
attachment_html += ' <a id="remove-attachment" href="javascript:void();">'; $('.fancy-file').after(json['html']);
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
attachment_html += ' </a>'; }
attachment_html += ' {!! Form::close() !!}'; });
attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html); @permission('delete-common-uploads')
$(document).on('click', '#remove-attachment', function (e) {
$(document).on('click', '#remove-attachment', function (e) { confirmDelete("#attachment-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $company->company_logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
confirmDelete("#attachment-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $company->company_logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); });
}); @endpermission
@endif @endif
}); });
</script> </script>

View File

@ -110,31 +110,30 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($item->picture) @if($item->picture)
placeholder : '<?php echo $item->picture->basename; ?>' placeholder : '{{ $item->picture->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($item->picture) @if($item->picture)
picture_html = '<span class="picture">'; $.ajax({
picture_html += ' <a href="{{ url('uploads/' . $item->picture->id . '/download') }}">'; url: '{{ url('uploads/' . $item->picture->id . '/show') }}',
picture_html += ' <span id="download-picture" class="text-primary">'; type: 'GET',
picture_html += ' <i class="fa fa-file-{{ $item->picture->aggregate_type }}-o"></i> {{ $item->picture->basename }}'; data: {column_name: 'picture'},
picture_html += ' </span>'; dataType: 'JSON',
picture_html += ' </a>'; success: function(json) {
picture_html += ' {!! Form::open(['id' => 'picture-' . $item->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $item->picture->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
picture_html += ' <a id="remove-picture" href="javascript:void();">'; $('.fancy-file').after(json['html']);
picture_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
picture_html += ' </a>'; }
picture_html += ' {!! Form::close() !!}'; });
picture_html += '</span>';
@permission('delete-common-uploads')
$('.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' => '<strong>' . $item->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
$(document).on('click', '#remove-picture', function (e) { });
confirmDelete("#picture-{!! $item->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $item->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); @endpermission
});
@endif @endif
}); });

View File

@ -64,31 +64,30 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($user->picture) @if($user->picture)
placeholder : '<?php echo $user->picture->basename; ?>' placeholder : '{{ $user->picture->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($user->picture) @if($user->picture)
picture_html = '<span class="picture">'; $.ajax({
picture_html += ' <a href="{{ url('uploads/' . $user->picture->id . '/download') }}">'; url: '{{ url('uploads/' . $user->picture->id . '/show') }}',
picture_html += ' <span id="download-picture" class="text-primary">'; type: 'GET',
picture_html += ' <i class="fa fa-file-{{ $user->picture->aggregate_type }}-o"></i> {{ $user->picture->basename }}'; data: {column_name: 'picture'},
picture_html += ' </span>'; dataType: 'JSON',
picture_html += ' </a>'; success: function(json) {
picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
picture_html += ' <a id="remove-picture" href="javascript:void();">'; $('.fancy-file').after(json['html']);
picture_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
picture_html += ' </a>'; }
picture_html += ' {!! Form::close() !!}'; });
picture_html += '</span>';
$('.fancy-file .fake-file').append(picture_html); @permission('delete-common-uploads')
$(document).on('click', '#remove-picture', function (e) {
$(document).on('click', '#remove-picture', function (e) { confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
confirmDelete("#picture-{!! $user->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); });
}); @endpermission
@endif @endif
}); });
</script> </script>

View File

@ -257,27 +257,24 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($bill->attachment) @if($bill->attachment)
placeholder : '<?php echo $bill->attachment->basename; ?>' placeholder : '{{ $bill->attachment->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($bill->attachment) @if($bill->attachment)
attachment_html = '<span class="attachment">'; $.ajax({
attachment_html += ' <a href="{{ url('uploads/' . $bill->attachment->id . '/download') }}">'; url: '{{ url('uploads/' . $bill->attachment->id . '/show') }}',
attachment_html += ' <span id="download-attachment" class="text-primary">'; type: 'GET',
attachment_html += ' <i class="fa fa-file-{{ $bill->attachment->aggregate_type }}-o"></i> {{ $bill->attachment->basename }}'; data: {column_name: 'attachment'},
attachment_html += ' </span>'; dataType: 'JSON',
attachment_html += ' </a>'; success: function(json) {
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $bill->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $bill->attachment->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
attachment_html += ' <a id="remove-attachment" href="javascript:void();">'; $('.fancy-file').after(json['html']);
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
attachment_html += ' </a>'; }
attachment_html += ' {!! Form::close() !!}'; });
attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html);
@endif @endif
@if(old('item')) @if(old('item'))
@ -285,11 +282,13 @@
@endif @endif
}); });
@permission('delete-common-uploads')
@if($bill->attachment) @if($bill->attachment)
$(document).on('click', '#remove-attachment', function (e) { $(document).on('click', '#remove-attachment', function (e) {
confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endif @endif
@endpermission
$(document).on('click', '#button-add-item', function (e) { $(document).on('click', '#button-add-item', function (e) {
$.ajax({ $.ajax({

View File

@ -311,23 +311,8 @@
</div> </div>
@if($bill->attachment) @if($bill->attachment)
<span class="attachment"> @php $file = $bill->attachment; @endphp
<a href="{{ url('uploads/' . $bill->attachment->id . '/download') }}"> @include('partials.media.file')
<span id="download-attachment" class="text-primary">
<i class="fa fa-file-{{ $bill->attachment->aggregate_type }}-o"></i> {{ $bill->attachment->basename }}
</span>
</a>
{!! Form::open([
'id' => 'attachment-' . $bill->attachment->id,
'method' => 'DELETE',
'url' => [url('uploads/' . $bill->attachment->id)],
'style' => 'display:inline'
]) !!}
<a id="remove-attachment" href="javascript:void();">
<span class="text-danger"><i class="fa fa fa-times"></i></span>
</a>
{!! Form::close() !!}
</span>
@endif @endif
</div> </div>
</div> </div>

View File

@ -137,31 +137,30 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($payment->attachment) @if($payment->attachment)
placeholder : '<?php echo $payment->attachment->basename; ?>' placeholder : '{{ $payment->attachment->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($payment->attachment) @if($payment->attachment)
attachment_html = '<span class="attachment">'; $.ajax({
attachment_html += ' <a href="{{ url('uploads/' . $payment->attachment->id . '/download') }}">'; url: '{{ url('uploads/' . $payment->attachment->id . '/show') }}',
attachment_html += ' <span id="download-attachment" class="text-primary">'; type: 'GET',
attachment_html += ' <i class="fa fa-file-{{ $payment->attachment->aggregate_type }}-o"></i> {{ $payment->attachment->basename }}'; data: {column_name: 'attachment'},
attachment_html += ' </span>'; dataType: 'JSON',
attachment_html += ' </a>'; success: function(json) {
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $payment->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $payment->attachment->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
attachment_html += ' <a id="remove-attachment" href="javascript:void();">'; $('.fancy-file').after(json['html']);
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
attachment_html += ' </a>'; }
attachment_html += ' {!! Form::close() !!}'; });
attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html); @permission('delete-common-uploads')
$(document).on('click', '#remove-attachment', function (e) {
$(document).on('click', '#remove-attachment', function (e) { confirmDelete("#attachment-{!! $payment->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $payment->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
confirmDelete("#attachment-{!! $payment->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $payment->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); });
}); @endpermission
@endif @endif
}); });

View File

@ -69,31 +69,30 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($vendor->logo) @if($vendor->logo)
placeholder : '<?php echo $vendor->logo->basename; ?>' placeholder : '{{ $vendor->logo->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($vendor->logo) @if($vendor->logo)
logo_html = '<span class="logo">'; $.ajax({
logo_html += ' <a href="{{ url('uploads/' . $vendor->logo->id . '/download') }}">'; url: '{{ url('uploads/' . $vendor->logo->id . '/show') }}',
logo_html += ' <span id="download-logo" class="text-primary">'; type: 'GET',
logo_html += ' <i class="fa fa-file-{{ $vendor->logo->aggregate_type }}-o"></i> {{ $vendor->logo->basename }}'; data: {column_name: 'logo'},
logo_html += ' </span>'; dataType: 'JSON',
logo_html += ' </a>'; success: function(json) {
logo_html += ' {!! Form::open(['id' => 'logo-' . $vendor->logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $vendor->logo->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
logo_html += ' <a id="remove-logo" href="javascript:void();">'; $('.fancy-file').after(json['html']);
logo_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
logo_html += ' </a>'; }
logo_html += ' {!! Form::close() !!}'; });
logo_html += '</span>';
$('.fancy-file .fake-file').append(logo_html);
@permission('delete-common-uploads')
$(document).on('click', '#remove-logo', function (e) { $(document).on('click', '#remove-logo', function (e) {
confirmDelete("#logo-{!! $vendor->logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $vendor->logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#logo-{!! $vendor->logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $vendor->logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endpermission
@endif @endif
}); });
</script> </script>

View File

@ -267,6 +267,7 @@
$.ajax({ $.ajax({
url: '{{ url('uploads/' . $invoice->attachment->id . '/show') }}', url: '{{ url('uploads/' . $invoice->attachment->id . '/show') }}',
type: 'GET', type: 'GET',
data: {column_name: 'attachment'},
dataType: 'JSON', dataType: 'JSON',
success: function(json) { success: function(json) {
if (json['success']) { if (json['success']) {
@ -281,11 +282,13 @@
@endif @endif
}); });
@permission('delete-common-uploads')
@if($invoice->attachment) @if($invoice->attachment)
$(document).on('click', '#remove-attachment', function (e) { $(document).on('click', '#remove-attachment', function (e) {
confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endif @endif
@endpermission
$(document).on('click', '#button-add-item', function (e) { $(document).on('click', '#button-add-item', function (e) {
$.ajax({ $.ajax({

View File

@ -137,32 +137,31 @@
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
@if($revenue->attachment) @if($revenue->attachment)
placeholder : '<?php echo $revenue->attachment->basename; ?>' placeholder : '{{ $revenue->attachment->basename }}'
@else @else
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif @endif
}); });
@if($revenue->attachment) @if($revenue->attachment)
attachment_html = '<span class="attachment">'; $.ajax({
attachment_html += ' <a href="{{ url('uploads/' . $revenue->attachment->id . '/download') }}">'; url: '{{ url('uploads/' . $revenue->attachment->id . '/show') }}',
attachment_html += ' <span id="download-attachment" class="text-primary">'; type: 'GET',
attachment_html += ' <i class="fa fa-file-{{ $revenue->attachment->aggregate_type }}-o"></i> {{ $revenue->attachment->basename }}'; data: {column_name: 'attachment'},
attachment_html += ' </span>'; dataType: 'JSON',
attachment_html += ' </a>'; success: function(json) {
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $revenue->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $revenue->attachment->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
attachment_html += ' <a id="remove-attachment" href="javascript:void();">'; $('.fancy-file').after(json['html']);
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
attachment_html += ' </a>'; }
attachment_html += ' {!! Form::close() !!}'; });
attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html); @permission('delete-common-uploads')
$(document).on('click', '#remove-attachment', function (e) {
$(document).on('click', '#remove-attachment', function (e) { confirmDelete("#attachment-{!! $revenue->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $revenue->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
confirmDelete("#attachment-{!! $revenue->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $revenue->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); });
});
@endif @endif
@endpermission
}); });
$(document).on('change', '#account_id', function (e) { $(document).on('change', '#account_id', function (e) {

View File

@ -21,14 +21,16 @@
{{ $file->readableSize() }} {{ $file->readableSize() }}
{!! Form::open([ {!! Form::open([
'id' => 'attachment-' . $file->id, 'id' => $column_name. '-' . $file->id,
'method' => 'DELETE', 'method' => 'DELETE',
'url' => [url('uploads/' . $file->id)], 'url' => [url('uploads/' . $file->id)],
'style' => 'display:inline' 'style' => 'display:inline'
]) !!} ]) !!}
<a id="remove-attachment" href="javascript:void();" class="btn btn-danger btn-xs pull-right"> @permission('delete-common-uploads')
<a href="javascript:void();" id="remove-{{ $column_name }}" class="btn btn-danger btn-xs pull-right mailbox-attachment-remove">
<i class="fa fa fa-times"></i> <i class="fa fa fa-times"></i>
</a> </a>
@endpermission
{!! Form::close() !!} {!! Form::close() !!}
<a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download"> <a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download">

View File

@ -27,9 +27,11 @@
'url' => [url('uploads/' . $file->id)], 'url' => [url('uploads/' . $file->id)],
'style' => 'display:inline' 'style' => 'display:inline'
]) !!} ]) !!}
<a id="remove-attachment" href="javascript:void();" class="btn btn-danger btn-xs pull-right"> @permission('delete-common-uploads')
<a href="javascript:void();" id="remove-attachment" class="btn btn-danger btn-xs pull-right mailbox-attachment-remove">
<i class="fa fa fa-times"></i> <i class="fa fa fa-times"></i>
</a> </a>
@endpermission
{!! Form::close() !!} {!! Form::close() !!}
<a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download"> <a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download">

View File

@ -246,27 +246,23 @@
}); });
@if($setting['company_logo']) @if($setting['company_logo'])
company_logo_html = '<span class="company_logo">'; $.ajax({
company_logo_html += ' <a href="{{ url('uploads/' . $setting['company_logo']->id . '/download') }}">'; url: '{{ url('uploads/' . $setting['company_logo']->id . '/show') }}',
company_logo_html += ' <span id="download-company_logo" class="text-primary">'; type: 'GET',
company_logo_html += ' <i class="fa fa-file-{{ $setting['company_logo']->aggregate_type }}-o"></i> {{ $setting['company_logo']->basename }}'; data: {column_name: 'company_logo'},
company_logo_html += ' </span>'; dataType: 'JSON',
company_logo_html += ' </a>'; success: function(json) {
company_logo_html += ' {!! Form::open(['id' => 'company_logo-' . $setting['company_logo']->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $setting['company_logo']->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
company_logo_html += ' <a id="remove-company_logo" href="javascript:void();">'; $('#company .fancy-file').after(json['html']);
company_logo_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
company_logo_html += ' </a>'; }
company_logo_html += ' <input type="hidden" name="page" value="setting" />'; });
company_logo_html += ' <input type="hidden" name="key" value="general.company_logo" />';
company_logo_html += ' <input type="hidden" name="value" value="{{ $setting['company_logo']->id }}" />'; @permission('delete-common-uploads')
company_logo_html += ' {!! Form::close() !!}'; $(document).on('click', '#remove-company_logo', function (e) {
company_logo_html += '</span>'; confirmDelete("#company_logo-{!! $setting['company_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $setting['company_logo']->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
$('#company .fancy-file .fake-file').append(company_logo_html); @endpermission
$(document).on('click', '#remove-company_logo', function (e) {
confirmDelete("#company_logo-{!! $setting['company_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $setting['company_logo']->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endif @endif
var invoice_file = false; var invoice_file = false;
@ -286,27 +282,23 @@
}); });
@if($setting['invoice_logo']) @if($setting['invoice_logo'])
invoice_logo_html = '<span class="invoice_logo">'; $.ajax({
invoice_logo_html += ' <a href="{{ url('uploads/' . $setting['invoice_logo']->id . '/download') }}">'; url: '{{ url('uploads/' . $setting['invoice_logo']->id . '/show') }}',
invoice_logo_html += ' <span id="download-invoice_logo" class="text-primary">'; type: 'GET',
invoice_logo_html += ' <i class="fa fa-file-{{ $setting['invoice_logo']->aggregate_type }}-o"></i> {{ $setting['invoice_logo']->basename }}'; data: {column_name: 'invoice_logo'},
invoice_logo_html += ' </span>'; dataType: 'JSON',
invoice_logo_html += ' </a>'; success: function(json) {
invoice_logo_html += ' {!! Form::open(['id' => 'invoice_logo-' . $setting['invoice_logo']->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $setting['invoice_logo']->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
invoice_logo_html += ' <a id="remove-invoice_logo" href="javascript:void();">'; $(target + ' .fancy-file').after(json['html']);
invoice_logo_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
invoice_logo_html += ' </a>'; }
invoice_logo_html += ' <input type="hidden" name="page" value="setting" />'; });
invoice_logo_html += ' <input type="hidden" name="key" value="general.invoice_logo" />';
invoice_logo_html += ' <input type="hidden" name="value" value="{{ $setting['invoice_logo']->id }}" />';
invoice_logo_html += ' {!! Form::close() !!}';
invoice_logo_html += '</span>';
$(target + ' .fancy-file .fake-file').append(invoice_logo_html);
@permission('delete-common-uploads')
$(document).on('click', '#remove-invoice_logo', function (e) { $(document).on('click', '#remove-invoice_logo', function (e) {
confirmDelete("#invoice_logo-{!! $setting['invoice_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $setting['invoice_logo']->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#invoice_logo-{!! $setting['invoice_logo']->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $setting['invoice_logo']->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endpermission
@endif @endif
invoice_file = true; invoice_file = true;

View File

@ -116,27 +116,23 @@
}); });
@if($company->company_logo) @if($company->company_logo)
company_logo_html = '<span class="company_logo">'; $.ajax({
company_logo_html += ' <a href="{{ url('uploads/' . $company->company_logo->id . '/download') }}">'; url: '{{ url('uploads/' . $company->company_logo->id . '/show') }}',
company_logo_html += ' <span id="download-company_logo" class="text-primary">'; type: 'GET',
company_logo_html += ' <i class="fa fa-file-{{ $company->company_logo->aggregate_type }}-o"></i> {{ $company->company_logo->basename }}'; data: {column_name: 'company_logo'},
company_logo_html += ' </span>'; dataType: 'JSON',
company_logo_html += ' </a>'; success: function(json) {
company_logo_html += ' {!! Form::open(['id' => 'company_logo-' . $company->company_logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $company->company_logo->id)], 'style' => 'display:inline']) !!}'; if (json['success']) {
company_logo_html += ' <a id="remove-company_logo" href="javascript:void();">'; $('.form-group.col-md-6 .fancy-file').after(json['html']);
company_logo_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>'; }
company_logo_html += ' </a>'; }
company_logo_html += ' <input type="hidden" name="page" value="setting" />'; });
company_logo_html += ' <input type="hidden" name="key" value="general.company_logo" />';
company_logo_html += ' <input type="hidden" name="value" value="{{ $company->company_logo->id }}" />';
company_logo_html += ' {!! Form::close() !!}';
company_logo_html += '</span>';
$('.form-group.col-md-6 .fancy-file .fake-file').append(company_logo_html);
@permission('delete-common-uploads')
$(document).on('click', '#remove-company_logo', function (e) { $(document).on('click', '#remove-company_logo', function (e) {
confirmDelete("#company_logo-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $company->company_logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#company_logo-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $company->company_logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endpermission
@endif @endif
}); });
</script> </script>