Skip to content

Commit

Permalink
Update card edit, Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
uozkl committed Apr 7, 2020
1 parent 5a33817 commit 802b487
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 104 deletions.
93 changes: 33 additions & 60 deletions Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
$is_male = $account_res[0]['user_gender']=="Male";
$is_female = $account_res[0]['user_gender']=="Female";
$is_others = $account_res[0]['user_gender']=="Others";

?>
<html>

Expand Down Expand Up @@ -104,77 +105,49 @@
</form>
</div>
<section>
<h2>My Cards</h2>
<table>
<tr>
<td><h2>My Cards</h2></td>
<td style="width:1000px;text-align:right">
<a href="Card_Edit.php?card=NEW" class="thm-btn">add</a></td>
</tr>
</table>
<caption class="accessible">Card link to my account</caption>
</section>
<hr>
<table class="table">
<tbody>
<tr class="accessible">
<th scope="col">Account Name</th>
<th scope="col">Institution</th>
</tr>
<tr>
<th scope="row">
<a href="Detail.php">
Credit card 1</span></a>
<br>
<span> Visa 4444******** 9999 </span>
</th>
<td>
<ul>
<li> <span class=""> Bank of XXXX </span> </li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<a href="Detail.php">
Credit card 2</span></a>
<br>
<span> Visa 4444******** 9999 </span>
</th>
<td>
<ul>
<li> <span class=""> XXX Bank </span> </li>
</ul>
</td>
<th scope="col">Card Name</th>
<th scope="col">Balance</th>
</tr>
<tr>
<th scope="row">
<a href="Detail.php">
Credit card 3</span></a>
<br>
<span> Visa 4444******** 9999 </span>
</th>
<td>
<ul>
<li> <span class=""> YYY Bank </span> </li>
</ul>
</td>
</tr>
<tr>
<th scope="row">
<a href="Detail.php">
Credit card 4</span></a>
<br>
<span> Visa 4444******** 9999 </span>
</th>
<td>
<ul>
<li> <span class=""> Bank of YYY </span> </li>
</ul>
</td>

<?php
for ($i=0; $i<sizeof($summary); $i++)
{

echo '
<tr>
<th scope="row">
<a href="Detail.php?card='.$summary[$i]['id'] .'">
'.$summary[$i]['name'].'</span></a>
<br>
<span> '. $summary[$i]['number'].' </span>
</th>
<td>
<ul>
<li> <span class=""> $'. $summary[$i]['balance']. ' </span> </li>
</ul>
</td>
</tr>';

}
?>
</tr>
</tbody>
</table>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<input id="form_botcheck" name="form_botcheck" class="form-control" type="hidden" value="">
<a href="Main.php" onclick="alert('Change Saved')" class="thm-btn2">Save</a>
<button class="thm-btn2" onclick="btn_exit()">Cancel</button>
</div>
</div>

</div>
<section class="footer-bottom">
<div class="container">
Expand Down
168 changes: 168 additions & 0 deletions Card_Edit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?php
require('db_fetch.php');
$this_card_id = $_GET['card'];
if ($this_card_id=="NEW") {
$this_card_id=0;
}
setcookie('this_card_id', $this_card_id);
$card_info = pg_fetch_all(pg_query($db_connection, "select * from card_info where card_id= $this_card_id"))[0];
$is_credit = $card_info['card_type']=="Credit";
$is_cash = $card_info['card_type']=="Cash";
$is_saving = $card_info['card_type']=="Savings";
$is_loan = $card_info['card_type']=="Loan";

?>
<html>
<style>
.thm-btndel {
position: relative;
background: transparent;
font-size: 14px;
line-height: 46px;
font-weight: 600;
color: #ff5858;
border: 2px solid #f4f4f4;
text-transform: uppercase;
font-family: 'Poppins', sans-serif;
display: inline-block;
padding: 0 38px;
transition: all .5s cubic-bezier(0.4, 0, 1, 1);
}
.thm-btndel:hover {
background: #ff5858;
border-color: #ff5858;
color: #fff;
transition: all .5s cubic-bezier(0.4, 0, 1, 1);
}
</style>
<head>
<title>Edit item</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/responsive.css">
</head>

<body>
<header class="top-bar">
<div class="container">
<div class="clearfix">
<div class="col-left float_left">
<ul class="top-bar-info">
<li>
<h3>Good morning </h3>
</li>
<li><?php echo $name?></li>
</ul>
</div>
<div class="col-right float_right">
<div class="link">
<a href="Account.php" class="thm-btn">My account</a>
</div>
</div>
</div>
</div>
</header>
<section class="theme_menu stricky slideIn animated">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="main-logo">
<a href="Main.php"><img src="image/logo_small.PNG" alt=""></a>
</div>
</div>
</div>
</div>
</section>
<section class="contact_us sec-padd-bottom">
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-12 col-xs-12">
<div class="section-title">
<br>
<h3>Edit your card details</h3>
</div>
<div class="default-form-area">
<form id="contact-form" name="contact_form" class="default-form" action="card_update.php" method="post"
novalidate="novalidate">
<div class="row clearfix">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<h3>Card Institution</h3>
<input type="text" name="card_name" class="form-control" value="<?php echo $card_info['card_institution']?>"
placeholder="Name of transaction" required>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<h3>Card Number</h3>
<input type="text" name="card_number" class="form-control" value="<?php echo $card_info['card_number']?>"
placeholder="Type of transaction" required>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="form-group">
<h3>Type of Card</h3>
<select name="card_type" value = "Female">
<option value="Credit" <?php if($is_credit){echo "selected";}?>>Credit</option>
<option value="Cash" <?php if($is_cash){echo "selected";}?>>Cash</option>
<option value="Savings" <?php if($is_saving){echo "selected";}?>>Savings</option>
<option value="Loan" <?php if($is_loan){echo "selected";}?>>Loan</option>
</select>
</div>
</div>
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="form-group">
<input id="form_botcheck" name="form_botcheck" class="form-control"
type="hidden" value="">
<button class="thm-btn2" type="submit">Save</button>
<button class="thm-btn2" type="button" onclick="btn_exit()">Cancel</button>
<?php if ($this_card_id!=0) {echo '<button class="thm-btndel" type="button" onclick="btn_del()">Delete</button>';}?>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="col-md-6 col-sm-8 col-xs-12">
<div class="home-google-map">
<div class="google-map" id="contact-google-map" data-map-lat="40.938541"
data-map-lng="-73.904893" data-icon-path="images/logo/map-marker.png"
data-map-title="Chester" data-map-zoom="11">
</div>
</div>
</div>
</div>
</div>
</section>
<section class="footer-bottom">
<div class="container">
<div class="pull-left copy-text">
<p>Copyright © 20XX. Some Company name All rights reserved.</p>
</div>
<div class="pull-right get-text">
<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>
<li><a href="#" onclick="alert('Work in progress')"> Terms &amp; Conditions</a></li>
</ul>
</div>
</div>
</section>
</body>
<script>
function btn_exit() {
var r = confirm("Do you really want to cancel your changes?")
if (r == true) {
window.event.returnValue = false;
window.location.href = "<?php if ($this_card_id==0) {echo 'Account.php';}else{echo 'Detail.php?card='.$this_card_id;}?>";
}
}
function btn_del() {
var r = confirm("Do you really want to delete this record? This will also delete all transactions under this card!")
if (r == true) {
window.event.returnValue = false;
window.location.href = "card_del.php";
}
}
</script>

</html>
14 changes: 11 additions & 3 deletions Detail.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
require('db_fetch.php');
$this_card_id = $_GET['card'];
//$this_card_id = $_GET['card'];
$this_card_id = !empty($_GET['card']) ? $_GET['card'] : $_COOKIE['this_card_id'];;
setcookie('this_card_id', $this_card_id);
$this_trans = array();
$total_in = 0;
Expand All @@ -13,8 +14,9 @@
$total_out=$total_out+$card_res[$i]['transaction_outflow'];
}
}
$card_index = array_search($tmp['card_id'],$mapping);
$card_index = array_search($this_card_id,$mapping);
$card_number = $summary[$card_index]['number'];
$card_name = $summary[$card_index]['name'];
?>
<html>

Expand Down Expand Up @@ -58,7 +60,13 @@
<div class="container">
<br>
<section>
<h2>Card</h2>
<table>
<tr>
<td><h2><?php echo $card_name?></h2></td>
<td style="width:800px;text-align:right">
<a href="Card_Edit.php?card= <?php echo $this_card_id ?>" class="thm-btn">edit</a></td>
</tr>
</table>
<caption class="accessible"><?php echo $card_number?></caption>
</section>
<hr>
Expand Down
9 changes: 5 additions & 4 deletions Edit.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
require('db_fetch.php');
$this_trans_id = $_GET['trans'];
//$this_trans_id = $_GET['trans'];
$this_trans_id = !empty($_GET['trans']) ? $_GET['trans'] : $_COOKIE['this_tran_id'];;
if ($this_trans_id=="NEW") {
$this_trans_id=0;
}
Expand Down Expand Up @@ -137,8 +138,8 @@
<input id="form_botcheck" name="form_botcheck" class="form-control"
type="hidden" value="">
<button class="thm-btn2" type="submit">Save</button>
<button class="thm-btn2" onclick="btn_exit()">Cancel</button>
<?php if ($this_trans_id!=0) {echo '<button class="thm-btndel" onclick="btn_del()">Delete</button>';}?>
<button class="thm-btn2" type="button" onclick="btn_exit()">Cancel</button>
<?php if ($this_trans_id!=0) {echo '<button class="thm-btndel" type="button" onclick="btn_del()">Delete</button>';}?>
</div>
</div>
</div>
Expand Down Expand Up @@ -188,4 +189,4 @@ function btn_del() {
}
</script>

</html>
</html>
8 changes: 4 additions & 4 deletions Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<tr>
<th scope="row">
<a href="Detail.php?card='.$summary[$i]['id'] .'">
Account '.$summary[$i]['id'].'</span></a>
'.$summary[$i]['name'].'</span></a>
<br>
<span> '. $summary[$i]['number'].' </span>
</th>
Expand Down Expand Up @@ -114,7 +114,7 @@
<tr>
<th scope="row">
<a href="Detail.php?card='.$summary[$i]['id'] .'">
Account '.$summary[$i]['id'].'</span></a>
'.$summary[$i]['name'].'</span></a>
<br>
<span> '. $summary[$i]['number'].' </span>
</th>
Expand Down Expand Up @@ -156,7 +156,7 @@
<tr>
<th scope="row">
<a href="Detail.php?card='.$summary[$i]['id'] .'">
account '.$summary[$i]['id'].'</span></a>
'.$summary[$i]['name'].'</span></a>
<br>
<span> '. $summary[$i]['number'].' </span>
</th>
Expand Down Expand Up @@ -199,7 +199,7 @@
<tr>
<th scope="row">
<a href="Detail.php?card='.$summary[$i]['id'] .'">
account '.$summary[$i]['id'].'</span></a>
'.$summary[$i]['name'].'</span></a>
<br>
<span> '. $summary[$i]['number'].' </span>
</th>
Expand Down
Loading

0 comments on commit 802b487

Please sign in to comment.