design updated
This commit is contained in:
parent
9940c10a33
commit
292d7d9dc3
@ -31,7 +31,6 @@ public function __invoke(Request $request)
|
||||
'secret' => bin2hex(random_bytes(16)),
|
||||
'status' => 'new'
|
||||
]);
|
||||
//dd($request->all());
|
||||
$data = $request->only('name', 'email', 'inn', 'legal_address', 'secret', 'status', 'type', 'phone');
|
||||
$company = Company::create($data);
|
||||
if (!$company)
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
use App\Models\Complex;
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\Bitrix\SendClient;
|
||||
use App\Models\Company\CompanyAdmin;
|
||||
|
||||
|
||||
class CreateClientForm extends Component
|
||||
@ -21,6 +22,7 @@ class CreateClientForm extends Component
|
||||
public $complexes;
|
||||
public $status;
|
||||
public $result;
|
||||
public $agent;
|
||||
protected $messages = [
|
||||
'client.firstName.required' => 'Необходимо указать имя клиента',
|
||||
'client.secondName.required' => 'Необходимо указать фамилию клиента',
|
||||
@ -47,6 +49,7 @@ public function mount()
|
||||
'complexId' => ''
|
||||
];
|
||||
$this->status = self::NEW;
|
||||
$this->agent = false;
|
||||
}
|
||||
public function update()
|
||||
{
|
||||
@ -96,7 +99,18 @@ public function render()
|
||||
{
|
||||
$this->status = self::READY;
|
||||
}
|
||||
return view('livewire.create-client-form');
|
||||
$data = [];
|
||||
if ($adminAccount = CompanyAdmin::where('user_id', auth()->user()->id)->first())
|
||||
{
|
||||
$data = [
|
||||
'adminAccount' => $adminAccount,
|
||||
'agents' => Agent::where('company_id', $adminAccount->company_id)->get()
|
||||
];
|
||||
}
|
||||
return view(
|
||||
'livewire.create-client-form',
|
||||
$data
|
||||
);
|
||||
}
|
||||
public function resetData()
|
||||
{
|
||||
@ -109,7 +123,7 @@ public function back()
|
||||
public function save()
|
||||
{
|
||||
$validated = $this->validate($this->rules());
|
||||
$agent = Agent::where('user_id', auth()->user()->id)->first();
|
||||
$agent = $this->agent || Agent::where('user_id', auth()->user()->id)->first()->id;
|
||||
$phone = '+7' . $this->client['phone'];
|
||||
$newUser = User::updateOrCreate(
|
||||
['phone' => $phone],
|
||||
@ -119,7 +133,7 @@ public function save()
|
||||
]
|
||||
);
|
||||
$data = [
|
||||
'agent_id' => $agent->id
|
||||
'agent_id' => $agent
|
||||
,
|
||||
'client_id' => $newUser->id
|
||||
,
|
||||
@ -129,7 +143,7 @@ public function save()
|
||||
|
||||
if ($newDeal = Deal::create($data))
|
||||
{
|
||||
if ($bitrixId = $this->sendToBitrix($newDeal->id))
|
||||
if ($bitrixId = $this->sendToBitrix($newDeal))
|
||||
{
|
||||
$newDeal->bitrix_id = $bitrixId;
|
||||
$newDeal->status = DealStatus::MODERATION;
|
||||
@ -144,10 +158,11 @@ public function save()
|
||||
}
|
||||
return $this->status = self::ERROR;
|
||||
}
|
||||
public function sendToBitrix($id)
|
||||
public function sendToBitrix(Deal $deal)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$agent = Agent::where('user_id', $user->id)->first();
|
||||
//$user = auth()->user();
|
||||
//$agent = Agent::where(column: 'user_id', $user->id)->first();
|
||||
$agent = $deal->agent;
|
||||
$agentName = $agent->user->getPartialsName();
|
||||
$data = [
|
||||
'CLIENT_FIRST_NAME' => $this->client['firstName'],
|
||||
@ -160,7 +175,7 @@ public function sendToBitrix($id)
|
||||
'OBJECT_NAME' => Complex::find($this->client['complexId'])->name,
|
||||
'CALLBACK_URL' => route('deal.confirm', ['hash' => $this->client['confirmToken']]),
|
||||
];
|
||||
$sender = new SendClient($id, $data);
|
||||
$sender = new SendClient($deal->id, $data);
|
||||
$response = $sender->send();
|
||||
if ($response)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
@section('content')
|
||||
<div>
|
||||
<form class="d-flex mb-3" method="GET" action="{{ route('clients.table') }}">
|
||||
<form class="d-block d-md-flex mb-3" method="GET" action="{{ route('clients.table') }}">
|
||||
<div class="p-2 border rounded-3 border-1 p-1 bg-white">
|
||||
<input type="radio" class="btn-check" name="status" value="all" id="option5" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $status == 'all' ? 'checked' : '' }}>
|
||||
@ -28,7 +28,7 @@
|
||||
<div class="p-2">
|
||||
<button type="button" class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal"
|
||||
data-bs-target="#createClientModal">
|
||||
<i class="bi bi-person-plus"></i>
|
||||
<i class="bi bi-person-plus"></i> <span class="d-inline d-md-none">Добавить клиента</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
<div class="col col-sm-2" id="leftPanel">
|
||||
@include('left-panel')
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<div class="col-10 px-0 px-md-4">
|
||||
@yield('content')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<li class="nav-item text-center m-2">
|
||||
<a href="{{ route('home') }}" class="nav-link d-flex align-items-center gap-2 fs-5 border rounded-4 active"
|
||||
aria-current="page">
|
||||
<i class="bi bi-columns-gap"></i> <span class="d-none d-lg-inline">Главная</span>
|
||||
<i class="bi bi-columns-gap"></i> <span class="d-none d-lg-inline text-truncate">Главная</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item text-center m-2">
|
||||
|
||||
@ -84,6 +84,28 @@ class="form-select rounded-4 @error('client.complexId') is-invalid @enderror" id
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
@if($adminAccount)
|
||||
<div class="form-floating mb-3">
|
||||
<select wire:model.live="agent"
|
||||
class="form-select rounded-4 @error('agent') is-invalid @enderror" id="agent"
|
||||
name="agent" aria-label="Агент">
|
||||
<option selected></option>
|
||||
@foreach ($agents as $agent)
|
||||
<option value="{{ $agent->id }}">
|
||||
{{ $agent->user->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<label for="client.complexId">Агент</label>
|
||||
@error('agent')
|
||||
<span class="invalid-feedback text-white" role="alert">
|
||||
<strong>{{ $message }}</strong>
|
||||
</span>
|
||||
@enderror
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($status == self::READY && !$errors->any())
|
||||
<div class="">
|
||||
<button wire:click="save" class="btn btn-secondary rounded-4 fw-bold fs-5 w-100 py-3"
|
||||
@ -102,7 +124,7 @@ class="form-select rounded-4 @error('client.complexId') is-invalid @enderror" id
|
||||
@endif
|
||||
|
||||
@if ($status == self::SUCCESS)
|
||||
<div class="text-center fs-1 text-white">
|
||||
<div class="text-center fs-1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" fill="currentColor"
|
||||
class="bi bi-check-circle-fill" viewBox="0 0 16 16">
|
||||
<path
|
||||
@ -111,7 +133,7 @@ class="bi bi-check-circle-fill" viewBox="0 0 16 16">
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
<div class="text-center fs-3 text-white">Клиент добавлен</div>
|
||||
<div class="text-center fs-3">Клиент добавлен</div>
|
||||
<div class="text-center fs-5 ">Мы проверим его уникальность и направим Вам информацию в личном
|
||||
кабинете</div>
|
||||
<div class="text-center mt-3">
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
@section('content')
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col col-6">
|
||||
<div class="col-12 col-lg-6 mb-2">
|
||||
<div class="">
|
||||
<a href="#"
|
||||
class="list-group-item list-group-item-action p-3 bg-white rounded border border-light-subtle"
|
||||
@ -75,7 +75,7 @@ class="list-group-item list-group-item-action p-3 bg-white rounded border border
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-6">
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="px-5 py-3 bg-primary border rounded-3 mx-auto d-flex align-items-center"
|
||||
style="min-height:30em;">
|
||||
<livewire:createClientForm />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user