обновлена таблица вознаграждений в админке
This commit is contained in:
parent
d2ceee50f5
commit
7fddfd54c7
@ -13,93 +13,90 @@
|
||||
|
||||
|
||||
class CreateClientForm extends Component
|
||||
{
|
||||
const NEW = 1;
|
||||
const ERROR = 2;
|
||||
{
|
||||
const NEW = 1;
|
||||
const ERROR = 2;
|
||||
const SUCCESS = 3;
|
||||
const READY = 4;
|
||||
const READY = 4;
|
||||
public $client;
|
||||
public $complexes;
|
||||
public $status;
|
||||
public $result;
|
||||
public $agent;
|
||||
protected $messages = [
|
||||
'client.firstName.required' => 'Необходимо указать имя клиента',
|
||||
'client.firstName.required' => 'Необходимо указать имя клиента',
|
||||
'client.secondName.required' => 'Необходимо указать фамилию клиента',
|
||||
'client.phone.required' => 'Необходимо указать телефон без кода страны "+7" или "8"',
|
||||
'client.phone.regex' => 'Телефон должен содержать 10 симвлов без указания кода страны "+7" или "8"',
|
||||
'client.phone.unique' => 'Клиент с таким телефоном уже существует',
|
||||
'agent.integer' => 'Необходимо указать агента, от которого добавляется контакт'
|
||||
'client.phone.required' => 'Необходимо указать телефон без кода страны "+7" или "8"',
|
||||
'client.phone.regex' => 'Телефон должен содержать 10 симвлов без указания кода страны "+7" или "8"',
|
||||
'client.phone.unique' => 'Клиент с таким телефоном уже существует',
|
||||
'agent.integer' => 'Необходимо указать агента, от которого добавляется контакт'
|
||||
];
|
||||
protected function rules()
|
||||
{
|
||||
{
|
||||
return [
|
||||
'agent' => ['required', 'integer'],
|
||||
'client.firstName' => ['required', 'string', 'max:255'],
|
||||
'agent' => ['required', 'integer'],
|
||||
'client.firstName' => ['required', 'string', 'max:255'],
|
||||
'client.secondName' => ['required', 'string', 'max:255'],
|
||||
'client.phone' => ['required', 'string', 'regex:/\(?([0-9]{3})\)([-]{1})([0-9]{3})([-]{1})([0-9]{4})/i']
|
||||
//'client.phone' => ['required', 'string', 'regex:/^(\+7)([0-9]{3})([-]{1})([0-9]{3})([-]{1})([0-9]{4})/i']
|
||||
'client.phone' => ['required', 'string', 'regex:/^\+7 \d{3} \d{3}-\d{2}-\d{2}$/']
|
||||
];
|
||||
}
|
||||
}
|
||||
public function mount()
|
||||
{
|
||||
{
|
||||
$userBroker = Agent::where('user_id', auth()->user()->id)->first();
|
||||
$this->complexes = Complex::all();
|
||||
$this->client = [
|
||||
'firstName' => '',
|
||||
'firstName' => '',
|
||||
'secondName' => '',
|
||||
'phone' => '',
|
||||
'complexId' => ''
|
||||
'phone' => '',
|
||||
'complexId' => ''
|
||||
];
|
||||
$this->status = self::NEW;
|
||||
if ($agent = Agent::where('user_id', auth()->user()->id)->first())
|
||||
{
|
||||
$this->agent = $agent->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->agent = false;
|
||||
}
|
||||
}
|
||||
public function update()
|
||||
{
|
||||
$this->agent = $agent->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->agent = false;
|
||||
}
|
||||
}
|
||||
public function update()
|
||||
{
|
||||
}
|
||||
|
||||
public function updated($propertyName)
|
||||
{
|
||||
{
|
||||
$this->status = self::NEW;
|
||||
if ($propertyName == 'client.phone')
|
||||
{
|
||||
{
|
||||
//$this->dispatch('phone-updated', ['newPhone' => 111]);
|
||||
//$this->js("checkPhoneFormat('123')");
|
||||
$phone = preg_replace('/[^0-9]/', "", $this->client['phone']);
|
||||
if (strlen($phone) == 10)
|
||||
{
|
||||
$sArea = substr($phone, 0, 3);
|
||||
$sPrefix = substr($phone, 3, 3);
|
||||
$sNumber = substr($phone, 6, 4);
|
||||
$phone = "(" . $sArea . ")-" . $sPrefix . "-" . $sNumber;
|
||||
$this->client['phone'] = $phone;
|
||||
}
|
||||
elseif (strlen($this->client['phone']) == 1)
|
||||
{
|
||||
if ($this->client['phone'] == "8" || $this->client['phone'] == "7" || $this->client['phone'] == "+")
|
||||
{
|
||||
$this->client['phone'] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->client['phone'] = $phone;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->client['phone'] = $phone;
|
||||
}
|
||||
$phone = preg_replace('/[^0-9\+]+/', "", $this->client['phone']);
|
||||
if (strlen($this->client['phone']) <= 2)
|
||||
{
|
||||
$this->client['phone'] = "+7";
|
||||
}
|
||||
elseif (strlen($phone) <= 12)
|
||||
{
|
||||
$code = substr($phone, 0, 2);
|
||||
$sArea = substr($phone, 2, 3);
|
||||
$sPrefix = substr($phone, 5, 3);
|
||||
$sNumber1 = substr($phone, 8, 2);
|
||||
$sNumber2 = substr($phone, 10, 2);
|
||||
|
||||
$phone = $code . " " . $sArea . " " . $sPrefix . "-" . $sNumber1 . "-" . $sNumber2;
|
||||
$this->client['phone'] = $phone;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->client['phone'] = $phone;
|
||||
}
|
||||
$this->validateOnly($propertyName);
|
||||
}
|
||||
$this->validateOnly($propertyName);
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
{
|
||||
if (
|
||||
$this->client['firstName']
|
||||
&& $this->client['secondName']
|
||||
@ -107,95 +104,95 @@ public function render()
|
||||
&& $this->client['complexId']
|
||||
&& $this->status == self::NEW
|
||||
)
|
||||
{
|
||||
{
|
||||
$this->status = self::READY;
|
||||
}
|
||||
}
|
||||
$data = [
|
||||
'adminAccount' => false
|
||||
];
|
||||
if ($adminAccount = CompanyAdmin::where('user_id', auth()->user()->id)->first())
|
||||
{
|
||||
{
|
||||
$data = [
|
||||
'adminAccount' => $adminAccount,
|
||||
'agents' => Agent::where('company_id', $adminAccount->company_id)->get()
|
||||
'agents' => Agent::where('company_id', $adminAccount->company_id)->get()
|
||||
];
|
||||
}
|
||||
}
|
||||
return view(
|
||||
'livewire.create-client-form',
|
||||
$data
|
||||
);
|
||||
}
|
||||
}
|
||||
public function resetData()
|
||||
{
|
||||
{
|
||||
$this->mount();
|
||||
}
|
||||
}
|
||||
public function back()
|
||||
{
|
||||
{
|
||||
$this->status = self::NEW;
|
||||
}
|
||||
}
|
||||
public function save()
|
||||
{
|
||||
{
|
||||
$validated = $this->validate($this->rules());
|
||||
$phone = '+7' . $this->client['phone'];
|
||||
$newUser = User::updateOrCreate(
|
||||
['phone' => $phone],
|
||||
[
|
||||
'name' => trim($this->client['firstName'] . ' ' . $this->client['secondName']),
|
||||
'name' => trim($this->client['firstName'] . ' ' . $this->client['secondName']),
|
||||
'phone' => $phone
|
||||
]
|
||||
);
|
||||
$data = [
|
||||
'agent_id' => $this->agent
|
||||
'agent_id' => $this->agent
|
||||
,
|
||||
'client_id' => $newUser->id
|
||||
'client_id' => $newUser->id
|
||||
,
|
||||
'complex_id' => $this->client['complexId']
|
||||
];
|
||||
$data['confirm_token'] = $this->client['confirmToken'] = hash('sha256', json_encode($data));
|
||||
|
||||
if ($newDeal = Deal::create($data))
|
||||
{
|
||||
{
|
||||
if ($bitrixId = $this->sendToBitrix($newDeal))
|
||||
{
|
||||
{
|
||||
$newDeal->bitrix_id = $bitrixId;
|
||||
$newDeal->status = DealStatus::MODERATION;
|
||||
$newDeal->save();
|
||||
$this->result = $bitrixId;
|
||||
return $this->status = self::SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
$newDeal->delete();
|
||||
}
|
||||
}
|
||||
return $this->status = self::ERROR;
|
||||
else
|
||||
{
|
||||
$newDeal->delete();
|
||||
}
|
||||
}
|
||||
return $this->status = self::ERROR;
|
||||
}
|
||||
public function sendToBitrix(Deal $deal)
|
||||
{
|
||||
{
|
||||
//$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'],
|
||||
'CLIENT_FIRST_NAME' => $this->client['firstName'],
|
||||
'CLIENT_SECOND_NAME' => $this->client['secondName'],
|
||||
'CLIENT_PHONE' => '+7' . $this->client['phone'],
|
||||
'BROKER_FIRST_NAME' => $agentName['firstName'],
|
||||
'CLIENT_PHONE' => '+7' . $this->client['phone'],
|
||||
'BROKER_FIRST_NAME' => $agentName['firstName'],
|
||||
'BROKER_SECOND_NAME' => $agentName['secondName'],
|
||||
'BROKER_PHONE' => $agent->user->phone,
|
||||
'BROKER_INN' => $agent->company->inn,
|
||||
'OBJECT_NAME' => Complex::find($this->client['complexId'])->name,
|
||||
'CALLBACK_URL' => route('api.client', ['hash' => $this->client['confirmToken']]),
|
||||
'BROKER_PHONE' => $agent->user->phone,
|
||||
'BROKER_INN' => $agent->company->inn,
|
||||
'OBJECT_NAME' => Complex::find($this->client['complexId'])->name,
|
||||
'CALLBACK_URL' => route('api.client', ['hash' => $this->client['confirmToken']]),
|
||||
];
|
||||
$sender = new SendClient($deal->id, $data);
|
||||
$response = $sender->send();
|
||||
if ($response)
|
||||
{
|
||||
{
|
||||
return $response;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -31,17 +31,11 @@ public function index(Request $request)
|
||||
'filter' => $request->filter
|
||||
]);
|
||||
}
|
||||
public function edit(City $city)
|
||||
{
|
||||
return view('admin::companies.edit', [
|
||||
'city' => $city,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, City $city)
|
||||
{
|
||||
$city->update($request->only('name'));
|
||||
return to_route('admin.companies');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function create(Request $request)
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
use App\Models\Agent\Agent;
|
||||
class Payments extends Component
|
||||
{
|
||||
public $value;
|
||||
public $newValue;
|
||||
public $companyId;
|
||||
public function mount()
|
||||
{
|
||||
@ -27,8 +27,8 @@ public function back()
|
||||
|
||||
public function setPaymentValueForCompany(Company $company, Complex $complex)
|
||||
{
|
||||
$company->setPayment($complex, $this->value);
|
||||
$this->value = null;
|
||||
$company->setPayment($complex, $this->newValue);
|
||||
$this->newValue = null;
|
||||
}
|
||||
|
||||
public function unsetPaymentForCompany(Company $company, Complex $complex)
|
||||
@ -38,14 +38,14 @@ public function unsetPaymentForCompany(Company $company, Complex $complex)
|
||||
|
||||
public function setPaymentValueForAgent(Agent $agent, Complex $complex)
|
||||
{
|
||||
$agent->setPayment($complex, $this->value);
|
||||
$this->value = null;
|
||||
$agent->setPayment($complex, $this->newValue);
|
||||
$this->newValue = null;
|
||||
}
|
||||
|
||||
public function setPaymentAsParentForAgent(Agent $agent, Complex $complex)
|
||||
{
|
||||
$agent->setAsParentPayment($complex);
|
||||
$this->value = null;
|
||||
$this->newValue = null;
|
||||
}
|
||||
|
||||
public function unsetPaymentForAgent(Agent $agent, Complex $complex)
|
||||
@ -53,6 +53,21 @@ public function unsetPaymentForAgent(Agent $agent, Complex $complex)
|
||||
$agent->unsetPayment($complex);
|
||||
}
|
||||
|
||||
public function setPaymentForAllAgentOfCompany(Company $company, Complex $complex)
|
||||
{
|
||||
$compPayment = $company->getPaymentable($complex);
|
||||
$compPayment = $compPayment->value;
|
||||
if ($compPayment == null || $compPayment == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$agents = Agent::where('company_id', $company->id)->get();
|
||||
foreach ($agents as $agent)
|
||||
{
|
||||
$agent->setPayment($complex, $compPayment);
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->companyId)
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
Route::post('/admin/companies/{company}/delete', [Modules\Admin\Http\Controllers\AdminUsersController::class, 'update'])->name('admin.companies.delete');
|
||||
|
||||
Route::get('/admin/cities', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'index'])->name('admin.cities');
|
||||
Route::get('/admin/cities/{city}/edit', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'edit'])->name('admin.cities.edit');
|
||||
Route::post('/admin/cities/{city}/update', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'update'])->name('admin.cities.update');
|
||||
Route::post('/admin/cities/create', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'create'])->name('admin.cities.create');
|
||||
Route::post('/admin/cities/{city}/delete', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'delete'])->name('admin.cities.delete');
|
||||
Route::post('/admin/cities/{city}/restore', [Modules\Admin\Http\Controllers\AdminCitiesController::class, 'restore'])->withTrashed()->name('admin.cities.restore');
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
@php($title = 'Города')
|
||||
@extends('layouts.admin')
|
||||
@section('content')
|
||||
<style>
|
||||
.collapsing {
|
||||
transition: none !important;
|
||||
}
|
||||
</style>
|
||||
<div class="d-flex mb-3">
|
||||
<form class="p-2 border rounded-3 border-1 bg-white" method="GET" action="{{ route('admin.cities') }}">
|
||||
<input type="radio" class="btn-check" name="filter" value="all" id="option_all" autocomplete="off"
|
||||
@ -36,7 +41,19 @@
|
||||
@foreach ($cities as $city)
|
||||
<tr scope="row" class="@if ($city->trashed()) bg-secondary @endif">
|
||||
<td class="align-middle">
|
||||
{{ $city->name }}
|
||||
<div class="collapse show" data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseName{{ $city->id }}" id="collapseName{{ $city->id }}">
|
||||
{{ $city->name }}
|
||||
</div>
|
||||
<div class="collapse" id="collapseName{{ $city->id }}">
|
||||
<form action="{{ route('admin.cities.update', ['city' => $city]) }}" method="post">
|
||||
@csrf
|
||||
<input class="form-control form-control-lg w-100" name="name" type="text"
|
||||
value="{{ $city->name }}" placeholder="Название города"
|
||||
aria-label="default input example">
|
||||
<input type="submit" hidden />
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{{ $city->created_at ? $city->created_at->diffForHumans() : '' }}
|
||||
@ -59,9 +76,12 @@
|
||||
<button class="dropdown-item" type="submit">Восстановить</button>
|
||||
</form>
|
||||
@else
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('admin.cities.edit', ['city' => $city]) }}">Редактировать</a>
|
||||
<form method="post" action="{{ route('admin.cities.delete', ['city' => $city]) }}">
|
||||
<button class="dropdown-item" type="button" data-bs-toggle="collapse"
|
||||
data-bs-target="#collapseName{{ $city->id }}">
|
||||
Редактировать
|
||||
</button>
|
||||
<form method="post"
|
||||
action="{{ route('admin.cities.delete', ['city' => $city]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>
|
||||
|
||||
@ -1,124 +1,209 @@
|
||||
<div>
|
||||
<button wire:click="back" class="btn border-0 icon-link icon-link-hover fs-5 mb-3 text-decoration-none text-primary"
|
||||
style="--bs-icon-link-transform: translate3d(-.125rem, 0, 0);" href="#">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-chevron-left"
|
||||
viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd"
|
||||
d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0" />
|
||||
</svg>
|
||||
{{ $company->name }}
|
||||
</button>
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Агент</th>
|
||||
@foreach ($complexes as $complex)
|
||||
<th>
|
||||
{{ $complex->name }}
|
||||
<div>
|
||||
@php($compPayment = $company->getPaymentable($complex))
|
||||
<span class="badge bg-secondary">
|
||||
@if ($compPayment->value === null)
|
||||
Не установлено
|
||||
@elseif($compPayment->value == -1)
|
||||
Наследовать
|
||||
@else
|
||||
{{ $compPayment->value }} %
|
||||
@endif
|
||||
</span>
|
||||
</div>
|
||||
</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($agents as $agent)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $agent->user->name }}
|
||||
</td>
|
||||
<div>
|
||||
<button wire:click="back"
|
||||
class="btn border-0 icon-link icon-link-hover fs-5 mb-3 text-decoration-none text-primary"
|
||||
style="--bs-icon-link-transform: translate3d(-.125rem, 0, 0);" href="#">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||
class="bi bi-chevron-left" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd"
|
||||
d="M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0" />
|
||||
</svg>
|
||||
{{ $company->name }}
|
||||
</button>
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0 table-striped-columns">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Агент</th>
|
||||
@foreach ($complexes as $complex)
|
||||
@php($paymentable = $agent->getPaymentable($complex))
|
||||
<td>
|
||||
@if ($paymentable->value == null)
|
||||
<th>
|
||||
{{ $complex->name }}
|
||||
<div>
|
||||
{{ $complex->city->name }}
|
||||
</div>
|
||||
<div>
|
||||
@php($compPayment = $company->getPaymentable($complex))
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light btn-sm" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Не установлено
|
||||
</button>
|
||||
<a class="btn bg-secondary-subtle btn-sm text-truncate" href="#"
|
||||
role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
@if ($compPayment->value === null)
|
||||
Не установлено
|
||||
@elseif($compPayment->value == -1)
|
||||
Наследовать
|
||||
@else
|
||||
{{ $compPayment->value }} %
|
||||
@endif
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</a>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#">
|
||||
<input class="form-control form-control-sm" type="text"
|
||||
placeholder="Процент вознаграждения" wire:model = "value"
|
||||
wire:keydown.enter="setPaymentValueForAgent({{ $agent->id }}, {{ $complex->id }})">
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor" class="bi bi-percent"
|
||||
viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $compPayment->value }}"
|
||||
wire:model.lazy = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="setPaymentAsParentForAgent({{ $agent->id }}, {{ $complex->id }})">Наследовать</button>
|
||||
</li>
|
||||
@if ($compPayment->value)
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li>
|
||||
<button class="dropdown-item"
|
||||
wire:click="setPaymentForAllAgentOfCompany({{ $company->id }}, {{ $complex->id }})">Установить
|
||||
{{ $compPayment->value }}
|
||||
% для всех агентов</button>
|
||||
</li>
|
||||
@endif
|
||||
</ul>
|
||||
</div>
|
||||
@elseif($paymentable->value == -1)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light btn-sm" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Наследовать
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#">
|
||||
<input class="form-control form-control-sm" type="text"
|
||||
placeholder="Процент вознаграждения" wire:model = "value"
|
||||
wire:keydown.enter="setPaymentValueForAgent({{ $agent->id }}, {{ $complex->id }})">
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForAgent({{ $agent->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
@else
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
{{ $paymentable->value }} %
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#">
|
||||
<input class="form-control form-control-sm" type="text"
|
||||
placeholder="Процент вознаграждения"
|
||||
value="{{ $paymentable->value }}" wire:model = "value"
|
||||
wire:keydown.enter="setPaymentValueForAgent({{ $agent->id }}, {{ $complex->id }})">
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><a class="dropdown-item disabled" href="#">Наследовать</a></li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForAgent({{ $agent->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button>
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="setPaymentAsParentForAgent({{ $agent->id }}, {{ $complex->id }})">Наследовать</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
</div>
|
||||
</th>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($agents as $agent)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $agent->user->name }}
|
||||
</td>
|
||||
@foreach ($complexes as $complex)
|
||||
@php($paymentable = $agent->getPaymentable($complex))
|
||||
<td>
|
||||
@if ($paymentable->value == null)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Не установлено
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor"
|
||||
class="bi bi-percent" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $paymentable->value }}"
|
||||
wire:model = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForAgent({{ $agent->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="setPaymentAsParentForAgent({{ $agent->id }}, {{ $complex->id }})">Наследовать</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@elseif($paymentable->value == -1)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Наследовать
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor"
|
||||
class="bi bi-percent" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $paymentable->value }}"
|
||||
wire:model = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForAgent({{ $agent->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForAgent({{ $agent->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
@else
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
{{ $paymentable->value }} %
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor"
|
||||
class="bi bi-percent" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $paymentable->value }}"
|
||||
wire:model = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForAgent({{ $agent->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForAgent({{ $agent->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button>
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="setPaymentAsParentForAgent({{ $agent->id }}, {{ $complex->id }})">Наследовать</button>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,97 +1,144 @@
|
||||
<div class="fs-5 bg-light p-0 m-0 border border-1 rounded-4 py-3">
|
||||
<table class="table m-0">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Компания</th>
|
||||
@foreach ($complexes as $complex)
|
||||
<th>{{ $complex->name }}
|
||||
</th>
|
||||
@endforeach
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($companies as $company)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $company->name }}
|
||||
</td>
|
||||
<div>
|
||||
<table class="table m-0 table-striped-columns ">
|
||||
<thead>
|
||||
<tr scope="col">
|
||||
<th>Компания</th>
|
||||
@foreach ($complexes as $complex)
|
||||
@php($paymentable = $company->getPaymentable($complex))
|
||||
<td>
|
||||
@if ($paymentable->value == null)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light btn-sm" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Не установлено
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#">
|
||||
<input class="form-control form-control-sm" type="text"
|
||||
placeholder="Процент вознаграждения" wire:model = "value"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@elseif($paymentable->value == -1)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light btn-sm" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Наследовать
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#">
|
||||
<input class="form-control form-control-sm" type="text"
|
||||
placeholder="Процент вознаграждения" wire:model = "value"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForCompany({{ $company->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
@else
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
{{ $paymentable->value }} %
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#">
|
||||
<input class="form-control form-control-sm" type="text"
|
||||
placeholder="Процент вознаграждения"
|
||||
value="{{ $paymentable->value }}" wire:model = "value"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForCompany({{ $company->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button>
|
||||
</li>
|
||||
<!--<li><a class="dropdown-item" href="#">Something else here</a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
<th>{{ $complex->name }}
|
||||
<div>
|
||||
{{ $complex->city->name }}
|
||||
</div>
|
||||
</th>
|
||||
@endforeach
|
||||
<td>
|
||||
<button class="btn btn-light" wire:click="setCompany({{ $company->id }})">
|
||||
<i class="bi bi-chevron-right"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody class=" ">
|
||||
@foreach ($companies as $company)
|
||||
<tr scope="row">
|
||||
<td class="">
|
||||
<a class="text-dark icon-link icon-link-hover text-decoration-none" href="#"
|
||||
wire:click="setCompany({{ $company->id }})">
|
||||
{{ $company->name }}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||
class="bi bi-chevron-right" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd"
|
||||
d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708" />
|
||||
</svg>
|
||||
</a>
|
||||
</td>
|
||||
@foreach ($complexes as $complex)
|
||||
@php($paymentable = $company->getPaymentable($complex))
|
||||
<td class="align-middle">
|
||||
@if ($paymentable->value == null)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Не установлено
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor" class="bi bi-percent"
|
||||
viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $paymentable->value }}" wire:model = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@elseif($paymentable->value == -1)
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
Наследовать
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor" class="bi bi-percent"
|
||||
viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $paymentable->value }}" wire:model = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForCompany({{ $company->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
@else
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light" type="button" data-bs-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
{{ $paymentable->value }} %
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item " href="#">
|
||||
<span class="badge text-dark">Введите размер вознаграждения:
|
||||
</span>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="basic-addon1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20"
|
||||
height="20" fill="currentColor" class="bi bi-percent"
|
||||
viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M13.442 2.558a.625.625 0 0 1 0 .884l-10 10a.625.625 0 1 1-.884-.884l10-10a.625.625 0 0 1 .884 0M4.5 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5m7 6a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3m0 1a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5" />
|
||||
</svg>
|
||||
</span>
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Вознаграждение"
|
||||
value="{{ $paymentable->value }}"
|
||||
wire:model.lazy = "newValue"
|
||||
wire:keydown.enter="setPaymentValueForCompany({{ $company->id }}, {{ $complex->id }})">
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<hr class="dropdown-divider">
|
||||
</li>
|
||||
<li><button class="dropdown-item"
|
||||
wire:click="unsetPaymentForCompany({{ $company->id }}, {{ $complex->id }})">Без
|
||||
вознаграждения</button>
|
||||
</li>
|
||||
<!--<li><a class="dropdown-item" href="#">Something else here</a></li>-->
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
</td>
|
||||
@endforeach
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
use App\Models\Complex;
|
||||
trait Paymentable
|
||||
{
|
||||
private $defaultValue = null; // -1 || null
|
||||
private $defaultValue = -1; // -1 || null
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
@ -15,11 +15,6 @@ protected static function boot()
|
||||
{
|
||||
|
||||
});
|
||||
|
||||
static::deleted(function ($item)
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private function getClassName()
|
||||
|
||||
@ -5,6 +5,10 @@ .bg-primary {
|
||||
border-color: #ce4711 !important;
|
||||
}
|
||||
|
||||
label {
|
||||
color: rgba(var(--bs-body-color-rgb), .65);
|
||||
}
|
||||
|
||||
.btn-secondary,
|
||||
.btn-secondary:disabled {
|
||||
color: white;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user