<?php
$sql_tbl_usrs = "SELECT * FROM users, department, usergroup WHERE users.department = department.id AND users.usergroup = usergroup.id";
$result_tbl_usrs = mysqli_query($connection, $sql_tbl_usrs);
$row_index = 1;
while ($row_tbl_usrs = mysqli_fetch_array($result_tbl_usrs)) {
echo '<tr>
<td>' . $row_index . '</td>
<td>' . $row_tbl_usrs['last_name'] . ' ' . $row_tbl_usrs['first_name'] . ' ' . $row_tbl_usrs['patronymic'] . '</td>
<td>' . $row_tbl_usrs['function'] . '</td>
<td>' . $row_tbl_usrs['department'] . '</td>
<td>' . $row_tbl_usrs['usergroup'] . '</td>
<td>' . $row_tbl_usrs['login'] . '</td>
<td>' . $row_tbl_usrs['date_registration'] . '</td>
</tr>';
$row_index++;
}
?>
$rawJsonResponse = '[{"id":323,"userId":676,"createdAt":"2019-08-23T13:05:56.830Z","status":"APPROVED","currency":"RUR","paySystem":"visa","paySystemGroup":"creditCard","total":69.00,"ipAddress":"246.227.2.4","OneTimeOffer":false,"ware":{"id":812,"title":"Заголовок.","type":"DIGITAL","userId":728},"income":297.08,"customer":{"id":8832,"fio":"Петрович","email":"test@test.ru"}}, {"id":324,"userId":677,"createdAt":"2019-08-23T14:05:56.830Z","status":"APPROVED","currency":"RUR","paySystem":"visa","paySystemGroup":"creditCard","total":69.00,"ipAddress":"246.227.2.4","OneTimeOffer":false,"ware":{"id":813,"title":"Заголовок.","type":"DIGITAL","userId":729},"income":297.08,"customer":{"id":8833,"fio":"Петрович","email":"test2@test.ru"}}, {"id":325,"userId":678,"createdAt":"2019-08-23T15:05:56.830Z","status":"APPROVED","currency":"RUR","paySystem":"visa","paySystemGroup":"creditCard","total":69.00,"ipAddress":"246.227.2.4","OneTimeOffer":false,"ware":{"id":814,"title":"Заголовок.","type":"DIGITAL","userId":730},"income":297.08,"customer":{"id":8834,"fio":"Петрович","email":"test3@test.ru"}}]';
$parsedResponse = json_decode($rawJsonResponse, true);
//разобраться, как создать объект PDO и подключиться к базе - в оффдоках php все есть
foreach ($parsedResponse as $singleUserResponse) {
$paymId = $singleUserResponse['id'];
$paymWareId = $singleUserResponse['ware']['id'];
$paymTitle = $singleUserResponse['ware']['title'];
$paymIncome = $singleUserResponse['income'];
$email = $singleUserResponse['customer']['email'];
$stmtGetUserByEmail = $pdo->prepare("SELECT id FROM dle_users WHERE email=? AND paym_income IS NULL");
$stmtGetUserByEmail->execute([$email]);
$userId = $stmtGetUserByEmail->fetch();
if ($userId) {
$updateUserPaymData = $pdo->prepare("UPDATE dle_users SET income = ?, paym_id = ? WHERE id = ?");
$stmt= $pdo->prepare($updateUserPaymData);
$stmt->execute([$paymIncome, $paymId, $userId]);
}
}
$(".tel_form").submit(function() {
console.log(this);
....
if ( !this.checkValidity() )
alert('Пожалуйста, заполните обязательные поля.');
else {
$.ajax({
type: "POST",
url: "/form/tel_mail.php",
data: $( this ).serialize(),
success: function (data) {
console.log(data);
window.location.href = "../спасибо-за-заказ.htm";
},
});
// очищаем поля
$('#form-tel').val('');
};
return false;
});
var_dump($somevariable); die();