Other file added

This commit is contained in:
cuneytsenturk 2018-01-02 18:20:52 +03:00
parent dd686409ef
commit 675b1ba42a
11 changed files with 181 additions and 10 deletions

View File

@ -7,10 +7,11 @@ use App\Traits\Currencies;
use App\Traits\DateTime; use App\Traits\DateTime;
use Bkwld\Cloner\Cloneable; use Bkwld\Cloner\Cloneable;
use Sofa\Eloquence\Eloquence; use Sofa\Eloquence\Eloquence;
use Plank\Mediable\Mediable;
class Bill extends Model class Bill extends Model
{ {
use Cloneable, Currencies, DateTime, Eloquence; use Cloneable, Currencies, DateTime, Eloquence, Mediable;
protected $table = 'bills'; protected $table = 'bills';
@ -128,4 +129,18 @@ class Bill extends Model
{ {
$this->attributes['currency_rate'] = (double) $value; $this->attributes['currency_rate'] = (double) $value;
} }
/**
* Get the current balance.
*
* @return string
*/
public function getAttachmentAttribute()
{
if (!$this->hasMedia('attachment')) {
return false;
}
return $this->getMedia('attachment')->last();
}
} }

View File

@ -5,10 +5,11 @@ namespace App\Models\Expense;
use App\Models\Model; use App\Models\Model;
use App\Traits\Currencies; use App\Traits\Currencies;
use App\Traits\DateTime; use App\Traits\DateTime;
use Plank\Mediable\Mediable;
class BillPayment extends Model class BillPayment extends Model
{ {
use Currencies, DateTime; use Currencies, DateTime, Mediable;
protected $table = 'bill_payments'; protected $table = 'bill_payments';
@ -78,4 +79,18 @@ class BillPayment extends Model
{ {
return $query->sum('amount'); return $query->sum('amount');
} }
/**
* Get the current balance.
*
* @return string
*/
public function getAttachmentAttribute()
{
if (!$this->hasMedia('attachment')) {
return false;
}
return $this->getMedia('attachment')->last();
}
} }

View File

@ -7,10 +7,11 @@ use App\Traits\Currencies;
use App\Traits\DateTime; use App\Traits\DateTime;
use Bkwld\Cloner\Cloneable; use Bkwld\Cloner\Cloneable;
use Sofa\Eloquence\Eloquence; use Sofa\Eloquence\Eloquence;
use Plank\Mediable\Mediable;
class Payment extends Model class Payment extends Model
{ {
use Cloneable, Currencies, DateTime, Eloquence; use Cloneable, Currencies, DateTime, Eloquence, Mediable;
protected $table = 'payments'; protected $table = 'payments';
@ -91,4 +92,18 @@ class Payment extends Model
{ {
return $query->orderBy('paid_at', 'desc'); return $query->orderBy('paid_at', 'desc');
} }
/**
* Get the current balance.
*
* @return string
*/
public function getAttachmentAttribute()
{
if (!$this->hasMedia('attachment')) {
return false;
}
return $this->getMedia('attachment')->last();
}
} }

View File

@ -5,10 +5,11 @@ namespace App\Models\Income;
use App\Models\Model; use App\Models\Model;
use App\Traits\Currencies; use App\Traits\Currencies;
use App\Traits\DateTime; use App\Traits\DateTime;
use Plank\Mediable\Mediable;
class InvoicePayment extends Model class InvoicePayment extends Model
{ {
use Currencies, DateTime; use Currencies, DateTime, Mediable;
protected $table = 'invoice_payments'; protected $table = 'invoice_payments';
@ -78,4 +79,18 @@ class InvoicePayment extends Model
{ {
return $query->sum('amount'); return $query->sum('amount');
} }
/**
* Get the current balance.
*
* @return string
*/
public function getAttachmentAttribute()
{
if (!$this->hasMedia('attachment')) {
return false;
}
return $this->getMedia('attachment')->last();
}
} }

View File

@ -7,10 +7,11 @@ use App\Traits\Currencies;
use App\Traits\DateTime; use App\Traits\DateTime;
use Bkwld\Cloner\Cloneable; use Bkwld\Cloner\Cloneable;
use Sofa\Eloquence\Eloquence; use Sofa\Eloquence\Eloquence;
use Plank\Mediable\Mediable;
class Revenue extends Model class Revenue extends Model
{ {
use Cloneable, Currencies, DateTime, Eloquence; use Cloneable, Currencies, DateTime, Eloquence, Mediable;
protected $table = 'revenues'; protected $table = 'revenues';
@ -97,4 +98,18 @@ class Revenue extends Model
{ {
return $query->orderBy('paid_at', 'desc'); return $query->orderBy('paid_at', 'desc');
} }
/**
* Get the current balance.
*
* @return string
*/
public function getAttachmentAttribute()
{
if (!$this->hasMedia('attachment')) {
return false;
}
return $this->getMedia('attachment')->last();
}
} }

View File

@ -204,9 +204,32 @@
$('#attachment').fancyfile({ $('#attachment').fancyfile({
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
placeholder : '<?php echo $bill->attachment; ?>' @if($bill->attachment)
placeholder : '<?php echo $bill->attachment->basename; ?>'
@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);
$(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
var autocomplete_path = "{{ url('items/items/autocomplete') }}"; var autocomplete_path = "{{ url('items/items/autocomplete') }}";
$(document).on('click', '.form-control.typeahead', function() { $(document).on('click', '.form-control.typeahead', function() {

View File

@ -167,6 +167,26 @@
@endpermission @endpermission
</ul> </ul>
</div> </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>
@endif
</div> </div>
</div> </div>
</div> </div>
@ -403,6 +423,11 @@
$('#email-modal').modal('show'); $('#email-modal').modal('show');
}); });
@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
}); });
function addPayment() { function addPayment() {

View File

@ -92,9 +92,32 @@
$('#attachment').fancyfile({ $('#attachment').fancyfile({
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
placeholder : '<?php echo ($payment->attachment) ? $payment->attachment : trans('general.form.no_file_selected'); ?>' @if($payment->attachment)
placeholder : '<?php echo $payment->attachment->basename; ?>'
@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>';
$('.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') !!}");
});
@endif
$(document).on('change', '#account_id', function (e) { $(document).on('change', '#account_id', function (e) {
$.ajax({ $.ajax({
url: '{{ url("settings/currencies/currency") }}', url: '{{ url("settings/currencies/currency") }}',

View File

@ -216,7 +216,6 @@
attachment_html += ' </span>'; attachment_html += ' </span>';
attachment_html += ' </a>'; 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 += ' {!! Form::open(['id' => 'attachment-' . $invoice->attachment->id, 'method' => 'DELETE', 'url' => [url('uploads/' . $invoice->attachment->id)], 'style' => 'display:inline']) !!}';
attachment_html += ' {{ Form::hidden('id', $invoice->id) }}';
attachment_html += ' <a id="remove-attachment" href="javascript:void();">'; 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 += ' <span class="text-danger"><i class="fa fa fa-times"></i></span>';
attachment_html += ' </a>'; attachment_html += ' </a>';
@ -224,6 +223,10 @@
attachment_html += '</span>'; attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html); $('.fancy-file .fake-file').append(attachment_html);
$(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 @endif
var autocomplete_path = "{{ url('items/items/autocomplete') }}"; var autocomplete_path = "{{ url('items/items/autocomplete') }}";

View File

@ -192,7 +192,6 @@
'url' => [url('uploads/' . $invoice->attachment->id)], 'url' => [url('uploads/' . $invoice->attachment->id)],
'style' => 'display:inline' 'style' => 'display:inline'
]) !!} ]) !!}
{{ Form::hidden('id', $invoice->id) }}
<a id="remove-attachment" href="javascript:void();"> <a id="remove-attachment" href="javascript:void();">
<span class="text-danger"><i class="fa fa fa-times"></i></span> <span class="text-danger"><i class="fa fa fa-times"></i></span>
</a> </a>

View File

@ -92,9 +92,32 @@
$('#attachment').fancyfile({ $('#attachment').fancyfile({
text : '{{ trans('general.form.select.file') }}', text : '{{ trans('general.form.select.file') }}',
style : 'btn-default', style : 'btn-default',
placeholder : '<?php echo $revenue->attachment; ?>' @if($revenue->attachment)
placeholder : '<?php echo $revenue->attachment->basename; ?>'
@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>';
$('.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') !!}");
});
@endif
$(document).on('change', '#account_id', function (e) { $(document).on('change', '#account_id', function (e) {
$.ajax({ $.ajax({
url: '{{ url("settings/currencies/currency") }}', url: '{{ url("settings/currencies/currency") }}',