-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
164 lines (148 loc) · 5.11 KB
/
profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!-- Done -->
<?php include 'includes/session.php'; ?>
<?php
if(!isset($_SESSION['user'])){
header('location: index.php');
}
?>
<?php include 'includes/header.php'; ?>
<body class="hold-transition skin-blue layout-top-nav">
<div class="wrapper">
<?php include 'includes/navbar.php'; ?>
<div class="content-wrapper">
<div class="container">
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-sm-9">
<?php
if(isset($_SESSION['error'])){
echo "
<div class='callout callout-danger'>
".$_SESSION['error']."
</div>
";
unset($_SESSION['error']);
}
if(isset($_SESSION['success'])){
echo "
<div class='callout callout-success'>
".$_SESSION['success']."
</div>
";
unset($_SESSION['success']);
}
?>
<div class="box box-solid">
<div class="box-body">
<div class="col-sm-3">
<img src="<?php echo (!empty($user['photo'])) ? 'images/'.$user['photo'] : 'images/profile.jpg'; ?>" width="100%">
</div>
<div class="col-sm-9">
<div class="row">
<div class="col-sm-3">
<h4>Name:</h4>
<h4>Email:</h4>
<h4>Contact Info:</h4>
<h4>Address:</h4>
</div>
<div class="col-sm-9">
<h4><?php echo $user['firstname'].' '.$user['lastname']; ?>
<span class="pull-right">
<a href="#edit" class="btn btn-success btn-flat btn-sm" data-toggle="modal"><i class="fa fa-edit"></i> Edit</a>
</span>
</h4>
<h4><?php echo $user['email']; ?></h4>
<h4><?php echo (!empty($user['contact_info'])) ? $user['contact_info'] : 'N/a'; ?></h4>
<h4><?php echo (!empty($user['address'])) ? $user['address'] : 'N/a'; ?></h4>
</div>
</div>
</div>
</div>
</div>
<!-- Transaction History Section -->
<div class="box box-solid">
<!-- <div class="box-header with-border">
<h4 class="box-title"><i class="fa fa-calendar"></i> <b>Transaction History</b></h4>
</div>
<div class="box-body">
<table class="table table-bordered" id="example1">
<thead>
<th class="hidden"></th>
<th>Date</th>
<th>Transaction#</th>
<th>Amount</th>
<th>Full Details</th>
</thead>
<tbody>
<?php
$conn = $pdo->open();
try{
$stmt = $conn->prepare("SELECT * FROM sales WHERE user_id=:user_id ORDER BY sales_date DESC");
$stmt->execute(['user_id'=>$user['id']]);
foreach($stmt as $row){
$stmt2 = $conn->prepare("SELECT * FROM details LEFT JOIN products ON products.id=details.product_id WHERE sales_id=:id");
$stmt2->execute(['id'=>$row['id']]);
$total = 0;
foreach($stmt2 as $row2){
$subtotal = $row2['price']*$row2['quantity'];
$total += $subtotal;
}
echo "
<tr>
<td class='hidden'></td>
<td>".date('M d, Y', strtotime($row['sales_date']))."</td>
<td>".$row['pay_id']."</td>
<td>$ ".number_format($total, 2)."</td>
<td><button class='btn btn-sm btn-flat btn-info transact' data-id='".$row['id']."'><i class='fa fa-search'></i> View</button></td>
</tr>
";
}
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
$pdo->close();
?>
</tbody>
</table>
</div>
</div> -->
</div>
<!-- <div class="col-sm-3">
<?php include 'includes/sidebar.php'; ?>
</div> -->
</div>
</section>
</div>
</div>
<?php include 'includes/footer.php'; ?>
<?php include 'includes/profile_modal.php'; ?>
</div>
<?php include 'includes/scripts.php'; ?>
<!-- <script>
$(function(){
$(document).on('click', '.transact', function(e){
e.preventDefault();
$('#transaction').modal('show');
var id = $(this).data('id');
$.ajax({
type: 'POST',
url: 'transaction.php',
data: {id:id},
dataType: 'json',
success:function(response){
$('#date').html(response.date);
$('#transid').html(response.transaction);
$('#detail').prepend(response.list);
$('#total').html(response.total);
}
});
});
$("#transaction").on("hidden.bs.modal", function () {
$('.prepend_items').remove();
});
});
</script> -->
</body>
</html>