This repository was archived by the owner on Jul 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmassreport.php
More file actions
68 lines (57 loc) · 2.18 KB
/
massreport.php
File metadata and controls
68 lines (57 loc) · 2.18 KB
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
include_once 'library/FullTable.php';
include_once 'library/functions.php';
include_once 'library/functions_pdf.php';
include_once 'library/presentation.php';
include_once 'library/responseContext.php';
$debug = false;
global $INDICATEDVAL;
/** @var queryContext $queryContext */
$queryContext = new queryContext();
/** @var responseContext $responseContext */
$responseContext = new responseContext();
try {
//Parse Inputs
$json = file_get_contents('php://input');
$obj = json_decode($json);
if ($obj == null) {
echo json_encode(array("error" => "Bad json input, check for extra chars"));
exit;
}
$queryContext->parseQueryContextJson($obj);
$queryContext->responseCtx = $responseContext;
if ($queryContext->subjPropId == "") {
echo json_encode(array("error" => "Must provide subject property id", "propId" => "0"));
exit;
}
$queryContext->validate();
if ($debug) error_log(var_dump($queryContext));
$fullTable = new FullTable();
try {
$fullTable->generateTableData($queryContext);
} catch (Exception $e) {
error_log("ERROR\tException in generating table: " . $e->getMessage());
$responseContext->errors[] = $e->getMessage();
}
if ($fullTable->getSubjCompArray() == null || sizeof($fullTable->getSubjCompArray()) == 1) {
$response = array("error" => "No comps found for propId=" . $queryContext->subjPropId,
"propId" => $queryContext->subjPropId,
"hiddenDetails" => $queryContext->responseCtx
);
echo json_encode($response, JSON_PRETTY_PRINT);
exit;
}
if (isset($_GET["pdf"])) {
$prop_pdfs = generatePropMultiPDF($queryContext);
$multiPDF = $prop_pdfs["mPDF"];
echo($multiPDF->Output($queryContext->subjPropId . '.pdf', 'I'));
} else {
header('Content-Type: application/json');
echo generateJsonRows($fullTable, $isEquityComp, $responseContext);
}
} catch (Throwable $e) {
error_log("Error in massreport : " . $e->getMessage() . $e->getTraceAsString());
header('HTTP/1.1 500 Internal Server Error');
echo "Internal error: Review error logs";
}
?>