-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccoRequestConfirmation.php
68 lines (56 loc) · 2.39 KB
/
AccoRequestConfirmation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
* Created by PhpStorm.
* User: Radon
* Date: 08.01.2019
* Time: 14:47
*/
include_once 'mySQLConnector2.0.php';
date_default_timezone_set("Asia/Tashkent");
$dateTime = date("Y-m-d H:i:s");
if ( !empty($_POST['Password']) && !empty($_POST['answer']) && !empty($_POST['requestID']) && !empty($_POST['comment']) ){
$Password = $_POST['Password'];
$answer = $_POST['answer'];
$requestID = $_POST['requestID'];
$comment = $_POST['comment'];
$value;
/*this is bookkeeper id = 0000005*/
$data = $mysqli->query("SELECT * FROM $base.user WHERE `id` = '0000005'");
$row = $data->fetch_assoc();
if($row['password'] == $Password) {
$dataRequest = $mysqli->query("SELECT * FROM accountant WHERE `id` = '$requestID'");
$rowRequest = $dataRequest->fetch_assoc();
if($rowRequest['answer'] != 'unknown') {
echo "AnsweredRequest-error";
die();
}
if ($answer == 'apply'){
$dataUser = $mysqli->query("SELECT * FROM $base.user WHERE `id` = '{$rowRequest['userid']}'");
$rowUser = $dataUser->fetch_assoc();
$mysqli->query("UPDATE accountant
SET
`value` = '{$rowUser['balance']}',
`answer` = 'applied',
`date` = '{$dateTime}',
`comment`= '{$comment}'
WHERE `id` = '$requestID'");
$mysqli->query("UPDATE $base.user
SET
balance = '0'
WHERE id = '{$rowUser['id']}'");
echo "SuccessConfirmed";
}elseif ($answer == 'deny'){
$mysqli->query("UPDATE accountant
SET
`answer` = 'denied',
`date` = '{$dateTime}',
`comment`= '{$comment}'
WHERE `id` = '$requestID'");
echo "SuccessConfirmed";
}else echo "InvalidAnswer-error";
}else{
echo "Password-invalid-value-error";
}
}else{
echo "PasswordOrInput-empty";
}