Compare commits

...

4 Commits

10 changed files with 174 additions and 11 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

13
www/logout.php Normal file
View File

@ -0,0 +1,13 @@
<?php
require 'webdata/init.php';
if(checkLogin()){
logoutUser();
echo "logged out?";
}
else {
echo "not logged in";
}
header("Location: ");

View File

@ -26,7 +26,7 @@
<hr>
</div>
<div id='totalPriceWrapper'>Space subtotal: <span id="totalPrice" class="priceWrapper price">239.00</span></div>
<div id='totalPriceWrapper'>Space subtotal: <span id="totalPrice" class="priceWrapper price">00.00</span></div>
<br>
<button id="addStore">Add store</button><br><br>
<button id="refreshAll">Refresh all</button>

View File

@ -505,7 +505,7 @@ function updateTotalPrice(){
totalPrice += store.itemsObj[itemID].amount*store.itemsObj[itemID].price;
}
}
$("#totalPrice").html(totalPrice);
$("#totalPrice").html(totalPrice.toFixed(2));
}
let spaceID = 0;

133
www/review/index.php Normal file
View File

@ -0,0 +1,133 @@
<?php $rPath = "../"; require $rPath.'webdata/init.php'; requireLogin(); ?><!DOCTYPE html>
<html lang="en">
<head>
<?=getHtmlHeaders($rPath);?>
<title>Review - PaperBag - Plan Your Shopping</title>
</head>
<body id='plan'>
<div id="page-container">
<div id="page-wrapper">
<?php include $rPath.'webdata/navbar.php'; ?>
<h1 class="headline text-center">WORK IN PROGRESS - PaperBag Review</h1>
<div class="container-md" style="padding-top: 5px; padding-bottom: 15px; text-align: center;">
<div id="spaceSelectWrapper" style="max-width: 900px; margin: auto;">
<div class="input-group" style="width: 200px;">
<label class="input-group-text" for="spaceSelect">Space:</label>
<select class="form-select" id='spaceSelect' aria-label="Select space">
<option>...</option>
</select>
</div>
</div>
<h2>Receipts to review</h2>
<hr>
<!-- <div class="row row-cols-1 row-cols-md-2">-->
<div class="" style="height: 220px;">
<!-- <div class="col">-->
<div class="card" style="font-size: small; width: 200px; height: 200px; float:left;">
<div class="card-header">Shopping-trip #2</div>
<div class="card-body" style="text-align: left">
<!--<ul class="list-group list-group-flush">
<li class="list-group-item"><span style='float: left;'>Item 1</span> <div class='priceWrapper'><span class="price">100.00</span></div></li>
<li class="list-group-item"><span style='float: left;'>Item 2</span> <div class='priceWrapper'><span class="price">20.00</span></div></li>
<li class="list-group-item"><span style='float: left;'>Item 3</span> <div class='priceWrapper'><span class="price">3.00</span></div></li>
</ul>-->
Store: Rema 1000<br>
Date: <br>
Items: 4<br>
Subtotal: 123.00<br>
</div>
<!--<div class="card-footer">Subtotal: <span class="price">123.00</span></div>-->
<div class="card-footer"><button class="btn btn-primary openModal">Continue...</button></div>
</div>
<!-- </div>-->
<!-- <div class="col">-->
<div class="card" style="font-size: small; width: 200px; height: 200px; float:left;">
<div class="card-header">Shopping-trip #1</div>
<div class="card-body" style="text-align: left">
Store: Coop Obs Sørlandsparken<br>
Date: 2021-05-23<br>
Items: 24<br>
Subtotal: 675.00
</div>
<div class="card-footer"><button class="btn btn-primary openModal">Continue...</button></div>
</div>
<!-- </div>-->
</div>
<hr>
<h4>Receipts</h4>
<hr>
<!-- <h2>Stats</h2>-->
<div class="modal" tabindex="-1" id="receiptModal">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Item</th>
<th scope="col">Expected Price</th>
<th scope="col">Actual price</th>
<th scope="col">Discounted?</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td>Cheese</td>
<td class="price">35.00</td>
<td><input type="number"></td>
<td><input type="checkbox"></td>
</tr>
<tr>
<th scope="row">2</th>
<td>Macaroni</td>
<td class="price">15.00</td>
<td><input type="number"></td>
<td><input type="checkbox"></td>
</tr>
<tr>
<th scope="row">3</th>
<td>Cheese</td>
<td class="price">35.00</td>
<td><input type="number"></td>
<td><input type="checkbox"></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</div>
<script>
var myModal = new bootstrap.Modal($("#receiptModal"));
$(".openModal").on('click', () => { myModal.show(); });
</script>
</div>
<?php include $rPath.'webdata/footer.html'; ?>
</div>
</body>
</html>

View File

@ -54,7 +54,8 @@ function getHtmlHeaders($prepend = ""){
<script src='".$prepend."js/jquery-3.5.1.min.js'></script>
<script src='".$prepend."js/popper.min.js'></script>
<script src='".$prepend."js/bootstrap.min.js'></script>
<!--<script src='".$prepend."js/hammer.js'></script>
<!--<script src='//cdn.jsdelivr.net/npm/marked/marked.min.js'></script>
<script src='".$prepend."js/hammer.js'></script>
<script src='".$prepend."js/hammer.jquery.js'></script>-->
\n";
}
@ -109,6 +110,22 @@ function loginUser($email, $pass) {
return $err;
}
function logoutUser(){
if(checkLogin()){
}
// Delete session-cookie
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
// Finally, destroy the session.
session_destroy();
}
function PwdGen($pass, $returnHashed = false): string {
global $config;

View File

@ -16,7 +16,7 @@ if($activePage == "/index.php"){ $activePage = "/"; }
<?php
$links["Home"] = $projectRoot."/";
$links["Plan"] = $projectRoot."/plan/";
$links["Review"] = "#";
$links["Review"] = $projectRoot."/review/";
foreach($links as $title => $href){
echo '<li class="nav-item">';
echo '<a class="nav-link'.($activePage == $href?" active\" aria-current=\"page":"").'" href="'.$href.'">'.$title.'</a>';
@ -25,7 +25,7 @@ if($activePage == "/index.php"){ $activePage = "/"; }
?>
</ul>
<div class="navbar-nav" id="navLogin">
<?php if(checkLoginSimple()){ echo "<span title='Logged in as: ".($_SESSION['user_name'] ?? '')."'>Logged in</span>"; } else { ?><a class="nav-item nav-link" id='login' href='<?=$projectRoot;?>/login.php'>Login</a><?php } ?>
<?php if(checkLoginSimple()){ echo "<span title='Logged in as: ".($_SESSION['user_name'] ?? '')."'><a class='nav-item nav-link' href='$projectRoot/logout.php'>Log out</a></span>"; } else { ?><a class="nav-item nav-link" id='login' href='<?=$projectRoot;?>/login.php'>Login</a><?php } ?>
</div>
</div>
</div>