confirmer updated
This commit is contained in:
parent
9fa55fed78
commit
b789a97c47
@ -60,7 +60,7 @@ public function confirm(Deal $deal, Request $request)
|
|||||||
return $deal->id;
|
return $deal->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function update_contract(Deal $deal, Request $request)
|
public function updateContract(Deal $deal, Request $request)
|
||||||
{
|
{
|
||||||
$contract = new ContractApiController;
|
$contract = new ContractApiController;
|
||||||
$contract($deal, $request);
|
$contract($deal, $request);
|
||||||
|
|||||||
@ -30,6 +30,7 @@ public function __invoke(Request $request)
|
|||||||
'secret' => bin2hex(random_bytes(16)),
|
'secret' => bin2hex(random_bytes(16)),
|
||||||
'status' => 'new'
|
'status' => 'new'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$data = $request->only('name', 'email', 'inn', 'legal_address', 'secret', 'status', 'type', 'phone');
|
$data = $request->only('name', 'email', 'inn', 'legal_address', 'secret', 'status', 'type', 'phone');
|
||||||
$company = Company::create($data);
|
$company = Company::create($data);
|
||||||
if (!$company)
|
if (!$company)
|
||||||
@ -44,7 +45,7 @@ public function __invoke(Request $request)
|
|||||||
if (!$sender = $companyConfirmByBitrix->send())
|
if (!$sender = $companyConfirmByBitrix->send())
|
||||||
{
|
{
|
||||||
$company->delete();
|
$company->delete();
|
||||||
return back()->withErrors(['msg' => 'Company creation error'])->withInput();
|
return back()->withErrors(['msg' => 'Error with bitrix sender'])->withInput();
|
||||||
}
|
}
|
||||||
return view('company.created');
|
return view('company.created');
|
||||||
}
|
}
|
||||||
|
|||||||
78
app/Livewire/ContractsTable.php
Normal file
78
app/Livewire/ContractsTable.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use Livewire\Component;
|
||||||
|
use Livewire\WithPagination;
|
||||||
|
use Livewire\WithoutUrlPagination;
|
||||||
|
|
||||||
|
use App\Models\Agent\Agent;
|
||||||
|
use App\Models\Company\CompanyAdmin;
|
||||||
|
use App\Models\Deal\Deal;
|
||||||
|
|
||||||
|
use App\Models\Deal\DealStatus;
|
||||||
|
|
||||||
|
class ContractsTable extends Component
|
||||||
|
{
|
||||||
|
use WithPagination, WithoutUrlPagination;
|
||||||
|
|
||||||
|
public $status;
|
||||||
|
public $count;
|
||||||
|
public $mode;//short || full
|
||||||
|
|
||||||
|
public function mount($status = null, $count = 10, $mode = 'full')
|
||||||
|
{
|
||||||
|
$this->status = $status;
|
||||||
|
$this->count = $count;
|
||||||
|
$this->mode = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getContracts()
|
||||||
|
{
|
||||||
|
$deals = false;
|
||||||
|
$user = auth()->user();
|
||||||
|
if ($agent = Agent::where('user_id', $user->id)->first())
|
||||||
|
{
|
||||||
|
$deals = Deal::where('agent_id', $agent->id);
|
||||||
|
}
|
||||||
|
elseif ($admin = CompanyAdmin::where('user_id', $user->id)->first())
|
||||||
|
{
|
||||||
|
$deals = Deal::whereIn('agent_id', function ($query) use ($admin)
|
||||||
|
{
|
||||||
|
$query->select('id');
|
||||||
|
$query->from('agents');
|
||||||
|
$query->where('company_id', $admin->company_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return $deals;
|
||||||
|
}
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$deals = $this->getDeals();
|
||||||
|
if ($this->status && $this->status == DealStatus::UNIQUE)
|
||||||
|
{
|
||||||
|
$deals = $deals
|
||||||
|
->whereIn('status', [DealStatus::UNIQUE])
|
||||||
|
->orderBy('id', 'desc')->paginate($this->count, ['*'], 'unique_clients');
|
||||||
|
}
|
||||||
|
elseif ($this->status && $this->status == DealStatus::NOT_UNIQUE)
|
||||||
|
{
|
||||||
|
$deals = $deals
|
||||||
|
->whereIn('status', [DealStatus::MODERATION, DealStatus::NEW , DealStatus::NOT_UNIQUE])
|
||||||
|
->orderBy('id', 'desc')->paginate($this->count, ['*'], 'not_unique_clients');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$deals = $deals->orderBy('id', 'desc')->paginate($this->count, ['*'], 'all_clients');
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
return view(
|
||||||
|
'livewire.clients-table',
|
||||||
|
[
|
||||||
|
'deals' => $deals,
|
||||||
|
'statuses' => DealStatus::class
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -25,7 +25,7 @@ class SendCompany
|
|||||||
|
|
||||||
public function __construct($id, array $data)
|
public function __construct($id, array $data)
|
||||||
{
|
{
|
||||||
$this->ID = $id;
|
$this->ID = env('BITRIX_CODE_PREFIX', '') . $id;
|
||||||
$data = array_change_key_case($data, CASE_UPPER);
|
$data = array_change_key_case($data, CASE_UPPER);
|
||||||
$finalData = $this->castConstants($data);
|
$finalData = $this->castConstants($data);
|
||||||
$this->data = $finalData;
|
$this->data = $finalData;
|
||||||
@ -55,7 +55,7 @@ public function send()
|
|||||||
$data = [
|
$data = [
|
||||||
'IBLOCK_TYPE_ID' => $this->IBLOCK_TYPE_ID,
|
'IBLOCK_TYPE_ID' => $this->IBLOCK_TYPE_ID,
|
||||||
'IBLOCK_ID' => $this->IBLOCK_ID,
|
'IBLOCK_ID' => $this->IBLOCK_ID,
|
||||||
'ELEMENT_CODE' => 'local' . $this->ID,
|
'ELEMENT_CODE' => $this->ID,
|
||||||
'FIELDS' => $this->data
|
'FIELDS' => $this->data
|
||||||
];
|
];
|
||||||
$sender = new BitrixSender($this->URL, $data);
|
$sender = new BitrixSender($this->URL, $data);
|
||||||
|
|||||||
@ -51,7 +51,6 @@
|
|||||||
/*
|
/*
|
||||||
* Header
|
* Header
|
||||||
*/
|
*/
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -60,19 +59,21 @@
|
|||||||
<div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">
|
<div class="cover-container d-flex w-100 h-100 p-3 mx-auto flex-column">
|
||||||
<header class="mb-auto">
|
<header class="mb-auto">
|
||||||
<h3 class="float-md-start mb-0">
|
<h3 class="float-md-start mb-0">
|
||||||
<img class=""
|
<img class="" data-original="{{ url('/images/logo.svg') }}" alt=""
|
||||||
data-original="{{ url('/images/logo.svg') }}" alt=""
|
|
||||||
imgfield="tn_img_1702578351550" src="{{ url('/images/logo.svg') }}" width="100">
|
imgfield="tn_img_1702578351550" src="{{ url('/images/logo.svg') }}" width="100">
|
||||||
</h3>
|
</h3>
|
||||||
<div class="justify-content-center float-md-end">
|
<div class="justify-content-center float-md-end">
|
||||||
<div>
|
<div>
|
||||||
<span class="fw-bold py-1 px-0 fs-3 text-secondary" aria-current="page" href="#">8-800-222-06-10</span>
|
<span class="fw-bold py-1 px-0 fs-3 text-secondary" aria-current="page"
|
||||||
|
href="#">8-800-222-06-10</span>
|
||||||
<div>Звонок по РФ бесплатный</div>
|
<div>Звонок по РФ бесплатный</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<main class="px-3">
|
<main class="px-3">
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
{{ $error }}
|
||||||
|
@endforeach
|
||||||
@yield('content')
|
@yield('content')
|
||||||
</main>
|
</main>
|
||||||
<footer class="mt-auto">
|
<footer class="mt-auto">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user