forked from sa2blv/SVXportal
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ctcss_map_table.php
360 lines (225 loc) · 8.95 KB
/
ctcss_map_table.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?php
include_once 'config.php';
$link->set_charset("utf8");
$talkgroup_array= array();
$station_array= array();
function Get_station_from_json() {
global $serveradress;
$context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
$json_data = file_get_contents($serveradress,false,$context);
//$json_data = file_get_contents($serveradress);
$json = json_decode($json_data);
global $talkgroup_array;
global $station_array;
foreach($json->nodes as $st => $station)
{
foreach ($station->qth as $qth => $qthdata)
{
$station_first_RX =array();
$station_first_TX =array();
$a=0;
foreach($qthdata->rx as $RX => $value)
{
$station_first_RX[ $a]= $value->freq;
$a++;
}
$b=0;
foreach($qthdata->tx as $TX => $value)
{
$station_first_TX[$b]= $value->freq;
$b++;
}
foreach($station_first_TX as $int => $data)
{
$offset=0;
if($station_first_TX[$int] == null)
{
$station_first_TX[$int] = $station_first_RX[$int];
}
else
{
$offset =$station_first_TX[$int]-$station_first_RX[$int];
}
$ofset_char ="";
if($offset != 0)
{
if (($station_first_RX[$int]-$station_first_TX[$int]) <0)
{
$ofset_char="-";
}
else
{
$ofset_char="+";
}
}
$offset =$station_first_TX[$int]-$station_first_RX[$int];
foreach($station->toneToTalkgroup as $tonegroup => $talkgroup)
{
if($int ==0 )
{
$talkgroup_array[$talkgroup] =$talkgroup;
$station_array[$st][$talkgroup] = $tonegroup;
$station_array[$st]["tx_freq"] =$station_first_TX[$int];
$station_array[$st]["Location"] =$station->NodeLocation;
if($station->NodeLocation == null)
{
$station_array[$st]["Location"] =$station->nodeLocation;
}
}
else
{
$talkgroup_array[$talkgroup] =$talkgroup;
$station_array[$st.$int][$talkgroup] = $tonegroup;
$station_array[$st.$int]["tx_freq"] =$station_first_TX[$int];
$station_array[$st.$int]["Location"] =$station->NodeLocation;
if($station->NodeLocation == null)
{
$station_array[$st.$int]["Location"] =$station->nodeLocation;
}
}
}
}
}
}
}
Get_station_from_json();
sort($talkgroup_array);
/*
echo '<pre>';
var_dump($talkgroup_array);
echo '<pre>';
var_dump($station_array);
*/
?>
<?php
if($noheader != 1){?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>CTCSS table</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<?php }?>
<div class="container-fluid">
<script type="text/javascript">
function validate_export()
{
var checked=false;
var elements = document.getElementsByName("Stationexpot[]");
for(var i=0; i < elements.length; i++){
if(elements[i].checked) {
checked = true;
}
}
if (!checked) {
alert('You nead to select a station for export');
return false;
}
return true;
}
</script>
<nav class="navbar navbar-expand-sm navbar-light bg-light" style="background-color: #e3f2fd;">
<a class="navbar-brand" href="#"><?php echo _('CTCSS Map table')?></a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item d-none d-lg-inline-flex">
<a class="nav-link " href="#" id="navbarDropdownMenuLink" onclick="PrintElem('print_export_log','<?php echo _('CTSS map table')?>')" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fas fa-print"></i>
<?php echo _('Print')?>
</a>
</li>
<li class=" d-none d-lg-inline-flex">
<a class="nav-link " href="#" id="navbarDropdownMenuLink" onclick="fnExcelexport('ctcss_data_table')" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="far fa-file-excel"></i>
<?php echo _('Export xls')?>
</a>
</li>
</ul>
</nav>
<form action="Get_Node_CSV.php" method="POST" onsubmit="return validate_export()" target="_blank">
<div id="print_export_log">
<table class="table table-hover table-sm" id="ctcss_data_table" >
<thead class="dash_header">
<tr>
<th> </th>
<th><?php echo _("Callsign")?></th>
<th><?php echo _("Frequency")?></th>
<th><?php echo _("Location")?></th>
<?php
foreach( $talkgroup_array as $tonegroup => $talkgroup)
{
if($talkgroup == 0)
{
echo '<th>'._('Local').'</th>';
}
else
{
echo '<th>'.$talkgroup.'</th>';
}
}
?>
</tr>
</thead>
<tbody>
<?php
foreach( $station_array as $station => $st_object)
{
if(!$_GET['hiddeexport'])
$chechbox ="<input type='checkbox' name='Stationexpot[]' value='".$station."'>";
else
$chechbox ="";
if(is_numeric(substr($station, -1)) && strpos($station, "-") === false)
{
$station= substr($station, 0, -1);
}
echo '<tr>
'.'<td>'.$chechbox
.'<td>'.$station.'</td>'
.'<td>'.number_format($st_object['tx_freq'], 4, '.', '').'</td>'
.'<td>'.$st_object['Location'].'</td>';
foreach( $talkgroup_array as $tonegroup => $talkgroup)
{
echo '<td>'.$st_object[$talkgroup].'</td>';
}
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<?php if(!$_GET['hiddeexport']){?>
<div class="row">
<div class="col-sm">
<div class="form-group">
<fieldset class="form-group row">
<label for="Softwareinput" class="col-2 col-form-label"><?php echo _("Software")?></label>
<div class="col-10">
<select class="form-control " name="Software" id="Softwareinput">
<option value="anytone" > AnyTone AT</option>
<option value="chirp">Chirp</option>
</select>
</div>
<label for="numberinpuet" class="col-2 col-form-label"><?php echo _('CSV index')?></label>
<div class="col-10">
<input class="form-control" type="number" value="0" name="index" id="numberinpuet">
</div>
<label for="countrypre" class="col-2 col-form-label"><?php echo _("Use three last char in call")?></label>
<div class="col-10">
<input class="form-control" type="checkbox" value="1" name="trimc" id="countrypre">
</div>
<div class="col-sm-10">
<input class="btn btn-primary" type="submit" value="<?php echo _("Export")?>">
</div>
</fieldset>
</div>
</div>
</div>
<?php }?>
</form>
</div>