function draw_timecard($payperiod=NULL, $user_id=NULL) {
  if ($payperiod)
    $payperiod=current_payperiod();

  if (!$user_id)
    $user_id=$_SESSION['user_id'];

  $user = get_user_info($user_id);

?><!--<div class="row row-toggle" id="main_segment_toggle" data-toggle="collapse" data-target="#dash3_toggle"><p>Your Time Card</p>
    </div>
    <div class="row collapse in" id="dash3_toggle" id="punch_clock_panel">-->
  <div class="col-md-8">
    <table class="table" id="punch_card_table">
      <tr><td colspan=4><center><h4>Your Time Card</h4></center></td></tr>
      <tr>
        <th class="punch_day" width="100">Date</th>
        <th class="punch_time">Time</th>
        <th class="punch_status">Punch Status</th>
        <th class="punch_hours">Hours</th>
      </tr>
<?php
    $punches = get_punch_data($user_id);
    $inout = '';
    $additional_hours = get_additional_hours($user_id,$payperiod);
    $total = 0;
    while ($row = $punches->fetch_array()) {
      $day = date('n/j',strtotime($row['timestamp']));
      $time = date('h:i a',strtotime($row['timestamp']));
      if ($inout=='in'){
        $inout = '<font color="#999">out</font>';
        $hours = count_hours($intime,mktime(strtotime($row['timestamp'])));
        //If hours is more than 8, then you probably forgot to punch out...
        if ($hours>8)
          alert("Did you forget to punch out?");        
        $total += $hours;
      }
      else {
        $inout = 'in';
        $intime = mktime(strtotime($row['timestamp']));
        $hours = '';
      }
      echo '<tr>';
      echo '<td class="punch_day">'.$day.'</td>';
      echo '<td class="punch_time">'.$time.'</td>';
      echo '<td class="punch_status">'.strtoupper($inout).'</td>';
      echo '<td class="punch_hours">'.$hours.'</td>';
      echo '</tr>';
    }
?>
      
    </table>

  </div>
<div class="col-md-4">

  <form role="form" action="punchclock.php" method="post">
    <div class="input-group" style="float:right;">
     <input type="password" class="form-control text_field" placeholder="ID Barcode" id="barcode" name="barcode">
     <span class="input-group-btn">
       <button class="btn btn-default" id="text_submit" type="submit"><span class="glyphicon glyphicon-time"></span>

<?php
        if (is_punched_in($_SESSION['user_id']))
          echo '<b>Punch Out</b>';
        else
          echo '<b>Punch In</b>';
        ?>

       </button>
     </span>
    </div>
  </form> 
  <P><BR><hr>
      <table class="table" id="punch_info">
        <tr><td colspan=2><center><h4>This Pay Period</h4></center></td></tr>
      <tr id="punch_coloredCells">
        <td><b>Start Date:</b> <?php echo date('m/d/Y',get_payperiod_start()); ?></td>
        <td><b>End Date:</b> <?php echo date('m/d/Y',get_payperiod_end()); ?></td>
      </tr>
      <tr>
        <td><?php echo ucfirst($user['lname']).', '.ucfirst($user['fname']); ?></td>
        <td><?php echo $user['emplid']; ?></td>
      </tr>
      <tr id="punch_coloredCells">
        <td><b>Subtotal: </b></td>
        <td><?php echo $total; ?></td>
      </tr> 
      <tr>
        <td>Additional Hours: </td>
        <td><?php echo $additional_hours; ?></td>
      </tr> 
      
      <tr>
        <td>Total Hours</td>
        <td><?php echo $total+$additional_hours; ?></td>
      </tr>  
    </table>
  </div>
<?php
//We can't work more than 20 hours.
if ($total+$additional_hours>20)
  alert("You are over!  Please double check your punches.");
}
function sum_hours($user_id = NULL, $payperiod = NULL)
{
    if (!isset($user_id)) {
        $user_id = $_SESSION['user_id'];
    }
    if (!isset($payperiod)) {
        $payperiod = get_current_payperiod();
    }
    $punches = get_punch_data($user_id);
    $inout = '';
    $total = 0;
    while ($row = $punches->fetch_array()) {
        $day = date('n/j', strtotime($row['timestamp']));
        $time = date('h:i a', strtotime($row['timestamp']));
        if ($inout == 'in') {
            $inout = 'out';
            $hours = count_hours($intime, mktime(strtotime($row['timestamp'])));
            $total += $hours;
        } else {
            $inout = 'in';
            $intime = mktime(strtotime($row['timestamp']));
            $hours = '';
        }
    }
    return $total;
}