добавлены трейты и таблицы для работы с plan7 и отправки в битрикс
This commit is contained in:
parent
20758a24aa
commit
d9366946c4
@ -13,5 +13,8 @@ class SendDeal extends BitrixSender
|
|||||||
public function __construct(Deal $deal)
|
public function __construct(Deal $deal)
|
||||||
{
|
{
|
||||||
$this->addDataItem('complexName', $deal->complex->name);
|
$this->addDataItem('complexName', $deal->complex->name);
|
||||||
|
if ($plan7Data = $deal->getPlan7Data()) {
|
||||||
|
$this->addDataItem('plan7', $plan7Data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,10 +6,13 @@
|
|||||||
use Laravel\Prompts\FormStep;
|
use Laravel\Prompts\FormStep;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Livewire\Attributes\Validate;
|
use Livewire\Attributes\Validate;
|
||||||
|
use Livewire\Attributes\On;
|
||||||
|
|
||||||
|
|
||||||
use Modules\Main\Models\Deal\Deal;
|
use Modules\Main\Models\Deal\Deal;
|
||||||
use Modules\Main\Models\Deal\Client;
|
use Modules\Main\Models\Deal\Client;
|
||||||
use Modules\Main\Models\Deal\DealClients;
|
use Modules\Main\Models\Deal\DealClients;
|
||||||
|
use Modules\Plan7\Models\DealPlan7;
|
||||||
class ClientCreateLivewire extends Component
|
class ClientCreateLivewire extends Component
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,6 +26,8 @@ class ClientCreateLivewire extends Component
|
|||||||
public $agentId;
|
public $agentId;
|
||||||
public $contacts;
|
public $contacts;
|
||||||
public $complexId;
|
public $complexId;
|
||||||
|
public $plan7Room = false;
|
||||||
|
////////////////////
|
||||||
public $currentContactIndex;
|
public $currentContactIndex;
|
||||||
public $contactLabels;
|
public $contactLabels;
|
||||||
public $bitrixId;
|
public $bitrixId;
|
||||||
@ -180,6 +185,10 @@ public function updated($propertyName)
|
|||||||
$this->status = FormStatus::IN_PROCESS;
|
$this->status = FormStatus::IN_PROCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#[On('plan7_selector_set_room')]
|
||||||
|
public function setPlan7Room($room) {
|
||||||
|
$this->plan7Room = $room;
|
||||||
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view(
|
return view(
|
||||||
@ -205,7 +214,7 @@ public function save()
|
|||||||
if (
|
if (
|
||||||
!$deal = Deal::create([
|
!$deal = Deal::create([
|
||||||
'agent_id' => $this->agentId,
|
'agent_id' => $this->agentId,
|
||||||
'complex_id' => $this->complexId
|
'complex_id' => $this->complexId,
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -213,6 +222,10 @@ public function save()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->plan7Room) {
|
||||||
|
$deal->setPlan7Data($this->plan7Room['id'], $this->plan7Room);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->contacts as $contact)
|
foreach ($this->contacts as $contact)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -174,7 +174,6 @@ class="bi bi-plus-circle" viewBox="0 0 16 16">
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if (count($availableAgents) > 1)
|
@if (count($availableAgents) > 1)
|
||||||
|
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<select wire:model.live="agentId" class="form-select rounded-4 @error('agentId') is-invalid @enderror"
|
<select wire:model.live="agentId" class="form-select rounded-4 @error('agentId') is-invalid @enderror"
|
||||||
id="agentId" name="agent" aria-label="Агент">
|
id="agentId" name="agent" aria-label="Агент">
|
||||||
|
|||||||
@ -7,12 +7,12 @@
|
|||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
use Modules\Main\Models\City;
|
use Modules\Main\Models\City;
|
||||||
use Modules\Plan7\Traits\Plan7;
|
use Modules\Plan7\Traits\Plan7Api;
|
||||||
class Complex extends Model
|
class Complex extends Model
|
||||||
{
|
{
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
use SoftDeletes;
|
use SoftDeletes;
|
||||||
use Plan7;
|
use Plan7Api;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'city_id'
|
'city_id'
|
||||||
|
|||||||
@ -12,13 +12,14 @@
|
|||||||
use Modules\Main\Models\Complex;
|
use Modules\Main\Models\Complex;
|
||||||
use Modules\Main\Models\Agent\Agent;
|
use Modules\Main\Models\Agent\Agent;
|
||||||
use Modules\Bitrix\Traits\Bitrixable;
|
use Modules\Bitrix\Traits\Bitrixable;
|
||||||
|
use Modules\Plan7\Traits\Plan7Deal;
|
||||||
|
|
||||||
use App\Notifications\Deal\DealCreated;
|
use App\Notifications\Deal\DealCreated;
|
||||||
use App\Notifications\Deal\DealUnique;
|
use App\Notifications\Deal\DealUnique;
|
||||||
use App\Notifications\Deal\DealNotUnique;
|
use App\Notifications\Deal\DealNotUnique;
|
||||||
class Deal extends Model
|
class Deal extends Model
|
||||||
{
|
{
|
||||||
use HasFactory, Notifiable, Bitrixable;
|
use HasFactory, Notifiable, Bitrixable, Plan7Deal;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'complex_id',
|
'complex_id',
|
||||||
'agent_id',
|
'agent_id',
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('deal_plan7', function (Blueprint $table)
|
||||||
|
{
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('deal_id')->references('id')->on('deals')->onDelete('cascade');
|
||||||
|
$table->integer('plan7_id');
|
||||||
|
$table->text('data')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('deal_plan7');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -31,7 +31,7 @@ public function mount()
|
|||||||
}
|
}
|
||||||
#[On('client_form_complex_updated')]
|
#[On('client_form_complex_updated')]
|
||||||
public function load() {
|
public function load() {
|
||||||
$this->room = false;
|
$this->unsetRoom();
|
||||||
$this->filter = [];
|
$this->filter = [];
|
||||||
$complex = Complex::find($this->complexId);
|
$complex = Complex::find($this->complexId);
|
||||||
$this->complexName = $complex->name;
|
$this->complexName = $complex->name;
|
||||||
@ -79,11 +79,12 @@ public function setHouse($id)
|
|||||||
|
|
||||||
public function setRoom($id)
|
public function setRoom($id)
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->room = $this->allObjects['data'][$id];
|
$this->room = $this->allObjects['data'][$id];
|
||||||
|
$this->dispatch('plan7_selector_set_room', room: $this->room);
|
||||||
}
|
}
|
||||||
public function unsetRoom() {
|
public function unsetRoom() {
|
||||||
$this->room = false;
|
$this->room = false;
|
||||||
|
$this->dispatch('plan7_selector_set_room', room: false);
|
||||||
}
|
}
|
||||||
public function resetFilter() {
|
public function resetFilter() {
|
||||||
$this->filter = [];
|
$this->filter = [];
|
||||||
|
|||||||
14
app/Modules/Plan7/Models/DealPlan7.php
Normal file
14
app/Modules/Plan7/Models/DealPlan7.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Plan7\Models;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
class DealPlan7 extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'deal_plan7';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'deal_id',
|
||||||
|
'plan7_id',
|
||||||
|
'data'
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -8,7 +8,7 @@
|
|||||||
use Illuminate\Database\Eloquent\Relations\HasOne;
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Modules\Plan7\Models\ComplexPlan7;
|
use Modules\Plan7\Models\ComplexPlan7;
|
||||||
trait Plan7
|
trait Plan7Api
|
||||||
{
|
{
|
||||||
public function getPlan7ApiData()
|
public function getPlan7ApiData()
|
||||||
{
|
{
|
||||||
29
app/Modules/Plan7/Traits/Plan7Deal.php
Normal file
29
app/Modules/Plan7/Traits/Plan7Deal.php
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Plan7\Traits;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\MorphOne;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Modules\Plan7\Models\DealPlan7;
|
||||||
|
trait Plan7Deal
|
||||||
|
{
|
||||||
|
public function setPlan7Data($id, $data)
|
||||||
|
{
|
||||||
|
return DealPlan7::updateOrCreate(['deal_id' => $this->id], [
|
||||||
|
'plan7_id' => $id,
|
||||||
|
'data' => json_encode($data)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
public function getPlan7Data()
|
||||||
|
{
|
||||||
|
if ($plan7 = DealPlan7::where('deal_id', $this->id)->first()) {
|
||||||
|
return $plan7->data;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<div class="">
|
<div class="">
|
||||||
<div id="{{ $containerId }}">
|
<div id="{{ $containerId }}">
|
||||||
<input type="hidden" name="plan7_apa" value="">
|
<input type="hidden" name="plan7_apa" value="{{ ($room) ? $room['id'] : '' }}">
|
||||||
<!-- Button trigger modal -->
|
<!-- Button trigger modal -->
|
||||||
<div class="d-flex flex-wrap justify-content-between align-self-start gap-2">
|
<div class="d-flex flex-wrap justify-content-between align-self-start gap-2">
|
||||||
@if($room)
|
@if($room)
|
||||||
|
|||||||
BIN
resources/fonts/TikTokSans.ttf
Normal file
BIN
resources/fonts/TikTokSans.ttf
Normal file
Binary file not shown.
BIN
resources/woff/bootstrap-icons.woff2
Normal file
BIN
resources/woff/bootstrap-icons.woff2
Normal file
Binary file not shown.
@ -15,7 +15,9 @@ export default defineConfig({
|
|||||||
'resources/css/docs.css',
|
'resources/css/docs.css',
|
||||||
'resources/css/multiselect.css',
|
'resources/css/multiselect.css',
|
||||||
'resources/js/phone-format.js',
|
'resources/js/phone-format.js',
|
||||||
'resources/js/trix.umd.min.js'
|
'resources/js/trix.umd.min.js',
|
||||||
|
'resources/fonts/TikTokSans.ttf',
|
||||||
|
'resources/woff/bootstrap-icons.woff2',
|
||||||
],
|
],
|
||||||
refresh: true,
|
refresh: true,
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user