Jump to content

Paginated Flights Page.


homer09001

Recommended Posts

Im trying to create a page viewable from the main site of all the flights in the system, which i've done, but i only want to view X at a time with next and prev links undereath is this possible with the way PHPVMS is done?

or would it be easer to do it in my own code?

my current code:

<?
class Flights extends CodonModule
{

public function Controller()
{
$schedules = SchedulesData::GetSchedules('', true);

	if(!is_array($schedules))
		return false;

	foreach($schedules as $sched)
	{
		$vars = get_object_vars($sched);

		$xml .= '<schedule>'.PHP_EOL;
		foreach($vars as $name=>$val)
		{
			$val = strip_tags($val);

			if($name == 'id' || $name == 'leg' || $name == 'enabled'
					|| $name == 'flighttime' || $name == 'timesflown'
					|| $name == 'depname' || $name == 'deplat'
					|| $name == 'deplong' || $name == 'arrname' 
					|| $name == 'arrlat' || $name == 'arrlong')
			{
				continue;
			}

			$xml .= "<{$name}>{$val}</{$name}>".PHP_EOL;
		}

		$xml .= '</schedule>'.PHP_EOL;
	}		

	$xml .= '</schedules>';	

?>

<h3><?php echo $title?></h3>
<?php
if(!$schedules)
{
echo '<p id="error">No schedules exist</p>';
return;
}
?>
<table id="tabledlist" class="tablesorter">
<thead>
<tr>
<th>Flight Number</th>
<th>Departure</th>
<th>Arrival</th>
<th>Days</th>
<th>Aircraft</th>
<th>Distance</th>
<th>Times Flown</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<?php
foreach($schedules as $sched)
{
?>
<tr id="row<?php echo $sched->id?>" class="<?php echo ($sched->enabled==0)?'disabled':''?>">
<td align="left"><?php echo $sched->code . $sched->flightnum; ?></td>
<td align="left"><?php echo $sched->depicao; ?> (<?php echo $sched->deptime;?>)</td>
<td align="left"><?php echo $sched->arricao; ?> (<?php echo $sched->arrtime;?>)</td>
<td align="left"><?php echo Util::GetDaysCompact($sched->daysofweek)?></td>
<td align="left"><?php echo $sched->aircraft.' ('.$sched->registration.')'; ?></td>
<td align="center"><?php echo $sched->distance; ?></td>
<td align="center"><?php echo $sched->timesflown; ?></td>
<td align="center">
	<?php echo $sched->flighttype . ' ('.$sched->maxload.'/'.$sched->price.')'; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>

<?	}
}
?>

its just a slightly modified version of the admin schedule list.

Link to comment
Share on other sites

  • Administrators

Easiest way would be using this:

http://tablesorter.com/docs/

And you can see in the code, that the tablesorter class is in the <table> tag, you should just have to include the javascript file, then it should just work...

Why is there XML output in the middle of your code?

There should be a start parameter for the GetSchedules -

GetSchedule(start, limit, only_enabled), IIRC

Link to comment
Share on other sites

I've given that a try and i can't make a heads or tails of it, no matter what i try even copying the code from the demo pages they provide yet it doesn't work?

as far as i can tell all the file references are corerct

<?
class Flights extends CodonModule
{

public function Controller()
{
$schedules = SchedulesData::GetSchedules('', true);

	if(!is_array($schedules))
		return false;


?>

<h3><?php echo $title?></h3>
<?php
if(!$schedules)
{
echo '<p id="error">No schedules exist</p>';
return;
}
?>
<style type="text/css">@import "/OpsCenter/core/modules/Flights/docs/assets/css/default.css";</style>
<style type="text/css">@import "/OpsCenter/core/modules/Flights/addons/pager/jquery.tablesorter.pager.css";</style>
<script type="text/javascript" src="/jquery-latest.js"></script>

<script type="text/javascript" src="/jquery.dimensions.pack.js"></script>
<script type="text/javascript" src="/jquery.tablesorter.js"></script>
<script type="text/javascript" src="/OpsCenter/core/modules/Flights/addons/pager/jquery.tablesorter.pager.js"></script>
<script type="text/javascript">
$(document).ready(function() { 
    $("tabledlist") 
    .tablesorter({widthFixed: true, widgets: ['zebra']}) 
    .tablesorterPager({container: $("#pager")}); 
}); 
</script>	



<table id="tabledlist" class="tablesorter">
<thead>
<tr>
<th>Flight Number</th>
<th>Departure</th>
<th>Arrival</th>
<th>Days</th>
<th>Aircraft</th>
<th>Distance</th>
<th>Times Flown</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<?php
foreach($schedules as $sched)
{
?>
<tr id="row<?php echo $sched->id?>" class="<?php echo ($sched->enabled==0)?'disabled':''?>">
<td align="left"><?php echo $sched->code . $sched->flightnum; ?></td>
<td align="left"><?php echo $sched->depicao; ?> (<?php echo $sched->deptime;?>)</td>
<td align="left"><?php echo $sched->arricao; ?> (<?php echo $sched->arrtime;?>)</td>
<td align="left"><?php echo Util::GetDaysCompact($sched->daysofweek)?></td>
<td align="left"><?php echo $sched->aircraft.' ('.$sched->registration.')'; ?></td>
<td align="center"><?php echo $sched->distance; ?></td>
<td align="center"><?php echo $sched->timesflown; ?></td>
<td align="center">
	<?php echo $sched->flighttype . ' ('.$sched->maxload.'/'.$sched->price.')'; ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div id="pager" class="pager">
<form>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/first.png" class="first"/>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/prev.png" class="prev"/>
	<input type="text" class="pagedisplay"/>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/next.png" class="next"/>
	<img src="/OpsCenter/core/modules/Flights/addons/pager/icons/last.png" class="last"/>
	<select class="pagesize">
		<option selected="selected"  value="5">5</option>
		<option value="20">10</option>
		<option value="30">15</option>
		<option  value="40">20</option>
	</select>
</form>
</div>
<?	}
}
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...