Edit fecha escritura
This commit is contained in:
6
app/resources/routes/api/ventas/escrituras.php
Normal file
6
app/resources/routes/api/ventas/escrituras.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\API\Ventas\Escrituras;
|
||||
|
||||
$app->group('/escritura/{venta_id}', function($app) {
|
||||
$app->post('/edit[/]', [Escrituras::class, 'edit']);
|
||||
});
|
6
app/resources/routes/ventas/escrituras.php
Normal file
6
app/resources/routes/ventas/escrituras.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Incoviba\Controller\Ventas\Escrituras;
|
||||
|
||||
$app->group('/escritura/{venta_id}', function($app) {
|
||||
$app->get('[/]', [Escrituras::class, 'show']);
|
||||
});
|
56
app/resources/views/ventas/escrituras/show.blade.php
Normal file
56
app/resources/views/ventas/escrituras/show.blade.php
Normal file
@ -0,0 +1,56 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">
|
||||
Escritura -
|
||||
{{$venta->proyecto()->descripcion}} -
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}">
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</a>
|
||||
</h2>
|
||||
<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" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button class="ui button">Guardar</button>
|
||||
</form>
|
||||
</div>
|
||||
@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
|
16
app/resources/views/ventas/estado/edit.blade.php
Normal file
16
app/resources/views/ventas/estado/edit.blade.php
Normal file
@ -0,0 +1,16 @@
|
||||
@extends('layout.base')
|
||||
|
||||
@section('page_content')
|
||||
<div class="ui container">
|
||||
<h2 class="ui header">
|
||||
Estado Venta -
|
||||
{{$venta->proyecto()->descripcion}} -
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}">
|
||||
{{$venta->propiedad()->summary()}}
|
||||
</a>
|
||||
</h2>
|
||||
<h3 class="ui sub header">
|
||||
{{$venta->currentEstado()->tipoEstadoVenta->descripcion}}
|
||||
</h3>
|
||||
</div>
|
||||
@endsection
|
@ -4,6 +4,11 @@
|
||||
@if (in_array($venta->currentEstado()->tipoEstadoVenta->descripcion, ['escriturando', 'firmado por inmobiliaria', 'archivado']))
|
||||
<div class="ui segment">
|
||||
Escriturado {{$venta->currentEstado()->fecha->format('d-m-Y')}}
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/ventas/escritura/{{$venta->id}}" class="ui icon link">
|
||||
<i class="small edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/informe">
|
||||
Informe
|
||||
<i class="right chevron icon"></i>
|
||||
|
@ -2,9 +2,11 @@
|
||||
<td>
|
||||
Bono Pie
|
||||
@if ($bonoPie !== null)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/bono_pie">
|
||||
<i class="edit button"></i>
|
||||
</a>
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/bono_pie">
|
||||
<i class="edit button"></i>
|
||||
</a>
|
||||
</sub>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/bono_pie/add">
|
||||
<i class="add icon"></i>
|
||||
|
@ -2,9 +2,11 @@
|
||||
<td>
|
||||
Crédito
|
||||
@if ($credito !== null)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/credito">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/credito">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/credito/add">
|
||||
<i class="plus icon"></i>
|
||||
|
@ -2,9 +2,11 @@
|
||||
<td>
|
||||
Escritura
|
||||
@if ($escritura !== null)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/add">
|
||||
<i class="plus icon"></i>
|
||||
|
@ -2,9 +2,11 @@
|
||||
<tr>
|
||||
<td>
|
||||
Pie
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
</td>
|
||||
<td></td>
|
||||
<td class="right aligned">{{$format->ufs($pie->valor)}}</td>
|
||||
|
@ -6,9 +6,11 @@
|
||||
>
|
||||
Subsidio
|
||||
@if ($subsidio !== null)
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/subsidio">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/subsidio">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/subsidio/add">
|
||||
<i class="plus icon"></i>
|
||||
|
38
app/src/Controller/API/Ventas/Escrituras.php
Normal file
38
app/src/Controller/API/Ventas/Escrituras.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Ventas;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Escrituras
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Service\Venta $ventaService, Repository\Venta\EstadoVenta $estadoVentaRepository,
|
||||
int $venta_id): ResponseInterface
|
||||
{
|
||||
$body = $request->getParsedBody();
|
||||
$output = [
|
||||
'venta_id' => $venta_id,
|
||||
'input' => $body,
|
||||
'edited' => false
|
||||
];
|
||||
try {
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
$estado = $venta->currentEstado();
|
||||
if (!in_array($estado->tipoEstadoVenta->descripcion, ['escriturando', 'firmado por inmobiliaria'])) {
|
||||
throw new EmptyResult('');
|
||||
}
|
||||
$body['fecha'] = (new DateTimeImmutable($body['fecha']))->format('Y-m-d');
|
||||
$estadoVentaRepository->edit($estado, $body);
|
||||
$output['edited'] = true;
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
16
app/src/Controller/Ventas/Escrituras.php
Normal file
16
app/src/Controller/Ventas/Escrituras.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Escrituras
|
||||
{
|
||||
public function show(ServerRequestInterface $request, ResponseInterface $response, View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.escrituras.show', compact('venta'));
|
||||
}
|
||||
}
|
17
app/src/Controller/Ventas/Estados.php
Normal file
17
app/src/Controller/Ventas/Estados.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\Ventas;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
use Incoviba\Service;
|
||||
|
||||
class Estados
|
||||
{
|
||||
public function edit(ServerRequestInterface $request, ResponseInterface $response,
|
||||
View $view, Service\Venta $ventaService, int $venta_id): ResponseInterface
|
||||
{
|
||||
$venta = $ventaService->getById($venta_id);
|
||||
return $view->render($response, 'ventas.estado', compact('venta'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user