<!-- Inbox Header -->
<div class="content-header">
    <div class="header-section">
        <h1><i class="gi gi-envelope"></i> <Strong>iMail</Strong><br><small>Communications & Resources | <?php echo SITE_NAME?> &copy; <?php echo date("Y");?></small></h1>
    </div>

</div>
<ul class="breadcrumb breadcrumb-top">
	<li>Crew Internal Services</li>
	<li>iMail</li>

</ul>
<!-- END Inbox Header -->
<!--PHP FIles DUMP-->
<?php
      function time_elapsed($datetime, $full = false) {
    $now = new DateTime;
    $ago = new DateTime($datetime);
    $diff = $now->diff($ago);

    $diff->w = floor($diff->d / 7);
    $diff->d -= $diff->w * 7;

    $string = array(
        'y' => 'year',
        'm' => 'month',
        'w' => 'week',
        'd' => 'day',
        'h' => 'hour',
        'i' => 'minute',
        's' => 'second',
    );
    foreach ($string as $k => &$v) {
        if ($diff->$k) {
            $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
        } else {
            unset($string[$k]);
        }
    }

    if (!$full) $string = array_slice($string, 0, 1);
    return $string ? implode(', ', $string) . ' ago' : 'just now';
}
?>

<!-- Inbox Content -->
<div class="row">
    <!-- Inbox Menu -->
    <?php
    	if($_POST['notify'] == '1') {
    		MainController::Run('BootstrapNotifications', 'Notify', 'iCrew Notification', 'Your inbox is now refreshed!', '5000', 'success');
    	}
    ?>

    <form id="refresh" method="post" action="<?php echo SITE_URL; ?>/index.php/Mail">
    	<input type="hidden" name="notify" value="1" />
    </form>
    <script>
    	function refreshMail() {
    		document.getElementById("refresh").submit();
    	}
    </script>
    <script>
function goBack() {
  window.history.back();
}
</script>
    <div class="col-sm-4 col-lg-3">
		<div class="block full">
      <div class="block-title clearfix">
         <div class="block-options pull-right">

         	<a href="javascript:void(0)" onclick="goBack();" class="btn btn-alt btn-sm btn-default" data-toggle="tooltip" title="" data-original-title="Previous Window"><i class="fa fa-arrow-left"></i></a>
            <a href="javascript:void(0)" onclick="refreshMail();" class="btn btn-alt btn-sm btn-default" data-toggle="tooltip" title="" data-original-title="Refresh"><i class="fa fa-refresh"></i></a>
         </div>
         <div class="block-options pull-left">
            <a href="<?php echo url("/mail/newmail"); ?>" class="btn btn-alt btn-sm btn-default"><i class="fa fa-pencil"></i> Compose New Mail</a>
         </div>
      </div>
      <ul class="nav nav-pills nav-stacked">
      	<table class="table table-borderless table-striped table-vcenter">
                <tbody>
                    <tr>
                    	<td>
                    	 ID
                    	</td>
                        <td>
                        	<span class="label label-info">
                        	<?php
                        		$firstname = Auth::$userinfo->firstname;
								$lastname  = Auth::$userinfo->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>
                        </td>
                    </tr>
                </tbody>
            </table>

         <?php
        	$item = MailData::checkformail();
            $items = $item->total;
            ?>
         <li class="">
            <a href="<?php echo url("mail/"); ?>">
            <?php if($items > 0) { echo '<span class="badge pull-right">'.$items.'</span>'; } ?>
            <strong>Mail Box</strong>
            </a>
         </li>
         <li class="">
            <a href="<?php echo url("mail/sent"); ?>">
            <strong>Sent Mails</strong>
            </a>
         </li>
         <li class="">
            <a href="<?php echo url("mail/settings"); ?>">
            <strong>Settings</strong>
            </a>
         </li>
      </ul>
   </div>



    </div>
    <!-- END Inbox Menu -->
