clients form updated for second contact
This commit is contained in:
parent
a032cd52aa
commit
c5f369e2a5
@ -6,9 +6,8 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use App\Models\Deal\Deal;
|
use App\Models\Deal\Deal;
|
||||||
use App\Models\Deal\Contract;
|
use Modules\Contracts\Models\Contract;
|
||||||
use App\Models\Deal\ContractStatus;
|
use Modules\Contracts\Models\ContractStatus;
|
||||||
use App\Models\Agent\Agent;
|
|
||||||
use App\Notifications\ContractUpdated;
|
use App\Notifications\ContractUpdated;
|
||||||
class ContractApiController
|
class ContractApiController
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,14 +5,9 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use App\Models\Deal\Deal;
|
use App\Models\Deal\Deal;
|
||||||
use App\Models\Agent\Agent;
|
|
||||||
use App\Models\Company\CompanyAdmin;
|
use App\Models\Company\CompanyAdmin;
|
||||||
|
|
||||||
use App\Models\City;
|
use App\Models\City;
|
||||||
|
|
||||||
use App\Models\Deal\ContractStatus;
|
|
||||||
|
|
||||||
|
|
||||||
class ClientsTableController extends Controller
|
class ClientsTableController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
|
|||||||
@ -5,10 +5,7 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
use App\Models\Deal\Deal;
|
use Modules\Contracts\Models\Contract;
|
||||||
use App\Models\Deal\Contract;
|
|
||||||
use App\Models\Deal\ContractStatus;
|
|
||||||
use App\Models\Agent\Agent;
|
|
||||||
|
|
||||||
class ContractController extends Controller
|
class ContractController extends Controller
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,9 +5,6 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Deal\Deal;
|
use App\Models\Deal\Deal;
|
||||||
|
|
||||||
use App\Notifications\UniqueContact;
|
|
||||||
use App\Notifications\NotUniqueContact;
|
|
||||||
use App\Notifications\ContractUpdated;
|
|
||||||
use App\Notifications\Deal\DealCreated;
|
use App\Notifications\Deal\DealCreated;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,7 @@ class CreateClientForm extends Component
|
|||||||
const SUCCESS = 3;
|
const SUCCESS = 3;
|
||||||
const READY = 4;
|
const READY = 4;
|
||||||
public $client;
|
public $client;
|
||||||
|
public $clientSecondary;
|
||||||
public $complexes;
|
public $complexes;
|
||||||
public $status;
|
public $status;
|
||||||
public $result;
|
public $result;
|
||||||
@ -26,8 +27,8 @@ class CreateClientForm extends Component
|
|||||||
protected $messages = [
|
protected $messages = [
|
||||||
'client.firstName.required' => 'Необходимо указать имя клиента',
|
'client.firstName.required' => 'Необходимо указать имя клиента',
|
||||||
'client.secondName.required' => 'Необходимо указать фамилию клиента',
|
'client.secondName.required' => 'Необходимо указать фамилию клиента',
|
||||||
'client.phone.required' => 'Необходимо указать телефон без кода страны "+7" или "8"',
|
'client.phone.required' => 'Необходимо указать телефон',
|
||||||
'client.phone.regex' => 'Телефон должен содержать 10 симвлов без указания кода страны "+7" или "8"',
|
'client.phone.regex' => 'Телефон должен быть в международном формате',
|
||||||
'client.phone.unique' => 'Клиент с таким телефоном уже существует',
|
'client.phone.unique' => 'Клиент с таким телефоном уже существует',
|
||||||
'agent.integer' => 'Необходимо указать агента, от которого добавляется контакт'
|
'agent.integer' => 'Необходимо указать агента, от которого добавляется контакт'
|
||||||
];
|
];
|
||||||
@ -37,9 +38,9 @@ protected function rules()
|
|||||||
'agent' => ['required', 'integer'],
|
'agent' => ['required', 'integer'],
|
||||||
'client.firstName' => ['required', 'string', 'max:255'],
|
'client.firstName' => ['required', 'string', 'max:255'],
|
||||||
'client.secondName' => ['required', 'string', 'max:255'],
|
'client.secondName' => ['required', 'string', 'max:255'],
|
||||||
//'client.phone' => ['required', 'string', 'regex:/^(\+7)([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}$/'],
|
//'client.phone' => ['required', 'string', 'regex:/^\+7 \d{3} \d{3}-\d{2}-\d{2}$/'],
|
||||||
'client.phone' => ['required', 'string']
|
//'client.phone' => ['required', 'string']
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
public function mount()
|
public function mount()
|
||||||
@ -68,6 +69,7 @@ public function mount()
|
|||||||
$this->complexes = Complex::where('city_id', $admin->company_id)->get();
|
$this->complexes = Complex::where('city_id', $admin->company_id)->get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->clientSecondary = false;
|
||||||
}
|
}
|
||||||
public function update()
|
public function update()
|
||||||
{
|
{
|
||||||
@ -76,33 +78,21 @@ public function update()
|
|||||||
public function updated($propertyName)
|
public function updated($propertyName)
|
||||||
{
|
{
|
||||||
$this->status = self::NEW;
|
$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($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 getClientSecondary()
|
||||||
|
{
|
||||||
|
$this->clientSecondary = [
|
||||||
|
'firstName' => '',
|
||||||
|
'secondName' => '',
|
||||||
|
'phone' => '',
|
||||||
|
'complexId' => ''
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function deleteClientSecondary()
|
||||||
|
{
|
||||||
|
$this->clientSecondary = false;
|
||||||
|
}
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
@ -141,12 +131,11 @@ public function back()
|
|||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
$validated = $this->validate($this->rules());
|
$validated = $this->validate($this->rules());
|
||||||
$phone = '+7' . $this->client['phone'];
|
|
||||||
$newUser = User::updateOrCreate(
|
$newUser = User::updateOrCreate(
|
||||||
['phone' => $phone],
|
['phone' => $this->client['phone']],
|
||||||
[
|
[
|
||||||
'name' => trim($this->client['firstName'] . ' ' . $this->client['secondName']),
|
'name' => trim($this->client['firstName'] . ' ' . $this->client['secondName']),
|
||||||
'phone' => $phone
|
'phone' => $this->client['phone']
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$data = [
|
$data = [
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
use App\Models\User\UserRole;
|
use App\Models\User\UserRole;
|
||||||
use App\Models\User\Role;
|
use App\Models\User\Role;
|
||||||
|
use Modules\Contracts\Models\Contract;
|
||||||
use Illuminate\Notifications\Notifiable;
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
|
||||||
class Deal extends Model
|
class Deal extends Model
|
||||||
|
|||||||
5
app/Modules/Contracts/Config/config.php
Normal file
5
app/Modules/Contracts/Config/config.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<?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('contracts', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('contracts');
|
||||||
|
}
|
||||||
|
};
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contracts\Http\Controllers;
|
||||||
|
|
||||||
|
use Modules\Contracts\Models\Contract;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ContractsController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
return view('contracts::index');
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Modules/Contracts/Models/Contract.php
Normal file
35
app/Modules/Contracts/Models/Contract.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contracts\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
use App\Models\Deal\Deal;
|
||||||
|
class Contract extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
const CREATED_AT = 'created_at';
|
||||||
|
const UPDATED_AT = 'updated_at';
|
||||||
|
protected $table = 'client_contract';
|
||||||
|
protected $fillable = [
|
||||||
|
'deal_id',
|
||||||
|
'status',
|
||||||
|
'comment',
|
||||||
|
'price',
|
||||||
|
'reward',
|
||||||
|
'square',
|
||||||
|
'floor',
|
||||||
|
|
||||||
|
'room',//Номер квартиры
|
||||||
|
'date',//дата ДДУ
|
||||||
|
'reg_date',//Дата регистрации ДДУ
|
||||||
|
'payment_type',//Вид оплаты
|
||||||
|
'plan7_id'//ид помещения из plan7
|
||||||
|
];
|
||||||
|
|
||||||
|
public function deal()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Deal::class, 'deal_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
11
app/Modules/Contracts/Models/ContractStatus.php
Normal file
11
app/Modules/Contracts/Models/ContractStatus.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
namespace Modules\Contracts\Models;
|
||||||
|
class ContractStatus
|
||||||
|
{
|
||||||
|
const NEW = 'NEW';
|
||||||
|
const TREATY = 'TREATY';
|
||||||
|
const RESERVATION = 'RESERVATION';
|
||||||
|
const SUCCESS = "SUSSCESS";
|
||||||
|
const DECLINE = "DECLINE";
|
||||||
|
}
|
||||||
|
|
||||||
68
app/Modules/Contracts/Providers/ModuleServiceProvider.php
Normal file
68
app/Modules/Contracts/Providers/ModuleServiceProvider.php
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contract\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Blade;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
|
||||||
|
class ModuleServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
protected String $moduleName = 'Contract';
|
||||||
|
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->app->register(RouteServiceProvider::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
$this->registerViews();
|
||||||
|
$this->registerLivewireViews();
|
||||||
|
$this->registerMigrations();
|
||||||
|
$this->registerConfig();
|
||||||
|
$this->registerComponent();
|
||||||
|
$this->registerLivewire();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerViews()
|
||||||
|
{
|
||||||
|
$moduleViewsPath = __DIR__.'/../Views';
|
||||||
|
$this->loadViewsFrom(
|
||||||
|
$moduleViewsPath, strtolower($this->moduleName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerLivewireViews()
|
||||||
|
{
|
||||||
|
$moduleViewsPath = __DIR__.'/../Views/livewire';
|
||||||
|
$this->loadViewsFrom(
|
||||||
|
$moduleViewsPath, strtolower($this->moduleName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerMigrations()
|
||||||
|
{
|
||||||
|
$this->loadMigrationsFrom(
|
||||||
|
app_path('Modules/'.$this->moduleName.'/Database/Migrations')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerConfig()
|
||||||
|
{
|
||||||
|
$path = app_path('Modules/'.$this->moduleName.'/Config/config.php');
|
||||||
|
$this->mergeConfigFrom(
|
||||||
|
$path, strtolower($this->moduleName)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerLivewire()
|
||||||
|
{
|
||||||
|
//Livewire::component('<name>', \Modules\<NAME>\Http\Livewire\<NAME>::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerComponent()
|
||||||
|
{
|
||||||
|
//Blade::component('<name>', \Modules\<NAME>\Http\Components\<NAME>::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
app/Modules/Contracts/Providers/RouteServiceProvider.php
Normal file
24
app/Modules/Contracts/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Modules\Contract\Providers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
class RouteServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
public function map()
|
||||||
|
{
|
||||||
|
$this->registerWebRoutes();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function registerWebRoutes()
|
||||||
|
{
|
||||||
|
//Add Web Routes with web Guard
|
||||||
|
Route::middleware('web')
|
||||||
|
//Set Default Controllers Namespace
|
||||||
|
->namespace('Modules\\Contract\\Http\\Controllers')
|
||||||
|
->group(app_path('Modules/Contract/Routes/web.php'));
|
||||||
|
}
|
||||||
|
}
|
||||||
13
app/Modules/Contracts/Routes/web.php
Normal file
13
app/Modules/Contracts/Routes/web.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use Modules\Contracts\Http\Controllers\ContractsController;
|
||||||
|
|
||||||
|
Route::middleware(['auth'])->group(function() {
|
||||||
|
|
||||||
|
Route::get('/contract', [ContractsController::class, 'index']);
|
||||||
|
|
||||||
|
Route::middleware(['hasAccess'])->group(function() {
|
||||||
|
/** Routes that need to be protected - Маршруты которые нужно защитить */
|
||||||
|
});
|
||||||
|
});
|
||||||
4
app/Modules/Contracts/Views/index.blade.php
Normal file
4
app/Modules/Contracts/Views/index.blade.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
@section('content')
|
||||||
|
<h1> Example views </h1>
|
||||||
|
@endsection
|
||||||
@ -7,7 +7,7 @@
|
|||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
use App\Models\Deal\Contract;
|
use Modules\Contracts\Models\Contract;
|
||||||
use App\Models\Deal\DealStatus;
|
use App\Models\Deal\DealStatus;
|
||||||
|
|
||||||
class ContractUpdated extends Notification
|
class ContractUpdated extends Notification
|
||||||
|
|||||||
@ -17,15 +17,15 @@
|
|||||||
<label class="btn p-2 fs-5" for="option7">Не
|
<label class="btn p-2 fs-5" for="option7">Не
|
||||||
уникальные</label>
|
уникальные</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="ms-auto p-2">
|
<!--<div class="ms-auto p-2">
|
||||||
<select class="form-select form-select-lg" disabled aria-label="Large select example">
|
<select class="form-select form-select-lg" disabled aria-label="Large select example">
|
||||||
<option selected="">Город: любой</option>
|
<option selected="">Город: любой</option>
|
||||||
@foreach ($cities as $city)
|
@foreach ($cities as $city)
|
||||||
<option value="{{ $city->id }}">{{ $city->name }}</option>
|
<option value="{{ $city->id }}">{{ $city->name }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>-->
|
||||||
<div class="p-2">
|
<div class="ms-auto p-2">
|
||||||
<button type="button" class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal"
|
<button type="button" class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal"
|
||||||
data-bs-target="#createClientModal">
|
data-bs-target="#createClientModal">
|
||||||
<i class="bi bi-person-plus"></i> <span class="d-inline d-md-none">Добавить клиента</span>
|
<i class="bi bi-person-plus"></i> <span class="d-inline d-md-none">Добавить клиента</span>
|
||||||
|
|||||||
@ -9,7 +9,10 @@
|
|||||||
<div class="h4 pb-2 mb-4 fw-bold ">
|
<div class="h4 pb-2 mb-4 fw-bold ">
|
||||||
<small>Добавить клиента</small>
|
<small>Добавить клиента</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="bg-secondary-subtle rounded-4 mb-3">
|
||||||
|
<div
|
||||||
|
class="p-3 rounded-4 rounded-top-4 @if ($clientSecondary) shadow-sm bg-dark-subtle @endif">
|
||||||
|
<div class="row mb-2">
|
||||||
<div class="col-12 col-xl-6">
|
<div class="col-12 col-xl-6">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input wire:model.live="client.firstName" id="client.firstName" type="text"
|
<input wire:model.live="client.firstName" id="client.firstName" type="text"
|
||||||
@ -27,7 +30,8 @@ class="form-control rounded-4 @error('client.firstName') is-invalid @enderror"
|
|||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<input wire:model.live="client.secondName" id="client.secondName" type="text"
|
<input wire:model.live="client.secondName" id="client.secondName" type="text"
|
||||||
class="form-control rounded-4 @error('client.secondName') is-invalid @enderror"
|
class="form-control rounded-4 @error('client.secondName') is-invalid @enderror"
|
||||||
name="client.secondName" required autocomplete="client.secondName" placeholder="Фамилия">
|
name="client.secondName" required autocomplete="client.secondName"
|
||||||
|
placeholder="Фамилия">
|
||||||
<label for="client.secondName">Фамилия</label>
|
<label for="client.secondName">Фамилия</label>
|
||||||
@error('client.secondName')
|
@error('client.secondName')
|
||||||
<span class="invalid-feedback" role="alert">
|
<span class="invalid-feedback" role="alert">
|
||||||
@ -39,9 +43,9 @@ class="form-control rounded-4 @error('client.secondName') is-invalid @enderror"
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12 hstack gap-2 mb-3">
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating me-auto w-100">
|
||||||
<input wire:model.live="client.phone" id="client.phone" type="tel"
|
<input wire:model="client.phone" id="client.phone" type="tel" data-phone-pattern
|
||||||
class="form-control rounded-4 @error('client.phone') is-invalid @enderror"
|
class="form-control rounded-4 @error('client.phone') is-invalid @enderror"
|
||||||
name="client.phone" required autocomplete="phone" placeholder="Телефон клиента">
|
name="client.phone" required autocomplete="phone" placeholder="Телефон клиента">
|
||||||
<label for="client.phone">Телефон</label>
|
<label for="client.phone">Телефон</label>
|
||||||
@ -51,12 +55,94 @@ class="form-control rounded-4 @error('client.phone') is-invalid @enderror"
|
|||||||
</span>
|
</span>
|
||||||
@enderror
|
@enderror
|
||||||
</div>
|
</div>
|
||||||
|
@if ($clientSecondary == false)
|
||||||
|
<a class="" wire:click="getClientSecondary">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30"
|
||||||
|
fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">
|
||||||
|
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16" />
|
||||||
|
<path
|
||||||
|
d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4" />
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
@if ($clientSecondary)
|
||||||
|
<div class="p-3" wire:transition.origin.top>
|
||||||
|
<div class="d-flex">
|
||||||
|
<div class="p-2 w-100">СУПРУГ / СУПРУГА</div>
|
||||||
|
<div class="p-2 flex-shrink-1">
|
||||||
|
<a class="" wire:click="deleteClientSecondary">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25"
|
||||||
|
fill="currentColor" class="bi bi-person-dash" viewBox="0 0 16 16">
|
||||||
|
<path
|
||||||
|
d="M12.5 16a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7M11 12h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1 0-1m0-7a3 3 0 1 1-6 0 3 3 0 0 1 6 0M8 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4" />
|
||||||
|
<path
|
||||||
|
d="M8.256 14a4.5 4.5 0 0 1-.229-1.004H3c.001-.246.154-.986.832-1.664C4.484 10.68 5.711 10 8 10q.39 0 .74.025c.226-.341.496-.65.804-.918Q8.844 9.002 8 9c-5 0-6 3-6 4s1 1 1 1z" />
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-xl-6">
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input wire:model.live="clientSecondary.firstName"
|
||||||
|
id="clientSecondary.firstName" type="text"
|
||||||
|
class="form-control rounded-4 @error('clientSecondary.firstName') is-invalid @enderror"
|
||||||
|
name="clientSecondary.firstName" required
|
||||||
|
autocomplete="clientSecondary.firstName" placeholder="Имя">
|
||||||
|
<label for="clientSecondary.firstName">Имя</label>
|
||||||
|
@error('clientSecondary.firstName')
|
||||||
|
<span class="invalid-feedback" role="alert">
|
||||||
|
<strong>{{ $message }}</strong>
|
||||||
|
</span>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-xl-6">
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input wire:model.live="clientSecondary.secondName"
|
||||||
|
id="clientSecondary.secondName" type="text"
|
||||||
|
class="form-control rounded-4 @error('clientSecondary.secondName') is-invalid @enderror"
|
||||||
|
name="clientSecondary.secondName" required
|
||||||
|
autocomplete="clientSecondary.secondName" placeholder="Фамилия">
|
||||||
|
<label for="clientSecondary.secondName">Фамилия</label>
|
||||||
|
@error('clientSecondary.secondName')
|
||||||
|
<span class="invalid-feedback" role="alert">
|
||||||
|
<strong>{{ $message }}</strong>
|
||||||
|
</span>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input wire:model="clientSecondary.phone" id="clientSecondary.phone"
|
||||||
|
type="tel" data-phone-pattern
|
||||||
|
class="form-control rounded-4 @error('client.phone') is-invalid @enderror"
|
||||||
|
name="clientSecondary.phone" required autocomplete="phone"
|
||||||
|
placeholder="Телефон клиента">
|
||||||
|
<label for="clientSecondary.phone">Телефон</label>
|
||||||
|
@error('clientSecondary.phone')
|
||||||
|
<span class="invalid-feedback" role="alert">
|
||||||
|
<strong>{{ $message }}</strong>
|
||||||
|
</span>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
<div class="form-floating mb-3">
|
<div class="form-floating mb-3">
|
||||||
<select wire:model.live="client.complexId"
|
<select wire:model.live="client.complexId"
|
||||||
class="form-select rounded-4 @error('client.complexId') is-invalid @enderror" id="client.complexId"
|
class="form-select rounded-4 @error('client.complexId') is-invalid @enderror"
|
||||||
name="client.complexId" aria-label="Жилой комплекс">
|
id="client.complexId" name="client.complexId" aria-label="Жилой комплекс">
|
||||||
<option selected></option>
|
<option selected></option>
|
||||||
@foreach ($complexes as $complex)
|
@foreach ($complexes as $complex)
|
||||||
<option value="{{ $complex->id }}">
|
<option value="{{ $complex->id }}">
|
||||||
@ -147,28 +233,32 @@ class="bi bi-emoji-astonished" viewBox="0 0 16 16">
|
|||||||
</div>
|
</div>
|
||||||
@script
|
@script
|
||||||
<script>
|
<script>
|
||||||
function checkPhoneFormat() {
|
eventCalllback = function(e) {
|
||||||
alert(1);
|
var el = e.target,
|
||||||
|
clearVal = el.dataset.phoneClear,
|
||||||
|
pattern = el.dataset.phonePattern,
|
||||||
|
matrix_def = "+7(___) ___-__-__",
|
||||||
|
matrix = pattern ? pattern : matrix_def,
|
||||||
|
i = 0,
|
||||||
|
def = matrix.replace(/\D/g, ""),
|
||||||
|
val = e.target.value.replace(/\D/g, "");
|
||||||
|
if (clearVal !== 'false' && e.type === 'blur') {
|
||||||
|
if (val.length < matrix.match(/([\_\d])/g).length) {
|
||||||
|
e.target.value = '';
|
||||||
return;
|
return;
|
||||||
var digits = phone.replace(/^8/, '7').replace(/[^\d]+/, '');
|
|
||||||
if (digits.length < 11) {
|
|
||||||
return phone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Домашний?
|
|
||||||
if (digits.substr(0, 2) === '74') {
|
|
||||||
// Для белгородских (и похожих) домашних возвращаем нормальное форматирование
|
|
||||||
// Для остальных пытаемся
|
|
||||||
return digits.substr(0, 3) === '747' ?
|
|
||||||
digits.replace(/^(\d)(\d+)(\d\d)(\d\d)(\d\d)$/, '+$1 ($2) $3‒$4‒$5') :
|
|
||||||
digits.replace(/^(\d)(\d+)(\d\d\d)(\d\d)(\d\d)$/, '+$1 ($2) $3‒$4‒$5');
|
|
||||||
}
|
}
|
||||||
|
if (def.length >= val.length) val = def;
|
||||||
// Для русских мобильных возвращаем нормальное форматирование
|
e.target.value = matrix.replace(/./g, function(a) {
|
||||||
// Для остальных пытаемся
|
return /[_\d]/.test(a) && i < val.length ? val.charAt(i++) : i >= val.length ? "" :
|
||||||
return digits.substr(0, 2) === '79' ?
|
a
|
||||||
digits.replace(/^(\d)(\d+)(\d\d\d)(\d\d)(\d\d)$/, '+$1 $2 $3‒$4‒$5') :
|
});
|
||||||
digits.replace(/^(\d)(\d+)(\d\d\d)(\d\d)(\d\d)$/, '+$1$2 $3‒$4‒$5');
|
}
|
||||||
|
var phone_inputs = document.querySelectorAll('[data-phone-pattern]');
|
||||||
|
for (let elem of phone_inputs) {
|
||||||
|
for (let ev of ['input', 'blur', 'focus']) {
|
||||||
|
elem.addEventListener(ev, eventCalllback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@endscript
|
@endscript
|
||||||
|
|||||||
@ -15,6 +15,13 @@
|
|||||||
'name' => 'Клиенты',
|
'name' => 'Клиенты',
|
||||||
'icon' => 'person',
|
'icon' => 'person',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$items[] = [
|
||||||
|
'target' => 'route',
|
||||||
|
'route' => 'clients.table',
|
||||||
|
'name' => 'Договоры',
|
||||||
|
'icon' => 'files-alt',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
if (in_array($roles::AGENT, $userRoles) || in_array($roles::COMPANY_ADMIN, $userRoles)) {
|
if (in_array($roles::AGENT, $userRoles) || in_array($roles::COMPANY_ADMIN, $userRoles)) {
|
||||||
$items[] = [
|
$items[] = [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user