<table class="ui single line table">

  <thead>

    <tr>

      <th><?php _e( 'Monitor', 'advanced-uptime-monitor-extension' ); ?></th>

      <th><?php _e( 'URL', 'advanced-uptime-monitor-extension' ); ?></th>

      <th><?php _e( 'Type', 'advanced-uptime-monitor-extension' ); ?></th>

      <th><?php _e( 'Status', 'advanced-uptime-monitor-extension' ); ?></th>

    </tr>

  </thead>

  <tbody>

    <tr>

      <td><?php echo $url->url_friendly_name; ?></td>

      <td><a href="<?php echo $url->url_address; ?>" target="_blank"><?php echo $url->url_address; ?></a></td>

      <td><?php echo Advanced_Uptime_Monitor_Extension::get_install()->monitor_types[ $url->url_monitor_type ]; ?></td>

      <td>

        <?php

        $last_status = $stats[0];

        if ( $last_status->monitor_type == '-1' ) {

          $type = $last_status->type;

          echo ucfirst( $monitor_statuses[ $type ] );

        } else {

          $type = $last_status->monitor_type;

          switch ( $type ) {

            	case '0':

              echo __( 'Paused', 'advanced-uptime-monitor-extension' );

            	break;

              case '1':

              echo __( 'Started', 'advanced-uptime-monitor-extension' );

              break;

            }

          }

          ?>

        </td>

      </tr>

    </tbody>

   </table>


   <?php

   $option = get_option( 'advanced_uptime_monitor_extension' );
	$offset_time = 0;

   if ( isset( $option[ 'api_timezone' ] ) && is_array( $option[ 'api_timezone' ] ) ) {

     $offset_time = $option[ 'api_timezone' ][ 'offset_time' ];

     $offset_time = $offset_time * 60 * 60;

   }


   if ( !empty( $stats ) ) {

     ?>

     <table class="ui single line table">

       <thead>

         <tr>

           <th><?php _e( 'Status', 'advanced-uptime-monitor-extension' ); ?></th>

           <th><?php _e( 'Details', 'advanced-uptime-monitor-extension' ); ?></th>

           <th><?php _e( 'Date / Time', 'advanced-uptime-monitor-extension' ); ?></th>

           <th><?php _e( 'Duration', 'advanced-uptime-monitor-extension' ); ?></th>

         </tr>

       </thead>

       <tbody>

         <?php

         foreach ( $stats as $event ) {

           $status = '';

           if ( $event->monitor_type == '-1' ) {

             $type = $event->type;

             $status = ucfirst( $monitor_statuses[ $type ] );

           } else {

             $type = $event->monitor_type;

             switch ( $type ) {

               case '0':

               $status = __( 'Paused', 'advanced-uptime-monitor-extension' );

               break;

               case '1':

               $status = __( 'Started', 'advanced-uptime-monitor-extension' );

                break;

              }

            }

            ?>

            <tr>

              <td class="<?php echo strtolower( $status ) ?>">

                <?php

                switch ( $status ) {

                  case 'Started':

                  echo  __( 'Started', 'advanced-uptime-monitor-extension' );

                  break;

                  case 'Up':

                  echo __( 'Up', 'advanced-uptime-monitor-extension' );

                  break;

                  case 'Paused':

                  echo __( 'Paused', 'advanced-uptime-monitor-extension' );

                  break;

                  case 'Down':

                  echo __( 'Down', 'advanced-uptime-monitor-extension' );

                  break;

                }

                ?>

              </td>

              <td>

                <?php

                switch ( $status ) {

                  case 'Started':

                  echo __( 'The monitor is started manually', 'advanced-uptime-monitor-extension' );

                  break;

                  case 'Up':

                  echo __( 'Successful response received.', 'advanced-uptime-monitor-extension' );

                  break;

                  case 'Paused':

                  echo __( 'The monitor is paused manually', 'advanced-uptime-monitor-extension' );

                  break;

                  case 'Down':

                  if ( $url->url_monitor_type == '2' ) {

                    echo __( 'The keyword exists.', 'advanced-uptime-monitor-extension' );
                  }
else {

                    echo __( 'No Response From The Website.', 'advanced-uptime-monitor-extension' );
                  }

                  break;

                }

                ?>

              </td>

              <td>

                <?php

                $datetime = strtotime( $event->event_datetime_gmt ) + $offset_time;

                $datetime = Advanced_Uptime_Monitor_Extension::get_install()->format_timestamp($datetime);

                echo $datetime;
                                ?>

              </td>

              <td>

                <?php

                $duration = $event->duration;

                $hrs = floor($duration / 3600);

                $mins =  floor(($duration - $hrs * 3600) / 60);

                echo $hrs . ' hrs, ' . $mins . ' mins' ;

                ?>

              </td>


            </tr>

          <?php } ?>

        </tbody>

      </table>

    <?php

  }

