yaptc/profile.php

84 lines
5.5 KiB
PHP
Raw Normal View History

<?php
session_start();
require_once("config.inc.php");
require_once($yaptc_inc . "functions.inc.php");
2015-02-25 16:01:50 -05:00
$yaptc_pagename = lang('ACCOUNT');
require_once($yaptc_inc . "header.inc.php");
require_once($yaptc_inc . "menu.inc.php");
if (getSessionStatus() == false):
2015-02-19 11:02:13 -05:00
killSession();
else: ?>
2015-02-25 16:01:50 -05:00
<!-- ********** BEGIN CONTENT ********** -->
<?php
2015-02-25 16:01:50 -05:00
if (isset($_POST['saveprofile'])):
if (empty($_POST['password']) && empty($_POST['newpassword2'])):
2015-02-25 16:01:50 -05:00
setUserInfo($db, $session_user["0"]["userid"], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $session_user["0"]["usertypeid"], $session_user["0"]["password"]);
header('Location: ' . $_SERVER['PHP_SELF']);
elseif (strlen($_POST['password']) < $yaptc_min_password):
echo "Password must be at least $yaptc_min_password characters.";
elseif (!empty($_POST['password']) && empty($_POST['newpassword2'])):
echo "Please confirm password if you wish to change it";
elseif ($_POST['password'] != $_POST['newpassword2']):
echo "New passwords do not match";
elseif (!empty($_POST['password']) && ($_POST['password'] = $_POST['newpassword2'])):
// change pw
require_once($yaptc_lib . "phpass-0.3/PasswordHash.php");
$hasher = new PasswordHash(8, FALSE);
$password = $hasher->HashPassword($_POST['password']);
2015-02-25 16:01:50 -05:00
setUserInfo($db, $session_user["0"]["userid"], $_POST['firstname'], $_POST['lastname'], $_POST['email'], $session_user["0"]["usertypeid"], $password);
header('Location: ' . $_SERVER['PHP_SELF']);
endif;
endif;
?>
2015-02-25 16:01:50 -05:00
<h2 class="content-subhead"><?php echo lang('ACCOUNT_INFO_HEADER'); ?></h2>
<p><?php echo lang('ACCOUNT_INFO_DESC') . $yaptc_min_password; ?></p>
<form class="pure-form pure-form-stacked" action="profile.php" method="post">
<fieldset>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-3">
<label for="username"><?php echo lang('USERNAME'); ?></label>
<input type="text" name="username" id="username" maxlength="50" value="<?php echo $session_user["0"]["username"]; ?>" readonly />
<label for="created"><?php echo lang('CREATED'); ?></label>
<input type="text" name="created" id="created" value="<?php echo $session_user["0"]["created"]; ?>" readonly />
<label for="usertype"><?php echo lang('USERTYPE'); ?></label>
<input type="text" name="usertype" id="usertype" maxlength="50" value="<?php echo $session_user["0"]["usertype"]; ?>" readonly />
</div>
<div class="pure-u-1 pure-u-md-1-3">
<label for="firstname"><?php echo lang('FIRSTNAME'); ?></label>
<input type="text" name="firstname" id="firstname" maxlength="50" value="<?php echo $session_user["0"]["firstname"]; ?>" />
<label for="lastname"><?php echo lang('LASTNAME'); ?></label>
<input type="text" name="lastname" id="lastname" maxlength="50" value="<?php echo $session_user["0"]["lastname"]; ?>" />
<label for="email"><?php echo lang('EMAIL'); ?></label>
<input type="text" name="email" id="email" maxlength="100" value="<?php echo $session_user["0"]["email"]; ?>" />
</div>
<div class="pure-u-1 pure-u-md-1-3">
<label for="password"><?php echo lang('NEW') . " " . lang('PASSWORD'); ?></label>
<input type="password" name="password" id="password" />
<label for="newpassword2"><?php echo lang('CONFIRM') . " " . lang('NEW') . " " . lang('PASSWORD'); ?></label>
<input type="password" name="newpassword2" id="newpassword2" />
</div>
<div class="pure-controls pure-u-1">
<button type="submit" name="saveprofile" id="saveprofile" class="pure-input-1 pure-button button-success "><?php echo lang('SAVE'); ?></button>
</div>
</div>
</fieldset>
</form>
<h2 class="content-subhead"><?php echo lang('PUNCH_HISTORY_HEADER'); ?></h2>
<p><?php echo lang('PUNCH_HISTORY_DESC'); ?></p>
<table class="pure-table">
<thead>
<tr><th><?php echo lang('IN') . " / " . lang('OUT'); ?></th><th><?php echo lang('HOURS'); ?></th><th><?php echo lang('FLAG'); ?></th><th><?php echo lang('NOTES'); ?></th></tr>
</thead>
<tbody>
<?php foreach (listPunches($db, $session_user["0"]["userid"]) as $row): ?>
<tr>
<td><?php echo $row['intime'] . " / " . $row['outtime']; ?></td><td><?php echo $row['punchhours']; ?></td><td><?php echo $row['modified']; ?></td><td><?php echo $row['notes']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
2015-02-25 16:01:50 -05:00
<!-- ********** END CONTENT ********** -->
<?php endif; require_once($yaptc_inc . "footer.inc.php"); ?>