Compare commits
8 Commits
7a97fc9dfe
...
da46914de4
Author | SHA1 | Date | |
---|---|---|---|
da46914de4 | |||
596bc71cf8 | |||
7f8e4ea943 | |||
5456485f71 | |||
836503a71b | |||
4df0cca675 | |||
00a0adb4ac | |||
037fcd60f3 |
@ -3,5 +3,6 @@
|
|||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a class="item" href="{{$urls->base}}/proyectos/unidades">Unidades</a>
|
<a class="item" href="{{$urls->base}}/proyectos/unidades">Unidades</a>
|
||||||
|
<a class="item" href="{{ $urls->base }}/proyectos/brokers">Operadores</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
<a class="item" href="{{$urls->base}}/ventas/precios">Precios</a>
|
<a class="item" href="{{$urls->base}}/ventas/precios">Precios</a>
|
||||||
|
<a class="item" href="{{ $urls->base }}/ventas/promotions">Promociones</a>
|
||||||
<a class="item" href="{{$urls->base}}/ventas/cierres">Cierres</a>
|
<a class="item" href="{{$urls->base}}/ventas/cierres">Cierres</a>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
Cuotas
|
Cuotas
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
@foreach($brokers as $broker)
|
@foreach($brokers as $broker)
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td class="top aligned">
|
||||||
<span
|
<span
|
||||||
@if ($broker->data()?->legalName !== '')
|
@if ($broker->data()?->legalName !== '')
|
||||||
data-tooltip="{{ $broker->data()?->legalName }}" data-position="right center"
|
data-tooltip="{{ $broker->data()?->legalName }}" data-position="right center"
|
||||||
@ -26,12 +26,13 @@
|
|||||||
{{$broker->rutFull()}}
|
{{$broker->rutFull()}}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="top aligned">
|
||||||
<a href="{{ $urls->base }}/proyectos/broker/{{ $broker->rut }}">
|
<a href="{{ $urls->base }}/proyectos/broker/{{ $broker->rut }}">
|
||||||
{{$broker->name}}
|
{{$broker->name}}
|
||||||
|
<i class="angle right icon"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="top aligned">
|
||||||
<span
|
<span
|
||||||
@if ($broker->data()?->representative?->email !== '' || $broker->data()?->representative?->phone !== '')
|
@if ($broker->data()?->representative?->email !== '' || $broker->data()?->representative?->phone !== '')
|
||||||
data-tooltip="{{ ($broker->data()?->representative?->email !== '') ? "Email: " . $broker->data()?->representative?->email : '' }}{{ ($broker->data()?->representative?->phone !== '') ? ' Teléfono: ' . $broker->data()?->representative?->phone : '' }}" data-position="right center"
|
data-tooltip="{{ ($broker->data()?->representative?->email !== '') ? "Email: " . $broker->data()?->representative?->email : '' }}{{ ($broker->data()?->representative?->phone !== '') ? ' Teléfono: ' . $broker->data()?->representative?->phone : '' }}" data-position="right center"
|
||||||
@ -40,7 +41,7 @@
|
|||||||
{{ $broker->data()?->representative?->name }}
|
{{ $broker->data()?->representative?->name }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td class="top aligned">
|
||||||
<div class="ui list">
|
<div class="ui list">
|
||||||
@foreach($broker->contracts() as $contract)
|
@foreach($broker->contracts() as $contract)
|
||||||
<div class="item">
|
<div class="item">
|
||||||
@ -51,7 +52,7 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td class="right aligned">
|
<td class="top aligned right aligned">
|
||||||
<button class="ui small tertiary icon button edit_button" data-index="{{$broker->rut}}">
|
<button class="ui small tertiary icon button edit_button" data-index="{{$broker->rut}}">
|
||||||
<i class="edit icon"></i>
|
<i class="edit icon"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -48,6 +48,22 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
<div class="ui card">
|
||||||
|
<div class="content">
|
||||||
|
<div class="header">
|
||||||
|
Promociones Aplicadas
|
||||||
|
</div>
|
||||||
|
<div class="description">
|
||||||
|
<div class="ui list">
|
||||||
|
@foreach ($contract->promotions() as $promotion)
|
||||||
|
<div class="item">
|
||||||
|
{{ $promotion->description }} {{ $format->percent($promotion->amount, 2, true) }} {{ ucwords($promotion->type->name()) }}
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="ui active inline loader"></div>
|
<div class="ui active inline loader"></div>
|
||||||
<div id="results">
|
<div id="results">
|
||||||
<div class="ui top attached tabular menu">
|
<div class="ui top attached tabular menu">
|
||||||
@ -55,13 +71,13 @@
|
|||||||
<a class="item" data-tab="lineas">Líneas</a>
|
<a class="item" data-tab="lineas">Líneas</a>
|
||||||
<a class="item" data-tab="unidades">Unidades</a>
|
<a class="item" data-tab="unidades">Unidades</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui bottom attached tab basic horizontally fitted segment active" data-tab="tipos">
|
<div class="ui bottom attached tab basic fitted segment active" data-tab="tipos">
|
||||||
@include('proyectos.brokers.contracts.show.tipo')
|
@include('proyectos.brokers.contracts.show.tipo')
|
||||||
</div>
|
</div>
|
||||||
<div class="ui bottom attached tab basic horizontally fitted segment" data-tab="lineas">
|
<div class="ui bottom attached tab basic fitted segment" data-tab="lineas">
|
||||||
@include('proyectos.brokers.contracts.show.linea')
|
@include('proyectos.brokers.contracts.show.linea')
|
||||||
</div>
|
</div>
|
||||||
<div class="ui bottom attached tab basic horizontally fitted segment" data-tab="unidades">
|
<div class="ui bottom attached tab basic fitted segment" data-tab="unidades">
|
||||||
@include('proyectos.brokers.contracts.show.unidades')
|
@include('proyectos.brokers.contracts.show.unidades')
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -59,23 +59,21 @@
|
|||||||
extend: 'excelHtml5',
|
extend: 'excelHtml5',
|
||||||
className: 'green',
|
className: 'green',
|
||||||
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
text: 'Exportar a Excel <i class="file excel icon"></i>',
|
||||||
title: 'Lista de Precios {{ $contract->broker->name }} {{ $contract->project->descripcion }} {{ (new DateTime())->format('Y-m-d') }}',
|
title: 'Lista de Precios - {{ $contract->broker->name }} - {{ $contract->project->descripcion }} - {{ (new DateTime())->format('Y-m-d') }}',
|
||||||
download: 'open',
|
download: 'open',
|
||||||
exportOptions: {
|
exportOptions: {
|
||||||
columns: [0, 2, 4, 5, 6, 7],
|
columns: [0, 2, 5, 6, 7],
|
||||||
/*format: {
|
rows: (idx, data, node) => {
|
||||||
|
return data[4] === 'Disponible'
|
||||||
|
},
|
||||||
|
format: {
|
||||||
body: (data, row, columnIdx, node) => {
|
body: (data, row, columnIdx, node) => {
|
||||||
const formats = this.columns.filter(columnDef => columnDef.format)
|
if (typeof data === 'string' && data.includes('<span')) {
|
||||||
const match = formats.map(({title}) => title).indexOf(this.columns[columnIdx].title)
|
return data.replace(/<span.*>(.*)<\/span>/, '$1')
|
||||||
if (match > -1) {
|
|
||||||
return formats[match].format(data)
|
|
||||||
}
|
|
||||||
if (typeof data === 'string' && data.includes('<span data-tooltip')) {
|
|
||||||
return data.replace(/<span data-tooltip="(.*)">(.*)<\/span>/, '$2')
|
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
},
|
},
|
||||||
customize: xlsx => {
|
customize: xlsx => {
|
||||||
const sheet = xlsx.xl.worksheets['sheet1.xml']
|
const sheet = xlsx.xl.worksheets['sheet1.xml']
|
||||||
@ -108,7 +106,7 @@
|
|||||||
unidad.proyecto_tipo_unidad.tipo_unidad.orden,
|
unidad.proyecto_tipo_unidad.tipo_unidad.orden,
|
||||||
unidad.descripcion,
|
unidad.descripcion,
|
||||||
unidad.descripcion.padStart(4, '0'),
|
unidad.descripcion.padStart(4, '0'),
|
||||||
unidad.sold ? 'Vendida' : 'Disponible',
|
unidad.sold ? '<span class="ui yellow text">Vendida</span>' : 'Disponible',
|
||||||
'UF ' + formatters.ufs.format(price.base ?? 0),
|
'UF ' + formatters.ufs.format(price.base ?? 0),
|
||||||
formatters.percent.format(price.amount ?? 0),
|
formatters.percent.format(price.amount ?? 0),
|
||||||
'UF ' + formatters.ufs.format(price.final ?? 0),
|
'UF ' + formatters.ufs.format(price.final ?? 0),
|
||||||
|
@ -47,6 +47,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="{{ $urls->base }}/proyectos/broker/{{ $broker->rut }}/contract/{{ $contract->id }}">
|
<a href="{{ $urls->base }}/proyectos/broker/{{ $broker->rut }}/contract/{{ $contract->id }}">
|
||||||
{{ $contract->project->descripcion }}
|
{{ $contract->project->descripcion }}
|
||||||
|
<i class="angle right icon"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ $format->percent($contract->commission, 2, true) }}</td>
|
<td>{{ $format->percent($contract->commission, 2, true) }}</td>
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="{{ $urls->base }}/ventas/promotion/{{ $promotion->id }}">
|
<a href="{{ $urls->base }}/ventas/promotion/{{ $promotion->id }}">
|
||||||
{{ $promotion->description }}
|
{{ $promotion->description }}
|
||||||
|
<i class="angle right icon"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ ucwords($promotion->type->name()) }}</td>
|
<td>{{ ucwords($promotion->type->name()) }}</td>
|
||||||
@ -32,8 +33,11 @@
|
|||||||
<td>{{ $promotion->endDate?->format('d-m-Y') }}</td>
|
<td>{{ $promotion->endDate?->format('d-m-Y') }}</td>
|
||||||
<td>{{ $promotion->validUntil?->format('d-m-Y') }}</td>
|
<td>{{ $promotion->validUntil?->format('d-m-Y') }}</td>
|
||||||
<td>
|
<td>
|
||||||
Proyectos: {{ count(array_unique(array_map(function ($contract) { return $contract->project->descripcion; }, $promotion->contracts()))) }} <br />
|
Proyectos: {{ count($promotion->projects()) +
|
||||||
Operadores: {{ count(array_unique(array_map(function ($contract) { return $contract->broker->name; }, $promotion->contracts()))) }}
|
count(array_unique(array_map(function($unitType) {return $unitType->project;},$promotion->unitTypes()))) +
|
||||||
|
count(array_unique(array_map(function($unitLine) {return $unitLine->proyecto;},$promotion->unitLines()))) +
|
||||||
|
count($promotion->units()) }} <br />
|
||||||
|
Operadores: {{ count($promotion->brokers()) }}
|
||||||
</td>
|
</td>
|
||||||
<td class="right aligned">
|
<td class="right aligned">
|
||||||
<button type="button" class="ui small tertiary icon button edit_button" data-id="{{ $promotion->id }}">
|
<button type="button" class="ui small tertiary icon button edit_button" data-id="{{ $promotion->id }}">
|
||||||
|
@ -51,15 +51,16 @@ class Precio extends Ideal\Repository
|
|||||||
*/
|
*/
|
||||||
public function fetchByProyecto(int $proyecto_id): array
|
public function fetchByProyecto(int $proyecto_id): array
|
||||||
{
|
{
|
||||||
$query = "SELECT a.*
|
$query = $this->connection->getQueryBuilder()
|
||||||
FROM `{$this->getTable()}` a
|
->select('a.*')
|
||||||
JOIN (SELECT e1.* FROM `estado_precio` e1 JOIN (SELECT MAX(`id`) AS 'id', `precio` FROM `estado_precio` GROUP BY `precio`) e0 ON e0.`id` = e1.`id`) ep ON ep.`precio` = a.`id`
|
->from("{$this->getTable()} a")
|
||||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
->joined($this->joinEstado())
|
||||||
JOIN `unidad` ON `unidad`.`id` = a.`unidad`
|
->joined('INNER JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`')
|
||||||
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`
|
->joined('INNER JOIN `unidad` ON `unidad`.`id` = a.`unidad`')
|
||||||
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
|
->joined('INNER JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
|
||||||
WHERE ptu.`proyecto` = ? AND tep.`descripcion` = 'vigente'
|
->joined('INNER JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`')
|
||||||
ORDER BY tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcion`, 4, '0')";
|
->where('ptu.`proyecto` = ? AND tep.`descripcion` = "vigente"')
|
||||||
|
->order('tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcion`, 4, "0")');
|
||||||
return $this->fetchMany($query, [$proyecto_id]);
|
return $this->fetchMany($query, [$proyecto_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +71,12 @@ ORDER BY tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcio
|
|||||||
*/
|
*/
|
||||||
public function fetchByUnidad(int $unidad_id): array
|
public function fetchByUnidad(int $unidad_id): array
|
||||||
{
|
{
|
||||||
$query = "SELECT a.*
|
$query = $this->connection->getQueryBuilder()
|
||||||
FROM `{$this->getTable()}` a
|
->select('a.*')
|
||||||
JOIN (SELECT e1.* FROM `estado_precio` e1 JOIN (SELECT MAX(`id`) AS 'id', `precio` FROM `estado_precio` GROUP BY `precio`) e0 ON e0.`id` = e1.`id`) ep ON ep.`precio` = a.`id`
|
->from("{$this->getTable()} a")
|
||||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
->joined($this->joinEstado())
|
||||||
WHERE `unidad` = ?";
|
->joined('INNER JOIN tipo_estado_precio tep ON tep.`id` = ep.`estado`')
|
||||||
|
->where('`unidad` = ?');
|
||||||
return $this->fetchMany($query, [$unidad_id]);
|
return $this->fetchMany($query, [$unidad_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,11 +87,12 @@ WHERE `unidad` = ?";
|
|||||||
*/
|
*/
|
||||||
public function fetchVigenteByUnidad(int $unidad_id): Define\Model
|
public function fetchVigenteByUnidad(int $unidad_id): Define\Model
|
||||||
{
|
{
|
||||||
$query = "SELECT a.*
|
$query = $this->connection->getQueryBuilder()
|
||||||
FROM `{$this->getTable()}` a
|
->select('a.*')
|
||||||
JOIN (SELECT e1.* FROM `estado_precio` e1 JOIN (SELECT MAX(`id`) AS 'id', `precio` FROM `estado_precio` GROUP BY `precio`) e0 ON e0.`id` = e1.`id`) ep ON ep.`precio` = a.`id`
|
->from("{$this->getTable()} a")
|
||||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
->joined($this->joinEstado())
|
||||||
WHERE `unidad` = ? AND tep.`descripcion` = 'vigente'";
|
->joined('INNER JOIN tipo_estado_precio tep ON tep.`id` = ep.`estado`')
|
||||||
|
->where('`unidad` = ? AND tep.`descripcion` = "vigente"');
|
||||||
return $this->fetchOne($query, [$unidad_id]);
|
return $this->fetchOne($query, [$unidad_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,11 +104,25 @@ WHERE `unidad` = ? AND tep.`descripcion` = 'vigente'";
|
|||||||
*/
|
*/
|
||||||
public function fetchByUnidadAndDate(int $unidad_id, string $date_time): Define\Model
|
public function fetchByUnidadAndDate(int $unidad_id, string $date_time): Define\Model
|
||||||
{
|
{
|
||||||
$query = "SELECT a.*
|
$query = $this->connection->getQueryBuilder()
|
||||||
FROM `{$this->getTable()}` a
|
->select('a.*')
|
||||||
JOIN (SELECT e1.* FROM `estado_precio` e1 JOIN (SELECT MAX(`id`) AS 'id', `precio` FROM `estado_precio` GROUP BY `precio`) e0 ON e0.`id` = e1.`id`) ep ON ep.`precio` = a.`id`
|
->from("{$this->getTable()} a")
|
||||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
->joined($this->joinEstado())
|
||||||
WHERE `unidad` = ? AND ep.`fecha` <= ? AND tep.`descripcion` = 'vigente'";
|
->joined('INNER JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`')
|
||||||
|
->where('`unidad` = ? AND ep.`fecha` <= ? AND tep.`descripcion` = "vigente"');
|
||||||
return $this->fetchOne($query, [$unidad_id, $date_time]);
|
return $this->fetchOne($query, [$unidad_id, $date_time]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function joinEstado(): string
|
||||||
|
{
|
||||||
|
$subSubQuery = $this->connection->getQueryBuilder()
|
||||||
|
->select('MAX(id) AS id, precio')
|
||||||
|
->from('estado_precio')
|
||||||
|
->group('precio');
|
||||||
|
$subQuery = $this->connection->getQueryBuilder()
|
||||||
|
->select('e1.*')
|
||||||
|
->from('estado_precio e1')
|
||||||
|
->joined("INNER JOIN ($subSubQuery) e0 ON e0.id = e1.id");
|
||||||
|
return "JOIN ($subQuery) ep ON ep.precio = a.id";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,15 +77,15 @@ class Promotion extends Common\Ideal\Repository
|
|||||||
$query = $this->connection->getQueryBuilder()
|
$query = $this->connection->getQueryBuilder()
|
||||||
->select('DISTINCT a.*')
|
->select('DISTINCT a.*')
|
||||||
->from("{$this->getTable()} a")
|
->from("{$this->getTable()} a")
|
||||||
->joined('LEFT OUTER JOIN promotion_broker pb ON pb.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_brokers pb ON pb.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN broker_contracts bc ON bc.id = pb.contract_id')
|
->joined('LEFT OUTER JOIN broker_contracts bc ON bc.broker_rut = pb.broker_rut')
|
||||||
->joined('LEFT OUTER JOIN promotion_projects pp ON pp.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_projects pp ON pp.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN broker_contracts bc2 ON bc2.project_id = pp.project_id')
|
->joined('LEFT OUTER JOIN broker_contracts bc2 ON bc2.project_id = pp.project_id')
|
||||||
->joined('LEFT OUTER JOIN promotion_unit_types put ON put.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_unit_types put ON put.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN broker_contracts bc3 ON bc3.project_id = put.project_id')
|
->joined('LEFT OUTER JOIN broker_contracts bc3 ON bc3.project_id = put.project_id')
|
||||||
->joined('LEFT OUTER JOIN promotion_unit_lines pul ON pul.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_unit_lines pul ON pul.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu ON ptu.id = pul.unit_line_id')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu ON ptu.id = pul.unit_line_id')
|
||||||
->joined('LEFT OUTER JOIN broker_contracts bc4 ON bc4.project_id = btu.proyecto')
|
->joined('LEFT OUTER JOIN broker_contracts bc4 ON bc4.project_id = ptu.proyecto')
|
||||||
->joined('LEFT OUTER JOIN promotion_units pu ON pu.promotion_id = a.id')
|
->joined('LEFT OUTER JOIN promotion_units pu ON pu.promotion_id = a.id')
|
||||||
->joined('LEFT OUTER JOIN unidad ON unidad.id = pu.unit_id')
|
->joined('LEFT OUTER JOIN unidad ON unidad.id = pu.unit_id')
|
||||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu2 ON ptu2.id = unidad.pt')
|
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu2 ON ptu2.id = unidad.pt')
|
||||||
|
Reference in New Issue
Block a user