-
Notifications
You must be signed in to change notification settings - Fork 1
/
proofs.php
238 lines (206 loc) · 7.32 KB
/
proofs.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<?php
include 'config.php';
date_default_timezone_set("$timezone");
$area_asc = $_GET['asc'];
$area_num = $_GET['areanum'];
$recurse = isset($_GET['recurse']) && $_GET['recurse'] == "true" ? "&recursive=1" : "";
$show_unpublished = isset($_GET['unpublished']) ? $_GET['unpublished'] : "false";
$sortby_day = isset($_GET['sortby']) && $_GET['sortby'] == "day";
$today=date("Y-m-d");
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// Remove parameter from query string
function filter_url($pattern, $url)
{
return rtrim(preg_replace('~(\?|&)'.$pattern.'=[^&]*~', '$1', $url), "&");
}
if ($sortby_day) {
$sortby_query = "weekday_tinyint,start_time";
$sortby_link = "<a href=\"".filter_url('sortby', $current_url)."\" class=\"no-print\">Sort By Meeting Name</a>";
} else {
$sortby_query = "meeting_name";
$sortby_link = "<a href=\"".filter_url('sortby', $current_url)."&sortby=day\" class=\"no-print\">Sort By Day/Time</a>";
}
if ($show_unpublished == "true") {
$published_unpublished_query = "&advanced_published=-1";
$published_unpublished_header = " (Unpublished Meetings Only)";
$published_unpublished_link = "<a href=\"".filter_url('unpublished', $current_url)."&unpublished=false\" class=\"no-print\">Show Published</a>";
} elseif ($show_unpublished == "both") {
$published_unpublished_query = "&advanced_published=0";
$published_unpublished_header = "";
$published_unpublished_link = "<a href=\"".filter_url('unpublished', $current_url)."&unpublished=both\" class=\"no-print\">Show Published</a>";
} else {
$published_unpublished_query = "&advanced_published=1";
$published_unpublished_header = "";
$published_unpublished_link = "<a href=\"".filter_url('unpublished', $current_url)."&unpublished=true\" class=\"no-print\">Show Unpublished</a>";
}
echo "<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: \"Helvetica Neue\",Arial,sans-serif; font-size: 12px; font-weight: 200; line-height: 1.25;}
body>div {
width:99%;
display:inline-table;
border:dotted;
text-align:left;
margin:1em auto;
vertical-align:top;
padding:3px
}
.right {
border-left:dotted;
}
.right p:first-child {
border-bottom:dotted;
}
.right p {
padding:0.5em;
margin:0;
min-height:40%;
box-sizing:border-box;
background:red;
}
@media print
{
.no-print, .no-print *
{
display: none !important;
}
}
</style>
</head>
<body>".
$published_unpublished_link.
" ".
$sortby_link
."<h2>Meeting List Proof Report for ".$area_asc.$published_unpublished_header."</h2>
Printed on: " .date("l jS \of F Y h:i A") . "
<h3>Pass this proof report around at your Area Service Committee meeting so that groups can check their listing and make changes.</h3>
";
function sortBySubkey(&$array, $subkey, $sortType = SORT_ASC)
{
if (empty($array)) {
return;
}
foreach ($array as $subarray) {
$keys[] = $subarray[$subkey];
}
array_multisort($keys, $sortType, $array);
}
$get_formats = file_get_contents($bmlt_server . "/client_interface/json/?switcher=GetFormats");
$formats = json_decode($get_formats, true);
sortBySubkey($formats, 'key_string');
$data_formats = "<table width=\"70%\"><tr><td colspan=\"2\">MEETING FORMATS</td></tr>";
$countmax = count($formats);
for ($count = 0; $count < $countmax; $count += 2) {
$data_formats .= '<tr>';
$data_formats .= "<td>".$formats[$count]['key_string']."</td>";
$data_formats .= "<td>".$formats[$count]['name_string']."</td>";
if (isset($formats[$count + 1])) {
$data_formats .= "<td>".$formats[$count + 1]['key_string']."</td>";
$data_formats .= "<td>".$formats[$count + 1]['name_string']."</td>";
} else {
$data_formats .= "<td colspan=\"2\"></td>";
}
$data_formats .= "</tr>";
}
$data_formats .= "</table>";
echo $data_formats;
//Changes printed on date and time
//echo "<hr>";
$url = $bmlt_server. "/client_interface/json/?switcher=GetSearchResults&get_used_formats=1&services=".$area_num."&weekdays[]=1&weekdays[]=2&weekdays[]=3&weekdays[]=4&weekdays[]=5&weekdays[]=6&weekdays[]=7&sort_keys=" . $sortby_query . $recurse . $published_unpublished_query;
// get json file contents
$json = json_decode(file_get_contents($url));
// loop begins
foreach ($json->meetings as $row) {
// begin new paragraph
echo "<div class=\"list-row\">
<div class=\"list-left\">
";
// Group Name
$unpublished = "";
if ($row->published == 0) {
$unpublished = " (UNPUBLISHED)";
}
echo "Group: <strong style=\"text-decoration: underline; font-size: larger;\">".$row->meeting_name.$unpublished."</strong>, ";
// Day of the Week
$weekday_tinyint=$row->weekday_tinyint;
if ($weekday_tinyint == "1") {
$weekday_tinyint = "Sunday";
}
if ($weekday_tinyint == "2") {
$weekday_tinyint = "Monday";
}
if ($weekday_tinyint == "3") {
$weekday_tinyint = "Tuesday";
}
if ($weekday_tinyint == "4") {
$weekday_tinyint = "Wednesday";
}
if ($weekday_tinyint == "5") {
$weekday_tinyint = "Thursday";
}
if ($weekday_tinyint == "6") {
$weekday_tinyint = "Friday";
}
if ($weekday_tinyint == "7") {
$weekday_tinyint = "Saturday";
}
// Print Week Day
echo "Day:<strong> ".$weekday_tinyint."</strong>, ";
// Start Time
$st = $row->start_time;
$start_time = date("g:i A", strtotime($st));
echo "Start:<strong> ".$start_time."</strong>, ";
// Duration
$dt = $row->duration_time;
$duration_time = date("g:i", strtotime($dt));
echo "Duration (H:M):<strong> ".$duration_time."</strong>
";
// List ID data
echo "<small>[ BMLT ID: ".$row->id_bigint." / ";
// List NAWS ID data
echo "NAWS ID: ".$row->worldid_mixed." / ";
// Published formats
$formats = $row->formats;
$formats = str_replace(",", ", ", $formats);
echo "Published Formats: <strong>".$formats."</strong> ]</small><br>";
// Virtual Meeting Additional Info
if (isset($row->phone_meeting_number) || isset($row->virtual_meeting_link) || isset($row->virtual_meeting_additional_info)) {
echo "Virtual Info: ";
if (isset($row->phone_meeting_number)) {
echo "[Phone: <strong> ".$row->phone_meeting_number."</strong>] ";
}
if (isset($row->virtual_meeting_link)) {
echo "[Link: <strong> ".$row->virtual_meeting_link."</strong>] ";
}
if (isset($row->virtual_meeting_additional_info)) {
echo "[Additional Info: <strong> ".$row->virtual_meeting_additional_info."</strong>]";
}
echo "<br>";
}
//Address
echo "
Address:<strong> ".$row->location_text.", ";
echo " ".$row->location_street.", ";
echo " ".$row->location_municipality.", ";
echo " ".$row->location_province.", ";
echo " ".$row->location_postal_code_1."</strong> ";
// Extra Info
if (isset($row->location_info)) {
echo "Extra Location Info:<strong> ".$row->location_info."</strong> / ";
}
// County
echo "County:<strong> ".$row->location_sub_province." County</strong><br>
CHANGES:<br><br><br><br>";
//echo "
// </div>
// <div class=\"list-right\">";
// End Paragraph
echo " </div>
</div>";
}
// loop ends
echo "</body>
</html>";