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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,5 +7,20 @@ class ContractStatus
|
||||
const RESERVATION = 'RESERVATION';
|
||||
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()
|
||||
{
|
||||
@ -29,7 +29,8 @@ protected function registerViews()
|
||||
{
|
||||
$moduleViewsPath = __DIR__ . '/../Views';
|
||||
$this->loadViewsFrom(
|
||||
$moduleViewsPath, strtolower($this->moduleName)
|
||||
$moduleViewsPath,
|
||||
strtolower($this->moduleName)
|
||||
);
|
||||
}
|
||||
|
||||
@ -37,7 +38,8 @@ protected function registerLivewireViews()
|
||||
{
|
||||
$moduleViewsPath = __DIR__ . '/../Views/livewire';
|
||||
$this->loadViewsFrom(
|
||||
$moduleViewsPath, strtolower($this->moduleName)
|
||||
$moduleViewsPath,
|
||||
strtolower($this->moduleName)
|
||||
);
|
||||
}
|
||||
|
||||
@ -52,13 +54,15 @@ protected function registerConfig()
|
||||
{
|
||||
$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>
|
||||
<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' => 'Отклонен'
|
||||
|
||||
];
|
||||
@ -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">
|
||||
|
||||
@ -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