<?php
$pilot = PilotData::getPilotData($screenshot->pilot_id);
?>
<div class="row">
	<div class="col-md-12">
		<div class="content-header">
			<div class="header-section">
				<h1>
						<i class="fa fa-image"></i><strong>Screenshot</strong> Center<br><small>Utilities | <?php echo SITE_NAME; ?> &copy; <?php echo date("Y"); ?></small>
				</h1>
			</div>
		</div>
	</div>
</div>
<ol class="breadcrumb breadcrumb-top">
  <li><a href="<?php echo SITE_URL; ?>/index.php"><i class="fa fa-home"></i></a></li>
  <li><a href="<?php echo SITE_URL; ?>/index.php/Screenshots">Screenshots</a></li>
  <li>View Tool</li>
</ol>
<div class="row">
	<div class="col-md-12">
		<div class="block">
			<div class="block-title">
				<div class="block-options pull-right">
					<span class="label label-success">
						<?php echo $screenshot->id; ?>
					</span>
				</div>
				<h3>Screenshot <Strong>ViewTool</Strong></h3>
			</div>
			<table width="100%">
        <tr>
            <td>
                <?php
                    $previous = ScreenshotsData::get_previous($screenshot->id);
                    if(!$previous)
                    {echo '&nbsp'; }
                    else
                    {
                ?>
                <form method="post" action="<?php echo SITE_URL ?>/index.php/Screenshots" >
                <input type="hidden" name="action" value="last" />
                <input type="hidden" name="id" value="<?php echo $previous->id; ?>" />
                <input class="btn btn-sm btn-info" type="submit" value="Previous">
                </form>
                <?php
                    }
                    ?>
            </td>
            <td colspan="2" align="right">
                <?php
                    $next = ScreenshotsData::get_next($screenshot->id);
                    if(!$next)
                    {echo '&nbsp'; }
                    else
                    {
                ?>
                <form method="post" action="<?php echo SITE_URL ?>/index.php/Screenshots" >
                <input type="hidden" name="action" value="last" />
                <input type="hidden" name="id" value="<?php echo $next->id; ?>" />
                <input class="btn btn-sm btn-danger" type="submit" value="Next">
                </form>
                <?php
                    }
                    ?>
            </td>
        </tr>
        <tr>
            <td colspan="3"><hr /></td>
        </tr>
        <tr>
            <td width="70%"valign="top"><h4>Uploaded by 
            <?php echo $pilot->firstname.' '.$pilot->lastname.' - '.PilotData::GetPilotCode($pilot->code, $pilot->pilotid); ?></h4></td>
            
            <td width="15%" valign="bottom" align="center">
                <b>Rating: </b><?php echo $screenshot->rating; ?>
            </td>
            <td  width="15%" valign="bottom">
                <?php
                    if(Auth::loggedin())
                    {
                    $boost = ScreenshotsData::check_boost(Auth::$userinfo->pilotid, $screenshot->id);
                    if($boost->total > 0)
                    {echo 'Already Rated';}
                    else
                    {
                    ?>
                    <form method="post" action="<?php echo SITE_URL ?>/index.php/Screenshots/addkarma">
                    <input type="hidden" name="id" value="<?php echo $screenshot->id; ?>" />
                    <input class="btn btn-md btn-warning" type="submit" value="Boost Rating"></form>
                    <?php
                    }
                    }
                    else
                    {echo 'Login To Rate Screenshot'; }
                    ?>
            </td>
        </tr>
        <tr>
            <td>
                <b>Date Submitted:</b> <?php echo date('m/d/Y', strtotime($screenshot->date_uploaded)); ?><br />
                <b>Description:</b> <?php 
                                        if(!$screenshot->file_description)
                                        {echo 'Not Available';}
                                        else
                                        {echo $screenshot->file_description;} ?>
                <br /></td>
            <td align="center"><b>Views:</b> <?php echo $screenshot->views; ?></td>
            <td>
                <!-- <form><input class="mail" type="button" value="Back To Gallery" onClick="history.go(-1);return true;"> </form> -->
                  <?php if(PilotGroups::group_has_perm(Auth::$usergroups, ACCESS_ADMIN))
                        { ?><a href="<?php echo SITE_URL ?>/index.php/Screenshots/delete_screenshot?id=<?php echo $screenshot->id; ?>"><b>Delete Screenshot</b></a><?php } else {} ?>
                <form method="link" action="<?php echo SITE_URL ?>/index.php/Screenshots">
                <input class="btn btn-md btn-warning" type="submit" value="Back To Gallery"></form>
            </td>
        </tr>
        <tr>
            <td colspan="3"><hr /></td>
        </tr>
        <tr>
            <td align="center" colspan="3">
                <img src="<?php echo SITE_URL; ?>/pics/<?php echo $screenshot->file_name; ?>" style="max-width: 940px" alt="<?php echo $screenshot->file_description; ?>" />
            </td>
        </tr>
        <tr>
            <td colspan="3"><hr /></td>
        </tr>
        <tr>
            <td colspan="2"><h4>Comments:</h4></td>
            <td>Posted By:</td>
        </tr>
        <?php if(!$comments)
            {echo '<tr><td colspan="3">No Comments</td></tr>';}
            else
            {
                echo '<tr><td colspan="3"><hr class="comment" /></td></tr>';
                foreach($comments as $comment){
                    $pilot = PilotData::getPilotData($comment->pilot_id);
                    echo '<tr>';
                    echo '<td colspan="2">'.$comment->comment.'</td>';
                    echo '<td>'.$pilot->firstname.' '.$pilot->lastname.' - '.PilotData::getPilotCode($pilot->code, $pilot->pilotid).'</td>';
                    echo '</tr>';
                    echo '<tr><td colspan="3"><hr class="comment" /></td></tr>';
                }
            }
        ?>
        <tr>
            <td colspan="3"><hr /></td>
        </tr>
        <?php if(Auth::LoggedIn())
        { ?>
        <tr>
            <td colspan="3"><h4>Add A Comment:</h4></td>
        </tr>
        <tr>
            <td colspan="3">
                <br />
                <form action="<?php echo url('/Screenshots');?>" method="post" enctype="multipart/form-data">
                <textarea name="comment" cols="50" rows="4"></textarea>
                    <br /><br />
                    <input type="hidden" name="id" value="<?php echo $screenshot->id; ?>" />
                    <input type="hidden" name="action" value="add_comment" />
                        <input class="mail" type="submit" value="Add Comment">
                </form>
            </td>
        </tr>
        <?php }
        else
        { ?>
        <tr>
            <td colspan="3">Login to add a comment</td>
        </tr>
        <?php } ?>
    </table>
			<!--<li class="media">
				<a href="page_ready_user_profile.php" class="pull-left">
					<img src="img/placeholders/avatars/avatar1.jpg" alt="Avatar" class="img-circle">
				</a>
				<div class="media-body">
				<p class="push-bit">
					<span class="text-muted pull-right">
						<small>45 min now</small>
						<span class="text-danger" data-toggle="tooltip" title="" data-original-title="From Web"><i class="fa fa-globe"></i></span>
					</span>
					<strong><a href="page_ready_user_profile.php">Explorer</a> published a new story.</strong>
				</p>

			<h5><a href="page_ready_article.php"><strong>The Mountain Trip</strong> • Once in a lifetime experience</a></h5>
					<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ultrices, justo vel imperdiet gravida, urna ligula hendrerit nibh, ac cursus nibh sapien in purus. Mauris tincidunt tincidunt turpis in porta. Etiam egestas fringilla enim, id convallis lectus laoreet at. Fusce purus nisi, gravida sed consectetur ut, interdum quis nisi. Quisque egestas nisl id lectus facilisis scelerisque? Proin rhoncus dui at ligula vestibulum ut facilisis ante sodales! Suspendisse potenti..</p>
					<p>
						<a href="javascript:void(0)" class="btn btn-xs btn-success"><i class="fa fa-thumbs-up"></i> You Like it</a>
						<a href="javascript:void(0)" class="btn btn-xs btn-default"><i class="fa fa-share-square-o"></i> Share</a>
					</p>
					<ul class="media-list push">
						<li class="media">
							<a href="page_ready_user_profile.php" class="pull-left">
								<img src="img/placeholders/avatars/avatar8.jpg" alt="Avatar" class="img-circle">
							</a>
							<div class="media-body">
								<a href="page_ready_user_profile.php"><strong>User</strong></a>
								<span class="text-muted"><small><em>29 min ago</em></small></span>
								<p>Sed porttitor pretium venenatis. Suspendisse potenti. Aliquam quis ligula elit. Aliquam at orci ac neque semper dictum.</p>
							</div>
						</li>
</ul>
</div>
</li>-->
		</div>
	</div>
</div>

