Files
intranet/resources/views/ventas/precios/add.blade.php
2020-12-01 17:23:13 -03:00

131 lines
4.8 KiB
PHP

@extends('layout.base')
@section('content')
<div class="page-heading">
<h3>Agregar Precios - {{$proyecto->descripcion}}</h3>
</div>
<br />
<form class="form-horizontal" method="post" action="{{nUrl('precios', 'agregar', ['proyecto' => $proyecto->id])}}">
<div class="form-group">
<div class="col-md-2">Fecha</div>
@include('form.fecha')
</div>
<table class="table">
<thead>
<tr>
<th rowspan="2" style="vertical-align: middle;">Tipo</th>
<th rowspan="2">Nombre</th>
<th rowspan="2">Abreviaci&oacute;n</th>
<th rowspan="2">L&iacute;neas</th>
<th rowspan="2">m&#0178; Vendible</th>
<th rowspan="2">#</th>
<th colspan="2">Precio</th>
</tr>
<tr>
<th>Anterior</th>
<th>Nuevo</th>
</tr>
</thead>
<tbody id="tipo_unidades">
@foreach ($proyecto->proyectoTipoUnidades() as $tipo)
<tr class="show-unidades" data-status="closed" data-tipo="{{$tipo->id}}">
<td>{{ucwords($tipo->tipo()->descripcion)}}</td>
<td>{{$tipo->nombre}}</td>
<td>{{$tipo->abreviacion}}</td>
<td>{{$tipo->lineas()}}</td>
<td>{{$tipo->m2()}}</td>
<td>{{count($tipo->unidades())}}</td>
<td>{{format('ufs', $tipo->precio(), true)}}</td>
<td><input type="text" name="precio_tipo:{{$tipo->id}}" class="form-control" /></td>
</tr>
<tr class="unidades" data-tipo="{{$tipo->id}}">
<td></td>
<td colspan="7">
<table class="table table-striped">
<thead>
<tr>
<th>Descripci&oacute;n</th>
<th>Piso</th>
<th>L&iacute;nea</th>
<th>Orientaci&oacute;n</th>
<th colspan="2">Precio</th>
</tr>
<tr>
<th colspan="4"></th>
<th>Anterior</th>
<th>Nuevo</th>
</tr>
</thead>
<tbody>
<?php $subtipo = ''; ?>
@foreach ($tipo->unidades() as $unidad)
@if ($subtipo != $unidad->subtipo)
<?php $subtipo = $unidad->subtipo; ?>
<tr data-id="{{$subtipo}}" data-status="closed" class="subtipo">
<th colspan="4">L&iacute;nea {{$subtipo}}</th>
<th>{{format('ufs', $tipo->precioSubtipo($subtipo), true)}}</th>
<th><input type="text" name="precio_sub:{{$tipo->id}}-{{$subtipo}}" class="form-control" /></th>
</tr>
@endif
<tr>
<td>{{$unidad->descripcion}}</td>
<td>{{$unidad->piso}}</td>
<td>{{$unidad->subtipo}}</td>
<td>{{$unidad->orientacion}}</td>
<td>
@if ($unidad->precio())
{{format('ufs', $unidad->precio()->valor, true)}}
@else
--
@endif
</td>
<td><input type="text" name="precio:{{$tipo->id}}-{{$subtipo}}-{{$unidad->id}}" class="form-control" /></td>
</tr>
@endforeach
</tbody>
</table>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="form-group">
<div class="col-md-offset-2 col-md-2"><button class="form-control" type="submit">Agregar</button></div>
</div>
</form>
@endsection
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
$('.unidades').hide()
$('.show-unidades').click(function(e) {
var id = $(this).attr('data-tipo')
var status = $(this).attr('data-status')
if (status == 'open') {
$(".unidades[data-tipo='" + id + "']").hide()
$(this).attr('data-status', 'closed')
} else {
$(".unidades[data-tipo='" + id + "']").show()
if ($(".unidades[data-tipo='" + id + "']").find('.subtipo').length > 0) {
$(".unidades[data-tipo='" + id + "']").find('tbody tr').hide()
$(".unidades[data-tipo='" + id + "']").find('.subtipo').show()
}
$(this).attr('data-status', 'open')
}
})
$('.subtipo').click(function(e) {
var id = $(this).attr('data-id')
var status = $(this).attr('data-status')
if (status == 'open') {
$(this).nextUntil('.subtipo').hide()
$(this).attr('data-status', 'closed')
} else {
$(this).nextUntil('.subtipo').show()
$(this).attr('data-status', 'open')
}
})
})
</script>
@endpush