-
Notifications
You must be signed in to change notification settings - Fork 7
/
updHoaAssessment.php
143 lines (125 loc) · 8.11 KB
/
updHoaAssessment.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/*==============================================================================
* (C) Copyright 2015,2018 John J Kauflin, All rights reserved.
*----------------------------------------------------------------------------
* DESCRIPTION:
*----------------------------------------------------------------------------
* Modification History
* 2015-03-06 JJK Initial version to get data
* 2016-04-10 JJK Added new lien fields to the update
* 2016-07-08 JJK Added logic to set current date on paid and lien if not
* specified
* 2016-09-02 JJK Added NonCollectible field
* 2018-11-04 JJK Re-factored to use POST and return JSON data of
* re-queried record
* 2020-08-01 JJK Re-factored to use jjklogin for authentication
* 2020-12-21 JJK Re-factored to use jjklogin package
* 2023-02-17 JJK Refactor for non-static jjklogin class and settings from DB
*============================================================================*/
// Define a super global constant for the log file (this will be in scope for all functions)
define("LOG_FILE", "./php.log");
require_once 'vendor/autoload.php';
// Figure out how many levels up to get to the "public_html" root folder
$webRootDirOffset = substr_count(strstr(dirname(__FILE__),"public_html"),DIRECTORY_SEPARATOR) + 1;
// Get settings and credentials from a file in a directory outside of public_html
// (assume a settings file in the "external_includes" folder one level up from "public_html")
$extIncludePath = dirname(__FILE__, $webRootDirOffset+1).DIRECTORY_SEPARATOR.'external_includes'.DIRECTORY_SEPARATOR;
require_once $extIncludePath.'hoadbSecrets.php';
require_once $extIncludePath.'jjkloginSettings.php';
// Common functions
require_once 'php_secure/commonUtil.php';
// Common database functions and table record classes
require_once 'php_secure/hoaDbCommon.php';
use \jkauflin\jjklogin\LoginAuth;
try {
$loginAuth = new LoginAuth($hostJJKLogin, $dbadminJJKLogin, $passwordJJKLogin, $dbnameJJKLogin);
$userRec = $loginAuth->getUserRec();
if ($userRec->userName == null || $userRec->userName == '') {
throw new Exception('User is NOT logged in', 500);
}
if ($userRec->userLevel < 2) {
throw new Exception('User is NOT authorized (contact Administrator)', 500);
}
$username = $userRec->userName;
header("Content-Type: application/json; charset=UTF-8");
# Get JSON as a string
$json_str = file_get_contents('php://input');
# Decode the string to get a JSON object
$param = json_decode($json_str);
/*
error_log(date('[Y-m-d H:i] '). "updHoaProperty, parcelId = " . $param->parcelId . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, ownerId = " . $param->ownerId . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, fy = " . $param->fy . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, duesAmount = " . $param->duesAmount . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, dateDue = " . $param->dateDue . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, paidCheckbox = " . $param->paidCheckbox . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, nonCollectibleCheckbox = " . $param->nonCollectibleCheckbox . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, datePaid = " . $param->datePaid . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, paymentMethod = " . $param->paymentMethod . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, assessmentsComments = " . $param->assessmentsComments . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, lienCheckbox = " . $param->lienCheckbox . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, lienRefNo = " . $param->lienRefNo . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, dateFiled = " . $param->dateFiled . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, disposition = " . $param->disposition . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, filingFee = " . $param->filingFee . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, releaseFee = " . $param->releaseFee . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, dateReleased = " . $param->dateReleased . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, lienDatePaid = " . $param->lienDatePaid . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, amountPaid = " . $param->amountPaid . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, stopInterestCalcCheckbox = " . $param->stopInterestCalcCheckbox . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, filingFeeInterest = " . $param->filingFeeInterest . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, assessmentInterest = " . $param->assessmentInterest . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, interestNotPaidCheckbox = " . $param->interestNotPaidCheckbox . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, bankFee = " . $param->bankFee . PHP_EOL, 3, "hoadb.log");
error_log(date('[Y-m-d H:i] '). "updHoaProperty, lienComment = " . $param->lienComment . PHP_EOL, 3, "hoadb.log");
*/
$currDateStr = date("Y-m-d");
if ($param->lienCheckbox && $param->disposition == '') {
$param->disposition = 'Open';
}
// if paid and Date Paid not set - set it to current date?
if ($param->paidCheckbox && $param->datePaid == '') {
$param->datePaid = $currDateStr;
}
// if lien and Date Filed not set - set to current date?
if ($param->lienCheckbox && $param->dateFiled == '') {
$param->dateFiled = $currDateStr;
}
//--------------------------------------------------------------------------------------------------------
// Create connection to the database
//--------------------------------------------------------------------------------------------------------
$conn = getConn($host, $dbadmin, $password, $dbname);
if (!$stmt = $conn->prepare("UPDATE hoa_assessments SET OwnerID=?,DuesAmt=?,DateDue=?,Paid=?,NonCollectible=?,DatePaid=?,PaymentMethod=?," .
"Lien=?,LienRefNo=?,DateFiled=?,Disposition=?,FilingFee=?,ReleaseFee=?,DateReleased=?,LienDatePaid=?,AmountPaid=?," .
"StopInterestCalc=?,FilingFeeInterest=?,AssessmentInterest=?,InterestNotPaid=?,BankFee=?,LienComment=?," .
"Comments=?,LastChangedBy=?,LastChangedTs=CURRENT_TIMESTAMP WHERE Parcel_ID = ? AND FY = ? ; ")) {
error_log("Prepare failed ");
echo "Prepare failed ";
}
if (!$stmt->bind_param("issiississssssssississssss", $param->ownerId,$param->duesAmount,$param->dateDue,$param->paidCheckbox,$param->nonCollectibleCheckbox,$param->datePaid,$param->paymentMethod,
$param->lienCheckbox,$param->lienRefNo,$param->dateFiled,$param->disposition,$param->filingFee,$param->releaseFee,$param->dateReleased,$param->lienDatePaid,$param->amountPaid,
$param->stopInterestCalcCheckbox,$param->filingFeeInterest,$param->assessmentInterest,$param->interestNotPaidCheckbox,$param->bankFee,$param->lienComment,
$param->assessmentsComments,$username,$param->parcelId,$param->fy)) {
error_log("Bind failed: " . $stmt->errno . ", Error = " . $stmt->error);
echo "Bind failed: (" . $stmt->errno . ") " . $stmt->error;
}
if (!$stmt->execute()) {
error_log("Add Assessment Execute failed: " . $stmt->errno . ", Error = " . $stmt->error);
echo "Add Assessment Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
$stmt->close();
// Re-query the record from the database and return as a JSON structure
$hoaRec = getHoaRec($conn,$param->parcelId,"","","");
$hoaRec->adminLevel = $userRec->userLevel;
$conn->close();
echo json_encode($hoaRec);
} catch(Exception $e) {
//error_log(date('[Y-m-d H:i] '). "in " . basename(__FILE__,".php") . ", Exception = " . $e->getMessage() . PHP_EOL, 3, LOG_FILE);
echo json_encode(
array(
'error' => $e->getMessage(),
'error_code' => $e->getCode()
)
);
}
?>