/
GUI_admin_pilot_map.php
308 lines (228 loc) · 10.4 KB
/
GUI_admin_pilot_map.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
<?
//************************************************************************
// Leonardo XC Server, http://www.leonardoxc.net
//
// Copyright (c) 2004-2010 by Andreadakis Manolis
//
// This program is free software. You can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License.
//
// $Id: GUI_admin_pilot_map.php,v 1.12 2012/01/16 07:21:22 manolis Exp $
//
//************************************************************************
//test of pilot priority mapping
/*
require_once dirname(__FILE__).'/CL_logReplicator.php';
logReplicator::checkPilot(12,array(userID=>101678));
exit;
*/
if ( !L_auth::isAdmin($userID) ) { echo "go away"; return; }
$legend="Pilot Mapping Tables";
openMain($legend,0,'');
if ($_GET['moveFlights']) {
$confirmMove=$_GET['confirmMoveFlights']+0;
echo "MOVING ALL FLIGHTS FROM MAPPED EXTERNAL PILOTS TO THEIR LOCALY MAPPED ID<BR><BR>";
if (!$confirmMove) {
echo "The listing below is what will be moved. <a href='".CONF_MODULE_ARG."&op=admin_pilot_map&moveFlights=1&confirmMoveFlights=1'>***PRESS HERE TO CONFIRM ***</a><BR><BR>\n";
}
$compareField='hash';
if (1) {
$localServerOnlyClause=" AND $remotePilotsTable.serverID = 0 ";
} else {
$localServerOnlyClause=" AND $remotePilotsTable.serverID = 5 ";
}
$query="SELECT * , $remotePilotsTable.userID as localUserID, $remotePilotsTable.serverID as localServerID FROM $remotePilotsTable , $flightsTable WHERE
$flightsTable.userID = $remotePilotsTable.remoteUserID AND
$flightsTable.userServerID = $remotePilotsTable.remoteServerID
$localServerOnlyClause
ORDER BY remoteServerID ASC";
// echo "#count query#$query<BR>";
$res= $db->sql_query($query);
if($res <= 0){
echo("<H3> Error in query: $query</H3>\n");
exit();
}
echo "<pre>";
echo "<table>";
echo "<tr><td>#</td><td>FlightID</td><td>user</td><td>Name</td><td>localUser</td><td>Name</td></tr>\n";
$i=1;
while ( $row = $db->sql_fetchrow($res) ) {
$pilotID1=$row['serverID'].'_'.$row['userID'];
fillPilotInfo($pilotID1,$row['serverID'],$row['userID']);
$pilotID2=$row['localServerID'].'_'.$row['localUserID'];
fillPilotInfo($pilotID2,$row['localServerID'],$row['localUserID']);
echo "<tr><td>$i</td>
<td><a href='".CONF_MODULE_ARG."&op=show_flight&flightID=".$row['ID']."'>".$row['ID']."</a></td>
<td>".$pilotID1."</td>
<td><a href='".CONF_MODULE_ARG."&op=list_flights&year=0&month=0&pilotID=$pilotID1'>".$pilotNames[$pilotID1]['lname']." ".$pilotNames[$pilotID1]['fname']." [ ".$pilotNames[$pilotID1]['country']." ] CIVLID: ".$pilotNames[$pilotID1]['CIVL_ID']."</td>
<td>".$pilotID2."</td>
<td><a href='".CONF_MODULE_ARG."&op=list_flights&year=0&month=0&pilotID=$pilotID2'>".$pilotNames[$pilotID2]['lname']." ".$pilotNames[$pilotID2]['fname']." [ ".$pilotNames[$pilotID2]['country']." ] CIVLID: ".$pilotNames[$pilotID2]['CIVL_ID']."</td>
</tr>
\n";
// move the flight from one pilot to another:
if ($confirmMove) {
$flight2move=new flight();
$flight2move->getFlightFromDB($row['ID']);
$flight2move->changeUser($row['localUserID'],$row['localServerID']);
if ($i>1000) {echo 'We are doing this in batches of 1000 , repeat unitil none left, exiting now !'; exit; }
}
$i++;
}
echo "</table><BR><BR>";
echo "</pre>";
closeMain();
return;
}
//-----------------------------------------------------------------------------------------------------------
?>
<style type="text/css">
<!--
.mapTable td {padding:2px; }
.mapTable tr.alt td { background-color:#FDFAEA; }
.mapTable tr.alt2 td { background-color:#FFFFFF; }
.mapTable td { border-bottom: 1px solid #CCCCCC; padding-bottom:4px; }
-->
</style>
<div id="stickyEl" style="position:fixed;bottom:0px;left:0px;z-index:3; background-color:#FFFFFF;width:250px;height:80px; display:none;">Results HERE</div>
<div id="pilotInfoDivExt" style=" position:absolute; display:none;background-color:#CCD2D9;width:750px;height:auto; padding:2px;">
<div align='right'><a href='javascript: hidePilotDiv()'>Close</a> </div>
<div id='updateDataDiv'></div>
<table><tr><td width="49%">
<div id="pilotInfoDiv1" style="position:relative; display:block;background-color:#EEECBF;width:100%;height:auto;">Results HERE</div>
</td><td width="49%">
<div id="pilotInfoDiv2" style=" position:relative;display:block;background-color:#EEECBF;width:100%;height:auto;">Results HERE</div>
</td></tr></table>
</div>
<script language="javascript">
function hidePilotDiv() {
$("#pilotInfoDivExt").hide();
}
function getPilotsInfo(row_id,serverID1,pilotID1,serverID2,pilotID2) {
$("#pilotInfoDivExt").css({
left:$("#row_"+row_id).offset().left,
top:$("#row_"+row_id).offset().top+16
}).show();
$("#updateDataDiv").html("<a href='javascript: getPilotInfo("+serverID1+","+pilotID1+
",\"pilotInfoDiv1\",1)'>Update Local DB</a>" +
":: <a href='javascript: getPilotInfo("+serverID1+","+pilotID1+
",\"pilotInfoDiv1\",2)'>Update Local DB (delete all current data)</a> :: "+
"<a href='javascript:copyRemoteToLocalInfo("+serverID1+","+pilotID1+","+serverID2+","+pilotID2+
",\"pilotInfoDiv1\")'>Copy Remote Info -> Local</a> :: "
);
getPilotInfo(serverID1,pilotID1,"pilotInfoDiv1",0) ;
getPilotInfo(serverID2,pilotID2,"pilotInfoDiv2",0) ;
}
function movePilotsFlights(divName,serverID,pilotID,serverID2,pilotID2) {
$("#pilotInfoDivExt").css({
left:$("#row_"+divName).offset().left,
top:$("#row_"+divName).offset().top+16
}).show();
$("#updateDataDiv").html("<img src='<?=$moduleRelPath?>/img/ajax-loader.gif'>").show();
$.get('<?=$moduleRelPath?>/EXT_pilot_functions.php',
{ op:"movePilotFlights","serverID1":serverID,"pilotID1":pilotID,"serverID2":serverID2,"pilotID2":pilotID2},
function(result){
$("#updateDataDiv").html(result).show();
$("#pilotInfoDivExt").show();
}
);
}
function copyRemoteToLocalInfo(serverID1,pilotID1,serverID2,pilotID2,divName) {
$("#"+divName).html("<img src='<?=$moduleRelPath?>/img/ajax-loader.gif'>").show();
$.get('<?=$moduleRelPath?>/EXT_pilot_functions.php',
{ op:"copyRemoteToLocalInfo","serverID1":serverID1,"pilotID1":pilotID1,"serverID2":serverID2,"pilotID2":pilotID2},
function(result){
$("#"+divName).html(result).show();
$("#pilotInfoDivExt").show();
}
);
}
function getPilotInfo(serverID,pilotID,divName,update) {
$("#"+divName).html("<img src='<?=$moduleRelPath?>/img/ajax-loader.gif'>").show();
$.get('<?=$moduleRelPath?>/EXT_pilot_functions.php',
{ op:"getExternalPilotInfo","serverID":serverID,"pilotID":pilotID,"updateData":update},
function(result){
/*var jsonData = eval('(' + result + ')');
var resStr='';
for ( varName in jsonData['log'][0]['item'] ) {
resStr+=varName+' : '+jsonData['log'][0]['item'][varName]+'<br>';
} */
$("#"+divName).html(result).show();
$("#pilotInfoDivExt").show();
}
);
}
function showResults(textStr) {
$("stickyEl").html(textStr);
}
</script>
<?
$query="SELECT * FROM $remotePilotsTable ORDER BY remoteServerID,remoteUserID,serverID ASC";
// echo "#count query#$query<BR>";
$res= $db->sql_query($query);
if($res <= 0){
echo("<H3> Error in query: $query</H3>\n");
exit();
}
echo "<a href='".CONF_MODULE_ARG."&op=admin_pilot_map&moveFlights=1'>>> PRESS HERE TO MOVE ALL FLIGHTS FROM MAPPED EXTERNAL PILOTS TO THEIR LOCALY MAPPED ID</a><BR> By pressing the link above you will have the chance to review the flights before moving them to the local pilot ID";
echo "<pre>";
echo "<table class='mapTable'>";
echo "<tr><td>#</td><td>Srv</td><td>UserID</td><td>Name</td><td>Cntry</td><td>CIVL</td>
<td></td><td>Srv</td><td>UserID</td><td>Name</td><td>Cntry</td><td>CIVL</td><td></td></tr>\n";
$i=1;
while ( $row = $db->sql_fetchrow($res) ) {
$pilotID1=$row['serverID'].'_'.$row['userID'];
fillPilotInfo($pilotID1,$row['serverID'],$row['userID']);
$pilotID2=$row['remoteServerID'].'_'.$row['remoteUserID'];
fillPilotInfo($pilotID2,$row['remoteServerID'],$row['remoteUserID']);
if ($i%2) $rowclass='alt';
else $rowclass='alt2';
echo "<tr class='$rowclass'><td id='row_$i'>$i</td>
<td id='$pilotID1'>".$row['remoteServerID']."</td>
<td>".$row['remoteUserID']."</td>
<td><a href='".CONF_MODULE_ARG."&op=list_flights&year=0&month=0&pilotID=$pilotID2'>".$pilotNames[$pilotID2]['lname']." ".$pilotNames[$pilotID2]['fname']."</td><td>".$pilotNames[$pilotID2]['country']."</td><td>".$pilotNames[$pilotID2]['CIVL_ID']."</td>
<td width=80>
<a href='javascript:movePilotsFlights($i,".
$row['remoteServerID'].','.$row['remoteUserID'].','.
$row['serverID'].','.$row['userID'].")'>*-></a>
->
<a href='javascript:movePilotsFlights($i,".
$row['serverID'].','.$row['userID'].','.
$row['remoteServerID'].','.$row['remoteUserID'].")'><-*</a>
</td>
<td id='$pilotID2'>".$row['serverID']."</td>
<td>".$row['userID']."</td>
<td><a href='".CONF_MODULE_ARG."&op=list_flights&year=0&month=0&pilotID=$pilotID1'>".$pilotNames[$pilotID1]['lname']." ".$pilotNames[$pilotID1]['fname']."</td><td> ".$pilotNames[$pilotID1]['country']."</td><td>".$pilotNames[$pilotID1]['CIVL_ID']."</td>";
echo "<td><a href='javascript:getPilotsInfo($i,".
$row['remoteServerID'].','.$row['remoteUserID'].','.
$row['serverID'].','.$row['userID'].")'>[INFO]</a></td>
</tr>
\n";
$i++;
}
echo "</table><BR><BR>";
echo "</pre>";
closeMain();
return;
function fillPilotInfo($pilotID,$userServerID,$userID) {
global $pilotNames,$CONF_use_utf;
if ( ! $pilotNames[$pilotID]){
$pilotInfo=getPilotInfo($userID,$userServerID );
if (!$CONF_use_utf ) {
$NewEncoding = new ConvertCharset;
$lName=$NewEncoding->Convert($pilotInfo[0],$langEncodings[$nativeLanguage], "utf-8", $Entities);
$fName=$NewEncoding->Convert($pilotInfo[1],$langEncodings[$nativeLanguage], "utf-8", $Entities);
} else {
$lName=$pilotInfo[0];
$fName=$pilotInfo[1];
}
$pilotNames[$pilotID]['lname']=$lName;
$pilotNames[$pilotID]['fname']=$fName;
$pilotNames[$pilotID]['country']=$pilotInfo[2];
$pilotNames[$pilotID]['sex']=$pilotInfo[3];
$pilotNames[$pilotID]['birthdate']=$pilotInfo[4];
$pilotNames[$pilotID]['CIVL_ID']=$pilotInfo[5];
if ($pilotInfo[5]==-1) $pilotNames[$pilotID]['lname']="ERROR:NOT IN THE DB !!!";
}
}
?>