Implementacion agregar abono a escritura
This commit is contained in:
@ -28,6 +28,9 @@ $app->group('/venta/{venta_id:[0-9]+}', function($app) {
|
||||
});
|
||||
$app->get('[/]', [Ventas::class, 'pie']);
|
||||
});
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->get('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->get('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->get('/desistir[/]', [Ventas::class, 'desistir']);
|
||||
$app->get('/desistida[/]', [Ventas::class, 'desistida']);
|
||||
|
@ -19,11 +19,17 @@ $app->group('/ventas', function($app) {
|
||||
$app->group('/escrituras', function($app) {
|
||||
$app->post('/estados[/]', [Ventas::class, 'escrituras']);
|
||||
});
|
||||
$app->group('/by', function($app) {
|
||||
$app->get('/unidad/{unidad_id}', [Ventas::class, 'unidad']);
|
||||
});
|
||||
$app->post('[/]', [Ventas::class, 'proyecto']);
|
||||
});
|
||||
$app->group('/venta/{venta_id}', function($app) {
|
||||
$app->get('/unidades[/]', [Ventas::class, 'unidades']);
|
||||
$app->get('/comentarios[/]', [Ventas::class, 'comentarios']);
|
||||
$app->group('/escritura', function($app) {
|
||||
$app->post('/add[/]', [Ventas\Escrituras::class, 'add']);
|
||||
});
|
||||
$app->post('/escriturar[/]', [Ventas::class, 'escriturar']);
|
||||
$app->group('/desistir', function($app) {
|
||||
$app->get('/eliminar[/]', [Ventas::class, 'insistir']);
|
||||
|
153
app/resources/views/ventas/escrituras/add.blade.php
Normal file
153
app/resources/views/ventas/escrituras/add.blade.php
Normal file
@ -0,0 +1,153 @@
|
||||
@extends('ventas.base')
|
||||
|
||||
@section('venta_subtitle')
|
||||
Agregar Abono en Escritura
|
||||
@endsection
|
||||
|
||||
@section('venta_content')
|
||||
<div class="ui basic segment">
|
||||
<p>Valor Promesa {{$format->ufs($venta->valor)}}</p>
|
||||
@if (isset($venta->formaPago()->pie))
|
||||
<p>Valor Anticipo {{$format->ufs($venta->formaPago()->pie->valor)}}</p>
|
||||
@endif
|
||||
@if (isset($venta->formaPago()->credito))
|
||||
<p>Crédito {{$format->ufs($venta->formaPago()->credito->pago->valor())}}</p>
|
||||
@endif
|
||||
</div>
|
||||
<form class="ui form" id="add_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" name="fecha" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label for="valor">Valor</label>
|
||||
<div class="ui labeled input" id="valor">
|
||||
<div class="ui basic label">$</div>
|
||||
<input type="text" name="valor" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui checkbox" id="uf">
|
||||
<input type="checkbox" name="uf" />
|
||||
<label>Valor en UFs</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="three wide field">
|
||||
<label for="bancos">Banco</label>
|
||||
<div class="ui search selection dropdown" id="bancos">
|
||||
<input type="hidden" name="banco" />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Banco</div>
|
||||
<div class="menu">
|
||||
@foreach ($bancos as $banco)
|
||||
<div class="item" data-value="{{$banco->id}}">{{$banco->nombre}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="tipo" value="1" checked="checked" />
|
||||
<label>Cheque</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" name="tipo" value="3" />
|
||||
<label>Vale Vista</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button">Agregar</button>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@push('page_scripts')
|
||||
<script>
|
||||
const escritura = {
|
||||
ids: {},
|
||||
add() {
|
||||
return {
|
||||
escritura: event => {
|
||||
event.preventDefault()
|
||||
const body = new FormData(event.currentTarget)
|
||||
const fecha = $(this.ids.fecha).calendar('get date')
|
||||
body.set('fecha', [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-'))
|
||||
const status = $(this.ids.checkbox).checkbox('is checked')
|
||||
body.set('uf', status)
|
||||
|
||||
const url = '{{$urls->api}}/venta/{{$venta->id}}/escritura/add'
|
||||
fetchAPI(url, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(json => {
|
||||
if (json.status) {
|
||||
window.location = '{{$urls->base}}/venta/{{$venta->id}}'
|
||||
}
|
||||
})
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
},
|
||||
toggle() {
|
||||
return {
|
||||
checkbox: () => {
|
||||
const status = $(this.ids.checkbox).checkbox('is checked')
|
||||
if (status) {
|
||||
return this.toggle().uf()
|
||||
}
|
||||
return this.toggle().pesos()
|
||||
},
|
||||
uf: () => {
|
||||
const valor = $(this.ids.valor)
|
||||
valor.attr('class', 'ui right labeled input')
|
||||
valor.find('.label').remove()
|
||||
valor.append(
|
||||
$('<div></div>').addClass('ui basic label').html('UF')
|
||||
)
|
||||
},
|
||||
pesos: () => {
|
||||
const valor = $(this.ids.valor)
|
||||
valor.attr('class', 'ui labeled input')
|
||||
valor.find('.label').remove()
|
||||
valor.prepend(
|
||||
$('<div></div>').addClass('ui basic label').html('$')
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(ids) {
|
||||
this.ids = ids
|
||||
|
||||
$(this.ids.fecha).calendar(calendar_date_options)
|
||||
$(this.ids.checkbox).checkbox({
|
||||
fireOnInit: true,
|
||||
onChange: this.toggle().checkbox
|
||||
})
|
||||
$(this.ids.bancos).dropdown()
|
||||
$(this.ids.form).submit(this.add().escritura)
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
escritura.setup({
|
||||
form: '#add_form',
|
||||
fecha: '#fecha',
|
||||
checkbox: '#uf',
|
||||
valor: '#valor',
|
||||
bancos: '#bancos'
|
||||
})
|
||||
})
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user