<?php if(!defined('IN_PHPVMS') && IN_PHPVMS !== true) { die(); } ?>
<?php 
/**
 * iCrew v4 Premium - Virtual Airline Crew Center
 * Copyright (c) 2017 iCrewSystems
 * 
 * This CrewCenter & and it's Modules (which are distinguished, and limited to unless specified)
 * are protected by copyright under Indian Copyright Act, 1957, with the 2012 amendments
 * No part of the website design or layout may be reproduced or transmitted in any form or by any other 
 * means electronic or mechanical to include photocopying, recording, reproducing, or electronic storage.
 * Any such act represents a copyright violation and theft of intellectual property owned by iCrewSystems. 
 * 
 * @author: Leonard Selvaraja
 * @copyright: Copyright (c) 2017, iCrewSystems
 * @link http://www.icrewsystems.com
 * @service name: iCrewSystems Virtual Airline Premium Services (with additions) 
 * Caution : NO SUPPORT WILL BE PROVIDED IF ANY MODULE / TEMPLATE IS FOUND TO BE TAMPERED WITH.
 * 
 */
?>
<div class="widget">
		<div class="widget-extra">
			<div class="timeline">
				<ul class="timeline-list">
          <?php
            $pics = 'fire,default,autumn,amethyst,night'; //Take the contents from the file to the variable
            $pictures = explode(',',$pics); //Split it by ','
              foreach($allactivities as $activity) {
              $themebg = $pictures[array_rand($pictures)];
              /*  Use the activity->type to determine the type of activity (duh?)
              Constants are in app.config.php 
                Like here, I put a specific link to the PIREP at the end of the message
                You can use the if/else's to add specific images?
                $activity->refid is the ID of the thing it's referring to, so if it's a
                new PIREP, the refid will be the ID of the PIREP
                $activity-> also contains all the fields about the pilot who this notice
                is about        
            */
              $link_title = '';
              $link_href = '';
              if($activity->type == ACTIVITY_NEW_PIREP) {
              $link_href = url('/pireps/view/'.$activity->refid);
              $link_title = 'View Flight Report';
              
              } elseif($activity->type == ACTIVITY_TWITTER) {
                      
              $link_href = 'http://twitter.com/#!/'.Config::get('TWITTER_AIRLINE_ACCOUNT').'/status/'.$activity->refid;
              $link_title = 'View Tweet';
                
              } 
          ?>
          <p>
          <?php
          /*  Example, if it's a twitter status update (ACTIVITY_TWITTER),
              then show an image (in this case, a small Twitter icon) */
              if($activity->type == ACTIVITY_TWITTER) {
                echo '<img src="'.fileurl('/lib/images/twitter.png').'" alt="twitter update" />';
              }
          ?>
          <?php
            /*  If there is a pilot associated with this feed update, show their name
                and a link to their profile page */ 
            if($activity->pilotid != 0) { 
                $pilotCode = PilotData::getPilotCode($activity->code, $activity->pilotid);
                ?>
            
                 
  			    		  
            <?php 
            } /* End if pilot ID != 0 */ 
          ?>
        <li class="active"> 
							<div class="timeline-icon themed-background-<?php echo $themebg; ?> themed-border-<?php echo $themebg; ?>"><i class="fa fa-clock-o"></i></div>
								<div class="timeline-time"><strong>
									<a href="<?php echo url('/profile/view/'.$activity->pilotid);?>">
                    <?php echo $activity->firstname;?>
									</a></strong></div>
									<div class="timeline-content">
									  <p class="push-bit"><?php echo stripslashes($activity->message); ?></p>
									    <?php
									    if($link_href != '') {
                        echo ' <a class="label label-success" href="'.$link_href.'">'.$link_title.'</a>';
									      }
									    ?>
									</div> 
						</li>
            						
          <?php
            }
          ?> 
        </ul>
		</div>     
	</div>
</div>
