Jump to content

Upcoming Departures


TB1

Recommended Posts

Hello guys,

I just wanted to share with you some code I have running on our logging site.

For this to work you need Zumeweb's Pacific skin, stuartpb's Airport Information Addon and Vansers VFleetTracker added.

This bit of code will display flights that have been bidded on on a table form with some cool links to the modules listed above.

When there is a flight that has been bidded on something like this will appear:

tanLwrL.png

If no flights have been bidded on then this will appear: (not the latest flights table, the thing below that).

xKQnG4O.png

Here is the code:

<?php
$lastbid = SchedulesData::GetAllBids();
if (count($lastbid) > 0)
{ ?>

<div class="row-fluid">
<div class="span12">
<div class="box">
<table width="100%" border="0" bordercolor="#FFFFFF">
<h3><center>Upcoming Departures</h3>
</div>

<style type="text/css">
table th { text-align: center; color:black; font-weight:bold;}
table td { text-align: center; }
</style>
<thead>
<tr>
<style type="text/css">
{ text-align: center; }
</style>
<th><div align="center">Flight Number</div></th>
<th><div align="center">Pilot</div></th>
<th><div align="center">Departure</div></th>
<th><div align="center">Arrival</div></th>
<th><div align="center">Flight Duration</div></th>
<th><div align="center">Aircraft</th>
<th><div align="center">Registration</div></th>
</tr>
</thead>
<tbody>
<?php

foreach($lastbids as $lastbid)
{
?>

<?php
$flightid = $lastbid->id
?>

<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/schedules/details/<?php echo '' . $flightid . '';?> "><?php echo $lastbid->code; ?><?php echo $lastbid->flightnum; ?></span></td>
<?php
$params = $lastbid->pilotid;

$pilot = PilotData::GetPilotData($params);
$pname = $pilot->firstname;
$psurname = $pilot->lastname;
?>
<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/profile/view/<?php echo '' . $params . ''; ?>"><?php echo $pname; ?> <?php echo $psurname; ?></span></td>
<td height="25" width="10%" align="center"><span><?php echo '<a href=" '.SITE_URL.'/index.php/airports/get_airport?icao='.$lastbid->depicao.'">'.$lastbid->depicao.'</a>';?></span></td>
<td height="25" width="10%" align="center"><span><?php echo '<a href=" '.SITE_URL.'/index.php/airports/get_airport?icao='.$lastbid->arricao.'">'.$lastbid->arricao.'</a>';?></span></td>
<td height="25" width="10%" align="center"><span><?php echo $lastbid->flighttime; ?> hours</span></td>
<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/vFleetTracker/view/<?php echo '' . $lastbid->registration . ''; ?>"><?php echo $lastbid->aircraft; ?></a></td>
<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/vFleetTracker/view/<?php echo '' . $lastbid->registration . ''; ?>"><?php echo $lastbid->registration; ?></a></td>

</tr>
</div>
</div>
</div>
<?php
}
} else { ?>
<div class="row-fluid">
<div class="span12">
<div class="box">
<table width="100%" border="0" bordercolor="#FFFFFF">
<h3><center>There Are No Upcoming Departures!</h3>
</div>
<?php
}
?>
</tbody>
</table>
</div>

For this to work you need to paste this into your frontpage_recentbids.tpl file. Remember the links will not work unless you have the modules mentioned above installed.

Enjoy!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 2 years later...
  • 1 month later...
  • 8 months later...
On 10/19/2016 at 2:12 AM, firejelle said:

I have the same error as Industrialshadow.

But at my site he says at line 1221.

And line 1221 is:

 


foreach($lastbids as $lastbid)
 

 

Hey, i did a few things to get this working :)

1. In the Modules > Airports, i renamed the " airport_main.tpl " and "airport_info.tpl" into  " airport_main.php " and "airport_info.php"
2. And for this error 

foreach($lastbids as $lastbid)

Just change the "$lastbids" into "$lastbid" 
should look like this : 

foreach($lastbid as $lastbid)

Regards, 

Leonard

Link to comment
Share on other sites

  • 4 months later...
3 hours ago, LeonardIGO4036 said:

How exactly do you want it to display? 

 

I've made some custom edits to it on my VA. 

Really, the upcoming departures (current bids) would be great to display on my main page (frontpage_main.tpl) 

I display live flights, but as we all know, you need smartCARS (or similar) active for those, but to display flights booked and not yet running would be great

Link to comment
Share on other sites

Okay, I have made it work with a custom skin here, I've added a feature which you could see "Upcoming", the green label. It'll turn into a red color label and say "No Departures" if there are no upcoming departures. and additionally, i've added the time till which the bid will be available. Which is 48 hours.

If you're using a Bootstrap theme, then just copy and paste my code into your frontpage_main.tpl

Capture.png

<div class="col-md-12">
    <!--Upcoming Departures block-->
    <div class="block">
        <div class="block-title">
            <?php
						$lastbids = SchedulesData::GetAllBids();
						if (count($lastbids) > 0)
						{
							$departurestatus = 'Upcominig';
							$label_clr = 'success';
						}
						else {
							$departurestatus = 'No Departures';
							$label_clr = 'danger';
						}
				?>

                <div class="block-options pull-right">
                    <span class="label label-<?php echo $label_clr ?> animation-pulse"><?php echo $departurestatus?></span>
                </div>
        </div>
        <h3><Strong>Upcoming</Strong> Departures</h3>
        <div class="table-responsive">
            <!--Remove this line if you dont want the departures box to be on a fixed scale-->
            <div style="overflow: auto; height: 270px; border: 0px solid #666; margin-bottom: 20px; padding: 5px; padding-top: 0px; padding-bottom: 20px;">
                <table class="table table-hover table-striped">
                    <thead>
                        <tr>
                            <th>
                                <div align="center">Flight #</div>
                            </th>
                            <th>
                                <div align="center">Pilot</div>
                            </th>
                            <th>
                                <div align="center">Slot added on</div>
                            </th>
                            <th>
                                <div align="center">Slot Expires on</div>
                            </th>
                            <th>
                                <div align="center">Departure</div>
                            </th>
                            <th>
                                <div align="center">Arrival</div>
                            </th>
                            <th>
                                <div align="center">Registration</div>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
						$lastbids = SchedulesData::GetAllBids();
						if (count($lastbids) > 0)
						{ ?>
                            <?php
							foreach($lastbids as $lastbid)
							{
							?>
                                <?php
							$flightid = $lastbid->id
							?>
                                    <td height="25" width="10%" align="center"><font face="Bauhaus"><span><?php echo $lastbid->code; ?><?php echo $lastbid->flightnum; ?></span></font></td>
                                    <?php
							$params = $lastbid->pilotid;

							$pilot = PilotData::GetPilotData($params);
							$pname = $pilot->firstname;
							$psurname = $pilot->lastname;
							$now = strtotime(date('d-m-Y',strtotime($lastbid->dateadded)));
            				$date = date("d-m-Y", strtotime('+48 hours', $now));

							?>
                                        <td height="25" width="10%" align="center"><span><?php echo $pname; ?> <?php echo $psurname; ?></span></td>
                                        <td height="25" width="10%" align="center"><span class="text-success"><?php echo date('d-m-Y',strtotime($lastbid->dateadded)); ?></span></td>
                                        <td height="25" width="10%" align="center"><span class="text-danger"><?php echo $date; ?></span></td>
                                        <td height="25" width="10%" align="center"><span><font face=""><?php echo '<a class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="Click to view Airport Information!" href="  '.SITE_URL.'/index.php/airports/get_airport?icao='.$lastbid->depicao.'">'.$lastbid->depicao.'</a>';?></font></span></td>
                                        <td height="25" width="10%" align="center"><span><font face=""><?php echo '<a class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="Click to view Airport Information!" href= '.SITE_URL.'/index.php/airports/get_airport?icao='.$lastbid->arricao.'">'.$lastbid->arricao.'</a>';?></font></span></td>
                                        <td height="25" width="10%" align="center"><span><a class="btn btn- btn-sm" data-toggle="tooltip" data-placement="top" title="Click to view Aircraft Information!" href="<?php echo SITE_URL?>/index.php/vFleetTracker/view/<?php echo '' . $lastbid->registration . ''; ?>"><?php echo $lastbid->registration; ?></a></td>
							</tr>
							<?php
							}
							} else { ?>

							<div class="alert alert-danger">
								<strong>Oops</strong><br>
								Looks like there are no upcoming departures at the moment, do you feel like flying? Click <a href="<?php echo SITE_URL?>/index.php/Schedules">here</a> to bid a flight! #tuigroupvirtual
							</div>

							<?php
							}
							?>

					</tbody>
			</table>
			</div>
			</div>
		</div>
		<!--END Upcoming Departures Block-->
	</div>


Let me know if this works for you! 
Regards, 
Leonard.

Edited by LeonardIGO4036
Link to comment
Share on other sites

1 minute ago, topher2880 said:

How do I give you a like? I certainly would do that. It doesnt have the great look of yours but it does look good matching my colour scheme

Simply hover over the heart icon below. slide to the left and press the "thanks" icon.
Thank you once again:)

Edited by LeonardIGO4036
Link to comment
Share on other sites

  • 2 months later...

I've made some minor changes, all I did was delete the "s" off of ; $lastbid-> on all of them, and worked perfectly. I actually added a page in the admin panel, but before I pasted the code to the page I did the following, after naming the page, "Upcoming Departures", ............click on the icon button that says source, then paste your code into the page, and click on public at the bottom of course also so everyone can see it, works nice, thanks gentlemen, been looking for this little code snippet ! below is the fixed code that was created into a page in the Admin Panel; It does work as an HTML file for me, I've got it pasted everywhere with it now, lol. 

Cheers, Jim

Duh Code;

<?php
$lastbid = SchedulesData::GetAllBids();
if (count($lastbid) > 0)
{ ?>

<div class="row-fluid">
<div class="span12">
<div class="box">
<table width="100%" border="0" bordercolor="#FFFFFF">
<h3><center>Upcoming Departures</h3>
</div>

<style type="text/css">
table th { text-align: center; color:black; font-weight:bold;}
table td { text-align: center; }
</style>
<thead>
<tr>
<style type="text/css">
{ text-align: center; }
</style>
<th><div align="center">Flight Number</div></th>
<th><div align="center">Pilot</div></th>
<th><div align="center">Departure</div></th>
<th><div align="center">Arrival</div></th>
<th><div align="center">Flight Duration</div></th>
<th><div align="center">Aircraft</th>
<th><div align="center">Registration</div></th>
</tr>
</thead>
<tbody>
<?php

foreach($lastbid as $lastbid)
{
?>

<?php
$flightid = $lastbid->id
?>

<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/schedules/details/<?php echo '' . $flightid . '';?> "><?php echo $lastbid->code; ?><?php echo $lastbid->flightnum; ?></span></td>
<?php
$params = $lastbid->pilotid;

$pilot = PilotData::GetPilotData($params);
$pname = $pilot->firstname;
$psurname = $pilot->lastname;
?>
<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/profile/view/<?php echo '' . $params . ''; ?>"><?php echo $pname; ?> <?php echo $psurname; ?></span></td>
<td height="25" width="10%" align="center"><span><?php echo '<a href=" '.SITE_URL.'/index.php/airports/get_airport?icao='.$lastbid->depicao.'">'.$lastbid->depicao.'</a>';?></span></td>
<td height="25" width="10%" align="center"><span><?php echo '<a href=" '.SITE_URL.'/index.php/airports/get_airport?icao='.$lastbid->arricao.'">'.$lastbid->arricao.'</a>';?></span></td>
<td height="25" width="10%" align="center"><span><?php echo $lastbid->flighttime; ?> hours</span></td>
<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/vFleetTracker/view/<?php echo '' . $lastbid->registration . ''; ?>"><?php echo $lastbid->aircraft; ?></a></td>
<td height="25" width="10%" align="center"><span><a href="<?php echo SITE_URL?>/index.php/vFleetTracker/view/<?php echo '' . $lastbid->registration . ''; ?>"><?php echo $lastbid->registration; ?></a></td>

</tr>
</div>
</div>
</div>
<?php
}
} else { ?>
<div class="row-fluid">
<div class="span12">
<div class="box">
<table width="100%" border="0" bordercolor="#FFFFFF">
<h3><center>There Are No Upcoming Departures!</h3>
</div>
<?php
}
?>
</tbody>
</table>
</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...