селектор помещений из апи
This commit is contained in:
parent
97a48aa657
commit
b2a11b212b
@ -14,7 +14,7 @@ class Plan7SelectorLivewire extends Component
|
||||
public $types;
|
||||
public $access;
|
||||
public $summary;
|
||||
public $room;
|
||||
public $room = false;
|
||||
public $objects = [];
|
||||
private $apiSummary = 'https://plan7.ru/catalog/exp/json/summary/?token=0754c5e6a3824322&zk=614';
|
||||
private $apiAll = 'https://plan7.ru/catalog/exp/json/?token=0754c5e6a3824322&zk=614';
|
||||
@ -63,7 +63,10 @@ public function setHouse($id)
|
||||
public function setRoom($id)
|
||||
{
|
||||
$this->room = $this->allObjects['data'][$id];
|
||||
$this->filter['id'] = $id;
|
||||
//$this->filter['id'] = $id;
|
||||
}
|
||||
public function unsetRoom() {
|
||||
$this->room = false;
|
||||
}
|
||||
public function resetFilter() {
|
||||
$this->filter = [];
|
||||
@ -71,6 +74,7 @@ public function resetFilter() {
|
||||
public function start() {
|
||||
$this->mode = 'select';
|
||||
$this->filter = [];
|
||||
//$this->room = false;
|
||||
$this->getData();
|
||||
}
|
||||
public function done() {
|
||||
@ -83,19 +87,19 @@ public function render()
|
||||
if (count($this->filter)) {
|
||||
foreach ($this->allObjects['data'] as $key => $room) {
|
||||
if ($room['access'] != 0) {
|
||||
if (array_key_exists('id', $this->filter) && $this->filter['id'] !== null && $room['id'] != $this->filter['id']) {
|
||||
if (array_key_exists('id', $this->filter) && $this->filter['id'] != null && $room['id'] != $this->filter['id']) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('bs', $this->filter) && $this->filter['bs'] !== null && $room['bs'] != $this->filter['bs']) {
|
||||
if (array_key_exists('bs', $this->filter) && $this->filter['bs'] != null && $room['bs'] != $this->filter['bs']) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('type', $this->filter) && $this->filter['type'] !== null && $room['type'] != $this->filter['type']) {
|
||||
if (array_key_exists('type', $this->filter) && $this->filter['type'] != null && $room['type'] != $this->filter['type']) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('min_area', $this->filter) && $this->filter['min_area'] !== null && $room['area'] < $this->filter['min_area']) {
|
||||
if (array_key_exists('min_area', $this->filter) && $this->filter['min_area'] != null && $room['area'] < $this->filter['min_area']) {
|
||||
continue;
|
||||
}
|
||||
if (array_key_exists('max_area', $this->filter) && $this->filter['max_area'] !== null && $room['area'] > $this->filter['max_area']) {
|
||||
if (array_key_exists('max_area', $this->filter) && $this->filter['max_area'] != null && $room['area'] > $this->filter['max_area']) {
|
||||
continue;
|
||||
}
|
||||
$room['mode'] = 'room';
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<button type="button" wire:click="start()" class="btn btn-primary" onclick="plan7SelectorModal = new bootstrap.Modal(document.getElementById('plan7_selector_modal'), {});plan7SelectorModal.show()">
|
||||
<button type="button" wire:click="start()" class="btn btn-primary"
|
||||
onclick="plan7SelectorModal = new bootstrap.Modal(document.getElementById('plan7_selector_modal'), {});plan7SelectorModal.show()">
|
||||
@if($room)
|
||||
Изменить
|
||||
@else
|
||||
@ -34,130 +35,163 @@
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="d-flex gap-2">
|
||||
<div class="col-4 p-2 rounded-4 mb-3 bg-light border d-flex gap-2">
|
||||
<div class="flex-fill">
|
||||
<label>Дом/секция:</label>
|
||||
<div>
|
||||
<select wire:loading.attr="disabled" class="form-select"
|
||||
wire:model.change="filter.bs">
|
||||
<option></option>
|
||||
@foreach($allObjects['values']['bs'] as $bs)
|
||||
<option value="{{ $bs['id'] }}">{{ $bs['name'] }} </option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@if($room)
|
||||
<div class="d-flex">
|
||||
<div class="col-12 col-md-7">
|
||||
<img src="{{ array_key_exists($room['pla'], $allObjects['pla']) ? $allObjects['pla'][$room['pla']]['pla'] : '...' }}"
|
||||
class="img-fluid rounded-start" alt="...">
|
||||
</div>
|
||||
<div class="flex-fill">
|
||||
<label>Тип помещения:</label>
|
||||
<div>
|
||||
<select wire:loading.attr="disabled" class="form-select"
|
||||
wire:model.change="filter.type">
|
||||
<option></option>
|
||||
@foreach($summary as $typeSummary)
|
||||
@if(array_key_exists('type', $typeSummary))
|
||||
<option value="{{ $typeSummary['type'] }}">{{ $types[$typeSummary['type']] }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
<div class="col px-3">
|
||||
<h3 class="fw-bold mb-3 text-uppercase">
|
||||
{{ (($room['type'] == 0) ? $room['room'] . ' комн. ' . mb_strtolower($this->types[$room['type']]) : $this->types[$room['type']]) }}
|
||||
</h3>
|
||||
<div class="d-flex flex-wrap gap-3">
|
||||
<div class="hstack gap-3 w-100">
|
||||
<div class="d-flex flex-column w-50 p-2 bg-light border border-1 rounded-4">
|
||||
<span class="text-secondary">Помещение</span><span class="fs-3">{{ $room['name'] }}</span>
|
||||
</div>
|
||||
<div class="d-flex flex-column w-50 p-2 bg-light border border-1 rounded-4">
|
||||
<span class="text-secondary">Этаж</span><span class="fs-3">{{ $room['level'] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex flex-column w-100 p-2 bg-light border border-1 rounded-4">
|
||||
<span class="text-secondary">Площадь</span><span class="fs-3">{{ $room['area'] }} м<sup>2</sup></span>
|
||||
</div>
|
||||
<div class="d-flex flex-column w-100 p-2 bg-light border border-1 rounded-4">
|
||||
<span class="text-secondary">Стоимость</span><span class="fs-3">{{ ($room['summ']) ? number_format($room['summ'], 0, '', ' ') . ' р.' : '' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@if(array_key_exists('type', $filter))
|
||||
@foreach($summary as $typeSummary)
|
||||
@if(array_key_exists('type', $typeSummary) && $typeSummary['type'] == $filter['type'])
|
||||
<div class="col-4 p-2 rounded-4 mb-3 bg-light border">
|
||||
<label>Площадь:</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">от</span>
|
||||
<input wire:loading.attr="disabled" type="number" wire:model.live="filter.min_area"
|
||||
class="form-control w-25" placeholder="{{ $typeSummary['min_area'] }}">
|
||||
<span class="input-group-text">до</span>
|
||||
<input wire:loading.attr="disabled" type="number" wire:model.live="filter.max_area"
|
||||
class="form-control w-25" placeholder="{{ $typeSummary['max_area'] }}">
|
||||
</div>
|
||||
@endif
|
||||
@if(!$room)
|
||||
<div class="d-flex gap-2">
|
||||
<div class="col-4 p-2 rounded-4 mb-3 bg-light border d-flex gap-2">
|
||||
<div class="flex-fill">
|
||||
<label>Дом/строение:</label>
|
||||
<div>
|
||||
<select wire:loading.attr="disabled" class="form-select"
|
||||
wire:model.change="filter.bs">
|
||||
<option></option>
|
||||
@foreach($allObjects['values']['bs'] as $bs)
|
||||
<option value="{{ $bs['id'] }}">{{ $bs['name'] }} </option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-4 p-2 rounded-4 mb-3 bg-light border">
|
||||
<label>Стоимость:</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">от</span>
|
||||
<input wire:loading.attr="disabled" wire:model.live="filter.min_price" type="number"
|
||||
class="form-control w-25"
|
||||
placeholder="{{ number_format($typeSummary['min_price'], 0, '', ' ') . ' р.' }}">
|
||||
<span class="input-group-text">до</span>
|
||||
<input wire:loading.attr="disabled" wire:model.live="filter.max_price" type="number"
|
||||
class="form-control w-25"
|
||||
placeholder="{{ number_format($typeSummary['max_price'], 0, '', ' ') . ' р.' }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-none p-2 rounded-4 mb-3 bg-light border">
|
||||
<label>На каком этаже:</label>
|
||||
<div>
|
||||
</div>
|
||||
<div class="flex-fill">
|
||||
<label>Тип помещения:</label>
|
||||
<div>
|
||||
<select wire:loading.attr="disabled" class="form-select"
|
||||
wire:model.change="filter.type">
|
||||
<option></option>
|
||||
@foreach($summary as $typeSummary)
|
||||
@if(array_key_exists('type', $typeSummary) && $typeSummary['type'] == $filter['type'])
|
||||
@foreach($typeSummary['floor'] as $floor)
|
||||
|
||||
@endforeach
|
||||
@if(array_key_exists('type', $typeSummary))
|
||||
<option value="{{ $typeSummary['type'] }}">{{ $types[$typeSummary['type']] }}
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
@if(count($filter) && count($objs))
|
||||
<div>Всего помещений: {{ count($objs) }}</div>
|
||||
@endif
|
||||
@if(!count($objs))
|
||||
<div wire:loading.remove class="p-5 text-secondary w-100 text-center fs-3">
|
||||
Нет помещений для отображения по выбранным параметрам
|
||||
</div>
|
||||
@endif
|
||||
<div wire:loading.class="opacity-50" class="d-flex flex-wrap">
|
||||
@foreach($objs as $obj)
|
||||
<div class="p-2 col-12 col-md-4">
|
||||
@if($obj['mode'] == 'bs')
|
||||
<div class="card" wire:click="setHouse({{ $obj['id'] }})">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ $obj['name'] }}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Секция/дoм</h6>
|
||||
<p class="card-text"></p>
|
||||
<a href="#" class="card-link">Выбрать</a>
|
||||
</div>
|
||||
</div>
|
||||
@elseif($obj['mode'] == 'room')
|
||||
<div wire:click="setRoom({{ $obj['id'] }})" class="card mb-3" style="max-width: 540px;">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4 d-none d-md-block">
|
||||
<img src="{{ array_key_exists($obj['pla'], $allObjects['pla']) ? $allObjects['pla'][$obj['pla']]['pla'] : '...' }}"
|
||||
class="img-fluid rounded-start" alt="...">
|
||||
</div>
|
||||
</div>
|
||||
@if(array_key_exists('type', $filter))
|
||||
@foreach($summary as $typeSummary)
|
||||
@if(array_key_exists('type', $typeSummary) && $typeSummary['type'] == $filter['type'])
|
||||
<div class="col-4 p-2 rounded-4 mb-3 bg-light border">
|
||||
<label>Площадь:</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">от</span>
|
||||
<input wire:loading.attr="disabled" type="number" wire:model.live="filter.min_area"
|
||||
class="form-control w-25" placeholder="{{ $typeSummary['min_area'] }}">
|
||||
<span class="input-group-text">до</span>
|
||||
<input wire:loading.attr="disabled" type="number" wire:model.live="filter.max_area"
|
||||
class="form-control w-25" placeholder="{{ $typeSummary['max_area'] }}">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
{{ (($obj['type'] == 0) ? $obj['room'] . ' комн. ' . mb_strtolower($this->types[$obj['type']]) : $this->types[$obj['type']]) }}
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
<div>Помещение: {{ $obj['name'] }}</div>
|
||||
<div>Площадь: {{ $obj['area'] }}</div>
|
||||
<div>Этаж: {{ $obj['level'] }}</div>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
{{ ($obj['summ']) ? number_format($obj['summ'], 0, '', ' ') . ' р.' : '' }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-4 p-2 rounded-4 mb-3 bg-light border">
|
||||
<label>Стоимость:</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">от</span>
|
||||
<input wire:loading.attr="disabled" wire:model.live="filter.min_price" type="number"
|
||||
class="form-control w-25"
|
||||
placeholder="{{ number_format($typeSummary['min_price'], 0, '', ' ') . ' р.' }}">
|
||||
<span class="input-group-text">до</span>
|
||||
<input wire:loading.attr="disabled" wire:model.live="filter.max_price" type="number"
|
||||
class="form-control w-25"
|
||||
placeholder="{{ number_format($typeSummary['max_price'], 0, '', ' ') . ' р.' }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-none p-2 rounded-4 mb-3 bg-light border">
|
||||
<label>На каком этаже:</label>
|
||||
<div>
|
||||
@foreach($summary as $typeSummary)
|
||||
@if(array_key_exists('type', $typeSummary) && $typeSummary['type'] == $filter['type'])
|
||||
@foreach($typeSummary['floor'] as $floor)
|
||||
|
||||
@endforeach
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
@if(count($filter) && count($objs))
|
||||
<div>Всего помещений: {{ count($objs) }}</div>
|
||||
@endif
|
||||
<? print_r($filter) ?>
|
||||
@if(!count($objs))
|
||||
<div wire:loading.remove class="p-5 text-secondary w-100 text-center fs-3">
|
||||
Нет помещений для отображения по выбранным параметрам
|
||||
</div>
|
||||
@endif
|
||||
<div wire:loading.class="opacity-50" class="d-flex flex-wrap">
|
||||
@foreach($objs as $obj)
|
||||
<div class="p-2 col-12 col-md-4">
|
||||
@if($obj['mode'] == 'bs')
|
||||
<div class="card" wire:click="setHouse({{ $obj['id'] }})">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ $obj['name'] }}</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">Секция/дoм</h6>
|
||||
<p class="card-text"></p>
|
||||
<a href="#" class="card-link">Выбрать</a>
|
||||
</div>
|
||||
</div>
|
||||
@elseif($obj['mode'] == 'room')
|
||||
<div wire:click="setRoom({{ $obj['id'] }})" class="card mb-3" style="max-width: 540px;">
|
||||
<div class="row g-0">
|
||||
<div class="col-md-4 d-none d-md-block">
|
||||
<img src="{{ array_key_exists($obj['pla'], $allObjects['pla']) ? $allObjects['pla'][$obj['pla']]['pla'] : '...' }}"
|
||||
class="img-fluid rounded-start" alt="...">
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
{{ (($obj['type'] == 0) ? $obj['room'] . ' комн. ' . mb_strtolower($this->types[$obj['type']]) : $this->types[$obj['type']]) }}
|
||||
</h5>
|
||||
<p class="card-text">
|
||||
<div>Помещение: {{ $obj['name'] }}</div>
|
||||
<div>Площадь: {{ $obj['area'] }}</div>
|
||||
<div>Этаж: {{ $obj['level'] }}</div>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
{{ ($obj['summ']) ? number_format($obj['summ'], 0, '', ' ') . ' р.' : '' }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@if(array_key_exists('id', $filter))
|
||||
@if($room)
|
||||
<div class="modal-footer">
|
||||
<button wire:click="unsetRoom()" type="button" class="btn btn-secondary">Выбрать другое</button>
|
||||
<button wire:click="done()" type="button" class="btn btn-primary" data-bs-dismiss="modal">Выбрать и
|
||||
закрыть</button>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user