forked from leonardoxc/leonardoxc
/
GUI_area_admin.php
381 lines (309 loc) · 10.1 KB
/
GUI_area_admin.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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<?
//************************************************************************
// 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_area_admin.php,v 1.15 2010/04/21 07:55:50 manolis Exp $
//
//************************************************************************
if ( !L_auth::isAdmin($userID) ) { echo "go away"; return; }
require_once dirname(__FILE__).'/CL_area.php';
$areaID=makeSane($_GET['areaID'],1);
$areaAction=makeSane($_GET['areaAction']);
if (!$areaID && $areaAction!='Add') {
openMain("Administer Area (group of takeoffs)",0,'');
echo "<a href='".getLeonardoLink(array('op'=>'area_admin','areaAction'=>'Add','areaID'=>0))."'>Add new Area</a><BR><BR>";
?>
<table class=main_text width="564" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td>ID</td>
<td>Name</td>
<td>Type</td>
<td>Actions</td>
</tr>
<?
$query="SELECT * FROM $areasTable ORDER BY ID";
// echo $query;
$res= $db->sql_query($query);
if($res <= 0){
echo "No areas found <BR>";
}
while ($row = $db->sql_fetchrow($res)) {
echo "<tr>
<td>".$row['ID']."</td>
<td>".$row['name']."</td>
<td>".area::areaTypeText($row['areaType'])."</td>
<td> ";
// echo "<a href='".CONF_MODULE_ARG."&op=area_admin&areaAction=Edit&areaID=".$row['ID']."'>Edit</a> :: ";
echo "<a href='".getLeonardoLink(array('op'=>'area_admin','areaAction'=>'Edit','areaID'=>$row['ID']))."'>Edit</a> :: ";
echo "<a href='".getLeonardoLink(array('op'=>'area_admin','areaAction'=>'Delete','areaID'=>$row['ID']))."'>Delete</a>";
// echo "<a href='".CONF_MODULE_ARG."&op=area_admin&areaAction=Delete&areaID=".$row['ID']."'>Delete</a> ";
if ($row['areaType']==0)
echo " :: <a href='".
getLeonardoLink(array('op'=>'area_admin','areaAction'=>'administerTakeoffs','areaID'=>$row['ID']))."'>Add/Remove takeoffs</a> ";
echo "</td></tr> \n";
}
echo "</table>";
closeMain();
return;
} else if (in_array($areaAction,array('Add','Edit','Delete') ) ) {
openMain("$areaAction Area # $areaID",0,'');
echo "<div align=center><a href='".
getLeonardoLink(array('op'=>'area_admin','areaAction'=>'none','areaID'=>0))."'>RETURN TO LIST</a> </div><BR>";
if ($_POST['formSubmitted'] ) { // do the action
if ($areaAction=='Delete') {
$area=new area($areaID);
$res=$area->deleteArea();
if ($res) {
echo "<BR>Area deleted! ";
} else {
echo "<BR>Problem in deleting Area ! ";
}
} else {
$area=new area($areaID);
foreach ( $area->valuesArray as $varName) {
$area->$varName=$_POST[$varName];
}
$area->ID= $areaID;
$res=$area->putToDB( $areaID?1:0 );
if ($res) {
echo "<BR>Area updated! ";
} else {
echo "<BR>Problem in updating Area ! ";
}
if ($areaAction=='Edit')
echo "<div align=center><a href='".
getLeonardoLink(array('op'=>'area_admin','areaAction'=>'Edit','areaID'=>$areaID))."'>RETURN TO AREA</a> </div><BR>";
}
} else {
if (in_array($areaAction,array('Add','Edit','Delete') ) ) {
$area=new area($areaID);
if ($areaID) $area->getFromDB();
}
?>
<form id="areaForm" name="areaForm" method="post" action="">
<table width="700" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="161">Area Name </td>
<td width="533">
<input type="text" name="name" size="40" value="<?=$area->name?>"/> </td>
</tr>
<tr>
<td>Type</td>
<td>
<select name='areaType' id='areaType' >
<? foreach ($areaTypeTextArray as $i=>$areaText) {
if ($area->areaType == $i) $sel='selected';
else $sel='';
echo "<option value='$i' $sel>$areaText</option>\n";
}
?>
</select> </td>
</tr>
<tr>
<td>Description</td>
<td> <?
if ($areaAction!='Delete'){
require_once dirname(__FILE__).'/FN_editor.php';
createTextArea(0,0,'desc',$area->desc ,'takeoff_description','Leonardo',true,710,600);
}else {
?>
<input type="text" name="desc" size="40" value="<?=$area->desc?>"/>
<? } ?>
</td>
</tr>
<tr>
<td>Description (in english) </td>
<td>
<?
if ($areaAction!='Delete'){
require_once dirname(__FILE__).'/FN_editor.php';
createTextArea(0,0,'descInt',$area->descInt ,'takeoff_description','Leonardo',true,710,600);
}else {
?>
<input type="text" name="descInt" size="40" value="<?=$area->desc?>"/>
<? } ?>
</td>
</tr>
<tr>
<td>Min Latitude </td>
<td>
<input type="text" name="min_lat" size="40" value="<?=$area->min_lat?>"/> </td>
</tr>
<tr>
<td>Max Latitude</td>
<td>
<input type="text" name="max_lat" size="40" value="<?=$area->max_lat?>"/> </td>
</tr>
<tr>
<td>Min Lontitude</td>
<td>
<input type="text" name="min_lon" size="40" value="<?=$area->min_lon?>"/> </td>
</tr>
<tr>
<td>Max Lontitude</td>
<td>
<input type="text" name="max_lon" size="40" value="<?=$area->max_lon?>"/> </td>
</tr>
<tr>
<td> </td>
<td>
<input type="hidden" name="isInclusive" value="<?=$area->isInclusive?>" />
<input type="hidden" name="center_lat" value="<?=$area->center_lat?>" />
<input type="hidden" name="center_lon" value="<?=$area->center_lon?>" />
<input type="hidden" name="radius" value="<?=$area->radius?>" />
<input type="hidden" name="polygon" value="<?=$area->polygon?>" />
<input type="hidden" name="formSubmitted" value=1 />
<input type="submit" value="<?=$areaAction?> Area" />
<?
?></td>
</tr>
</table>
</form>
<?
}
closeMain();
} else if ($areaAction=='administerTakeoffs') {
openMain("Administer Takeoffs for Area # $areaID",0,'');
echo "<div align=center><a href='".
getLeonardoLink(array('op'=>'area_admin','areaAction'=>'none','areaID'=>0))."'>RETURN TO LIST</a> </div><BR>";
?>
<script src="<?=$moduleRelPath?>/js/jquery.selectboxes.js" type="text/javascript"></script>
<script language="javascript">
function removeTakeoffFromArea() {
}
function addTakeoffToArea () {
$("#resDiv").html("<img src='<?=$moduleRelPath?>/img/ajax-loader.gif'>");
var tID=$('#addList').val();
var tName=$('#addList :selected').text();
$("#resDiv").load("<?=$moduleRelPath?>/EXT_takeoff_functions.php?op=addToArea&aID=<?=$areaID?>&tID="+tID );
$("#takeoffList").append("<tr id='row_"+tID+"'><td>"+tName+"</td><td><div class='removeTakeoff' id='"+tID+"'>Remove Takeoff from area</div></td></tr>");
};
$(document).ready(function(){
// Your code here
$('.stripeMe tr:even:gt(0)').addClass('alt');
$('.stripeMe tr:odd').addClass('alt2');
$(".removeTakeoff").live('click',function() {
$("#resDiv").html("<img src='<?=$moduleRelPath?>/img/ajax-loader.gif'>");
$("#resDiv").load("<?=$moduleRelPath?>/EXT_takeoff_functions.php?op=removeFromArea&aID=<?=$areaID?>&tID="+$(this).attr("id") );
$(this).parent().parent().addClass("deleted");
});
$("#countryList").change(function(f) {
cCode=$("#countryList").val();
getTakeoffsForCountry(cCode);
});
<? if ($CONF['takeoffAreas']['defaultCountry'] ) { ?>
$("#countryList").val('<?=$CONF['takeoffAreas']['defaultCountry']?>');
getTakeoffsForCountry('<?=$CONF['takeoffAreas']['defaultCountry']?>');
<? } ?>
});
function getTakeoffsForCountry(cCode) {
$("#addList").removeOption(/./);
$("#addList").ajaxAddOption('<?=$moduleRelPath?>/EXT_takeoff.php?op=get_country_takeoffs&countryCode='+cCode);
}
</script>
<style type="text/css">
<!--
tr.alt td {
background: #ecf6fc;
}
tr.alt2 td {
background: #FFFFFF;
}
tr.over td {
background: #bcd4ec;
}
tr.deleted td {
display:none;
background:#F6E4E9;
text-decoration:line-through;
}
tr.marked td {
background:#CDECBB;
}
div#floatDiv , div#takeoffInfoDiv
{
width: 20%;
float: right;
border: 1px solid #8cacbb;
margin: 0.5em;
background-color: #dee7ec;
padding-bottom: 5px;
position :fixed;
right :0.5em;
top :13em;
width :15em;
}
div#takeoffInfoDiv {
float :left;
left : 0.5em;
}
div#floatDiv h3, div#takeoffInfoDiv h3
{
margin:0;
font-size:12px;
background-color:#336699;
color:#FFFFFF;
}
.takeoffLink {
cursor: pointer;
text-decoration:underline;
}
.removeTakeoff
{
cursor: pointer;
text-decoration:underline;
}
-->
</style>
<form name="formFilter" method="post" action="">
<br>
<table class="main_text" border="0" align="left" cellpadding="2" cellspacing="0">
<tr>
<td><div align="right"><strong><? echo _SELECT_COUNTRY ?></strong></div></td>
<td>
<select id="countryList">
<?
asort($countries);
foreach($countries as $cCode=>$cName) {
echo "<option value='$cCode' >$cName</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><div align="right"><strong><? echo _SELECT_TAKEOFF ?></strong></div></td>
<td><select name="addList" id="addList">
</select>
<input type="button" name="SubmitButton" id="SubmitButton" onclick='addTakeoffToArea()' value="Add takeoff to Area" />
<input type="hidden" name="addTakeoffForm" value="1" /></td>
</tr>
<tr>
<td colspan="2" bgcolor="#E3F2F1"><div id ='resDiv'><BR /><BR /></div></td>
</tr>
</table>
</form>
<h3>List of takeoffs that belong to this area</h3><BR />
<table class='stripeMe' id='takeoffList'>
<?
list($takeoffs,$takeoffsID)=area::getTakeoffs($areaID);
$i=0;
foreach ($takeoffs as $name) {
$takeoffID=$takeoffsID[$i];
echo "<tr id='row_$takeoffID'><td>$name</td><td><div class='removeTakeoff' id='$takeoffID'>Remove Takeoff from area</div></td></tr>";
$i++;
}
?>
</table>
<?
echo "<div align=center><a href='".
getLeonardoLink(array('op'=>'area_admin','areaAction'=>'none','areaID'=>0))."'>RETURN TO LIST</a> </div><BR>";
closeMain();
}
?>