2024-01-18 17:15:32 -03:00
|
|
|
@extends('ventas.base')
|
2023-12-04 21:43:57 -03:00
|
|
|
|
2024-01-18 17:15:32 -03:00
|
|
|
@section('venta_subtitle')
|
|
|
|
Escritura
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('venta_content')
|
2024-11-28 17:12:35 -03:00
|
|
|
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
|
|
|
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui small green button">Ver Cuotas</a>
|
|
|
|
<p>{{$format->pesos(array_reduce($venta->formaPago()->cuotas, function($sum, $cuota) {return $sum + $cuota->pago->valor;}, 0))}}</p>
|
|
|
|
<p>{{$format->ufs(array_reduce($venta->formaPago()->cuotas, function($sum, $cuota) {return $sum + $cuota->pago->valor();}, 0.0))}}</p>
|
|
|
|
@else
|
|
|
|
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas" class="ui small green button"><i class="plus icon"></i> Agregar Cuotas</a>
|
|
|
|
@endif
|
2024-01-18 17:15:32 -03:00
|
|
|
<form class="ui form" id="edit_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" placeholder="Fecha" />
|
2023-12-04 21:43:57 -03:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-18 17:15:32 -03:00
|
|
|
</div>
|
2024-11-28 17:12:35 -03:00
|
|
|
<div class="three wide field">
|
|
|
|
<label for="valor">Valor</label>
|
|
|
|
<div class="ui left labeled input">
|
|
|
|
<div class="ui basic label">$</div>
|
|
|
|
<input type="text" name="valor" value="{{$venta->formaPago()->escritura->pago->valor}}" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="three wide field">
|
|
|
|
<label>Estado</label>
|
|
|
|
<div class="ui selection dropdown" id="estado">
|
|
|
|
<input type="hidden" name="estado" />
|
|
|
|
<div class="default text">Estado</div>
|
|
|
|
<i class="dropdown icon"></i>
|
|
|
|
<div class="menu">
|
|
|
|
@foreach($estados as $estado)
|
|
|
|
<div class="item" data-value="{{$estado->id}}">{{ucwords($estado->descripcion)}}</div>
|
|
|
|
@endforeach
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-01-18 17:15:32 -03:00
|
|
|
<button class="ui button">Guardar</button>
|
|
|
|
</form>
|
2023-12-04 21:43:57 -03:00
|
|
|
@endsection
|
|
|
|
|
|
|
|
@push('page_scripts')
|
|
|
|
<script>
|
|
|
|
function editEscritura() {
|
|
|
|
const url = '{{$urls->api}}/ventas/escritura/{{$venta->id}}/edit'
|
|
|
|
const data = new FormData()
|
|
|
|
data.set('venta', {{$venta->id}})
|
|
|
|
const fecha = $('#fecha').calendar('get date')
|
|
|
|
data.set('fecha', fecha.toISOString())
|
2024-11-28 17:12:35 -03:00
|
|
|
data.set('estado', $('#estado').dropdown('get value'))
|
2023-12-04 21:43:57 -03:00
|
|
|
return fetchAPI(url, {method: 'post', body: data}).then(response => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.json()
|
|
|
|
}
|
|
|
|
}).then(json => {
|
2024-11-28 17:12:35 -03:00
|
|
|
if (!json.success) {
|
2023-12-04 21:43:57 -03:00
|
|
|
return
|
|
|
|
}
|
|
|
|
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
$(document).ready(() => {
|
|
|
|
calendar_date_options.initialDate = new Date({{$venta->currentEstado()->fecha->format('Y, m-1, j')}})
|
|
|
|
$('#fecha').calendar(calendar_date_options)
|
2024-11-28 17:12:35 -03:00
|
|
|
$('#estado').dropdown()
|
|
|
|
$('#estado').dropdown('set selected', '{{$venta->currentEstado()->id}}')
|
2023-12-04 21:43:57 -03:00
|
|
|
$('#edit_form').submit(event => {
|
|
|
|
event.preventDefault()
|
|
|
|
editEscritura()
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
@endpush
|