Added feature to let admins edit all punches
This commit is contained in:
parent
769f6b16c3
commit
c768fb1bf5
@ -33,6 +33,27 @@ function killSession()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Edit Punch
|
||||||
|
function editPunch($yaptc_db, $punchid, $intime, $outtime, $notes)
|
||||||
|
{
|
||||||
|
$stmt = $yaptc_db->prepare("UPDATE punches SET punches.intime = :intime, punches.outtime = :outtime, punches.notes = :notes WHERE punches.id = :punchid;");
|
||||||
|
$stmt->execute(array(
|
||||||
|
':punchid' => $punchid,
|
||||||
|
':intime' => $intime,
|
||||||
|
':outtime' => $outtime,
|
||||||
|
':notes' => $notes
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// Delete Punch
|
||||||
|
function deletePunch($yaptc_db, $punchid)
|
||||||
|
{
|
||||||
|
$stmt = $yaptc_db->prepare("DELETE FROM punches WHERE punches.id = :punchid;");
|
||||||
|
$stmt->execute(array(
|
||||||
|
':punchid' => $punchid
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Punch Out
|
// Punch Out
|
||||||
function punchOut($yaptc_db, $punchid, $notes, $outtime, $modified=NULL)
|
function punchOut($yaptc_db, $punchid, $notes, $outtime, $modified=NULL)
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ else: ?>
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
$timenow = date('Y-m-d H:i');
|
$timenow = date('Y-m-d H:i');
|
||||||
if (!empty($_POST)) {
|
if (!empty($_POST['punchuser'])) {
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST['notes'])) { if (!empty($_POST['notes'])) { $notes = $_POST['notes']; } else { $notes = NULL; } } else { $notes = NULL; }
|
if (isset($_POST['notes'])) { if (!empty($_POST['notes'])) { $notes = $_POST['notes']; } else { $notes = NULL; } } else { $notes = NULL; }
|
||||||
@ -63,7 +63,10 @@ elseif (!empty($user_punch['0']['outtime'])): $status = "Out"; $statustime = dat
|
|||||||
else: $status = "In"; $statustime = date('g:i a \o\n M jS, Y', strtotime($user_punch['0']['intime'])); $punchid = $user_punch['0']['punchid']; if (!empty($user_punch['0']['notes'])): $notes = $user_punch['0']['notes']; else: $notes=""; endif;
|
else: $status = "In"; $statustime = date('g:i a \o\n M jS, Y', strtotime($user_punch['0']['intime'])); $punchid = $user_punch['0']['punchid']; if (!empty($user_punch['0']['notes'])): $notes = $user_punch['0']['notes']; else: $notes=""; endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
echo "<td>" . $status . " since " . $statustime . "</td>"; ?>
|
echo "<td>";
|
||||||
|
if ($statustime == "No Punches"): echo $statustime; else: echo $status . " since " . $statustime; endif;
|
||||||
|
echo "</td>"; ?>
|
||||||
|
|
||||||
<form method="post" onsubmit="return confirm('Are you sure you want to punch this user NOW?')">
|
<form method="post" onsubmit="return confirm('Are you sure you want to punch this user NOW?')">
|
||||||
<td><input type="text" name="notes" placeholder="<?php echo $notes; ?>"></td>
|
<td><input type="text" name="notes" placeholder="<?php echo $notes; ?>"></td>
|
||||||
<td>
|
<td>
|
||||||
@ -78,14 +81,43 @@ echo "<td>" . $status . " since " . $statustime . "</td>"; ?>
|
|||||||
<button type="submit" name="punchuser" value="punchuser" class="pure-button button-success">Punch IN</button>
|
<button type="submit" name="punchuser" value="punchuser" class="pure-button button-success">Punch IN</button>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
if (!empty($_POST['editpunch'])) {
|
||||||
|
editPunch($yaptc_db, $_POST['punchid'], $_POST['intime'], $_POST['outtime'], $_POST['notes']);
|
||||||
|
}
|
||||||
|
if (!empty($_POST['deletepunch'])) {
|
||||||
|
deletePunch($yaptc_db, $_POST['punchid']);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<h2 class="content-subhead">Edit Punches</h2>
|
||||||
|
<p>Edit existing punches for users if needed.</p>
|
||||||
|
<table class="pure-table">
|
||||||
|
<thead><tr><th>In/Out</th><th>Name</th><th>Hours</th><th>Flag</th><th>Notes</th><th>Action</th></tr></thead>
|
||||||
|
<tbody><?php foreach (listPunches($db, "%") as $row): ?>
|
||||||
|
<tr><form method="post" onsubmit="return confirm('Are you sure you want to save the edit to this user punch?')">
|
||||||
|
<td><input type="text" name="intime" value="<?php echo $row['intime']; ?>"><input type="text" name="outtime" value="<?php echo $row['outtime']; ?>"></td>
|
||||||
|
<td><?php echo $row['lastname'] . ", " . $row['firstname']; ?></td><td><?php echo $row['punchhours']; ?></td><td><?php echo $row['modified']; ?></td>
|
||||||
|
<td><input type="text" name="notes" value="<?php echo $row['notes']; ?>"></td>
|
||||||
|
<td><input type="hidden" name="punchid" value="<?php echo $row['punchid']; ?>"><button type="submit" name="editpunch" value="editpunch" class="pure-button button-success">Save</button><button type="submit" name="deletepunch" value="deletepunch" class="pure-button button-error">Delete</button></td></form>
|
||||||
|
</tr><?php endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<h2 class="content-subhead">NOT AUTHORIZED!</h2>
|
<h2 class="content-subhead">NOT AUTHORIZED!</h2>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user