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>
|
||||
<div class="menu">
|
||||
<a class="item" href="{{$urls->base}}/proyectos/unidades">Unidades</a>
|
||||
<a class="item" href="{{ $urls->base }}/proyectos/brokers">Operadores</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -3,6 +3,7 @@
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="menu">
|
||||
<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>
|
||||
<div class="item">
|
||||
Cuotas
|
||||
|
@ -17,7 +17,7 @@
|
||||
</thead>
|
||||
@foreach($brokers as $broker)
|
||||
<tr>
|
||||
<td>
|
||||
<td class="top aligned">
|
||||
<span
|
||||
@if ($broker->data()?->legalName !== '')
|
||||
data-tooltip="{{ $broker->data()?->legalName }}" data-position="right center"
|
||||
@ -26,12 +26,13 @@
|
||||
{{$broker->rutFull()}}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<td class="top aligned">
|
||||
<a href="{{ $urls->base }}/proyectos/broker/{{ $broker->rut }}">
|
||||
{{$broker->name}}
|
||||
<i class="angle right icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<td class="top aligned">
|
||||
<span
|
||||
@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"
|
||||
@ -40,7 +41,7 @@
|
||||
{{ $broker->data()?->representative?->name }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<td class="top aligned">
|
||||
<div class="ui list">
|
||||
@foreach($broker->contracts() as $contract)
|
||||
<div class="item">
|
||||
@ -51,7 +52,7 @@
|
||||
@endforeach
|
||||
</div>
|
||||
</td>
|
||||
<td class="right aligned">
|
||||
<td class="top aligned right aligned">
|
||||
<button class="ui small tertiary icon button edit_button" data-index="{{$broker->rut}}">
|
||||
<i class="edit icon"></i>
|
||||
</button>
|
||||
|
@ -48,6 +48,22 @@
|
||||
</div>
|
||||
</div>
|
||||
<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 id="results">
|
||||
<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="unidades">Unidades</a>
|
||||
</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')
|
||||
</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')
|
||||
</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')
|
||||
</div>
|
||||
</div>
|
||||
|
@ -59,23 +59,21 @@
|
||||
extend: 'excelHtml5',
|
||||
className: 'green',
|
||||
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',
|
||||
exportOptions: {
|
||||
columns: [0, 2, 4, 5, 6, 7],
|
||||
/*format: {
|
||||
columns: [0, 2, 5, 6, 7],
|
||||
rows: (idx, data, node) => {
|
||||
return data[4] === 'Disponible'
|
||||
},
|
||||
format: {
|
||||
body: (data, row, columnIdx, node) => {
|
||||
const formats = this.columns.filter(columnDef => columnDef.format)
|
||||
const match = formats.map(({title}) => title).indexOf(this.columns[columnIdx].title)
|
||||
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')
|
||||
if (typeof data === 'string' && data.includes('<span')) {
|
||||
return data.replace(/<span.*>(.*)<\/span>/, '$1')
|
||||
}
|
||||
return data
|
||||
}
|
||||
}*/
|
||||
}
|
||||
},
|
||||
customize: xlsx => {
|
||||
const sheet = xlsx.xl.worksheets['sheet1.xml']
|
||||
@ -108,7 +106,7 @@
|
||||
unidad.proyecto_tipo_unidad.tipo_unidad.orden,
|
||||
unidad.descripcion,
|
||||
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),
|
||||
formatters.percent.format(price.amount ?? 0),
|
||||
'UF ' + formatters.ufs.format(price.final ?? 0),
|
||||
|
@ -47,6 +47,7 @@
|
||||
<td>
|
||||
<a href="{{ $urls->base }}/proyectos/broker/{{ $broker->rut }}/contract/{{ $contract->id }}">
|
||||
{{ $contract->project->descripcion }}
|
||||
<i class="angle right icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ $format->percent($contract->commission, 2, true) }}</td>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<td>
|
||||
<a href="{{ $urls->base }}/ventas/promotion/{{ $promotion->id }}">
|
||||
{{ $promotion->description }}
|
||||
<i class="angle right icon"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>{{ ucwords($promotion->type->name()) }}</td>
|
||||
@ -32,8 +33,11 @@
|
||||
<td>{{ $promotion->endDate?->format('d-m-Y') }}</td>
|
||||
<td>{{ $promotion->validUntil?->format('d-m-Y') }}</td>
|
||||
<td>
|
||||
Proyectos: {{ count(array_unique(array_map(function ($contract) { return $contract->project->descripcion; }, $promotion->contracts()))) }} <br />
|
||||
Operadores: {{ count(array_unique(array_map(function ($contract) { return $contract->broker->name; }, $promotion->contracts()))) }}
|
||||
Proyectos: {{ count($promotion->projects()) +
|
||||
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 class="right aligned">
|
||||
<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
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` 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`
|
||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
||||
JOIN `unidad` ON `unidad`.`id` = a.`unidad`
|
||||
JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`
|
||||
JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`
|
||||
WHERE ptu.`proyecto` = ? AND tep.`descripcion` = 'vigente'
|
||||
ORDER BY tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcion`, 4, '0')";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select('a.*')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined($this->joinEstado())
|
||||
->joined('INNER JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`')
|
||||
->joined('INNER JOIN `unidad` ON `unidad`.`id` = a.`unidad`')
|
||||
->joined('INNER JOIN `proyecto_tipo_unidad` ptu ON ptu.`id` = `unidad`.`pt`')
|
||||
->joined('INNER JOIN `tipo_unidad` tu ON tu.`id` = ptu.`tipo`')
|
||||
->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]);
|
||||
}
|
||||
|
||||
@ -70,11 +71,12 @@ ORDER BY tu.`orden`, ptu.`nombre`, `unidad`.`subtipo`, LPAD(`unidad`.`descripcio
|
||||
*/
|
||||
public function fetchByUnidad(int $unidad_id): array
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` 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`
|
||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
||||
WHERE `unidad` = ?";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select('a.*')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined($this->joinEstado())
|
||||
->joined('INNER JOIN tipo_estado_precio tep ON tep.`id` = ep.`estado`')
|
||||
->where('`unidad` = ?');
|
||||
return $this->fetchMany($query, [$unidad_id]);
|
||||
}
|
||||
|
||||
@ -85,11 +87,12 @@ WHERE `unidad` = ?";
|
||||
*/
|
||||
public function fetchVigenteByUnidad(int $unidad_id): Define\Model
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` 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`
|
||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
||||
WHERE `unidad` = ? AND tep.`descripcion` = 'vigente'";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select('a.*')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined($this->joinEstado())
|
||||
->joined('INNER JOIN tipo_estado_precio tep ON tep.`id` = ep.`estado`')
|
||||
->where('`unidad` = ? AND tep.`descripcion` = "vigente"');
|
||||
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
|
||||
{
|
||||
$query = "SELECT a.*
|
||||
FROM `{$this->getTable()}` 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`
|
||||
JOIN `tipo_estado_precio` tep ON tep.`id` = ep.`estado`
|
||||
WHERE `unidad` = ? AND ep.`fecha` <= ? AND tep.`descripcion` = 'vigente'";
|
||||
$query = $this->connection->getQueryBuilder()
|
||||
->select('a.*')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined($this->joinEstado())
|
||||
->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]);
|
||||
}
|
||||
|
||||
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()
|
||||
->select('DISTINCT a.*')
|
||||
->from("{$this->getTable()} a")
|
||||
->joined('LEFT OUTER JOIN promotion_broker pb ON pb.promotion_id = a.id')
|
||||
->joined('LEFT OUTER JOIN broker_contracts bc ON bc.id = pb.contract_id')
|
||||
->joined('LEFT OUTER JOIN promotion_brokers pb ON pb.promotion_id = a.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 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 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 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 unidad ON unidad.id = pu.unit_id')
|
||||
->joined('LEFT OUTER JOIN proyecto_tipo_unidad ptu2 ON ptu2.id = unidad.pt')
|
||||
|
Reference in New Issue
Block a user