<?php
  // @ini_set('display_errors', 'on');
?>
<div class="row">

<div style="overflow: auto; height: 200px; margin-bottom: 20px; padding: 5px; padding-top: 0px; padding-bottom: 20px;">
<?php
$issued = 0;
if(!$allawardtpes) {
  ?>
    <div class="alert alert-danger">
        <strong>Oops</strong>, there are no awards to show
    </div>
  <?php
	return;
} else {
  foreach($allawardtpes as $type) {

  	$allissuedawards = vAwardsData::GetAllIssuedAward($pilotid, $type->typ_id);
  	if($allissuedawards) {
  		$issued++;
  		foreach($allissuedawards as $award) {
      ?>

      <div class="col-md-4 text-center">
        <a data-toggle="modal" data-target="#award_<?php echo $award->awd_id; ?>" class="widget widget-hover-effect1">
          <div class="widget-simple">
            <h3 class="widget-content animation-pullDown">
              <?php
              if(!empty($award->awd_image)) { ?>
                <img style="width: 100px; height: auto; border-radius: 5px;" src="<?php echo $award->awd_image;?>" /><br /><br />
                <?php
              } else {  ?>
                <code>No Award Image</code>
              <?php }
              ?>

              <br />
              <?php echo $award->awd_name; ?><br>
              <small><?php echo date(DATE_FORMAT, $award->grt_dategrant);?></small>
            </h3>
          </div>
        </a>
      </div>
      <div id="award_<?php echo $award->awd_id; ?>" class="modal fade" role="dialog">
         <div class="modal-dialog">
            <div class="modal-content">
               <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal">&times;</button>
                  <h4 class="modal-title">
                     <strong><?php echo $pilot->firstname.' '.$pilot->lastname; ?>'s</strong> Awards <br />
                     <small>Human Resources Department | <?php echo SITE_NAME; ?></small>
                  </h4>
               </div>
               <div class="modal-body text-center">
                  <p>
                    <h2><?php echo $award->awd_name; ?></h2>
                    This award of <?php echo $type->typ_name; ?> category was proudly issued to <?php echo $pilot->code.$pilot->pilotid.' - '.$pilot->firstname.' '.$pilot->lastname; ?> on <?php echo date(DATE_FORMAT, $award->grt_dategrant); ?> by the <?php echo SITE_NAME; ?> Staff. <br />
                    <br />
                    <?php
                    if(!empty($award->awd_image)) { ?>

                      <img style="width: 100px; height: auto; border-radius: 5px;" src="<?php echo $award->awd_image;?>" /><br /><br /><br /><br />
                      <?php
                    } else {  ?>
                      <code>No Award Image</code>
                    <?php }
                    ?>
                    <span class="well">
                      <?php
                        if($award->awd_desc == '') {
                          echo "No award description";
                        } else {
                          echo $award->awd_desc;
                        }
                      ?>
                    </span>
                  </p>
               </div>
               <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
               </div>
            </div>
         </div>
      </div>
      <?php
    }
  	}

  }
}


$otherawards = AwardsData::GetPilotAwards($pilotid);
if($otherawards) {
  foreach($otherawards as $award) {
    $issued++;
    ?>
    <div class="col-md-4 text-center">
      <a data-toggle="modal" data-target="#award_2<?php echo $award->id; ?>" class="widget widget-hover-effect1">
        <div class="widget-simple">
          <h3 class="widget-content animation-pullDown">
            <?php
            if(!empty($award->image)) { ?>
              <img style="width: 100px; height: auto; border-radius: 5px;" src="<?php echo $award->image;?>" /><br /><br />
              <?php
            } else {  ?>
              <code>No Award Image</code>
              <br />
            <?php }
            ?>

            <br />
            <?php echo $award->name; ?>
          </h3>
        </div>
      </a>
    </div>
    <div id="award_2<?php echo $award->id; ?>" class="modal fade" role="dialog">
       <div class="modal-dialog">
          <div class="modal-content">
             <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">
                   <strong><?php echo $pilot->firstname.' '.$pilot->lastname; ?>'s</strong> Awards <br />
                   <small>Human Resources Department | <?php echo SITE_NAME; ?></small>
                </h4>
             </div>
             <div class="modal-body text-center">
                <p>
                  <h2><?php echo $award->name; ?></h2>
                  This award was proudly issued to <?php echo $pilot->code.$pilot->pilotid.' - '.$pilot->firstname.' '.$pilot->lastname; ?> by the <?php echo SITE_NAME; ?> Staff. <br />
                  <br />
                  <?php
                  if(!empty($award->image)) { ?>
                    <img style="width: 150px; height: auto; border-radius: 5px;" src="<?php echo $award->image;?>" /><br /><br /><br /><br />
                    <?php
                  } else {  ?>
                    <code>No Award Image</code>
                  <?php }
                  ?>
                  <span class="well">
                    <?php
                      if($award->descrip == '') {
                        echo "No award description";
                      } else {
                        echo $award->descrip;
                      }
                    ?>
                  </span>
                </p>
             </div>
             <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
             </div>
          </div>
       </div>
    </div>
    <?php
  }
}
?>

<?php
	if($issued == 0){
		?>
    <div class="col-md-12">
      <div class="alert alert-danger">
          <strong>Oops</strong>, there are no awards to show yet.
      </div>
    </div>
		<?php
	}
?>
	</div>
</div>
