Add login, signup, and account pages ( issue #8 )
Parent
06f7f4d9d2
révision
bb59035e46
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
if (!defined('NICKELBOX')) {
|
||||
die("Direct access denied.");
|
||||
}
|
||||
|
||||
if ($loggedin !== true || is_null($account)) {
|
||||
header('Location: ./?page=login');
|
||||
die("Please log in.");
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container mt-4">
|
||||
<h1 class="display-4">Account</h1>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<h3>Recent Orders</h3>
|
||||
<div class="list-group">
|
||||
<?php
|
||||
$orders = $database->select('transactions', ['txid', 'txdate', 'type'], ['customerid' => $account['id'], 'ORDER' => ['txdate' => 'DESC'], 'LIMIT' => 50]);
|
||||
foreach ($orders as $o) {
|
||||
$lines = $database->select('lines', ['lineid', 'amount', 'qty', 'name'], ['txid' => $o['txid']]);
|
||||
$itemcount = 0;
|
||||
$total = 0.0;
|
||||
foreach ($lines as $l) {
|
||||
$itemcount += $l['qty'];
|
||||
$total += $l['amount'] * $l['qty'];
|
||||
}
|
||||
?>
|
||||
<div class="list-group-item">
|
||||
Date: <?php echo date(DATETIME_FORMAT, strtotime($o['txdate'])); ?><br />
|
||||
Type: <?php
|
||||
switch ($o['type']) {
|
||||
case 1:
|
||||
echo "In-store";
|
||||
break;
|
||||
case 2:
|
||||
echo "Return";
|
||||
break;
|
||||
case 3:
|
||||
echo "Online";
|
||||
break;
|
||||
default:
|
||||
echo "Other";
|
||||
break;
|
||||
}
|
||||
?><br />
|
||||
Total: $<?php echo number_format($total, 2); ?><br />
|
||||
<div class="list-group list-group-flush">
|
||||
<?php
|
||||
foreach ($lines as $l) {
|
||||
?>
|
||||
<div class="list-group-item d-flex justify-content-between">
|
||||
<div><?php echo $l['name']; ?></div>
|
||||
<div><?php echo $l['qty'] * 1.0; ?>@<?php echo number_format($l['amount'], 2); ?></div>
|
||||
<div>$<?php echo number_format($l['amount'] * $l['qty'], 2); ?></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
if (!defined('NICKELBOX')) {
|
||||
die("Direct access denied.");
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<form class="card" action="action.php" method="post">
|
||||
<input type="hidden" name="action" value="login" />
|
||||
<div class="card-header">
|
||||
Log In
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php
|
||||
$alert = "";
|
||||
if (!empty($_GET['msg'])) {
|
||||
switch ($_GET['msg']) {
|
||||
case "badlogin":
|
||||
$alert = "Bad email or password.";
|
||||
break;
|
||||
case "invalidemail":
|
||||
$alert = "Invalid email address.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($alert != "") {
|
||||
?>
|
||||
<div class="text-danger mb-2">
|
||||
<?php echo $alert; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<p class="small"><a href="./?page=signup">Don't have an account? Click here</a></p>
|
||||
<input type="email" name="email" class="form-control mb-2" placeholder="Email address" required />
|
||||
<input type="password" name="password" class="form-control" placeholder="Password" required />
|
||||
</div>
|
||||
<div class="card-footer d-flex">
|
||||
<a href="./" class="btn btn-default">Back</a>
|
||||
<button type="submit" class="btn btn-primary ml-auto">Log in</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
if (!defined('NICKELBOX')) {
|
||||
die("Direct access denied.");
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container mt-4">
|
||||
<div class="row justify-content-center">
|
||||
<form class="card" action="action.php" method="post">
|
||||
<input type="hidden" name="action" value="signup" />
|
||||
<div class="card-header">
|
||||
Create Account
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php
|
||||
$alert = "";
|
||||
if (!empty($_GET['msg'])) {
|
||||
switch ($_GET['msg']) {
|
||||
case "badlogin":
|
||||
$alert = "Bad email or password.";
|
||||
break;
|
||||
case "invalidemail":
|
||||
$alert = "Invalid email address.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($alert != "") {
|
||||
?>
|
||||
<div class="text-danger mb-2">
|
||||
<?php echo $alert; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<p class="small"><a href="./?page=login">Already have an account? Click here</a></p>
|
||||
<input type="text" name="name" class="form-control mb-2" placeholder="Name" required />
|
||||
<input type="email" name="email" class="form-control mb-2" placeholder="Email address" required />
|
||||
<input type="password" name="password" class="form-control mb-2" placeholder="Password" required />
|
||||
<input type="phone" name="phone" class="form-control" placeholder="Phone (optional)" />
|
||||
</div>
|
||||
<div class="card-footer d-flex">
|
||||
<a href="./" class="btn btn-default">Back</a>
|
||||
<button type="submit" class="btn btn-primary ml-auto">Create Account</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
Chargement…
Référencer dans un nouveau ticket