diff --git a/app/resources/routes/proyectos/brokers.php b/app/resources/routes/proyectos/brokers.php index 72e7a5e..718259f 100644 --- a/app/resources/routes/proyectos/brokers.php +++ b/app/resources/routes/proyectos/brokers.php @@ -4,3 +4,6 @@ use Incoviba\Controller\Proyectos\Brokers; $app->group('/brokers', function($app) { $app->get('[/]', Brokers::class); }); +$app->group('/broker/{broker_rut}', function($app) { + $app->get('[/]', [Brokers::class, 'show']); +}); diff --git a/app/resources/views/layout/head.blade.php b/app/resources/views/layout/head.blade.php index 98233b9..9d6c07f 100644 --- a/app/resources/views/layout/head.blade.php +++ b/app/resources/views/layout/head.blade.php @@ -1,9 +1,9 @@ @hasSection('page_title') - Incoviba - @yield('page_title') + Incoviba - @yield('page_title') @else - Incoviba + Incoviba @endif @include('layout.head.styles') diff --git a/app/resources/views/proyectos/brokers.blade.php b/app/resources/views/proyectos/brokers.blade.php index 00b8302..1472bc9 100644 --- a/app/resources/views/proyectos/brokers.blade.php +++ b/app/resources/views/proyectos/brokers.blade.php @@ -17,16 +17,20 @@ @foreach($brokers as $broker) - {{$broker->rutFull()}} data()?->legalName !== '') - data-tooltip="{{ $broker->data()?->legalName }}" data-position="right center" + @if ($broker->data()?->legalName !== '') + data-tooltip="{{ $broker->data()?->legalName }}" data-position="right center" @endif > - {{$broker->name}} + {{$broker->rutFull()}} + + + {{$broker->name}} + + data()?->representative?->email !== '' || $broker->data()?->representative?->phone !== '') @@ -40,7 +44,9 @@
@foreach($broker->contracts() as $contract) @endforeach
@@ -57,10 +63,23 @@ @endforeach @include('proyectos.brokers.add_modal') + @include('proyectos.brokers.edit_modal') @endsection @push('page_scripts') diff --git a/app/resources/views/proyectos/brokers/add_modal.blade.php b/app/resources/views/proyectos/brokers/add_modal.blade.php index 46a6ba6..f6821ef 100644 --- a/app/resources/views/proyectos/brokers/add_modal.blade.php +++ b/app/resources/views/proyectos/brokers/add_modal.blade.php @@ -18,7 +18,7 @@ -
+
@@ -55,19 +55,19 @@ @include('layout.body.scripts.rut') @push('page_scripts') @endpush diff --git a/app/resources/views/proyectos/brokers/base.blade.php b/app/resources/views/proyectos/brokers/base.blade.php index bd54fc5..ef52115 100644 --- a/app/resources/views/proyectos/brokers/base.blade.php +++ b/app/resources/views/proyectos/brokers/base.blade.php @@ -1,15 +1,22 @@ @extends('layout.base') @section('page_title') - Operadores @hasSection('brokers_title') - - @yield('brokers_title') + Operadores - @yield('brokers_title') + @else + Operadores @endif @endsection @section('page_content')
-

Operadores

+

+ @hasSection('brokers_header') + Operador - @yield('brokers_header') + @else + Operadores + @endif +

@yield('brokers_content')
@endsection diff --git a/app/resources/views/proyectos/brokers/edit_modal.blade.php b/app/resources/views/proyectos/brokers/edit_modal.blade.php new file mode 100644 index 0000000..c5aa4ea --- /dev/null +++ b/app/resources/views/proyectos/brokers/edit_modal.blade.php @@ -0,0 +1,111 @@ + + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/show.blade.php b/app/resources/views/proyectos/brokers/show.blade.php new file mode 100644 index 0000000..a300150 --- /dev/null +++ b/app/resources/views/proyectos/brokers/show.blade.php @@ -0,0 +1,165 @@ +@extends('proyectos.brokers.base') + +@section('brokers_title') + {{ $broker->name }} +@endsection + +@section('brokers_header') + {{ $broker->name }} +@endsection + +@section('brokers_content') +
+ RUT: {{ $broker->rutFull() }}
+ Razón Social: {{ $broker->data()?->legalName }} +
+ @if ($broker->data()?->representative->name !== null) +
+
+
+ Contacto +
+
+ Nombre: {{ $broker->data()?->representative?->name }}
+ Email: {{ $broker->data()?->representative?->email }}
+ Teléfono: {{ $broker->data()?->representative?->phone }}
+ Dirección: {{ $broker->data()?->representative?->address }} +
+
+
+ @endif + + + + + + + + + + + @foreach($broker->contracts() as $contract) + + + + + + + @endforeach + +
ProyectoComisiónFecha Inicio + +
{{ $contract->project->descripcion }}{{ $format->percent($contract->commission, 2, true) }}{{ $contract->current()->date->format('d-m-Y') }} + +
+ + @include('proyectos.brokers.show.add_modal') +@endsection + +@include('layout.body.scripts.datatables') + +@push('page_scripts') + +@endpush diff --git a/app/resources/views/proyectos/brokers/show/add_modal.blade.php b/app/resources/views/proyectos/brokers/show/add_modal.blade.php new file mode 100644 index 0000000..7b6bfd7 --- /dev/null +++ b/app/resources/views/proyectos/brokers/show/add_modal.blade.php @@ -0,0 +1,96 @@ + + +@push('page_scripts') + +@endpush diff --git a/app/src/Controller/Proyectos/Brokers.php b/app/src/Controller/Proyectos/Brokers.php index 8807c81..ea02e8c 100644 --- a/app/src/Controller/Proyectos/Brokers.php +++ b/app/src/Controller/Proyectos/Brokers.php @@ -1,23 +1,46 @@ getAll(); - } catch (Read) {} - return $view->render($response, 'proyectos.brokers', compact('brokers')); + $projects = $proyectoRepository->fetchAll('descripcion'); + } catch (EmptyResult $exception) { + $logger->error($exception); + } + $brokers = $brokerService->getAll(); + return $view->render($response, 'proyectos.brokers', compact('brokers', 'projects')); + } + public function show(ServerRequestInterface $request, ResponseInterface $response, LoggerInterface $logger, + Service\Proyecto\Broker $brokerService, Repository\Proyecto $proyectoRepository, + View $view, int $broker_rut): ResponseInterface + { + $broker = null; + try { + $broker = $brokerService->get($broker_rut); + } catch (Read $exception) { + $logger->error($exception); + } + $projects = []; + try { + $projects = $proyectoRepository->fetchAll('descripcion'); + } catch (EmptyResult $exception) { + $logger->error($exception); + } + return $view->render($response, 'proyectos.brokers.show', compact('broker', 'projects')); } } diff --git a/app/src/Model/Proyecto/Broker/Contract.php b/app/src/Model/Proyecto/Broker/Contract.php index 3d63ed3..ef8876b 100644 --- a/app/src/Model/Proyecto/Broker/Contract.php +++ b/app/src/Model/Proyecto/Broker/Contract.php @@ -9,9 +9,9 @@ class Contract extends Common\Ideal\Model public Model\Proyecto $project; public Model\Proyecto\Broker $broker; public float $commission; - protected array $states = []; + protected ?array $states; - public function states(): array + public function states(): ?array { if (!isset($this->states) or count($this->states) === 0) { $this->states = $this->runFactory('states'); @@ -20,7 +20,7 @@ class Contract extends Common\Ideal\Model } protected ?Contract\State $current; - public function currentState(): ?Contract\State + public function current(): ?Contract\State { if (!isset($this->current)) { try { @@ -39,7 +39,7 @@ class Contract extends Common\Ideal\Model 'broker_rut' => $this->broker->rut, 'commission' => $this->commission, 'states' => $this->states(), - 'current' => $this->currentState(), + 'current' => $this->current(), ]; } } diff --git a/app/src/Service/Format.php b/app/src/Service/Format.php index 4e6d4f8..c2119c5 100644 --- a/app/src/Service/Format.php +++ b/app/src/Service/Format.php @@ -6,12 +6,12 @@ use IntlDateFormatter; class Format { - public function localDate(string $valor, string $format, bool $print = false): string + public function localDate(string $valor, ?string $format = null, bool $print = false): string { $date = new DateTimeImmutable($valor); $formatter = new IntlDateFormatter('es_ES'); if ($format == null) { - $format = 'DD [de] MMMM [de] YYYY'; + $format = "dd 'de' MMMM 'de' YYYY"; } $formatter->setPattern($format); return $formatter->format($date); diff --git a/app/src/Service/Proyecto/Broker.php b/app/src/Service/Proyecto/Broker.php index b2d4aa1..c8829f8 100644 --- a/app/src/Service/Proyecto/Broker.php +++ b/app/src/Service/Proyecto/Broker.php @@ -17,7 +17,8 @@ class Broker extends Ideal\Service protected Repository\Proyecto\Broker $brokerRepository, protected Repository\Proyecto\Broker\Data $dataRepository, protected Repository\Proyecto\Broker\Contact $contactRepository, - protected Repository\Proyecto\Broker\Contract $contractRepository) + protected Repository\Proyecto\Broker\Contract $contractRepository, + protected Service\Proyecto\Broker\Contract $contractService) { parent::__construct($logger); } @@ -115,8 +116,8 @@ class Broker extends Ideal\Service ->setArgs(['broker_rut' => $broker->rut]) ->setCallable([$this->dataRepository, 'fetchByBroker'])) ->addFactory('contracts', (new Factory()) - ->setArgs(['brokerRut' => $broker->rut]) - ->setCallable([$this->contractRepository, 'fetchByBroker'])); + ->setArgs(['broker_rut' => $broker->rut]) + ->setCallable([$this->contractService, 'getByBroker'])); return $broker; } diff --git a/app/src/Service/Proyecto/Broker/Contract.php b/app/src/Service/Proyecto/Broker/Contract.php index 5695a43..40664af 100644 --- a/app/src/Service/Proyecto/Broker/Contract.php +++ b/app/src/Service/Proyecto/Broker/Contract.php @@ -118,7 +118,7 @@ class Contract extends Ideal\Service { try { $contract = $this->contractRepository->fetchById($id); - $this->contractRepository->remove($contract->id); + $this->contractRepository->remove($contract); return $contract; } catch (PDOException | Implement\Exception\EmptyResult $exception) { throw new ServiceAction\Delete(__CLASS__, $exception); @@ -145,9 +145,6 @@ class Contract extends Ideal\Service $contract->addFactory('states', (new Implement\Repository\Factory()) ->setCallable([$this->stateRepository, 'fetchByContract']) ->setArgs(['contract_id' => $contract->id])); - /*$contract->addFactory('currentState', (new Implement\Repository\Factory()) - ->setCallable([$this->stateRepository, 'fetchActiveByContract']) - ->setArgs(['contract_id' => $contract->id]));*/ return $contract; } }