Ejemplo n.º 1
0
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.");
}
Ejemplo n.º 2
0
function draw_userlist() {
	global $pp;
 	$supers = get_users('super');
 	$users = get_users('user');
 	?>
 	<div class="col-md-10">
 	<table class="userlist table table-condensed">
        <tr>
          <th>Last Name</th>
          <th>First Name</th>
          <th>Username</th>
          <th>Additional Hours</th>
        </tr>
        <?php 
    while ($row = $supers->fetch_array()) {
        $row['role'] = 'super';
        $row['hours'] = get_additional_hours($row['user_id'], $pp);
        echo '<tr class="userlist ';
        echo 'userlist-' . $row['role'];
        if ($row['inactive']) {
            echo ' userlist-inactive';
        }
        echo '" onclick="openAddhours(' . $row['user_id'] . ')">';
        echo '<td>' . $row['lname'] . "</td>";
        echo '<td>' . $row['fname'] . "</td>";
        echo '<td>' . $row['username'] . "</td>";
        echo '<td>' . $row['hours'] . '</td>';
        echo '</tr>';
    }
    while ($row = $users->fetch_array()) {
        $row['role'] = 'user';
        $row['hours'] = get_additional_hours($row['user_id'], $pp);
        echo '<tr class="userlist ';
        echo 'userlist-' . $row['role'];
        if ($row['inactive']) {
            echo ' userlist-inactive';
        }
        echo '" onclick="openAddhours(' . $row['user_id'] . ')">';
        echo '<td>' . $row['lname'] . "</td>";
        echo '<td>' . $row['fname'] . "</td>";
        echo '<td>' . $row['username'] . "</td>";
        echo '<td>' . $row['hours'] . '</td>';
        echo '</tr>';
    }
    ?>
      </table>
      </div>
      <div class="col-md-2">
      	<form class="form form-horizontal" action="">
	 	<label for="pp">Pay Period: </label>
    <select name="pp" class="form-control" onchange="this.form.submit()">
	 	<?php 
    $number_of_payperiods = get_number_of_payperiods();
    for ($i = 1; $i <= $number_of_payperiods; $i++) {
        echo '<option value="' . $i . '"';
        if ($pp == $i) {
            echo ' selected="selected" ';
        }
        echo '>' . $i . '</div>';
    }
    ?>
	 	</select>
	 	</form>
      </div>
      <?php 
}