Merge pull request #748 from cuneytsenturk/master

Attachment stylesheet
This commit is contained in:
Cüneyt Şentürk 2019-02-02 14:44:24 +03:00 committed by GitHub
commit d05caa7152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 431 additions and 245 deletions

View File

@ -28,6 +28,55 @@ class Uploads extends Controller
return response()->file($path);
}
/**
* Get the specified resource.
*
* @param $id
* @return mixed
*/
public function show($id, Request $request)
{
$file = false;
$options = false;
$column_name = 'attachment';
if ($request->has('column_name')) {
$column_name = $request->get('column_name');
}
if ($request->has('page')) {
$options = [
'page' => $request->get('page'),
'key' => $request->get('key'),
];
}
$media = Media::find($id);
// Get file path
if (!$path = $this->getPath($media)) {
return response()->json([
'success' => false,
'error' => true,
'data' => [],
'message' => 'null',
'html' => '',
]);
}
$file = $media;
$html = view('partials.media.file', compact('file', 'column_name', 'options'))->render();
return response()->json([
'success' => true,
'error' => false,
'data' => [],
'message' => 'null',
'html' => $html,
]);
}
/**
* Download the specified resource.
*

View File

@ -0,0 +1,62 @@
<?php
namespace App\Listeners\Updates\V13;
use App\Events\UpdateFinished;
use App\Listeners\Updates\Listener;
use App\Models\Auth\Role;
use App\Models\Auth\Permission;
use Artisan;
class Version1311 extends Listener
{
const ALIAS = 'core';
const VERSION = '1.3.11';
/**
* Handle the event.
*
* @param $event
* @return void
*/
public function handle(UpdateFinished $event)
{
// Check if should listen
if (!$this->check($event)) {
return;
}
$this->updatePermissions();
// Update database
Artisan::call('migrate', ['--force' => true]);
}
protected function updatePermissions()
{
$permissions = [];
// Common Uploads
$permissions[] = Permission::firstOrCreate([
'name' => 'read-common-uploads',
'display_name' => 'Read Common Uploads',
'description' => 'Read Common Uploads',
]);
// Attach permission to roles
$roles = Role::all();
foreach ($roles as $role) {
$allowed = ['admin', 'manager'];
if (!in_array($role->name, $allowed)) {
continue;
}
foreach ($permissions as $permission) {
$role->attachPermission($permission);
}
}
}
}

View File

@ -33,6 +33,7 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\Updates\V13\Version135',
'App\Listeners\Updates\V13\Version138',
'App\Listeners\Updates\V13\Version139',
'App\Listeners\Updates\V13\Version1311',
],
'Illuminate\Auth\Events\Login' => [
'App\Listeners\Auth\Login',

View File

@ -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',

11
public/css/app.css vendored
View File

@ -933,3 +933,14 @@ input[type="number"] {
.table-report {
overflow-x: auto !important;
}
.mailbox-attachment-file-name {
white-space: nowrap;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
.mailbox-attachment-download {
margin-right: 5px;
}

View File

@ -86,31 +86,30 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($user->picture)
placeholder : '<?php echo $user->picture->basename; ?>'
placeholder : '{{ $user->picture->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($user->picture)
picture_html = '<span class="picture">';
picture_html += ' <a href="{{ url('uploads/' . $user->picture->id . '/download') }}">';
picture_html += ' <span id="download-picture" class="text-primary">';
picture_html += ' <i class="fa fa-file-{{ $user->picture->aggregate_type }}-o"></i> {{ $user->picture->basename }}';
picture_html += ' </span>';
picture_html += ' </a>';
picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}';
picture_html += ' <a id="remove-picture" href="javascript:void();">';
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);
$(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') !!}");
});
$.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' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
@endif

View File

@ -63,31 +63,30 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($company->company_logo)
placeholder : '<?php echo $company->company_logo->basename; ?>'
placeholder : '{{ $company->company_logo->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($company->company_logo)
attachment_html = '<span class="attachment">';
attachment_html += ' <a href="{{ url('uploads/' . $company->company_logo->id . '/download') }}">';
attachment_html += ' <span id="download-attachment" class="text-primary">';
attachment_html += ' <i class="fa fa-file-{{ $company->company_logo->aggregate_type }}-o"></i> {{ $company->company_logo->basename }}';
attachment_html += ' </span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $company->company_logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $company->company_logo->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::close() !!}';
attachment_html += '</span>';
$.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' => '<strong>' . $company->company_logo->basename . '</strong>', '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' => '<strong>' . $company->company_logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
});
</script>

View File

@ -110,31 +110,30 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($item->picture)
placeholder : '<?php echo $item->picture->basename; ?>'
placeholder : '{{ $item->picture->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($item->picture)
picture_html = '<span class="picture">';
picture_html += ' <a href="{{ url('uploads/' . $item->picture->id . '/download') }}">';
picture_html += ' <span id="download-picture" class="text-primary">';
picture_html += ' <i class="fa fa-file-{{ $item->picture->aggregate_type }}-o"></i> {{ $item->picture->basename }}';
picture_html += ' </span>';
picture_html += ' </a>';
picture_html += ' {!! Form::open(['id' => 'picture-' . $item->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $item->picture->id)], 'style' => 'display:inline']) !!}';
picture_html += ' <a id="remove-picture" href="javascript:void();">';
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);
$(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') !!}");
});
$.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' => '<strong>' . $item->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
});

View File

@ -64,31 +64,30 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($user->picture)
placeholder : '<?php echo $user->picture->basename; ?>'
placeholder : '{{ $user->picture->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($user->picture)
picture_html = '<span class="picture">';
picture_html += ' <a href="{{ url('uploads/' . $user->picture->id . '/download') }}">';
picture_html += ' <span id="download-picture" class="text-primary">';
picture_html += ' <i class="fa fa-file-{{ $user->picture->aggregate_type }}-o"></i> {{ $user->picture->basename }}';
picture_html += ' </span>';
picture_html += ' </a>';
picture_html += ' {!! Form::open(['id' => 'picture-' . $user->picture->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $user->picture->id)], 'style' => 'display:inline']) !!}';
picture_html += ' <a id="remove-picture" href="javascript:void();">';
picture_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
picture_html += ' </a>';
picture_html += ' {!! Form::close() !!}';
picture_html += '</span>';
$.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' => '<strong>' . $user->picture->basename . '</strong>', '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' => '<strong>' . $user->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
});
</script>

View File

@ -257,27 +257,24 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($bill->attachment)
placeholder : '<?php echo $bill->attachment->basename; ?>'
placeholder : '{{ $bill->attachment->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($bill->attachment)
attachment_html = '<span class="attachment">';
attachment_html += ' <a href="{{ url('uploads/' . $bill->attachment->id . '/download') }}">';
attachment_html += ' <span id="download-attachment" class="text-primary">';
attachment_html += ' <i class="fa fa-file-{{ $bill->attachment->aggregate_type }}-o"></i> {{ $bill->attachment->basename }}';
attachment_html += ' </span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $bill->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $bill->attachment->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
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);
$.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' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endif
@endpermission
$(document).on('click', '#button-add-item', function (e) {
$.ajax({

View File

@ -311,23 +311,8 @@
</div>
@if($bill->attachment)
<span class="attachment">
<a href="{{ url('uploads/' . $bill->attachment->id . '/download') }}">
<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>
@php $file = $bill->attachment; @endphp
@include('partials.media.file')
@endif
</div>
</div>
@ -446,11 +431,13 @@
@push('scripts')
<script type="text/javascript">
@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' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endif
@endpermission
$(document).on('click', '#button-payment', function (e) {
$('#modal-add-payment').remove();

View File

@ -137,31 +137,30 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($payment->attachment)
placeholder : '<?php echo $payment->attachment->basename; ?>'
placeholder : '{{ $payment->attachment->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($payment->attachment)
attachment_html = '<span class="attachment">';
attachment_html += ' <a href="{{ url('uploads/' . $payment->attachment->id . '/download') }}">';
attachment_html += ' <span id="download-attachment" class="text-primary">';
attachment_html += ' <i class="fa fa-file-{{ $payment->attachment->aggregate_type }}-o"></i> {{ $payment->attachment->basename }}';
attachment_html += ' </span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $payment->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $payment->attachment->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::close() !!}';
attachment_html += '</span>';
$.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' => '<strong>' . $payment->attachment->basename . '</strong>', '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' => '<strong>' . $payment->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
});

View File

@ -69,31 +69,30 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($vendor->logo)
placeholder : '<?php echo $vendor->logo->basename; ?>'
placeholder : '{{ $vendor->logo->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($vendor->logo)
logo_html = '<span class="logo">';
logo_html += ' <a href="{{ url('uploads/' . $vendor->logo->id . '/download') }}">';
logo_html += ' <span id="download-logo" class="text-primary">';
logo_html += ' <i class="fa fa-file-{{ $vendor->logo->aggregate_type }}-o"></i> {{ $vendor->logo->basename }}';
logo_html += ' </span>';
logo_html += ' </a>';
logo_html += ' {!! Form::open(['id' => 'logo-' . $vendor->logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $vendor->logo->id)], 'style' => 'display:inline']) !!}';
logo_html += ' <a id="remove-logo" href="javascript:void();">';
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);
$.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' => '<strong>' . $vendor->logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
});
</script>

View File

@ -257,27 +257,24 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($invoice->attachment)
placeholder : '<?php echo $invoice->attachment->basename; ?>'
placeholder : '{{ $invoice->attachment->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($invoice->attachment)
attachment_html = '<span class="attachment">';
attachment_html += ' <a href="{{ url('uploads/' . $invoice->attachment->id . '/download') }}">';
attachment_html += ' <span id="download-attachment" class="text-primary">';
attachment_html += ' <i class="fa fa-file-{{ $invoice->attachment->aggregate_type }}-o"></i> {{ $invoice->attachment->basename }}';
attachment_html += ' </span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $invoice->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $invoice->attachment->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
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);
$.ajax({
url: '{{ url('uploads/' . $invoice->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($invoice->attachment)
$(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') !!}");
});
@endif
@endpermission
$(document).on('click', '#button-add-item', function (e) {
$.ajax({

View File

@ -339,23 +339,8 @@
</div>
@if($invoice->attachment)
<span class="attachment">
<a href="{{ url('uploads/' . $invoice->attachment->id . '/download') }}">
<span id="download-attachment" class="text-primary">
<i class="fa fa-file-{{ $invoice->attachment->aggregate_type }}-o"></i> {{ $invoice->attachment->basename }}
</span>
</a>
{!! Form::open([
'id' => 'attachment-' . $invoice->attachment->id,
'method' => 'DELETE',
'url' => [url('uploads/' . $invoice->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>
@php $file = $invoice->attachment; @endphp
@include('partials.media.file')
@endif
</div>
</div>
@ -474,11 +459,13 @@
@push('scripts')
<script type="text/javascript">
@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' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endif
@endpermission
$(document).on('click', '#button-payment', function (e) {
$('#modal-add-payment').remove();

View File

@ -137,32 +137,31 @@
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($revenue->attachment)
placeholder : '<?php echo $revenue->attachment->basename; ?>'
placeholder : '{{ $revenue->attachment->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
});
@if($revenue->attachment)
attachment_html = '<span class="attachment">';
attachment_html += ' <a href="{{ url('uploads/' . $revenue->attachment->id . '/download') }}">';
attachment_html += ' <span id="download-attachment" class="text-primary">';
attachment_html += ' <i class="fa fa-file-{{ $revenue->attachment->aggregate_type }}-o"></i> {{ $revenue->attachment->basename }}';
attachment_html += ' </span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::open(['id' => 'attachment-' . $revenue->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $revenue->attachment->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">';
attachment_html += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
attachment_html += ' </a>';
attachment_html += ' {!! Form::close() !!}';
attachment_html += '</span>';
$.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' => '<strong>' . $revenue->attachment->basename . '</strong>', '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' => '<strong>' . $revenue->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endif
@endpermission
});
$(document).on('change', '#account_id', function (e) {

View File

@ -0,0 +1,53 @@
@php
$column_name = !empty($column_name) ? $column_name : 'attachment';
$options = !empty($options) ? $options : false;
@endphp
<ul class="mailbox-attachments clearfix margin-top">
<li>
@if ($file->aggregate_type != 'image')
<span class="mailbox-attachment-icon">
<i class="fa fa-file-{{ $file->aggregate_type }}-o"></i>
</span>
@else
<span class="mailbox-attachment-icon has-img">
<img src="{{ url('uploads/' . $file->id) }}" alt="{{ $file->basename }}">
</span>
@endif
<div class="mailbox-attachment-info">
<a href="javascript:void();" class="mailbox-attachment-name">
<p class="mailbox-attachment-file-name">
<i class="fa fa-paperclip"></i> {{ $file->basename }}
</p>
</a>
<span class="mailbox-attachment-size">
{{ $file->readableSize() }}
@permission('delete-common-uploads')
{!! Form::open([
'id' => $column_name. '-' . $file->id,
'method' => 'DELETE',
'url' => [url('uploads/' . $file->id)],
'style' => 'display:inline'
]) !!}
<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>
</a>
@if ($options)
<input type="hidden" name="page" value="{{ $options['page'] }}" />
<input type="hidden" name="key" value="{{ $options['key'] }}" />
<input type="hidden" name="value" value="{{ $file->id }}" />
@endif
{!! Form::close() !!}
@endpermission
<a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download">
<i class="fa fa-cloud-download"></i>
</a>
</span>
</div>
</li>
</ul>

View File

@ -0,0 +1,55 @@
@php
$column_name = !empty($column_name) ? $column_name : 'attachment';
$options = !empty($options) ? $options : false;
@endphp
<ul class="mailbox-attachments clearfix margin-top">
@foreach ($files as $file)
<li>
@if ($file->aggregate_type != 'image')
<span class="mailbox-attachment-icon">
<i class="fa fa-file-{{ $file->aggregate_type }}-o"></i>
</span>
@else
<span class="mailbox-attachment-icon has-img">
<img src="{{ url('uploads/' . $file->id) }}" alt="{{ $file->basename }}">
</span>
@endif
<div class="mailbox-attachment-info">
<a href="javascript:void();" class="mailbox-attachment-name">
<p class="mailbox-attachment-file-name">
<i class="fa fa-paperclip"></i> {{ $file->basename }}
</p>
</a>
<span class="mailbox-attachment-size">
{{ $file->readableSize() }}
@permission('delete-common-uploads')
{!! Form::open([
'id' => 'attachment-' . $file->id,
'method' => 'DELETE',
'url' => [url('uploads/' . $file->id)],
'style' => 'display:inline'
]) !!}
<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>
</a>
@if ($options)
<input type="hidden" name="page" value="{{ $options['page'] }}" />
<input type="hidden" name="key" value="{{ $options['key'] }}" />
<input type="hidden" name="value" value="{{ $file->id }}" />
@endif
{!! Form::close() !!}
@endpermission
<a href="{{ url('uploads/' . $file->id . '/download') }}" class="btn btn-info btn-xs pull-right mailbox-attachment-download">
<i class="fa fa-cloud-download"></i>
</a>
</span>
</div>
</li>
@endforeach
</ul>

View File

@ -246,27 +246,23 @@
});
@if($setting['company_logo'])
company_logo_html = '<span class="company_logo">';
company_logo_html += ' <a href="{{ url('uploads/' . $setting['company_logo']->id . '/download') }}">';
company_logo_html += ' <span id="download-company_logo" class="text-primary">';
company_logo_html += ' <i class="fa fa-file-{{ $setting['company_logo']->aggregate_type }}-o"></i> {{ $setting['company_logo']->basename }}';
company_logo_html += ' </span>';
company_logo_html += ' </a>';
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 += ' <a id="remove-company_logo" href="javascript:void();">';
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 }}" />';
company_logo_html += ' {!! Form::close() !!}';
company_logo_html += '</span>';
$('#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' => '<strong>' . $setting['company_logo']->basename . '</strong>', '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', page: 'setting', key: 'general.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' => '<strong>' . $setting['company_logo']->basename . '</strong>', '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 = '<span class="invoice_logo">';
invoice_logo_html += ' <a href="{{ url('uploads/' . $setting['invoice_logo']->id . '/download') }}">';
invoice_logo_html += ' <span id="download-invoice_logo" class="text-primary">';
invoice_logo_html += ' <i class="fa fa-file-{{ $setting['invoice_logo']->aggregate_type }}-o"></i> {{ $setting['invoice_logo']->basename }}';
invoice_logo_html += ' </span>';
invoice_logo_html += ' </a>';
invoice_logo_html += ' {!! Form::open(['id' => 'invoice_logo-' . $setting['invoice_logo']->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $setting['invoice_logo']->id)], 'style' => 'display:inline']) !!}';
invoice_logo_html += ' <a id="remove-invoice_logo" href="javascript:void();">';
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);
$.ajax({
url: '{{ url('uploads/' . $setting['invoice_logo']->id . '/show') }}',
type: 'GET',
data: {column_name: 'invoice_logo', page: 'setting', key: 'general.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' => '<strong>' . $setting['invoice_logo']->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
invoice_file = true;

View File

@ -116,27 +116,23 @@
});
@if($company->company_logo)
company_logo_html = '<span class="company_logo">';
company_logo_html += ' <a href="{{ url('uploads/' . $company->company_logo->id . '/download') }}">';
company_logo_html += ' <span id="download-company_logo" class="text-primary">';
company_logo_html += ' <i class="fa fa-file-{{ $company->company_logo->aggregate_type }}-o"></i> {{ $company->company_logo->basename }}';
company_logo_html += ' </span>';
company_logo_html += ' </a>';
company_logo_html += ' {!! Form::open(['id' => 'company_logo-' . $company->company_logo->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $company->company_logo->id)], 'style' => 'display:inline']) !!}';
company_logo_html += ' <a id="remove-company_logo" href="javascript:void();">';
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);
$.ajax({
url: '{{ url('uploads/' . $company->company_logo->id . '/show') }}',
type: 'GET',
data: {column_name: 'company_logo', page: 'setting', key: 'general.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' => '<strong>' . $company->company_logo->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
});
</script>

View File

@ -4,6 +4,7 @@ Route::group(['middleware' => 'language'], function () {
Route::group(['middleware' => 'auth'], function () {
Route::group(['prefix' => 'uploads'], function () {
Route::get('{id}', 'Common\Uploads@get');
Route::get('{id}/show', 'Common\Uploads@show');
Route::get('{id}/download', 'Common\Uploads@download');
});