Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
uozkl committed Apr 7, 2020
2 parents 802b487 + 5b7574f commit bf2c003
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 20 deletions.
27 changes: 23 additions & 4 deletions Detail.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
require('db_fetch.php');
//$this_card_id = $_GET['card'];
// Gets the card ID so we know which card it is.
$this_card_id = !empty($_GET['card']) ? $_GET['card'] : $_COOKIE['this_card_id'];;
setcookie('this_card_id', $this_card_id);
// Variable initialization.
$this_trans = array();
$total_in = 0;
$total_out = 0;
// Loops over all transactions of the card and calculates total inflow/outlfow.
for ($i=0; $i<sizeof($card_res); $i++)
{
if($card_res[$i]["card_id"]==$this_card_id){
Expand All @@ -19,14 +21,16 @@
$card_name = $summary[$card_index]['name'];
?>
<html>

<!-- Card detail -->
<head>
<title>Detailed list</title>
<!-- CSS stylesheet -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/responsive.css">
</head>

<body>
<!-- The top UI component that displays a welcome message and the MY ACCOUNT link. -->
<header class="top-bar">
<div class="container">
<div class="clearfix">
Expand All @@ -40,12 +44,14 @@
</div>
<div class="col-right float_right">
<div class="link">
<!-- Page redirection -->
<a href="Account.php" class="thm-btn">My account</a>
</div>
</div>
</div>
</div>
</header>
<!-- The section that diplays the logo under the top bar. -->
<section class="theme_menu stricky slideIn animated">
<div class="container">
<div class="row">
Expand All @@ -57,6 +63,7 @@
</div>
</div>
</section>
<!-- The container that contains the main content of the page. -->
<div class="container">
<br>
<section>
Expand All @@ -71,11 +78,13 @@
</section>
<hr>
<div>
<!-- Page title -->
</section>
<h3>Current Balance</h3>
<h4>$<?php echo $total_in-$total_out?></h4>
</section>
<br>
<!-- List of all the transactions for this card. -->
<section id="transactionList">
<div class="accTableHeader">
<h3> Transactions </h3>
Expand All @@ -90,7 +99,10 @@
<th scope="col">Out Flow</th>

</tr>

<!--
Fetch data from DB to display card info.
Variables refer to db_fetch.php
-->
<?php
for ($i=0; $i<sizeof($this_trans); $i++)
{
Expand Down Expand Up @@ -123,13 +135,15 @@
}
?>


<!-- The total balance for all the transactions. -->
<tr class="totalRow">
<td><a href="Edit.php?trans=NEW" class="thm-btn">add</a></td>
<td></td>
<!-- Total inflow -->
<td><span class="total">Total:</span>
<ul> <span>$<?php echo $total_in?></span> </ul>
</td>
<!-- Total outflow -->
<td><span class="total">Total:</span>
<ul> <span>$<?php echo $total_out?></span> </ul>
</td>
Expand All @@ -139,12 +153,17 @@
</section>
</div>
</div>
<!-- The bottom UI section that contains copyright and other info. -->
<section class="footer-bottom">
<div class="container">
<!-- Left section -->
<div class="pull-left copy-text">
<!-- Copyright -->
<p>Copyright © 20XX. Some Company name All rights reserved.</p>
</div>
<!-- Right section -->
<div class="pull-right get-text">
<!-- Support, privacy, terms -->
<ul>
<li><a href="#" onclick="alert('Work in progress')">Support | </a></li>
<li><a href="#" onclick="alert('Work in progress')">Privacy &amp; Policy |</a></li>
Expand Down
30 changes: 28 additions & 2 deletions Edit.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<?php
require('db_fetch.php');
//$this_trans_id = $_GET['trans'];
// Gets the transaction ID so we know which transacton it is.
$this_trans_id = !empty($_GET['trans']) ? $_GET['trans'] : $_COOKIE['this_tran_id'];;
if ($this_trans_id=="NEW") {
$this_trans_id=0;
}
// Sets cookie.
setcookie('this_tran_id', $this_trans_id);
// Gets data for this transaction from DB.
$tran_info = pg_fetch_all(pg_query($db_connection, "select * from transaction_info where transaction_id= $this_trans_id"))[0];
//print_r($tran_info);

$format_date = substr($tran_info['transaction_date'], 0, 4).'-'.substr($tran_info['transaction_date'], 4, 2).'-'.substr($tran_info['transaction_date'], 6, 2);

?>
<html>
<!-- This is the page where you can edit each transaction. -->
<style>
.thm-btndel {
position: relative;
Expand All @@ -36,11 +39,13 @@
</style>
<head>
<title>Edit item</title>
<!-- CSS stylesheet -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/responsive.css">
</head>

<body>
<!-- The top UI component that displays a welcome message and the MY ACCOUNT link. -->
<header class="top-bar">
<div class="container">
<div class="clearfix">
Expand All @@ -54,12 +59,14 @@
</div>
<div class="col-right float_right">
<div class="link">
<!-- Page redirection -->
<a href="Account.php" class="thm-btn">My account</a>
</div>
</div>
</div>
</div>
</header>
<!-- The section that diplays the logo under the top bar. -->
<section class="theme_menu stricky slideIn animated">
<div class="container">
<div class="row">
Expand All @@ -71,6 +78,7 @@
</div>
</div>
</section>
<!-- The container that contains the main content of the page. -->
<section class="contact_us sec-padd-bottom">
<div class="container">
<div class="row">
Expand All @@ -80,53 +88,61 @@
<h3>Edit your transition record</h3>
</div>
<div class="default-form-area">
<!-- Form for submition. -->
<form id="contact-form" name="contact_form" class="default-form" action="edit_edit.php" method="post"
novalidate="novalidate">
<div class="row clearfix">
<div class="col-md-6 col-sm-6 col-xs-12">

<!-- Date of transaction. -->
<div class="form-group">
<h3>Transition Date</h3>
<input type="date" name="trans_date" class="form-control" value="<?php echo $format_date?>"
placeholder="Transition Date" required="" aria-required="true">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<!-- Name of transaction. -->
<div class="form-group">
<h3>Transition Name</h3>
<input type="text" name="trans_name" class="form-control" value="<?php echo $tran_info['transaction_name']?>"
placeholder="Name of transaction">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<!-- Type of transaction. -->
<div class="form-group">
<h3>Transition Type</h3>
<input type="text" name="trans_type" class="form-control" value="<?php echo $tran_info['transaction_type']?>"
placeholder="Type of transaction">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<!-- Source or destination of transaction. -->
<div class="form-group">
<h3>Source/Destination</h3>
<input type="text" name="source_des" class="form-control" value="<?php echo $tran_info['transaction_dest']?>"
placeholder="To/From ...">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<!-- In flow of transaction. -->
<div class="form-group">
<h3>In Flow</h3>
<input type="number" name="in_flow" class="form-control" value="<?php echo $tran_info['transaction_inflow']?>"
placeholder="0.0">
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<!-- Out flow of transaction. -->
<div class="form-group">
<h3>Out Flow</h3>
<input type="number" name="out_flow" class="form-control" value="<?php echo $tran_info['transaction_outflow']?>"
placeholder="0.0">
</div>
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
<!-- Note of transaction. -->
<div class="form-group">
<H3>Note</H3>
<textarea name="form_message" class="form-control textarea required"
Expand All @@ -137,8 +153,11 @@
<div class="form-group">
<input id="form_botcheck" name="form_botcheck" class="form-control"
type="hidden" value="">
<!-- Save button -->
<button class="thm-btn2" type="submit">Save</button>
<!-- Cancel button -->
<button class="thm-btn2" type="button" onclick="btn_exit()">Cancel</button>
<!-- Delete button -->
<?php if ($this_trans_id!=0) {echo '<button class="thm-btndel" type="button" onclick="btn_del()">Delete</button>';}?>
</div>
</div>
Expand All @@ -157,12 +176,17 @@
</div>
</div>
</section>
<!-- The bottom UI section that contains copyright and other info. -->
<section class="footer-bottom">
<div class="container">
<!-- Left section -->
<div class="pull-left copy-text">
<!-- Copyright -->
<p>Copyright © 20XX. Some Company name All rights reserved.</p>
</div>
<!-- Right section -->
<div class="pull-right get-text">
<!-- Support, privacy, terms -->
<ul>
<li><a href="#" onclick="alert('Work in progress')">Support | </a></li>
<li><a href="#" onclick="alert('Work in progress')">Privacy &amp; Policy |</a></li>
Expand All @@ -173,13 +197,15 @@
</section>
</body>
<script>
// Function for cancel button.
function btn_exit() {
var r = confirm("Do you really want to cancel your changes?")
if (r == true) {
window.event.returnValue = false;
window.location.href = "Detail.php";
}
}
// Function for delete button.
function btn_del() {
var r = confirm("Do you really want to delete this record?")
if (r == true) {
Expand Down
9 changes: 9 additions & 0 deletions Index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<!DOCTYPE html>
<html>
<!--
This is the first page you see after launch.
It is a welcome page.
-->

<head>
<style>
Expand Down Expand Up @@ -65,16 +69,21 @@
</head>

<body>
<!-- Back ground image; Source is folder /Image -->
<div class="bgIMG">
<!-- The middle of the page. -->
<div class="middle">
<div>
<!-- The logo located in the center of the page. -->
<img src="image/logo3.PNG" style="width: 500px;">
<hr>
<!-- Login button -->
<button type="toLoginBTN" onclick="btn_login()">Login</button>
</div>
</div>
</div>
</body>
<!-- JS for page redirection for login button. -->
<script>
function btn_login() {
window.location.href = "Login_Page.php";
Expand Down
18 changes: 14 additions & 4 deletions Login_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
?>
<!DOCTYPE html>
<html>
<!-- Login page -->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
Expand Down Expand Up @@ -78,20 +79,26 @@
</head>

<body>
<!-- Back ground image; Source is folder /Image -->
<div class = "bgimg">

<!-- The light blue container that contains the login form. -->
<div class="container" style="background-color:#f5f9f7">
<h2>LOGIN</h2>
<!-- Login form -->
<form method="post">
<!-- Username label and input box. -->
<label for="uName"><b>Username</b></label>
<br>
<input type="text" placeholder="Enter Username" name="uName" value = "" required>
<br>
<!-- Password label and input box. -->
<label for="pWord"><b>Password</b></label>
<br>
<input type="password" placeholder="Enter Password" name="pWord" required>
<br>
<!-- Login button -->
<input type="submit" value="Login">
<!-- Register link -->
<span class="rgs"> <a href="Register.php">Need an account?</a></span>
</form>
</div>
Expand All @@ -110,17 +117,20 @@
$result = pg_query($db_connection, $query) or die(pg_error($db_connection));
$count = pg_num_rows($result);

// Verifies login credentials, if true:
if ($count == 1) {

//echo "Login Credentials verified";
// Shows login successful and sets cookies.
echo "<script type='text/javascript'>alert('Login Credentials verified')</script>";
setcookie('this_id', pg_fetch_all($result)[0]['user_id']);

// Page redirection.
echo "<script> window.location.href = 'Main.php' </script>";
} else {
} else { // If false:
// Displays login fail message.
echo "<script type='text/javascript'>alert('Invalid Login Credentials')</script>";
// Stay on this page.
echo "<script> window.location.href = 'Login_Page.php' </script>";
//echo "Invalid Login Credentials";
}
}
?>
Loading

0 comments on commit bf2c003

Please sign in to comment.