plan7 iframe setter in admin menu

This commit is contained in:
developer 2026-04-10 08:32:02 +08:00
parent 71e0257c3d
commit e5b14bdfd8
5 changed files with 59 additions and 34 deletions

View File

@ -6,6 +6,8 @@
use Illuminate\Http\Request;
use Modules\Main\Models\Complex;
use Modules\Plan7\Models\ComplexPlan7;
use Modules\Main\Models\Design;
class AdminPlan7Controller extends Controller
{
@ -16,8 +18,9 @@ public function index()
]);
}
public function save(Request $request) {
foreach ($request->plan7 as $complexId=>$plan7ApiData) {
public function save(Request $request)
{
foreach ($request->complexes as $complexId => $plan7ApiData) {
if ($plan7ApiData['token'] && $plan7ApiData['zk']) {
ComplexPlan7::updateOrCreate([
'complex_id' => $complexId,
@ -30,6 +33,16 @@ public function save(Request $request) {
ComplexPlan7::where('complex_id', $complexId)->delete();
}
}
if ($request->has('plan7_iframe')) {
if (!$request->plan7_iframe) {
Design::where('parameter', 'plan7_iframe')->delete();
} else {
Design::updateOrCreate([
'parameter' => 'plan7_iframe',
'value' => $request->plan7_iframe
]);
}
}
return to_route('admin.plan7');
}
}

View File

@ -115,11 +115,7 @@
</label>
</div>
</div>
<div class="col d-flex flex-row justify-content-start align-items-center gap-2 bg-light rounded p-2">
<label for="plan7_iframe" class="form-label m-0 w-25">Ссылка на iframe Plan7</label>
<input type="text" class="form-control" id="plan7_iframe" name="plan7_iframe"
value="{{ ($parameters['plan7_iframe'] ?? '') }}">
</div>
</div>
<input type="submit" class="btn btn-primary mt-3" value="Сохранить" />
</form>

View File

@ -1,32 +1,44 @@
@php($title = 'Интеграция Plan7')
@extends('layouts.admin')
@section('content')
<form action="{{ route('admin.plan7.save') }}" method="post">
@csrf
<div class="col d-flex flex-column justify-content-start align-items-start gap-2 bg-light rounded p-2 mb-2">
<label for="plan7_iframe" class="form-label m-0 w-25">Ссылка на iframe Plan7</label>
<small>Отображается на главной странице в разделе "Подбор недвижимости". Укажите только атрибут src, без разметки</small>
<input type="text" class="form-control" id="plan7_iframe" name="plan7_iframe" value="{{ array_key_exists('plan7_iframe', DESIGN_PARAMETERS) ? DESIGN_PARAMETERS['plan7_iframe'] : "" }}">
</div>
<div class="d-flex flex-column gap-2 bg-light rounded p-2">
<label class="form-label m-0">API для подбора помещений в форме</label>
<div class="alert alert-primary" role="alert">
Активируйте передачу данных в JSON для каталога отдельного ЖК на вкладке API и
скопируйте полученные токен и идентфикатор жилого комплекса в соответствующиие поля ниже
</div>
<form action="{{ route('admin.plan7.save') }}" method="post">
@csrf
<div class="container rounded border">
@foreach($complexes as $complex)
<div class="row my-2 border-bottom">
<div class="col-3 vstack">
<div class="row py-2 border-bottom align-items-center">
<div class="col-3">
<span class="fw-bold">{{ $complex->name }}</span>
</div>
<div class="col-3 vstack">
<div class="col-3">
<span class="fw-bold">{{ $complex->city->name }}</span>
</div>
<div class="col-2">
<input class="form-control" type="text" name="plan7[{{ $complex->id }}][zk]" placeholder="ID ЖК из Plan7"
value="{{ $complex->getPlan7ApiData()?->zk }}">
<input class="form-control" type="text" name="complexes[{{ $complex->id }}][zk]"
placeholder="ID ЖК из Plan7" value="{{ $complex->getPlan7ApiData()?->zk }}">
</div>
<div class="col-4">
<input class="form-control" type="text" name="plan7[{{ $complex->id }}][token]" placeholder="API токен для ЖК из Plan7"
value="{{ $complex->getPlan7ApiData()?->token }}">
<input class="form-control" type="text" name="complexes[{{ $complex->id }}][token]"
placeholder="API токен для ЖК из Plan7" value="{{ $complex->getPlan7ApiData()?->token }}">
</div>
</div>
@endforeach
<button type="submit" class="btn btn-primary mb-3">
</div>
</div>
<button type="submit" class="btn btn-primary my-3">
<i class="bi bi-save"></i> Сохранить
</button>
</form>

View File

@ -130,6 +130,7 @@
</main>
</div>
@if(array_key_exists('plan7_iframe', DESIGN_PARAMETERS))
<!-- Plan 7 Modal -->
<div class="modal fade" id="plan7Modal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-fullscreen">
@ -145,7 +146,7 @@
</div>
<div class="modal-body">
<div id="catalogFrame" data-multicat="1" style="position:relative; width:100%; height:240px;">
<iframe src="https://plan7.ru/catalog/exp/?module=52&name=asdsasd" style="position:absolute; left:0px; top:0px; width:100%; height:100%; border:none;"></iframe>
<iframe src="{{ DESIGN_PARAMETERS['plan7_iframe'] }}" style="position:absolute; left:0px; top:0px; width:100%; height:100%; border:none;"></iframe>
</div>
</div>
<div class="modal-footer">
@ -154,6 +155,7 @@
</div>
</div>
</div>
@endif
@include('notice::index')
</body>

View File

@ -11,8 +11,9 @@
</div>
</div>
<div class="row d-none d-md-flex">
<div class="col-12 col-lg-6 d-flex flex-column">
<div class="mb-auto" data-bs-toggle="modal" data-bs-target="#plan7Modal">
<div class="col-12 col-lg-6 d-flex flex-column gap-3">
@if(array_key_exists('plan7_iframe', DESIGN_PARAMETERS))
<div class="" data-bs-toggle="modal" data-bs-target="#plan7Modal">
<a href="#"
class="list-group-item list-group-item-action p-3 bg-white rounded border border-light-subtle"
aria-current="true">
@ -31,7 +32,8 @@ class="list-group-item list-group-item-action p-3 bg-white rounded border border
</div>
</a>
</div>
<div class="">
@endif
<div class="bg-light px-2 flex-fill rounded">
<div class="hstack gap-2">
<div class="fs-5 fw-bold">Клиенты</div>
<div class="ms-auto p-2">