-
Notifications
You must be signed in to change notification settings - Fork 1
/
business.php
139 lines (119 loc) · 3.14 KB
/
business.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
<?php
include('includes/header.php');
/*
* Define the PCRE to match all entity IDs
*/
$entity_id_pcre = '/(F|S|T|L|M|[0-9]{1})([0-9]{6})/';
/*
* If no business ID has been passed in the URL
*/
if (!isset($id))
{
header($_SERVER['SERVER_PROTOCOL'] . " 400 Bad Request", true, 400);
exit();
}
/*
* If the business ID has an invalid format
*/
elseif ( preg_match($entity_id_pcre, $id) == 0 )
{
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found", true, 404);
exit();
}
/*
* Query our own API
*/
$api_url = API_URL . '/api/business/' . $id;
$business_json = get_content($api_url);
$business = json_decode($business_json, TRUE);
if ($business === FALSE)
{
header($_SERVER['SERVER_PROTOCOL'] . " 500 Internal Server Error", true, 500);
exit();
}
elseif (empty($business))
{
header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found", true, 404);
exit();
}
$template = new Smarty;
$page_title = $business['Name'];
$browser_title = 'Virginia Businesses';
/*
* Display a table of all field values
*/
$page_body = '
<article>
<table>
<thead>
<tr>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>';
$field_order = array
(
'Name' => 'Name',
'EntityID' => 'Corporate ID',
'IncorpDate' => 'Incorporation Date',
'IncorpState' => 'State Incorporated',
'IndustryText' => 'Industry',
'Status' => 'Status',
'StatusDate' => 'Date',
'Duration' => 'Duration',
'Street1' => 'Street Address',
'Street2' => 'Street Address 2',
'City' => 'City',
'State' => 'State',
'Zip' => 'ZIP',
'PrinOffEffDate' => 'PrinOffEffDate',
'AssessIndText' => 'AssessInd',
'StockInd' => 'StockInd',
'TotalShares' => 'Total Shares',
'Stock1' => 'Stock1',
'Stock2' => 'Stock2',
'Stock3' => 'Stock3',
'Stock4' => 'Stock4',
'Stock5' => 'Stock5',
'Stock6' => 'Stock6',
'Stock7' => 'Stock7',
'Stock8' => 'Stock8',
'Stock9' => 'Stock9',
);
$business['IncorpDate'] = date('M d, Y', strtotime($business['IncorpDate']));
foreach ($field_order as $key => $label)
{
if (empty($business[$key]))
{
continue;
}
$page_body .= '<tr><td>' . $label . '</td><td>' . $business[$key] . '</td></tr>';
}
foreach ($business as $field_name => $field_value)
{
if ( is_array($field_value) )
{
if ($field_name == 'Officers')
{
foreach ($field_value as $officer)
{
$page_body .= '<tr><td>' . $officer['OfficerTitle'] . '</td><td>' . $officer['OfficerFirstName'] . ' ' . $officer['OfficerLastName'] . '</td></tr>';
}
}
elseif ($field_name == 'RegisteredAgent')
{
foreach ($field_value as $key => $value)
{
$page_body .= '<tr><td>Registered Agent ' . $key . '</td><td>' . $value . '</td></tr>';
}
}
}
}
$page_body .= '
</table>
</article>';
$template->assign('page_body', $page_body);
$template->assign('page_title', $page_title);
$template->assign('browser_title', $browser_title);
$template->display('includes/templates/simple.tpl');