contracts import finished
This commit is contained in:
parent
28a8933fb9
commit
c1397ae4a7
@ -4,7 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use App\Models\Deal\ContractStatus;
|
||||
class Contract extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
@ -31,4 +31,9 @@ public function deal()
|
||||
{
|
||||
return $this->belongsTo(Deal::class, 'deal_id');
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,26 @@
|
||||
<?php
|
||||
namespace App\Models\Deal;
|
||||
class ContractStatus
|
||||
{
|
||||
const NEW = 'NEW';
|
||||
const TREATY = 'TREATY';
|
||||
{
|
||||
const NEW = 'NEW';
|
||||
const TREATY = 'TREATY';
|
||||
const RESERVATION = 'RESERVATION';
|
||||
const SUCCESS = "SUSSCESS";
|
||||
const DECLINE = "DECLINE";
|
||||
const SUCCESS = "SUSSCESS";
|
||||
const DECLINE = "DECLINE";
|
||||
public static function getName($status)
|
||||
{
|
||||
return __('contracts.status_' . $status);
|
||||
}
|
||||
public static function getColor($status)
|
||||
{
|
||||
switch ( $status )
|
||||
{
|
||||
case self::NEW:
|
||||
return '#ccc';
|
||||
case self::TREATY:
|
||||
return '#ccc';
|
||||
}
|
||||
return '#fff';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\Deal\Contract;
|
||||
use App\Models\Deal\Deal;
|
||||
use App\Models\Deal\DealStatus;
|
||||
use Modules\Bitrix\Models\BitrixId;
|
||||
@ -41,6 +42,10 @@ public function syncDeals(Agent $agent)
|
||||
$deals = json_decode($data, true);
|
||||
foreach ($deals as $deal)
|
||||
{
|
||||
if (count($deal['contacts']) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$client = false;
|
||||
//Загрузка контактов
|
||||
if ($deal['contacts'][0]['phone'])
|
||||
@ -53,8 +58,12 @@ public function syncDeals(Agent $agent)
|
||||
]
|
||||
);
|
||||
}
|
||||
;
|
||||
$dealItem = false;
|
||||
$bitrixId = BitrixId::where('bx_id', $deal['deal']['deal_id'])
|
||||
->where('bitrixable_type', get_class(new Deal()));
|
||||
//Загрузка сделок
|
||||
if (BitrixId::where('bx_id', $deal['deal']['deal_id'])->count() == 0)
|
||||
if ($bitrixId->count() == 0)
|
||||
{
|
||||
$dealItem = Deal::create([
|
||||
'client_id' => $client->id,
|
||||
@ -64,6 +73,23 @@ public function syncDeals(Agent $agent)
|
||||
]);
|
||||
$dealItem->setBitrixId($deal['deal']['deal_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bitrixId = $bitrixId->first();
|
||||
$dealItem = Deal::find($bitrixId->bitrixable_id);
|
||||
}
|
||||
;
|
||||
$inDeal = $deal['deal'];
|
||||
$contract = Contract::updateOrCreate(
|
||||
['deal_id' => $dealItem->id],
|
||||
[
|
||||
'price' => $inDeal['price'],
|
||||
'square' => $inDeal['square'],
|
||||
'floor' => $inDeal['floor'],
|
||||
'room' => $inDeal['room'],
|
||||
'plan7_id' => $inDeal['plan7_id']
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,6 +12,8 @@ class ContractsController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('contracts::index');
|
||||
return view('contracts::index', [
|
||||
'status' => 'all'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Contracts\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use App\Models\Company\Company;
|
||||
use App\Models\Complex;
|
||||
use App\Models\Agent\Agent;
|
||||
use App\Models\Deal\Deal;
|
||||
use App\Models\Deal\Contract;
|
||||
use App\Models\Deal\ContractStatus;
|
||||
|
||||
class ContractsTableLivewire extends Component
|
||||
{
|
||||
public function mount()
|
||||
{
|
||||
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
$contracts = Contract::all();
|
||||
return view('contracts::livewire.table.index', [
|
||||
'contracts' => $contracts,
|
||||
'statuses' => ContractStatus::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Contract\Providers;
|
||||
namespace Modules\Contracts\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
class ModuleServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected String $moduleName = 'Contract';
|
||||
protected string $moduleName = 'Contracts';
|
||||
|
||||
public function register()
|
||||
{
|
||||
@ -27,38 +27,42 @@ public function boot()
|
||||
|
||||
protected function registerViews()
|
||||
{
|
||||
$moduleViewsPath = __DIR__.'/../Views';
|
||||
$moduleViewsPath = __DIR__ . '/../Views';
|
||||
$this->loadViewsFrom(
|
||||
$moduleViewsPath, strtolower($this->moduleName)
|
||||
$moduleViewsPath,
|
||||
strtolower($this->moduleName)
|
||||
);
|
||||
}
|
||||
|
||||
protected function registerLivewireViews()
|
||||
{
|
||||
$moduleViewsPath = __DIR__.'/../Views/livewire';
|
||||
$moduleViewsPath = __DIR__ . '/../Views/livewire';
|
||||
$this->loadViewsFrom(
|
||||
$moduleViewsPath, strtolower($this->moduleName)
|
||||
$moduleViewsPath,
|
||||
strtolower($this->moduleName)
|
||||
);
|
||||
}
|
||||
|
||||
protected function registerMigrations()
|
||||
{
|
||||
$this->loadMigrationsFrom(
|
||||
app_path('Modules/'.$this->moduleName.'/Database/Migrations')
|
||||
app_path('Modules/' . $this->moduleName . '/Database/Migrations')
|
||||
);
|
||||
}
|
||||
|
||||
protected function registerConfig()
|
||||
{
|
||||
$path = app_path('Modules/'.$this->moduleName.'/Config/config.php');
|
||||
$path = app_path('Modules/' . $this->moduleName . '/Config/config.php');
|
||||
$this->mergeConfigFrom(
|
||||
$path, strtolower($this->moduleName)
|
||||
$path,
|
||||
strtolower($this->moduleName)
|
||||
);
|
||||
}
|
||||
|
||||
protected function registerLivewire()
|
||||
{
|
||||
//Livewire::component('<name>', \Modules\<NAME>\Http\Livewire\<NAME>::class);
|
||||
Livewire::component('contracts.table', \Modules\Contracts\Http\Livewire\ContractsTableLivewire::class);
|
||||
}
|
||||
|
||||
protected function registerComponent()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Contract\Providers;
|
||||
namespace Modules\Contracts\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
@ -18,7 +18,7 @@ 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'));
|
||||
->namespace('Modules\\Contracts\\Http\\Controllers')
|
||||
->group(app_path('Modules/Contracts/Routes/web.php'));
|
||||
}
|
||||
}
|
||||
@ -3,11 +3,7 @@
|
||||
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 - Маршруты которые нужно защитить */
|
||||
});
|
||||
Route::middleware(['auth'])->group(function ()
|
||||
{
|
||||
Route::get('/contracts', [ContractsController::class, 'index'])->name('contracts');
|
||||
});
|
||||
@ -1,4 +1,46 @@
|
||||
@extends('layouts.app')
|
||||
@section('content')
|
||||
<h1> Example views </h1>
|
||||
@endsection
|
||||
@section('content')
|
||||
<div>
|
||||
<form class="d-block d-md-flex mb-3" method="GET" action="{{ route('contracts') }}">
|
||||
<div class="border rounded-3 border-1 p-1 bg-white">
|
||||
<input type="radio" class="btn-check" name="status" value="active" id="option6" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $status == 'active' ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option6">Активные</label>
|
||||
|
||||
<input type="radio" class="btn-check" name="status" value="finished" id="option7" autocomplete="off"
|
||||
onclick="this.form.submit()" {{ $status == 'finished' ? 'checked' : '' }}>
|
||||
<label class="btn p-2 fs-5" for="option7">Оконченные</label>
|
||||
</div>
|
||||
<div class="ms-auto hstack gap-2">
|
||||
<div>Всего: 136 договоров</div>
|
||||
<button type="button" class="btn bg-white p-3 fw-bold border rounded-3 border-1" data-bs-toggle="modal"
|
||||
data-bs-target="#contractFilterModal">
|
||||
Фильтр <i class="bi bi-person-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
@livewire('contracts.table')
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" id="contractFilterModal" tabindex="-1" aria-labelledby="contractFilterModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body" style="">
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||||
<input type="submit" class="btn btn-primary" value="Применить">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
65
app/Modules/Contracts/Views/livewire/table/index.blade.php
Normal file
65
app/Modules/Contracts/Views/livewire/table/index.blade.php
Normal file
@ -0,0 +1,65 @@
|
||||
@php($statuses = App\Models\Deal\ContractStatus::class)
|
||||
<div>
|
||||
<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>Город
|
||||
<th>ЖК
|
||||
<th>Площадь
|
||||
<th>Сумма
|
||||
<th>Вознаграждение
|
||||
<th>Статус
|
||||
<th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="">
|
||||
@foreach ($contracts as $contract)
|
||||
<tr scope="row">
|
||||
<td class="align-middle">
|
||||
{{ $contract->deal->user->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $contract->deal->complex->city->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $contract->deal->complex->name }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $contract->square }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $contract->price }}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
{{ $contract->reward }}
|
||||
</td>
|
||||
<td>
|
||||
<div class="py-1 px-3 border rounded rounded-5"
|
||||
style="background-color:{{ $statuses::getColor($contract->status) }}">
|
||||
{{ $statuses::getName($contract->status) }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown" style="">
|
||||
<button class="btn btn-light" type="button" id="dropdownMenuButton"
|
||||
data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('contract', ['contract' => $contract->id]) }}">Детали</a>
|
||||
<!--<form method="post" action="">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>-->
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
9
lang/ru/contracts.php
Normal file
9
lang/ru/contracts.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'status_NEW' => 'Новый',
|
||||
'status_TREATY' => 'Выплачено',
|
||||
'status_RESERVATION' => 'Забронировано',
|
||||
'status_SUSSCESS' => 'Успех',
|
||||
'status_DECLINE' => 'Отклонен'
|
||||
|
||||
];
|
||||
@ -37,20 +37,20 @@ class="bi bi-arrow-right" viewBox="0 0 16 16">
|
||||
</div>
|
||||
<div class="col-3 text-end">
|
||||
<!--<a href="" class="btn border-1 border-secondary-subtle text-secondary rounded-4 p-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
|
||||
class="bi bi-trash3" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5M11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47M8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5" />
|
||||
</svg>
|
||||
</a>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
|
||||
class="bi bi-trash3" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5M11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47M8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5" />
|
||||
</svg>
|
||||
</a>
|
||||
|
||||
<a href="" class="btn border-1 border-secondary-subtle text-secondary rounded-4 p-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
|
||||
class="bi bi-pen" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="m13.498.795.149-.149a1.207 1.207 0 1 1 1.707 1.708l-.149.148a1.5 1.5 0 0 1-.059 2.059L4.854 14.854a.5.5 0 0 1-.233.131l-4 1a.5.5 0 0 1-.606-.606l1-4a.5.5 0 0 1 .131-.232l9.642-9.642a.5.5 0 0 0-.642.056L6.854 4.854a.5.5 0 1 1-.708-.708L9.44.854A1.5 1.5 0 0 1 11.5.796a1.5 1.5 0 0 1 1.998-.001m-.644.766a.5.5 0 0 0-.707 0L1.95 11.756l-.764 3.057 3.057-.764L14.44 3.854a.5.5 0 0 0 0-.708z" />
|
||||
</svg>
|
||||
</a>-->
|
||||
<a href="" class="btn border-1 border-secondary-subtle text-secondary rounded-4 p-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor"
|
||||
class="bi bi-pen" viewBox="0 0 16 16">
|
||||
<path
|
||||
d="m13.498.795.149-.149a1.207 1.207 0 1 1 1.707 1.708l-.149.148a1.5 1.5 0 0 1-.059 2.059L4.854 14.854a.5.5 0 0 1-.233.131l-4 1a.5.5 0 0 1-.606-.606l1-4a.5.5 0 0 1 .131-.232l9.642-9.642a.5.5 0 0 0-.642.056L6.854 4.854a.5.5 0 1 1-.708-.708L9.44.854A1.5 1.5 0 0 1 11.5.796a1.5 1.5 0 0 1 1.998-.001m-.644.766a.5.5 0 0 0-.707 0L1.95 11.756l-.764 3.057 3.057-.764L14.44 3.854a.5.5 0 0 0 0-.708z" />
|
||||
</svg>
|
||||
</a>-->
|
||||
</div>
|
||||
</div>
|
||||
<!--Основная часть-->
|
||||
|
||||
@ -17,14 +17,6 @@
|
||||
<label class="btn p-2 fs-5" for="option7">Не
|
||||
уникальные</label>
|
||||
</div>
|
||||
<!--<div class="ms-auto p-2">
|
||||
<select class="form-select form-select-lg" disabled aria-label="Large select example">
|
||||
<option selected="">Город: любой</option>
|
||||
@foreach ($cities as $city)
|
||||
<option value="{{ $city->id }}">{{ $city->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>-->
|
||||
<div class="ms-auto p-2">
|
||||
<button type="button" class="btn btn-primary py-2 px-3 fs-5" data-bs-toggle="modal"
|
||||
data-bs-target="#createClientModal">
|
||||
@ -59,9 +51,9 @@
|
||||
<livewire:createClientForm />
|
||||
</div>
|
||||
<!--<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||||
<input type="submit" class="btn btn-primary" value="Добавить">
|
||||
</div>-->
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button>
|
||||
<input type="submit" class="btn btn-primary" value="Добавить">
|
||||
</div>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -18,12 +18,11 @@
|
||||
|
||||
$items[] = [
|
||||
'target' => 'route',
|
||||
'route' => 'clients.table',
|
||||
'route' => 'contracts',
|
||||
'name' => 'Договоры',
|
||||
'icon' => 'files-alt',
|
||||
];
|
||||
}
|
||||
if (in_array($roles::AGENT, $userRoles) || in_array($roles::COMPANY_ADMIN, $userRoles)) {
|
||||
|
||||
$items[] = [
|
||||
'target' => 'modal',
|
||||
'modal' => '#plan7Modal',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user