Skip to content
This repository was archived by the owner on Dec 6, 2019. It is now read-only.

Commit aa999a1

Browse files
author
nshahzad
committed
final beta build, various fixes
git-svn-id: file:///var/svn/phpvms/trunk@923 e188d3d8-5a48-0410-b2de-ed2772025908
1 parent b17d2fb commit aa999a1

File tree

13 files changed

+457
-244
lines changed

13 files changed

+457
-244
lines changed

admin/modules/Operations/Operations.php

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public function editairline()
131131

132132
public function calculatedistance($depicao='', $arricao='')
133133
{
134-
cndebug(print_r($this->get, true));
135134
if($depicao == '')
136135
$depicao = $this->get->depicao;
137136

@@ -163,7 +162,7 @@ public function getfuelprice()
163162

164163
public function findairport()
165164
{
166-
$results = OperationsData::findAirport($this->get->term);
165+
$results = OperationsData::searchAirport($this->get->term);
167166

168167
if(count($results) > 0)
169168
{
@@ -259,9 +258,101 @@ public function airports()
259258
}
260259
}
261260

262-
$this->set('airports', OperationsData::GetAllAirports());
261+
//$this->set('airports', OperationsData::getAllAirports());
263262
$this->render('ops_airportlist.tpl');
264263
}
264+
265+
public function airportgrid()
266+
{
267+
$page = $this->get->page; // get the requested page
268+
$limit = $this->get->rows; // get how many rows we want to have into the grid
269+
$sidx = $this->get->sidx; // get index row - i.e. user click to sort
270+
$sord = $this->get->sord; // get the direction
271+
if(!$sidx) $sidx =1;
272+
273+
# http://dev.phpvms.net/admin/action.php/operations/
274+
# ?_search=true&nd=1270940867171&rows=20&page=1&sidx=flightnum&sord=asc&searchField=code&searchString=TAY&searchOper=eq
275+
276+
/* Do the search using jqGrid */
277+
$where = array();
278+
if($this->get->_search == 'true')
279+
{
280+
$searchstr = jqgrid::strip($this->get->filters);
281+
$where_string = jqgrid::constructWhere($searchstr);
282+
283+
# Append to our search, add 1=1 since it comes with AND
284+
# from above
285+
$where[] = "1=1 {$where_string}";
286+
}
287+
288+
# Do a search without the limits so we can find how many records
289+
$count = count(OperationsData::findAirport($where));
290+
291+
if($count > 0)
292+
{
293+
$total_pages = ceil($count/$limit);
294+
}
295+
else
296+
{
297+
$total_pages = 0;
298+
}
299+
300+
if ($page > $total_pages)
301+
{
302+
$page = $total_pages;
303+
}
304+
305+
$start = $limit * $page - $limit; // do not put $limit*($page - 1)
306+
if ($start < 0)
307+
{
308+
$start = 0;
309+
}
310+
311+
# And finally do a search with the limits
312+
$airports = OperationsData::findAirport($where, $limit, $start, "{$sidx} {$sord}");
313+
if(!$airports)
314+
{
315+
$airports = array();
316+
}
317+
318+
# Form the json header
319+
$json = array(
320+
'page' => $page,
321+
'total' => $total_pages,
322+
'records' => $count,
323+
'rows' => array()
324+
);
325+
326+
# Add each row to the above array
327+
foreach($airports as $row)
328+
{
329+
if($row->fuelprice == 0)
330+
{
331+
$row->fuelprice = 'Live';
332+
}
333+
334+
$edit = '<a href="#" onclick="editairport(\''.$row->icao.'\'); return false;">Edit</a>';
335+
336+
$tmp = array(
337+
'id' => $row->id,
338+
'cell' => array(
339+
# Each column, in order
340+
$row->icao,
341+
$row->name,
342+
$row->country,
343+
$row->fuelprice,
344+
$row->lat,
345+
$row->lng,
346+
$edit,
347+
),
348+
);
349+
350+
$json['rows'][] = $tmp;
351+
}
352+
353+
header("Content-type: text/x-json");
354+
echo json_encode($json);
355+
}
265356

266357
public function addschedule()
267358
{
@@ -354,6 +445,10 @@ public function schedulegrid()
354445

355446
# And finally do a search with the limits
356447
$schedules = SchedulesData::findSchedules($where, $limit, $start);
448+
if(!$schedules)
449+
{
450+
$schedules = array();
451+
}
357452

358453
# Form the json header
359454
$json = array(
@@ -605,20 +700,21 @@ protected function add_aircraft_post()
605700
return;
606701
}
607702

608-
$data = array( 'icao'=>$this->post->icao,
609-
'name'=>$this->post->name,
610-
'fullname'=>$this->post->fullname,
611-
'registration'=>$this->post->registration,
612-
'downloadlink'=>$this->post->downloadlink,
613-
'imagelink'=>$this->post->imagelink,
614-
'range'=>$this->post->range,
615-
'weight'=>$this->post->weight,
616-
'cruise'=>$this->post->cruise,
617-
'maxpax'=>$this->post->maxpax,
618-
'maxcargo'=>$this->post->maxcargo,
619-
'minrank'=>$this->post->minrank,
620-
'enabled'=>$this->post->enabled);
621-
703+
$data = array(
704+
'icao'=>$this->post->icao,
705+
'name'=>$this->post->name,
706+
'fullname'=>$this->post->fullname,
707+
'registration'=>$this->post->registration,
708+
'downloadlink'=>$this->post->downloadlink,
709+
'imagelink'=>$this->post->imagelink,
710+
'range'=>$this->post->range,
711+
'weight'=>$this->post->weight,
712+
'cruise'=>$this->post->cruise,
713+
'maxpax'=>$this->post->maxpax,
714+
'maxcargo'=>$this->post->maxcargo,
715+
'minrank'=>$this->post->minrank,
716+
'enabled'=>$this->post->enabled
717+
);
622718

623719
OperationsData::AddAircaft($data);
624720

admin/modules/PilotAdmin/PilotAdmin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,10 @@ public function getpilotsjson()
339339

340340
# And finally do a search with the limits
341341
$allpilots = PilotData::findPilots($where, $limit, $start);
342+
if(!$allpilots)
343+
{
344+
$allpilots = array();
345+
}
342346

343347
# Form the json header
344348
$json = array(

admin/templates/ops_airportlist.tpl

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,46 @@
11
<h3>Airports List</h3>
2-
<?php
3-
if(!$airports)
2+
3+
<table id="grid"></table>
4+
<div id="pager"></div>
5+
<br />
6+
7+
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo fileurl('/lib/js/jqgrid/css/ui.jqgrid.css');?>" />
8+
<script src="<?php echo fileurl('/lib/js/jqgrid/js/i18n/grid.locale-en.js');?>" type="text/javascript"></script>
9+
<script src="<?php echo fileurl('/lib/js/jqgrid/js/jquery.jqGrid.min.js');?>" type="text/javascript"></script>
10+
11+
<script type="text/javascript">
12+
$("#grid").jqGrid({
13+
url: '<?php echo adminaction('/operations/airportgrid');?>',
14+
datatype: 'json',
15+
mtype: 'GET',
16+
colNames: ['ICAO', 'Airport Name', 'Airport Country', 'Fuel Cost', 'Lat', 'Lng', 'Edit'],
17+
colModel : [
18+
{index: 'icao', name : 'icao', width: 40, sortable : true, align: 'center', search: 'true', searchoptions:{sopt:['eq','ne']}},
19+
{index: 'name', name : 'name', width: 65, sortable : true, align: 'center', searchoptions:{sopt:['in']}},
20+
{index: 'country', name : 'country', width: 65, sortable : true, align: 'center', searchoptions:{sopt:['in']}},
21+
{index: 'fuelprice', name : 'fuelprice', width: 65, sortable : true, align: 'center', search:false},
22+
{index: 'lat', name : 'lat', width: 65, sortable : true, align: 'center', search:false},
23+
{index: 'lng', name : 'lng', width: 65, sortable : true, align: 'center', search:false},
24+
{index: '', name : '', width: 100, sortable : true, align: 'center', search: false}
25+
],
26+
pager: '#pager', rowNum: 25,
27+
sortname: 'icao', sortorder: 'asc',
28+
viewrecords: true, autowidth: true,
29+
height: '100%'
30+
});
31+
32+
jQuery("#grid").jqGrid('navGrid','#pager',
33+
{edit:false,add:false,del:false,search:true,refresh:true},
34+
{}, // edit
35+
{}, // add
36+
{}, //del
37+
{multipleSearch:true} // search options
38+
);
39+
40+
function editairport(icao)
441
{
5-
echo '<p id="error">No airports have been added</p>';
6-
return;
42+
$('#jqmdialog').jqm({
43+
ajax:'<?php echo adminaction('/operations/editairport?icao=');?>'+icao,
44+
}).jqmShow();
745
}
8-
?>
9-
<table id="tabledlist" class="tablesorter">
10-
<thead>
11-
<tr>
12-
<th>ICAO</th>
13-
<th>Airport Name</th>
14-
<th>Airport Country</th>
15-
<th>Latitude</th>
16-
<th>Longitude</th>
17-
<th>Fuel Cost</th>
18-
<th>Options</th>
19-
</tr>
20-
</thead>
21-
<tbody>
22-
<?php
23-
foreach($airports as $airport)
24-
{
25-
?>
26-
<tr class="<?php if($airport->hub==1) { echo 'background_yellow'; } ?>">
27-
<td align="center"><?php if($airport->hub==1) { echo '<strong>'; } echo $airport->icao; if($airport->hub==1) { echo '</strong>'; } ?></td>
28-
<td><?php if($airport->hub==1) { echo '<strong>'; } echo $airport->name; if($airport->hub==1) { echo '</strong>'; } ?></td>
29-
<td align="center"><?php echo $airport->country; ?></td>
30-
<td align="center"><?php echo $airport->lat; ?></td>
31-
<td align="center"><?php echo $airport->lng; ?></td>
32-
<td align="center"><?php echo $airport->fuelprice == 0 ? 'live' : $airport->fuelprice; ?></td>
33-
<td align="center" width="1%" nowrap>
34-
<button id="dialog" class="jqModal {button:{icons:{primary:'ui-icon-wrench'}}}"
35-
href="<?php echo adminaction('/operations/editairport?icao='.$airport->icao);?>">Edit</button></td>
36-
</tr>
37-
<?php
38-
}
39-
?>
40-
</tbody>
41-
</table>
46+
</script>

core/classes/ezdb/ezdb.class.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,10 @@ public static function set_table_prefix($prefix)
273273
* @param constant $type
274274
* @return resultset
275275
*/
276-
public static function quick_select($params)
276+
public static function quick_select($table, $fields='', $cond='')
277277
{
278278
self::$DB->throw_exceptions = self::$throw_exceptions;
279-
280-
return self::$DB->quick_select($params);
279+
return self::$DB->quick_select($table, $fields, $cond);
281280
}
282281

283282
/**
@@ -310,6 +309,14 @@ public static function quick_update($table, $fields, $cond='', $allowed_cols='')
310309
return self::$DB->quick_update($table, $fields, $cond, $allowed_cols);
311310
}
312311

312+
/**
313+
* Build a SELECT statement
314+
*
315+
*/
316+
public static function build_select($params)
317+
{
318+
return self::$DB->build_select($params);
319+
}
313320

314321
/**
315322
* Build a WHERE clause for an SQL statement with supplied parameters

0 commit comments

Comments
 (0)