develop (#45)
Co-authored-by: Juan Pablo Vial <jpvialb@incoviba.cl> Reviewed-on: #45
This commit is contained in:
@ -3,9 +3,9 @@
|
||||
COMENTARIOS
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
<a href="javascript: addComment()" style="color: inherit;">
|
||||
<button class="ui icon button" style="background: none; color: inherit; padding: 0;" id="add_comentario_button">
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui segment">
|
||||
@ -13,37 +13,199 @@
|
||||
<tbody id="comentarios"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ui modal" id="addComment">
|
||||
<div class="header">
|
||||
Agregar Comentario
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form">
|
||||
<div class="three wide field">
|
||||
<label>Fecha</label>
|
||||
<div class="ui calendar" id="fecha">
|
||||
<div class="ui icon input">
|
||||
<input type="text" placeholder="Fecha">
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Comentario</label>
|
||||
<textarea id="comentario" rows="2"></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui black deny button">
|
||||
Cancelar
|
||||
</div>
|
||||
<div class="ui positive right labeled icon button">
|
||||
Agregar
|
||||
<i class="checkmark icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui modal" id="editComment">
|
||||
<div class="header">
|
||||
Edit Comentario
|
||||
</div>
|
||||
<div class="content">
|
||||
<form class="ui form">
|
||||
<input type="hidden" name="id" />
|
||||
<div class="three wide field">
|
||||
<label>Fecha</label>
|
||||
<div class="ui calendar" id="fechaEdit">
|
||||
<div class="ui icon input">
|
||||
<input type="text" placeholder="Fecha">
|
||||
<i class="calendar icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Comentario</label>
|
||||
<textarea id="comentarioEdit" rows="2"></textarea>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<div class="ui black deny button">
|
||||
Cancelar
|
||||
</div>
|
||||
<div class="ui positive right labeled icon button">
|
||||
Editar
|
||||
<i class="checkmark icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
class Comentario
|
||||
{
|
||||
<script>
|
||||
class Comentario {
|
||||
id
|
||||
fecha
|
||||
texto
|
||||
|
||||
constructor({fecha, texto})
|
||||
constructor({id, fecha, texto})
|
||||
{
|
||||
this.id = id
|
||||
this.fecha = new Date(fecha + 'T00:00:00')
|
||||
this.texto = texto
|
||||
}
|
||||
draw(dateFormatter)
|
||||
{
|
||||
return $('<tr></tr>').append(
|
||||
$('<td></td>').html(dateFormatter.format(this.fecha))
|
||||
).append(
|
||||
$('<td></td>').html(this.texto)
|
||||
).append(
|
||||
$('<td></td>').addClass('right aligned').append(
|
||||
$('<a></a>').attr('href', 'javascript: removeComment();').append(
|
||||
$('<i></i>').addClass('minus icon')
|
||||
)
|
||||
)
|
||||
)
|
||||
return [
|
||||
'<tr>',
|
||||
`<td class="collapsing">${dateFormatter.format(this.fecha)}</td>`,
|
||||
`<td>${this.texto}</td>`,
|
||||
'<td class="right aligned">',
|
||||
`<button class="ui tiny tertiary icon button editComentario" data-id="${this.id}">`,
|
||||
'<i class="edit icon"></i>',
|
||||
'</button>',
|
||||
`<button class="ui tiny tertiary red icon button removeComentario" data-id="${this.id}">`,
|
||||
'<i class="minus icon"></i>',
|
||||
'</button>',
|
||||
'</td>',
|
||||
'</tr>'
|
||||
].join("\n")
|
||||
}
|
||||
}
|
||||
class AddModal {
|
||||
props
|
||||
constructor({id}) {
|
||||
this.props = {
|
||||
id
|
||||
}
|
||||
$(this.props.id).modal({
|
||||
onApprove: () => {
|
||||
this.approve()
|
||||
}
|
||||
})
|
||||
const cdo = structuredClone(calendar_date_options)
|
||||
$(this.props.id).find('.ui.calendar').calendar(cdo)
|
||||
this.hide()
|
||||
}
|
||||
approve() {
|
||||
const fecha = $(this.props.id).find('#fecha').calendar('get date')
|
||||
const fechaString = [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-')
|
||||
const comentario = $(this.props.id).find('#comentario').val()
|
||||
const uri = '{{$urls->api}}/venta/{{$venta->id}}/comentarios/add'
|
||||
const body = new FormData()
|
||||
body.append('fecha', fechaString)
|
||||
body.append('texto', comentario)
|
||||
fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(data => {
|
||||
if (data.added) {
|
||||
comentarios.comentarios.push(new Comentario(data.comentario))
|
||||
comentarios.draw().comentarios()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
show() {
|
||||
const modal = $(this.props.id)
|
||||
modal.find('form').trigger('reset')
|
||||
modal.modal('show')
|
||||
}
|
||||
hide() {
|
||||
const modal = $(this.props.id)
|
||||
modal.modal('hide')
|
||||
}
|
||||
}
|
||||
class EditModal {
|
||||
props
|
||||
constructor({id}) {
|
||||
this.props = {
|
||||
id
|
||||
}
|
||||
$(this.props.id).modal({
|
||||
onApprove: () => {
|
||||
this.approve()
|
||||
}
|
||||
})
|
||||
const cdo = structuredClone(calendar_date_options)
|
||||
$(this.props.id).find('.ui.calendar').calendar(cdo)
|
||||
this.hide()
|
||||
}
|
||||
approve() {
|
||||
const id = $(this.props.id).find("[name='id']").val()
|
||||
const fecha = $(this.props.id).find('#fechaEdit').calendar('get date')
|
||||
const fechaString = [fecha.getFullYear(), fecha.getMonth()+1, fecha.getDate()].join('-')
|
||||
const comentario = $(this.props.id).find('#comentarioEdit').val()
|
||||
const uri = `{{$urls->api}}/ventas/comentario/${id}/edit`
|
||||
const body = new FormData()
|
||||
body.append('fecha', fechaString)
|
||||
body.append('texto', comentario)
|
||||
fetchAPI(uri, {method: 'post', body}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(data => {
|
||||
if (data.edited) {
|
||||
const idx = comentarios.comentarios.findIndex(comentario => comentario.id === data.comentario_id)
|
||||
comentarios.comentarios[idx] = new Comentario(data.comentario)
|
||||
comentarios.draw().comentarios()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
show() {
|
||||
const modal = $(this.props.id)
|
||||
modal.modal('show')
|
||||
}
|
||||
hide() {
|
||||
const modal = $(this.props.id)
|
||||
modal.modal('hide')
|
||||
}
|
||||
}
|
||||
const comentarios = {
|
||||
comentarios: [],
|
||||
id: '',
|
||||
modals: {
|
||||
add: null,
|
||||
edit: null
|
||||
},
|
||||
fetch: function() {
|
||||
return {
|
||||
comentarios: () => {
|
||||
@ -60,6 +222,7 @@
|
||||
this.comentarios.push(new Comentario(settings))
|
||||
})
|
||||
this.draw().comentarios()
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -73,11 +236,41 @@
|
||||
this.comentarios.forEach(comentario => {
|
||||
body.append(comentario.draw(dateFormatter))
|
||||
})
|
||||
$('.editComentario').on('click', event => {
|
||||
const id = $(event.currentTarget).data('id')
|
||||
const comentario = this.comentarios.find(comentario => comentario.id === id)
|
||||
const modal = this.modals.edit
|
||||
const fecha = new Date(comentario.fecha)
|
||||
$(modal.props.id).find("[name='id']").val(id)
|
||||
$(modal.props.id).find('#fechaEdit').calendar('set date', fecha)
|
||||
$(modal.props.id).find('#comentarioEdit').val(comentario.texto)
|
||||
modal.show()
|
||||
})
|
||||
$('.removeComentario').click(event => {
|
||||
const id = $(event.currentTarget).data('id')
|
||||
const uri = `{{$urls->api}}/ventas/comentario/${id}/remove`
|
||||
fetchAPI(uri, {method: 'delete'}).then(response => {
|
||||
if (!response) {
|
||||
return
|
||||
}
|
||||
return response.json().then(data => {
|
||||
if (data.removed) {
|
||||
this.comentarios = this.comentarios.filter(comentario => comentario.id !== id)
|
||||
this.draw().comentarios()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
setup: function(id) {
|
||||
this.id = id
|
||||
this.modals.add = new AddModal({id: '#addComment'})
|
||||
this.modals.edit = new EditModal({id: '#editComment'})
|
||||
$('#add_comentario_button').click(() => {
|
||||
this.modals.add.show()
|
||||
})
|
||||
this.fetch().comentarios()
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
<tr>
|
||||
<td>{{$format->ufs($venta->valor)}}</td>
|
||||
<td>{{$format->ufs($venta->util())}}</td>
|
||||
<td>{{$format->number($venta->util() / $venta->propiedad()->vendible(), 2)}} UF/m²</td>
|
||||
<td>{{($venta->propiedad()->vendible() > 0) ? $format->number($venta->util() / $venta->propiedad()->vendible(), 2) : 0}} UF/m²</td>
|
||||
<td>0,00 UF (0,00%)</td>
|
||||
<td>
|
||||
{{$venta->fecha->format('d-m-Y')}}<br/>
|
||||
|
@ -18,8 +18,8 @@
|
||||
Firmar
|
||||
</a>
|
||||
<br />
|
||||
<a href="{{$urls->base}}/ventas/factura/{{$venta->id}}">
|
||||
Factura
|
||||
<a href="{{$urls->base}}/ventas/factura/{{$venta->id}}" class="ui icon link">
|
||||
Factura<i class="small file alternate outline icon"></i>
|
||||
</a>
|
||||
</div>
|
||||
@else
|
||||
|
@ -33,7 +33,7 @@
|
||||
</div>
|
||||
|
||||
@push('page_scripts')
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
class Anchor
|
||||
{
|
||||
classes
|
||||
|
@ -1,6 +1,6 @@
|
||||
<tr>
|
||||
<td><strong>Anticipo</strong></td>
|
||||
<td></td>
|
||||
<td>{{ $format->percent($anticipo['uf'] / $venta->valor, 2, true) }}</td>
|
||||
<td class="right aligned"><strong>{{$format->ufs($anticipo['uf'])}}</strong></td>
|
||||
<td class="right aligned"><strong>{{$format->pesos($anticipo['pesos'])}}</strong></td>
|
||||
<td colspan="2"></td>
|
||||
|
@ -4,7 +4,7 @@
|
||||
@if ($bonoPie !== null)
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/bono_pie">
|
||||
<i class="edit button"></i>
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
@else
|
||||
@ -14,7 +14,7 @@
|
||||
@endif
|
||||
</td>
|
||||
@if ($bonoPie !== null)
|
||||
<td></td>
|
||||
<td>{{ $format->percent($bonoPie->pago->valor() / $venta->valor, 2, true) }}</td>
|
||||
<td class="right aligned">{{$format->ufs($bonoPie->pago->valor())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($bonoPie->pago->valor)}}</td>
|
||||
<td colspan="2"></td>
|
||||
|
@ -14,7 +14,7 @@
|
||||
@endif
|
||||
</td>
|
||||
@if ($credito !== null)
|
||||
<td></td>
|
||||
<td>{{ $format->percent($credito->pago->valor() / $venta->valor, 2, true) }}</td>
|
||||
<td class="right aligned">
|
||||
{{$format->ufs($credito->pago->valor())}}
|
||||
</td>
|
||||
|
@ -15,8 +15,18 @@
|
||||
</td>
|
||||
@if ($escritura !== null)
|
||||
<td></td>
|
||||
<td class="right aligned">{{$format->ufs($escritura->pago->valor())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($escritura->pago->valor)}}</td>
|
||||
<td class="right aligned">
|
||||
{{$format->ufs($escritura->pago->valor())}}
|
||||
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
||||
<br /> + (<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas">{{$format->ufs($venta->formaPago()->cuotasAbono())}}</a>)
|
||||
@endif
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
{{$format->pesos($escritura->pago->valor)}}
|
||||
@if (count($venta->formaPago()->cuotasAbono) > 0)
|
||||
<br /> + (<a href="{{$urls->base}}/venta/{{$venta->id}}/escritura/cuotas">{{$format->pesos($venta->formaPago()->cuotasAbono('pesos'))}}</a>)
|
||||
@endif
|
||||
</td>
|
||||
<td id="escritura_pago" class="{{$escritura->pago->currentEstado->tipoEstadoPago->descripcion === 'no pagado' ? 'warning' : ($escritura->pago->currentEstado->tipoEstadoPago->descripcion === 'depositado' ? 'positive' : '')}}">
|
||||
<span class="text">{{$escritura->pago->currentEstado->fecha->format('d-m-Y')}}</span>
|
||||
@if ($escritura->pago->currentEstado->tipoEstadoPago->descripcion === 'no pagado')
|
||||
|
@ -1,42 +1,52 @@
|
||||
@if ($pie !== null)
|
||||
<tr>
|
||||
<td>
|
||||
Pie
|
||||
<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>
|
||||
<td class="right aligned">{{$format->pesos($pie->valor * $pie->uf)}}</td>
|
||||
<td class="right aligned">Cuotas</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
|
||||
<span data-tooltip="Pagadas">{{count($pie->cuotas(true))}}</span>/{{$pie->cuotas}}
|
||||
</a>
|
||||
@if (count($pie->cuotas(false, true)) < $pie->cuotas)
|
||||
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
|
||||
@if ($pie !== null)
|
||||
<sub>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie">
|
||||
<i class="edit icon"></i>
|
||||
</a>
|
||||
</sub>
|
||||
@else
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/add">
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
@endif
|
||||
</td>
|
||||
@if ($pie !== null)
|
||||
<td>{{ $format->percent($pie->valor / $venta->valor, 2, true) }}</td>
|
||||
<td class="right aligned">{{$format->ufs($pie->valor)}}</td>
|
||||
<td class="right aligned">{{$format->pesos($pie->valor * $pie->uf)}}</td>
|
||||
<td class="right aligned">Cuotas</td>
|
||||
<td>
|
||||
<a href="{{$urls->base}}/venta/{{$venta->id}}/pie/cuotas">
|
||||
<span data-tooltip="Pagadas">{{count($pie->cuotas(true, true))}}</span>/{{$pie->cuotas}}
|
||||
</a>
|
||||
@if (count($pie->cuotas(vigentes: true)) < $pie->cuotas)
|
||||
<a href="{{$urls->base}}/ventas/pie/{{$pie->id}}/cuotas/add">
|
||||
<i class="plus icon"></i>
|
||||
</a>
|
||||
@endif
|
||||
</td>
|
||||
@else
|
||||
<td colspan="4"></td>
|
||||
@endif
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Pagado</td>
|
||||
<td></td>
|
||||
<td class="right aligned">{{$format->ufs($pie->pagado())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($pie->pagado('pesos'))}}</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
@if ($pie->reajuste)
|
||||
<tr>
|
||||
<td>Reajuste</td>
|
||||
<td></td>
|
||||
<td class="right aligned">{{$format->ufs($pie->reajuste->valor())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($pie->reajuste->valor)}}</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
@endif
|
||||
@if ($pie !== null)
|
||||
<tr>
|
||||
<td>Pagado</td>
|
||||
<td>{{$format->percent($pie->pagado() / $venta->valor, 2, true)}}</td>
|
||||
<td class="right aligned">{{$format->ufs($pie->pagado())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($pie->pagado('pesos'))}}</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
@if ($pie->reajuste)
|
||||
<tr>
|
||||
<td>Reajuste</td>
|
||||
<td></td>
|
||||
<td class="right aligned">{{$format->ufs($pie->reajuste->valor())}}</td>
|
||||
<td class="right aligned">{{$format->pesos($pie->reajuste->valor)}}</td>
|
||||
<td colspan="2"></td>
|
||||
</tr>
|
||||
@endif
|
||||
@endif
|
||||
|
@ -50,7 +50,7 @@
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
@if ($unidad->proyectoTipoUnidad->tipoUnidad->descripcion === 'departamento')
|
||||
{{$format->number(($unidad->valor ?? $precio) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||
{{$format->number((($unidad->valor === null or $unidad->valor === 0.0) ? $precio : $unidad->valor) / $unidad->proyectoTipoUnidad->vendible(), 2)}} UF/m²
|
||||
@endif
|
||||
</td>
|
||||
<td class="center aligned">
|
||||
|
Reference in New Issue
Block a user