-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
156 lines (145 loc) · 5.37 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
<?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-12">
<?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" style="background:#CCD1D1">
<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"></br>
<h4><b>CUSTOMER NAME:</b></h4>
<h4><b>CUSTOMER EMAIL:</b></h4>
<h4><b>MOBILE NO:</b></h4>
<h4><b>ADDRESS:</b></h4>
<h4><b>REGISTRATION DATE:</b></h4>
</div>
<div class="col-sm-9"></br>
<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-"></i><b> UPDATE</b></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>
<h4><?php echo date('M d, Y', strtotime($user['created_on'])); ?></h4>
</div>
</div>
</div>
</div>
</div>
<div class="box box-solid">
<div class="box-header with-border">
<center><big><h1 class="page-header"><b><u>TRANSACTION DETAILS</u></b></h1></big></center>
</div>
<div class="box-body">
<table id="example1" class="table table-bordered" style="background:#CCD1D1">
<thead style="background:#ABEBC6">
<th class="hidden"></th>
<th><big><b><center>TRANSACTION DATE</center></b></big></th>
<th><big><b><center>TRANSACTION ID</center></b></big></th>
<th><big><b><center>TRANSACTION AMOUNT</center></b></big></th>
<th><big><b><center>VIEW</center></b></big></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><center>".date('M d, Y', strtotime($row['sales_date']))."</center></td>
<td><center>".$row['pay_id']."</center></td>
<td><center>BDT - ".number_format($total, 2)."</center></td>
<td><center><button class='btn btn-sm btn-flat btn-info transact' data-id='".$row['id']."'><i class='fa fa-'></i><b> DETAILS</b></button></center></td>
</tr>
";
}
}
catch(PDOException $e){
echo "There is some problem in connection: " . $e->getMessage();
}
$pdo->close();
?>
</tbody>
</table>
</div>
</div>
</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>