Servicio y vista
This commit is contained in:
@ -15,15 +15,15 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="proveedores">
|
||||
@foreach ($sociedades as $sociedad)
|
||||
@foreach ($proveedores as $proveedor)
|
||||
<tr>
|
||||
<td>{{$sociedad->nombre}}</td>
|
||||
<td>{{$sociedad->contacto->nombreCompleto()}}</td>
|
||||
<td>{{$proveedor->nombre}}</td>
|
||||
<td>{{$proveedor->contacto->nombreCompleto()}}</td>
|
||||
<td class="right aligned">
|
||||
<button class="ui icon button" data-sociedad="{{$sociedad->rut}}">
|
||||
<button class="ui icon button" data-sociedad="{{$proveedor->rut}}">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
<button class="ui red icon button" data-sociedad="{{$sociedad->rut}}">
|
||||
<button class="ui red icon button" data-sociedad="{{$proveedor->rut}}">
|
||||
<i class="remove icon"></i>
|
||||
</button>
|
||||
</td>
|
||||
@ -38,62 +38,53 @@
|
||||
<div class="three wide field">
|
||||
<label for="rut">RUT</label>
|
||||
<div class="ui right labeled input">
|
||||
<input class="right aligned" type="text" id="rut" name="rut" placeholder="RUT" maxlength="10" required />
|
||||
<input class="right aligned" type="text" id="rut" name="rut" placeholder="RUT" maxlength="10"
|
||||
required/>
|
||||
<div class="ui basic label">-<span id="dv"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="five wide field">
|
||||
<label for="nombre">Nombre</label>
|
||||
<input type="text" id="nombre" name="nombre" placeholder="Nombre" required />
|
||||
<input type="text" id="nombre" name="nombre" placeholder="Nombre" required/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="razon">Razón Social</label>
|
||||
<input type="text" id="razon" name="razon" placeholder="Razón Social" required />
|
||||
</div>
|
||||
<div class="four wide field">
|
||||
<label for="tipo">Tipo</label>
|
||||
<div class="ui selection dropdown" id="tipo">
|
||||
<input type="hidden" name="tipo" required />
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">Tipo</div>
|
||||
<div class="menu">
|
||||
@foreach ($tiposSociedades as $tipo)
|
||||
<div class="item" data-value="{{$tipo->id}}">{{$tipo->descripcion}}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
<input type="text" id="razon" name="razon" placeholder="Razón Social" required/>
|
||||
</div>
|
||||
<div class="ui divider">Contacto</div>
|
||||
<div class="three wide field">
|
||||
<label for="rut_contacto">RUT</label>
|
||||
<div class="ui right labeled input">
|
||||
<input type="text" id="rut_contacto" name="rut_contacto" placeholder="RUT" maxlength="10" required />
|
||||
<input type="text" id="rut_contacto" name="rut_contacto" placeholder="RUT" maxlength="10"
|
||||
required/>
|
||||
<div class="ui basic label">-<span id="dv_contacto"></span></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="fields">
|
||||
<div class="five wide field">
|
||||
<label for="nombre_contacto">Nombre</label>
|
||||
<input type="text" id="nombre_contacto" name="nombre_contacto" placeholder="Nombre" required />
|
||||
<input type="text" id="nombre_contacto" name="nombre_contacto" placeholder="Nombre" required/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apellido_paterno_contacto">Apellido Paterno</label>
|
||||
<input type="text" id="apellido_paterno_contacto" name="apellido_paterno_contacto" placeholder="Apellido Paterno" required />
|
||||
<input type="text" id="apellido_paterno_contacto" name="apellido_paterno_contacto"
|
||||
placeholder="Apellido Paterno" required/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="apellido_materno_contacto">Apellido Materno</label>
|
||||
<input type="text" id="apellido_materno_contacto" name="apellido_materno_contacto" placeholder="Apellido Materno" />
|
||||
<input type="text" id="apellido_materno_contacto" name="apellido_materno_contacto"
|
||||
placeholder="Apellido Materno"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="email_contacto">Email</label>
|
||||
<input type="email" id="email_contacto" name="email_contacto" placeholder="Email" />
|
||||
<input type="email" id="email_contacto" name="email_contacto" placeholder="Email"/>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="telefono_contacto">Teléfono</label>
|
||||
<div class="ui left labeled input">
|
||||
<div class="ui basic label">+56</div>
|
||||
<input type="text" id="telefono_contacto" name="telefono_contacto" placeholder="Teléfono" />
|
||||
<input type="text" id="telefono_contacto" name="telefono_contacto" placeholder="Teléfono"/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@ -133,7 +124,7 @@
|
||||
},
|
||||
proveedores: ''
|
||||
},
|
||||
data: JSON.parse('{!! json_encode($sociedades) !!}'),
|
||||
data: JSON.parse('{!! json_encode($proveedores) !!}'),
|
||||
add() {
|
||||
return {
|
||||
sociedad: () => {
|
||||
@ -175,7 +166,8 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
edit() {},
|
||||
edit() {
|
||||
},
|
||||
remove() {
|
||||
return {
|
||||
sociedad: rut => {
|
||||
@ -253,7 +245,7 @@
|
||||
}
|
||||
let suma = 0
|
||||
let mul = 2
|
||||
for (let i = rut.length-1; i >= 0; i--) {
|
||||
for (let i = rut.length - 1; i >= 0; i--) {
|
||||
suma += parseInt(rut[i]) * mul
|
||||
mul = (mul + 1) % 8 || 2
|
||||
}
|
||||
|
@ -11,17 +11,13 @@ use Incoviba\Service;
|
||||
class Proveedores
|
||||
{
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, View $view,
|
||||
Service\Sociedad $sociedadService,
|
||||
Service\Inmobiliaria\Proveedor $proveedorService,
|
||||
Repository\Inmobiliaria\TipoSociedad $tipoSociedad): ResponseInterface
|
||||
{
|
||||
$sociedades = [];
|
||||
$proveedores = [];
|
||||
try {
|
||||
$sociedades = $sociedadService->getAll('nombre');
|
||||
$proveedores = $proveedorService->getAll('nombre');
|
||||
} catch (EmptyResult) {}
|
||||
$tiposSociedades = [];
|
||||
try {
|
||||
$tiposSociedades = $tipoSociedad->fetchAll('descripcion');
|
||||
} catch (EmptyResult) {}
|
||||
return $view->render($response, 'inmobiliarias.proveedores', compact('sociedades', 'tiposSociedades'));
|
||||
return $view->render($response, 'inmobiliarias.proveedores', compact('proveedores'));
|
||||
}
|
||||
}
|
||||
|
35
app/src/Service/Inmobiliaria/Proveedor.php
Normal file
35
app/src/Service/Inmobiliaria/Proveedor.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Incoviba\Service\Inmobiliaria;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Repository;
|
||||
use Incoviba\Model;
|
||||
|
||||
class Proveedor extends Ideal\Service
|
||||
{
|
||||
public function __construct(LoggerInterface $logger, protected Repository\Inmobiliaria\Proveedor $proveedorRepository)
|
||||
{
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
public function getAll(?string $orderBy = null): array
|
||||
{
|
||||
try {
|
||||
return $this->proveedorRepository->fetchAll($orderBy);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
public function getByRut(int $proveedor_rut): ?Model\Inmobiliaria\Proveedor
|
||||
{
|
||||
try {
|
||||
return $this->proveedorRepository->fetchById($proveedor_rut);
|
||||
} catch (Implement\Exception\EmptyResult) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user