fix of contracts
This commit is contained in:
parent
b400487e0c
commit
043653df9c
@ -27,7 +27,8 @@ public function __invoke(Deal $deal, Request $request)
|
||||
'date' => $request->date,//дата ДДУ
|
||||
'reg_date' => $request->reg_date,//Дата регистрации ДДУ
|
||||
'payment_type' => $request->payment_type,//Вид оплаты
|
||||
'plan7_id' => $request->plan7_id
|
||||
'plan7_id' => $request->plan7_id,
|
||||
'base64_image' => $request->plan_image
|
||||
]
|
||||
);
|
||||
$agent = $deal->agent;
|
||||
|
||||
@ -38,6 +38,7 @@ public function setAgentId(Request $request, Agent $agent)
|
||||
}
|
||||
public function syncDeals(Agent $agent)
|
||||
{
|
||||
$importedCount = 0;
|
||||
$url = 'https://b24alfa.pro/channels/lk/getDealsOfContact?id=' . $agent->bitrixId();
|
||||
$data = file_get_contents($url);
|
||||
$deals = json_decode($data, true);
|
||||
@ -51,7 +52,7 @@ public function syncDeals(Agent $agent)
|
||||
//Загрузка контактов
|
||||
if ($deal['contacts'][0]['phone'])
|
||||
{
|
||||
$client = User::createOrFirst(
|
||||
$client = User::firstOrCreate(
|
||||
['phone' => $deal['contacts'][0]['phone']],
|
||||
[
|
||||
'name' => $deal['contacts'][0]['name'],
|
||||
@ -60,7 +61,7 @@ public function syncDeals(Agent $agent)
|
||||
);
|
||||
}
|
||||
;
|
||||
$dealItem = false;
|
||||
$dealItem = false; //собственный, не из битрикса
|
||||
$bitrixId = BitrixId::where('bx_id', $deal['deal']['deal_id'])
|
||||
->where('bitrixable_type', Deal::class);
|
||||
//Загрузка сделок
|
||||
@ -80,19 +81,24 @@ public function syncDeals(Agent $agent)
|
||||
$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']
|
||||
]
|
||||
);
|
||||
$this->sendDealToBitrix($dealItem);
|
||||
$inDeal = $deal['deal'];//входящие данные по сделке
|
||||
if ($dealItem)
|
||||
{
|
||||
$importedCount++;
|
||||
$contract = Contract::updateOrCreate(
|
||||
['deal_id' => $dealItem->id],
|
||||
[
|
||||
'price' => $inDeal['price'],
|
||||
'square' => $inDeal['square'],
|
||||
'floor' => $inDeal['floor'],
|
||||
'room' => $inDeal['room'],
|
||||
'plan7_id' => $inDeal['plan7_id']
|
||||
]
|
||||
);
|
||||
$this->sendDealToBitrix($dealItem);
|
||||
}
|
||||
}
|
||||
return back()->with('success', 'Импортировано ' . $importedCount . ' сделок');
|
||||
}
|
||||
|
||||
function sendDealToBitrix(Deal $deal)
|
||||
|
||||
@ -34,4 +34,19 @@ public function setBitrixId($id): bool
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::deleted(function ($bitrixableItem)
|
||||
{
|
||||
$this->bitrixable()->delete();
|
||||
});
|
||||
|
||||
static::forceDeleted(function ($bitrixableItem)
|
||||
{
|
||||
$this->bitrixable()->delete();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('contracts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->timestamps();
|
||||
Schema::table('client_contract', function (Blueprint $table)
|
||||
{
|
||||
$table->longText('base64_image')->nullable(); // Or not nullable if required
|
||||
});
|
||||
}
|
||||
|
||||
@ -22,6 +22,6 @@ public function up(): void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('contracts');
|
||||
//Schema::dropIfExists('contracts');
|
||||
}
|
||||
};
|
||||
@ -16,4 +16,18 @@ public function index()
|
||||
'status' => 'all'
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete(Contract $contract)
|
||||
{
|
||||
$deal = $contract->deal();
|
||||
if ($contract->delete())
|
||||
{
|
||||
if ($deal->delete())
|
||||
{
|
||||
return back()->with('success', 'Договор был успешно удален из базы данных');
|
||||
|
||||
}
|
||||
}
|
||||
return back()->withErrors('Не удалось корректно удалить договор и сделку. Попробуйте позже.');
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,8 @@ class Contract extends Model
|
||||
'date',//дата ДДУ
|
||||
'reg_date',//Дата регистрации ДДУ
|
||||
'payment_type',//Вид оплаты
|
||||
'plan7_id'//ид помещения из plan7
|
||||
'plan7_id',//ид помещения из plan7
|
||||
'base64_image'
|
||||
];
|
||||
|
||||
public function deal()
|
||||
|
||||
@ -3,9 +3,30 @@
|
||||
class ContractStatus
|
||||
{
|
||||
const NEW = 'NEW';
|
||||
const TREATY = 'TREATY'; //переговоры
|
||||
const TREATY = 'TREATY'; //Выплачено
|
||||
const RESERVATION = 'RESERVATION'; //бронь
|
||||
const SUCCESS = "SUCCESS";
|
||||
const DECLINE = "DECLINE";
|
||||
}
|
||||
|
||||
public static function getName($status)
|
||||
{
|
||||
return __('contracts.status_' . $status);
|
||||
}
|
||||
public static function getHtmlColor($status)
|
||||
{
|
||||
switch ( $status )
|
||||
{
|
||||
case self::NEW:
|
||||
return '#ccc';
|
||||
case self::RESERVATION:
|
||||
return '#4fb5e5';
|
||||
case self::TREATY:
|
||||
return '#e3e54f';
|
||||
case self::SUCCESS:
|
||||
return '#4fe576';
|
||||
case self::DECLINE:
|
||||
return '#eb612c';
|
||||
}
|
||||
return '#ccc';
|
||||
}
|
||||
}
|
||||
@ -6,4 +6,6 @@
|
||||
Route::middleware(['auth'])->group(function ()
|
||||
{
|
||||
Route::get('/contracts', [ContractsController::class, 'index'])->name('contracts');
|
||||
Route::post('/contracts/{contract}/delete', [ContractsController::class, 'delete'])->name('contract.delete');
|
||||
|
||||
});
|
||||
@ -1,4 +1,4 @@
|
||||
@php($statuses = App\Models\Deal\ContractStatus::class)
|
||||
@php($statuses = Modules\Contracts\Models\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">
|
||||
@ -51,8 +51,8 @@
|
||||
{!! $reward !!}
|
||||
</td>
|
||||
<td>
|
||||
<div class="py-1 px-3 border rounded rounded-5"
|
||||
style="background-color:{{ $statuses::getColor($contract->status) }}">
|
||||
<div class="py-1 px-3 border rounded rounded-5 text-center"
|
||||
style="background-color:{{ $statuses::getHtmlColor($contract->status) }}">
|
||||
{{ $statuses::getName($contract->status) }}
|
||||
</div>
|
||||
</td>
|
||||
@ -65,10 +65,11 @@
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item"
|
||||
href="{{ route('contract', ['contract' => $contract->id]) }}">Детали</a>
|
||||
<!--<form method="post" action="">
|
||||
<form method="post"
|
||||
action="{{ route('contract.delete', ['contract' => $contract]) }}">
|
||||
@csrf
|
||||
<button class="dropdown-item" type="submit">Удалить</button>
|
||||
</form>-->
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
return [
|
||||
'status_NEW' => 'Новый',
|
||||
'status_TREATY' => 'Выплачено',
|
||||
'status_RESERVATION' => 'Забронировано',
|
||||
'status_SUSSCESS' => 'Успех',
|
||||
'status_RESERVATION' => 'Бронь',
|
||||
'status_SUCCESS' => 'Успех',
|
||||
'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>
|
||||
<!--Основная часть-->
|
||||
@ -107,7 +107,8 @@ class="bi bi-pen" viewBox="0 0 16 16">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-lg-4 p-3">
|
||||
<div class="rounded-4 h-100 w-100" style="background-color:#ebeef5"></div>
|
||||
<div class="rounded-4 h-100 w-100" style="background-color:#ebeef5"
|
||||
data-base64="{{ $contract->base64_image }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user