79 lines
2.9 KiB
PHP
79 lines
2.9 KiB
PHP
|
@extends('layout.base')
|
||
|
|
||
|
@section('page_content')
|
||
|
<div class="ui container">
|
||
|
<h1 class="ui header">
|
||
|
Desistida - {{$venta->proyecto()->descripcion}} -
|
||
|
<a href="{{$urls->base}}/venta/{{$venta->id}}">
|
||
|
{{$venta->propiedad()->summary()}}
|
||
|
</a>
|
||
|
</h1>
|
||
|
<form class="ui form" id="desistida_form">
|
||
|
<div class="three wide field">
|
||
|
<label for="fecha">Fecha</label>
|
||
|
<div class="ui calendar" id="fecha">
|
||
|
<div class="ui left icon input">
|
||
|
<i class="calendar icon"></i>
|
||
|
<input type="text" />
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="three wide field">
|
||
|
<label for="devolucion">Devolución</label>
|
||
|
<div class="ui left labeled input">
|
||
|
<div class="ui basic label">$</div>
|
||
|
<input type="text" id="devolucion" value="{{$venta->resciliacion()->valor}}" />
|
||
|
</div>
|
||
|
</div>
|
||
|
</form>
|
||
|
</div>
|
||
|
@endsection
|
||
|
|
||
|
@push('page_scripts')
|
||
|
<script>
|
||
|
function alertResponse(message, color = 'green') {
|
||
|
$.toast({
|
||
|
message,
|
||
|
showProgress: 'bottom',
|
||
|
progressUp: true,
|
||
|
class: color,
|
||
|
showIcon: 'check circle',
|
||
|
classProgress: 'blue'
|
||
|
})
|
||
|
}
|
||
|
$(document).ready(() => {
|
||
|
const url = '{{$urls->api}}/ventas/pago/{{$venta->resciliacion()->id}}'
|
||
|
let old = new Date({{$venta->resciliacion()->fecha->format('Y')}},
|
||
|
{{$venta->resciliacion()->fecha->format('n')}}-1, {{$venta->resciliacion()->fecha->format('j')}})
|
||
|
calendar_date_options['initialDate'] = old
|
||
|
calendar_date_options['onChange'] = function(date, text, mode) {
|
||
|
if (date.getTime() === old.getTime()) {
|
||
|
return
|
||
|
}
|
||
|
const body = new FormData()
|
||
|
body.set('fecha', date.toISOString())
|
||
|
fetchAPI(url, {method: 'post', body}).then(response => {
|
||
|
if (!response) {
|
||
|
return
|
||
|
}
|
||
|
old = date
|
||
|
alertResponse('Fecha cambiada correctamente.')
|
||
|
})
|
||
|
}
|
||
|
$('#fecha').calendar(calendar_date_options)
|
||
|
$('#devolucion').change(event => {
|
||
|
console.debug(event)
|
||
|
const val = $(event.currentTarget).val()
|
||
|
const body = new FormData()
|
||
|
body.set('valor', val)
|
||
|
fetchAPI(url, {method: 'post', body}).then(response => {
|
||
|
if (!response) {
|
||
|
return
|
||
|
}
|
||
|
alertResponse('Devolución cambiada correctamente.')
|
||
|
})
|
||
|
})
|
||
|
})
|
||
|
</script>
|
||
|
@endpush
|