Cleanup logs, fixed add Venta, fixed search
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">Nueva Venta</h2>
|
||||
<form class="ui form" id="add_form" action="{{$urls->api}}/ventas/add" method="post">
|
||||
<form class="ui form" id="add_form" method="post">
|
||||
<label for="fecha_venta">Fecha de Venta</label>
|
||||
<div class="inline field">
|
||||
<div class="ui calendar" id="fecha_venta_calendar">
|
||||
@ -686,7 +686,7 @@
|
||||
$('<div></div>').addClass('content').append(tipo.charAt(0).toUpperCase() + tipo.slice(1) + ' ').append(
|
||||
unidad.draw(this.unidades[tipo])
|
||||
).append(
|
||||
$('<button></button>').addClass('ui icon button').attr('type', 'button').attr('data-number', number).append(
|
||||
$('<button></button>').addClass('ui basic red icon button').attr('type', 'button').attr('data-number', number).append(
|
||||
$('<i></i>').addClass('remove icon')
|
||||
).click(event => {
|
||||
const number = $(event.currentTarget).attr('data-number')
|
||||
@ -766,7 +766,7 @@
|
||||
}
|
||||
|
||||
function showErrors(errors) {
|
||||
console.debug(errors)
|
||||
console.error(errors)
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
@ -789,20 +789,21 @@
|
||||
|
||||
$('#add_form').submit(event => {
|
||||
event.preventDefault()
|
||||
const data = new FormData(event.currentTarget)
|
||||
const uri = $(event.currentTarget).attr('action')
|
||||
fetch(uri, {method: 'post', body: data}).then(response => {
|
||||
if (response.ok) {
|
||||
return response.json()
|
||||
const body = new FormData(event.currentTarget)
|
||||
const uri = '{{$urls->api}}/ventas/add'
|
||||
return fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return false
|
||||
}
|
||||
}).then(data => {
|
||||
if (data.status) {
|
||||
window.location = '{{$urls->base}}'
|
||||
return true
|
||||
}
|
||||
showErrors(data.errors)
|
||||
return response.json().then(data => {
|
||||
if (data.status) {
|
||||
window.location = '{{$urls->base}}/venta/' + data.venta_id
|
||||
return true
|
||||
}
|
||||
showErrors(data.errors)
|
||||
return false
|
||||
})
|
||||
})
|
||||
return false
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user