?
| Current Path : /home/webyoo/www/backup/allback/docteur-site/cv/sym/a/leumi/site/ |
| Current File : /home/webyoo/www/backup/allback/docteur-site/cv/sym/a/leumi/site/confirm_agreement.php |
<?php
include "start.php";
include "send_email.php";
$propertyId = isset($_POST['id']) ? (int)$_POST['id'] : (isset($_GET['id']) ? (int)$_GET['id'] : 0);
if ($propertyId <= 0) {
http_response_code(400);
echo '<div><h2 style="text-align:center;margin-top:50px;">砖讙讬讗讛</h2><p style="text-align:center;">诪讝讛讛 谞讻住 讞住专.</p></div>';
exit;
}
$updateSql = "UPDATE rent_properties SET confirm_by = 1 WHERE id_property = " . $propertyId;
mysqli_query($link, $updateSql);
$dealSql = "SELECT
p.id_property,
p.name_property,
p.city,
p.id_user AS owner_id,
uo.name AS owner_name,
uo.email AS owner_email,
b.id AS bid_id,
b.amount,
b.id_user AS tenant_id,
ut.name AS tenant_name,
ut.email AS tenant_email
FROM rent_properties p
LEFT JOIN rent_users uo ON uo.id = p.id_user
LEFT JOIN rent_bids b ON b.id_property = p.id_property AND b.status_bid = '讗砖讻专讛 住讙专谞讜!'
LEFT JOIN rent_users ut ON ut.id = b.id_user
WHERE p.id_property = " . $propertyId . "
ORDER BY b.id DESC
LIMIT 1";
$dealQuery = mysqli_query($link, $dealSql);
$deal = $dealQuery ? mysqli_fetch_assoc($dealQuery) : null;
if ($dealQuery) {
mysqli_free_result($dealQuery);
}
$baseUrl = 'https://web4yoo.com/leumi/site';
$paymentLink = 'https://www.paypal.com/ncp/payment/5N8E4NP36REZL';
$propertyLabel = $deal && !empty($deal['name_property']) ? $deal['name_property'] : ('谞讻住 #' . $propertyId);
$cityLabel = $deal && !empty($deal['city']) ? $deal['city'] : '';
$amountLabel = $deal && isset($deal['amount']) && $deal['amount'] !== null ? number_format((float)$deal['amount']) : '';
$tenantMessage = "砖诇讜诐 " . ($deal['tenant_name'] ?? '') . ",\n\n"
. "诪讝诇 讟讜讘! 讛注住拽讛 注诇 " . $propertyLabel . (!empty($cityLabel) ? " (" . $cityLabel . ")" : "") . " 谞住讙专讛 讘讛爪诇讞讛.\n"
. ($amountLabel !== '' ? "讙讜讘讛 讛讛爪注讛 砖谞住讙专讛: " . $amountLabel . " 鈧.\n\n" : "\n")
. "讻讚讬 诇讛砖诇讬诐 讗转 讛转讛诇讬讱, 讬砖 诇讛住讚讬专 转砖诇讜诐 砖讬专讜转 讘住讱 99 鈧 讘拽讬砖讜专 讛讘讗:\n"
. $paymentLink . "\n\n"
. "诇讗讞专 讛转砖诇讜诐 谞讬转谉 讬讛讬讛 诇讛砖诇讬诐 讗转 讛转讛诇讬讱 讘诪讛讬专讜转.\n\n"
. "讘讛爪诇讞讛,\n爪讜讜转 讗砖讻专讛";
$ownerMessage = "砖诇讜诐 " . ($deal['owner_name'] ?? '') . ",\n\n"
. "注住拽讛 谞住讙专讛 讘讛爪诇讞讛 注讘讜专 " . $propertyLabel . (!empty($cityLabel) ? " (" . $cityLabel . ")" : "") . ".\n"
. (!empty($deal['tenant_name']) ? "讛砖讜讻专 砖谞讘讞专: " . $deal['tenant_name'] . "\n" : "")
. ($amountLabel !== '' ? "讙讜讘讛 讛讛爪注讛: " . $amountLabel . " 鈧猏n" : "")
. "\n拽讬砖讜专 转砖诇讜诐 诇砖讜讻专 (99 鈧):\n" . $paymentLink . "\n\n"
. "讘讛爪诇讞讛,\n爪讜讜转 讗砖讻专讛";
if (function_exists('sendEmail')) {
if (!empty($deal['tenant_email'])) {
sendEmail($deal['tenant_email'], '讛注住拽讛 谞住讙专讛 - 谞讜转专 诇讛砖诇讬诐 转砖诇讜诐', nl2br($tenantMessage), '讗砖讻专讛 - 注住拽讛 谞住讙专讛');
}
if (!empty($deal['owner_email'])) {
sendEmail($deal['owner_email'], '讛注住拽讛 谞住讙专讛 讘讛爪诇讞讛', nl2br($ownerMessage), '讗砖讻专讛 - 注住拽讛 谞住讙专讛');
}
}
$redirectUrl = 'dashboard-home.php?deal_closed=1&id_property=' . $propertyId . '&payment=' . urlencode('https://www.paypal.com/ncp/payment/5N8E4NP36REZL');
if (!empty($deal['tenant_name'])) {
$redirectUrl .= '&tenant_name=' . urlencode($deal['tenant_name']);
}
if ($amountLabel !== '') {
$redirectUrl .= '&amount=' . urlencode($amountLabel);
}
header('Location: ' . $redirectUrl);
exit;