function get_punch_data($user_id, $payperiod = NULL) { if (!$payperiod) { $payperiod = current_payperiod(); } $ppstart = get_payperiod_start($payperiod); $ppend = get_payperiod_end($payperiod); $sql = "SELECT id,timestamp FROM punchclock WHERE "; $sql .= "user_id=" . $user_id; $sql .= " AND timestamp > FROM_UNIXTIME(" . $ppstart . ")"; $sql .= " AND timestamp < FROM_UNIXTIME(" . $ppend . ")"; $result = $_SESSION['dbconn']->query($sql) or die("Error getting punchdata: " . $_SESSION['dbconn']->error); return $result; }
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 total_hours($user_id, $payperiod = NULL) { if (!$payperiod) { $payperiod = current_payperiod(); } }
require_once "incdir.php.inc"; require_once "config.php"; include_php_dir("includes"); mysql_init(); document_header(); echo include_javascript_dir("js", $debug); echo include_stylesheet_dir("stylesheets", $debug); check_validated(); //Pre-page logic goes here: if (isset($_POST['addhours-submit'])) { add_hours($_POST['user_id'], $_SESSION['user_id'], $_POST['amount'], $_POST['pp']); } if (isset($_GET['pp'])) { $pp = $_GET['pp']; } else { $pp = current_payperiod(); } open_page("Add Hours"); draw_page(); close_page(); ob_end_flush(); // Flush the buffer out to client document_footer(); mysql_end(); function draw_page() { ?> <div class="container"> <?php open_panel('userlist', 'User List'); draw_userlist();