Jump to content

Recommended Posts

  • Administrators
Posted

Cool idea. Something like;


<table>
 <tr>
<td>flight num</td>
...
<td>deprt city</td>
<?php
// We are gonna loop each day of the week
for($dayofweek = 0; $dayofweek < 7; $dayofweek++)
{
	// echo our column opening
	echo '<td>';

	// Check if $i (the current day of week) exists
	if(substr_count($schedule->daysofweek, $dayofweek) > 0)
	{ 
  		// there is a flight for sunday , so echo that plane icon out
  		echo 'plane icon';
	}

	// Close that column
	echo '</td>';

}
?>
<td>arrival time</td>
...
 </tr>
</table>

Some pseudo code,

  • Like 1
  • 9 months later...
Posted

Thanks Nabeel, I've been trying to figure this out for a while. The code worked perfectly, apart from the $schedule->daysofweek bit, I just had to change it to $route

Here's a pic:

daysofweek.JPG

  • Like 1
Posted

Stuart Can you please share the code with us or maybe if you could post it in code snippets please i would really appreciate it.

Regards

Ahmad

Nabeel has already given the code, and it was the same code I used. The only amendment I made was on this line:

if(substr_count($schedule->daysofweek, $dayofweek) > 0) 

Changed to:

if(substr_count($route->daysofweek, $dayofweek) > 0)

Then it's just a case of amending the echo output to suit.

Posted

<?php
if(!$allroutes)
{
echo '<p align="center">No routes have been found!</p>';
return;
}
?>

<script type="text/javascript">
$(document).ready(function() {
$('#schedule').dataTable( {
	"sPaginationType": "full_numbers"
} );
} );
	</script>	
   	<div>
<table border="1" class="display" id="schedule">

<thead>
 <tr id="tablehead">
   	<th>Flight No.</th>
   	<th>Dep. Time</th>
   	<th>Dep. Airport</th>
   	<th>Sun</th>
   	<th>Mon</th>
   	<th>Tue</th>
   	<th>Wed</th>
   	<th>Thurs</th>
   	<th>Fri</th>
   	<th>Sat</th>
   	<th>Arr. Time</th>
   	<th>Arr. Airport</th>
   	<th>Distance</th>
   	<th>Aircraft</th>
   	<th>Options</th>
   	</tr>
   	</thead>
   	<tbody>
   	<?php
foreach($allroutes as $route)
{

/* Uncomment this code if you want only schedules which are from the last PIREP that
	pilot filed */
/*if(Auth::LoggedIn())
{
	$search = array(
		'p.pilotid' => Auth::$userinfo->pilotid,
		'p.accepted' => PIREP_ACCEPTED
	);

	$reports = PIREPData::findPIREPS($search, 1); // return only one

	if(is_object($reports))
	{
		# IF the arrival airport doesn't match the departure airport
		if($reports->arricao != $route->depicao)
		{
			continue;
		}
	}
}*/

/*
Skip over a route if it's not for this day of week
Left this here, so it can be omitted if your VA
 doesn't use this. 

Comment out these two lines if you don't want to.
*/

/*	Check if a 7 is being used for Sunday, since PHP
	thinks 0 is Sunday */
$route->daysofweek = str_replace('7', '0', $route->daysofweek);

if(strpos($route->daysofweek, date('w')) === false)
	continue;

/* END DAY OF WEEK CHECK */



/*
This will skip over a schedule if it's been bid on
This only runs if the below setting is enabled

If you don't want it to skip, then comment out
this code below by adding // in front of each 
line until the END DISABLE SCHEDULE comment below

If you do that, and want to show some text when
it's been bid on, see the comment below
*/
if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0)
{
	continue;
}
/* END DISABLE SCHEDULE ON BID */


/*	Skip any schedules which have aircraft that the pilot
	is not rated to fly (according to RANK), only skip them if
	they are logged in. */
if(Config::Get('RESTRICT_AIRCRAFT_RANKS') === true && Auth::LoggedIn())
{
	/*	This means the aircraft rank level is higher than
		what the pilot's ranklevel, so just do "continue"
		and move onto the next route in the list 
	 */
	if($route->aircraftlevel > Auth::$userinfo->ranklevel)
	{
		continue;
	}
}

/* THIS BEGINS ONE TABLE ROW */
?>
<tr>
<td class="center">
	<a href="<?php echo url('/schedules/details/'.$route->id);?>"><?php echo $route->code . $route->flightnum?></a>
<td><?php echo $route->deptime;?></td>
<td  class="centre"><?php echo $route->depicao . ' '. $route->depname;?></td>
   	<?php
   	// We are gonna loop each day of the week
   	for($dayofweek = 0; $dayofweek < 7; $dayofweek++)
   	{
           	// echo our column opening
           	echo '<td  class="centre">';

           	// Check if $i (the current day of week) exists
           	if(substr_count($route->daysofweek, $dayofweek) > 0)
           	{ 
                   	// there is a flight for sunday , so echo that plane icon out
                   	echo 'Plane Image goes here';
           	}

           	// Close that column
           	echo '</td>';

   	}
   	?>
<td><?php echo $route->arrtime;?></td>
<td><?php echo $route->arricao .' '. $route->arrname;?></td>
<td><?php echo $route->distance . Config::Get('UNITS');?></td>
<td><?php echo $route->aircraft; ?></td>
<td nowrap>
	<a href="<?php echo url('/schedules/details/'.$route->id);?>">View Details</a><br />
	<a href="<?php echo url('/schedules/brief/'.$route->id);?>">Pilot Brief</a><br />

	<?php 
	# Don't allow overlapping bids and a bid exists
	if(Config::Get('DISABLE_SCHED_ON_BID') == true && $route->bidid != 0)
	{
	?>
		<a id="<?php echo $route->id; ?>" class="addbid" 
			href="<?php echo actionurl('/schedules/addbid');?>">Add to Bid</a>
	<?php
	}
	else
	{
		if(Auth::LoggedIn())
		{
		 ?>
			<a id="<?php echo $route->id; ?>" class="addbid" 
				href="<?php echo url('/schedules/addbid');?>">Add to Bid</a>
		<?php			 
		}
	}		
	?>
</td>

 <?php
/* END OF ONE TABLE ROW */
}
?>
</tbody>
</table>
</div>
<div class="spacer"></div>
<hr>

There is the full code, for the schedules page.

  • Like 1
  • 3 weeks later...
Posted

Hi, sorry for this question but i have problems to show the plane image, this is the code :

{

// there is a flight for sunday , so echo that plane icon out

// img src="<?php echo SITE_URL?>/lib/skins/Template1/images/inair.png;?">

echo '"<?php echo SITE_URL?>/lib/skins/Template1/images/inair.png;?">';

}

I have two options, wich is the correct sentence ?????. Also when activate the first or second option a message with error appear in the page "Parse error: syntax error, unexpected $end in /home/xxxxxxxxxx/xxxxx/schedule_results.tpl on line 172" line 172 is the last but it's a blank row, i tried deleted but the error still there. Any suggestion ???

Thanks for the help.

Regards

Posted

The unexpected end, just means that the script has ended before it should have. To get the picture to show, you will need to put it in an img tag.

{ 

// there is a flight for sunday , so echo that plane icon out
// img src="<?php echo SITE_URL?>/lib/skins/Template1/images/inair.png;?">
echo '<img src="<?php echo SITE_URL?>/lib/skins/Template1/images/inair.png;?">" alt=""/>';

}

That code will get the image to show.

Posted

Many thanks for the reply and help, but still have the problem with error message "Parse error: syntax error, unexpected $end in /home/xxxxxxxxxx/xxxxx/schedule_results.tpl on line 172" The complete code is the same than you posted.

Thanks anyway

Regards

  • Moderators
Posted

Many thanks for the reply and help, but still have the problem with error message "Parse error: syntax error, unexpected $end in /home/xxxxxxxxxx/xxxxx/schedule_results.tpl on line 172" The complete code is the same than you posted.

Thanks anyway

Regards

Reupload the stock template and modify again.

Posted

Thanks for the help, i do that, the error message was killed but no image is present, just this words......" alt=" "/>. Also see the attached image.

Regards

post-408-005559000 1310080365_thumb.jpg

Posted

Thought I'd share how I have mine. It took me a while to figure out how and where to place the items, but hope you like it.

I won't share the coding, but it is very easy to figure out how it is done.

  • Like 1
Posted

Thought I'd share how I have mine. It took me a while to figure out how and where to place the items, but hope you like it.

I won't share the coding, but it is very easy to figure out how it is done.

Awesome!

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...