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')
|
|
|
|
<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>
|
|
|
|
<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())
|
|
|
|
return fetchAPI(url, {method: 'post', body: data}).then(response => {
|
|
|
|
if (response.ok) {
|
|
|
|
return response.json()
|
|
|
|
}
|
|
|
|
}).then(json => {
|
|
|
|
if (!json.edited) {
|
|
|
|
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)
|
|
|
|
$('#edit_form').submit(event => {
|
|
|
|
event.preventDefault()
|
|
|
|
editEscritura()
|
|
|
|
return false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
@endpush
|