<?php
///////////////////////////////////////////////
///   SceneryDatabase v2.1 by php-mods.eu   ///
///            Author php-mods.eu           ///
///           Packed at 29/08/2012          ///
///     Copyright (c) 2012, php-mods.eu     ///
///////////////////////////////////////////////

?>
<h3><?php echo SITE_NAME; ?> Scenery Database</h3>
<?php Template::Show('scenery/scenery_menu.tpl'); ?>

<?php if($details->ai == '0'){echo '<center>This scenery has not been validated yet.</center>';} else { ?>
 
<table width="50%" border="0" cellpadding="1" cellspacing="0" align="center">
<tr><td colspan="2" align="center">
<?php if($details->photo == ''){ ?><img src="<?php echo SITE_URL; ?>/core/templates/scenery/images/no-image.jpg" /><?php }
else { ?><img src="<?php echo $details->photo; ?>" width="450" height="282" /> <?php } ?>
</td></tr>
<tr>
<td width="20%">ICAO:</td>
<td width="30%"><?php echo $details->icao; ?></td>
</tr>
<tr>
<td>Country:</td>
<td><?php echo $details->country; ?></td>
</tr>
<tr>
<td>Scenery Version:</td>
<td><?php echo $details->fsvers ?></td>
</tr>
<tr>
<td>Scenery Type:</td>
<td><?php if($details->type == '1'){echo 'Airport';}
if($details->type == '2'){echo 'AFCAD';}
if($details->type == '3'){echo 'Other';}
?></td>
</tr>
<tr>
<td>Freeware/Payware:</td>
<td><?php if($details->payfree == '1'){echo 'Freeware';}
if($details->payfree == '2'){echo 'Payware';}
?></td>
</tr>
<tr>
<td>Description:</td>
<td><?php echo $details->description; ?></td>
</tr>
<tr>
<td>Author:</td>
<td><?php echo $details->author; ?></td>
</tr>
<tr>
<td>Uploaded:</td>
<td><?php echo $details->uploaded; ?></td>
<tr>
<td>Uploaded by:</td>
<td><?php echo PilotData::getPilotData($details->uploadedby)->firstname; ?> <?php echo PilotData::getPilotData($details->uploadedby)->lastname; ?></td>
</tr>
<tr>
<td>Scenery Link:</td>
<td><a href="<?php echo $details->link; ?>" target="_blank"><?php echo $details->link; ?></a></td>
</tr>
</table>
<center><table width="50%" border="0">
<tr><?php 
$rated = SceneryData::checkifrated($details->id, $userinfo->pilotid);
$negative = SceneryData::count_negative($details->id);
$positive = SceneryData::count_positive($details->id); ?>
<td colspan="2" align="center"><br /><b>Rating:</b> +<?php echo $positive; ?> / -<?php echo $negative; ?>&nbsp;&nbsp;
<?php $finalrate=$positive-$negative ?>
(<?php if($finalrate > '0'){?>&nbsp;+<?php echo $finalrate; ?><?php } else {?>&nbsp;<?php echo $finalrate; ?><?php } ?>&nbsp;)

</td></tr>
<?php if($rated > '0'){echo '<tr><td colspan="2" align="center">You have already rated this scenery! Thank you...</td></tr>';} else{ ?>
<tr><td align="right" width="25%">
<form action="<?php echo SITE_URL; ?>/index.php/scenery/rate_increase" method="post">
<input type="hidden" name="id" id="id" value="<?php echo $details->id;?>" />
<input type="hidden" name="pilotid" id="pilotid" value="<?php echo $userinfo->pilotid; ?>" />
<input type="hidden" name="scenery" id="scenery" value="<?php echo $details->id; ?>" />
<input type="hidden" name="value" id="value" value="1" />
<input type="submit" value="+1" />
</form></td><td width="25%"> <form action="<?php echo SITE_URL; ?>/index.php/scenery/rate_decrease" method="post">
<input type="hidden" name="id" id="id" value="<?php echo $details->id;?>" />
<input type="hidden" name="pilotid" id="pilotid" value="<?php echo $userinfo->pilotid; ?>" />
<input type="hidden" name="scenery" id="scenery" value="<?php echo $details->id; ?>" />
<input type="hidden" name="value" id="value" value="2" />
<input type="submit" value="-1" />
</form><?php } ?></td>
</tr>
</table></center>
<br />
<table width="80%" border="0" cellpadding="1" cellspacing="0" align="center">
<tr>
<td width="60%" align="center"><b>Comment</b></td>
<td width="20%" align="center"><b>Posted By</b></td>
</tr>
<?php
if(!$comment)
              {echo '<tr><td colspan="5"><center>There are no any comments about this scenery!</center></td></tr>';}
            else
            {
 foreach($comment as $comment)
{ ?>
<tr>
<td align="center"><?php echo $comment->comment; ?></td>
<td align="center"><?php echo PilotData::getPilotData($comment->pilot)->firstname; ?> <?php echo PilotData::getPilotData($comment->pilot)->lastname; ?></td>
</tr>
<?php } } ?>
</table><br />
<center><form action="<?php echo SITE_URL; ?>/index.php/scenery/CommentAdd" method="post">
<table width="60%" border="0">
  <tr>
    <td>Your Comment:</td>
    <td><textarea cols="40" rows="5" id="comment" name="comment"></textarea>
    <input type="hidden" name="pilot" id="pilot" value="<?php echo $userinfo->pilotid; ?>" />
    <input type="hidden" name="sc_id" id="sc_id" value="<?php echo $details->id; ?>" /></td>
  </tr>
  <tr>
    <td colspan="2"><center><input type="submit" name="submit" value="Submit" /></center></td>
  </tr>
  </table>
</form></center>
<?php } ?>