<?php include ('header.php'); ?>
    <div class="col-sm-8 col-lg-9">
        <!-- View Message Block -->
        <div class="block full">
            <div class="block-title">
            	<h2><i class="fa fa-paper-plane"></i> <Strong>iMail</Strong> Open Mail</h2>
            </div>
            <!-- Message Body -->
            <?php
        		foreach ($mail as $data) {
    		?>
        <!-- Widget -->
	       <?php
            if($data->who_to == Auth::$userinfo->pilotid){
             $user = PilotData::GetPilotData($data->who_from);
             $pilot = PilotData::GetPilotCode($user->code, $data->who_from);

        	}
        	 if($data->who_from == Auth::$userinfo->pilotid){
             $user = PilotData::GetPilotData($data->who_to);
             $pilot = PilotData::GetPilotCode($user->code, $data->who_to);

        	}
          ?>

    		<!-- View Message Title -->

            <!-- END View Message Title -->


              <div class="block-header">
                <center>
                <h3 class="text-success text-left">
                	<?php echo $data->subject; ?>
                </h3>
              </center>

        	    </div>
            	<hr>
            	<p><?php echo str_replace(array("\\n","\\r"), array("<br />","<br />"), $data->message); ?></p>
			        <?php
        	      }
        	    ?>
        	     <a href="<?php echo SITE_URL ?>/index.php/Mail/reply/<?php echo $data->thread_id; ?>" class="btn btn-md btn-default">
	            	<i class="fa fa-reply text-success"></i> Reply
	             </a>
        	<div class="block-footer">
        	  <hr>
        	  <span class="text-muted">
        	    <h5><span class="pull-left"> <span class="hide-xs"><?php echo date(DATE_FORMAT . ' @ h:ia', strtotime($data->date)); ?> from</span> 
        	    <?php $firstname = $user->firstname;
								$lastname  = $user->lastname;
								$site_name = SITE_URL;
								$site_name = str_replace("https://", "", $site_name);
								$site_name = str_replace("http://", "", $site_name);
								$site_name = str_replace("icrew.", "", $site_name);
								$firstname = str_replace(' ','', $firstname);
								$lastname = str_replace(' ','', $lastname);
								echo strtolower($firstname).'.'.strtolower($lastname).'@'.$site_name; ?>
        	    </span> <span class="pull-right">iMail <strong><em>v4</em></strong></span><br></h5>
        	  </span>
        	</div>
            <!-- END Message Body -->
        </div>
        <!-- END View Message Block -->
    </div>
    <!-- END View Message -->
</div>
<!-- END Inbox Content -->
<!-- END Inbox Content -->
