forked from ringelweb/RingelNew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseller_profile.php
458 lines (329 loc) · 15.7 KB
/
seller_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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<?php
require 'includes/connect.php';
$user_name=$_SESSION['user_name'];
$sellerid=$_SESSION['sellerid'];
$sellerid=$_SESSION['sellerid'];
//Declaring variables to prevent error
/*if(!isset($_SESSION['user_name']))
{
header('Location: index.php');
}*/
if(empty($_GET)) {
$query="SELECT orgname,address,coverimage,siteurl,contact,email,description FROM org_info WHERE sellerid='".$sellerid."'";
$result= mysqli_query($con, $query);
$row= mysqli_fetch_array($result);
//logic to display the posts from product_info table
//only recent 6 are shown
$post_query = "SELECT productimage FROM product_info WHERE sellerid='".$sellerid."' " ;
$result_post_query = mysqli_query($con, $post_query);
//$row_post_query = mysqli_fetch_array($result_post_query);
$img = array("","","","","","");//array to store 6 posts into the post area
$i = 0;
while ($row2 = mysqli_fetch_array($result_post_query,MYSQLI_ASSOC))
{
$temp = $row2["productimage"];
$img[$i++] = $temp;
//echo $temp;
}}
else {
$id=$_GET['id'];
$insert=FALSE;
$check=mysqli_query($con,"SELECT * FROM seller_follow WHERE buyerid='".$buyerid."' and sellerid='".$id."'");
$num= mysqli_num_rows($check);
if($num==0){
$insert=FALSE;
}
else{
$insert=TRUE;
}
$query="SELECT orgname,address,coverimage,siteurl,contact,email,description FROM org_info WHERE sellerid='".$id."'";
$result= mysqli_query($con, $query);
$row= mysqli_fetch_array($result);
//logic to display the posts from product_info table
//only recent 6 are shown
$post_query = "SELECT productimage FROM product_info WHERE sellerid='".$id."' " ;
$result_post_query = mysqli_query($con, $post_query);
//$row_post_query = mysqli_fetch_array($result_post_query);
$img = array("","","","","","");//array to store 6 posts into the post area
$i = 0;
while ($row2 = mysqli_fetch_array($result_post_query,MYSQLI_ASSOC))
{
$temp = $row2["productimage"];
$img[$i++] = $temp;
//echo $temp;
}
if(isset($_POST['follow'])){
$check=mysqli_query($con,"SELECT * FROM seller_follow WHERE buyerid='".$buyerid."' and sellerid='".$id."'");
if(mysqli_num_rows($check)==0){
$query="INSERT INTO seller_follow VALUES('','".$id."','".$buyerid."')";
$insert=mysqli_query($con,$query);
}
} if(isset($_POST['following'])){
$check=mysqli_query($con,"SELECT * FROM seller_follow WHERE buyerid='".$buyerid."' and sellerid='".$id."'");
$num1=mysqli_num_rows($check);
if($num1>0){
$query1="DELETE FROM seller_follow WHERE buyerid='".$buyerid."' and sellerid='".$id."'";
$result= mysqli_query($con,$query1);
$insert=FALSE;
}
}
$follow_result= mysqli_query($con,"SELECT * FROM seller_follow WHERE sellerid='".$id."'");
$num_follow= mysqli_num_rows($follow_result);
}
?>
<title>Welcome to Home Feed</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3-theme-blue-grey.css">
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Open+Sans'>
<body >
<?php include 'includes/header.php';
$user_name=$_SESSION['user_name'];
$sellerid=$_SESSION['sellerid'];
?>
<div class="container margin-container">
<?php
if(isset($_POST['message_submit']))
{
$message_to = $_POST['buyer_name'];
$message_body = $_POST['comment_body'];
$query = "SELECT * from buyer_users WHERE username = '".$message_to."' ";
$run_query = mysqli_query($con,$query);
if(mysqli_num_rows($run_query) == 0)
{
?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Warning:</strong> Please check and Enter again. Buyer not found in our database!
</div>
<?php
}
else
{
$query = "INSERT INTO pvt_msgs(_to, _from, message, _read) VALUES ('".$message_to."','".$user_name."','".$message_body."', 'no')";
$insert_message = mysqli_query($con,$query);
?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success:</strong> Message sent successfully!
</div>
<?php
}
}
//
?>
<div class="row">
<?php if(empty($_GET)) { ?>
<div class="col-md-12 ">
<div class="panel panel-primary panel_setting" >
<div class="panel-heading panel_heading_height">
<span class="glyphicon glyphicon-user font-icon" aria-hidden="true"> Profile</span>
</div>
<div class="panel-body">
<div class="col-sm-offset-6 col-md-2">
<button class="btn btn-success btn-block">
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>
See Orders</button>
</div>
<!--<div class="col-md-2">
<button class="btn btn-success btn-block" data-toggle="modal" data-target="#send_message">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
Send Message</button>-->
<!-- Clicking review button above launches comment modal -->
<!-- <div id="send_message" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Add your Message here!!</h4>
</div>
<div class="modal-body">-->
<!-- form starts here-->
<!--<form id = "message_form" action="" method="POST" enctype="multipart/form-data">
<div class="form-group">
<input type="text" name="buyer_name" placeholder="Enter buyer name to send Message to..." required >
</div>
<div class="form-group">
<textarea class="form-control" name="comment_body" placeholder="your comment goes here..." required></textarea>
</div>
<input type="submit" class="btn btn-block btn-success" value="submit" name="message_submit" > -->
<!-- form ends here-->
<!-- </form> -->
<!-- logic to insert comment-->
<!-- </div>
</div>
</div>
</div> -->
<!--End of comment modal -->
<!--</div>-->
<?php
?>
<div class="col-md-2">
<a class="btn btn-success btn-block" href="msg.php"><span class="glyphicon glyphicon-comment" aria-hidden="true"></span> View Inbox
<?php
$query_notif = "SELECT * FROM pvt_msgs WHERE _to = '".$sellerid."' ";
if($run_query_notif = mysqli_query($con,$query_notif))
{
$no_of_unread_messages = mysqli_num_rows($run_query_notif);
}
$query_notif_badge = "SELECT * FROM pvt_msgs WHERE _to = '".$sellerid."' AND _read = 'no' ";
if($run_query_notif_badge = mysqli_query($con,$query_notif_badge))
{
$no_of_unread_messages_badge = mysqli_num_rows($run_query_notif_badge);
}
if($no_of_unread_messages_badge > 0)
echo '<span class="notification_badge" id="unread_message">'."$no_of_unread_messages".'</span>'; ?>
</a>
</div>
<div class="col-md-2">
<button class="btn btn-success btn-block" data-toggle="modal" data-target="#">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
Message</button>
</div>
</div>
</div> <?php } ?>
</div>
<br>
<div class="row">
<div class="col-md-8 ">
<div class="panel panel-info panel_setting" >
<div class="panel-body">
<!--
<div class="col-md-3">
<button class="btn btn-info btn-block">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
views
</button>
</div>
<div class=" col-md-offset-1 col-md-3">
<button class="btn btn-warning btn-block">
<span class="glyphicon glyphicon-tags" aria-hidden="true"></span>
Products</button>
</div>
<?php if(!empty($_GET)&&($insert==FALSE)) { ?>
<div class=" col-md-offset-1 col-md-3">
<form action="seller_profile.php?id=<?php echo $id;?>" method="post">
<input type="submit" class="btn btn-block btn-info" value="Follow (<?php echo $num_follow; ?>)" name="follow">
</form>
</div>
<?php } else if(empty($_GET)){ ?>
<div class=" col-md-offset-1 col-md-3">
<button class="btn btn-info btn-block">
<span class="glyphicon glyphicon-align-left" aria-hidden="true"></span>
See Followers</button>
</div>
<?php } ?>
<?php if(!empty($_GET)&&($insert==TRUE)){ ?>
<div class=" col-md-offset-1 col-md-3">
<form action="seller_profile.php?id=<?php echo $id;?>" method="post">
<input type="submit" class="btn btn-block btn-info" value=" <?php echo $num_follow; ?> Following" name="following">
</form>
</div>
<?php } ?>
-->
</div>
</div>
</div>
<div class="col-md-4">
<div class="panel panel-info panel_setting" >
<div class="panel-body">
<label>Store Image</label>
<!--<img src="img/product_img/coder.jpg" height="100px">-->
<div class="row">
<div class="col-xs-6 col-md-6">
<a href="#" class="thumbnail">
<img src="<?php echo "img/org_coverimg/".$row['coverimage'].""; ?>" height="100px">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<div class="row">
<?php if(empty($_GET)){ ?>
<div class="col-md-8">
<div class="well well-lg" >
<a href="postproduct.php"><button class="btn btn-warning btn-block" >
<span class="glyphicon glyphicon-cloud-upload" aria-hidden="true"></span>
Add a Product</button></a>
</div>
</div>
<?php } ?>
<div class="col-md-4">
<div class="well well-lg" >
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
<label>Store Name:</label>
<?php echo $row['orgname']; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="well well-lg shared_post">
<center><label>Posts:</label></center>
<div class="row">
<div class="col-xs-6 col-md-4">
<a href="#" class="thumbnail">
<img src="<?php echo "img/product_img/".$img[0].""; ?>" alt = "No More Posts" height="100px">
</a>
</div>
<div class="col-xs-6 col-md-4">
<a href="#" class="thumbnail">
<img src="<?php echo "img/product_img/".$img[1].""; ?>" alt = "No More Posts" height="100px">
</a>
</div>
<div class="col-xs-6 col-md-4">
<a href="#" class="thumbnail">
<img src="<?php echo "img/product_img/".$img[2].""; ?>" alt = "No More Posts" height="100px">
</a>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-4">
<a href="#" class="thumbnail">
<img src="<?php echo "img/product_img/".$img[3].""; ?>" alt = "No More Posts" height="100px">
</a>
</div>
<div class="col-xs-6 col-md-4">
<a href="#" class="thumbnail">
<img src="<?php echo "img/product_img/".$img[4].""; ?>" alt = "No More Posts" height="100px">
</a>
</div>
<div class="col-xs-6 col-md-4">
<a href="#" class="thumbnail">
<img src="<?php echo "img/product_img/".$img[5].""; ?>" alt = "No More Posts" height="100px">
</a>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="well well-lg store_intro">
<center><label>Store Intro:</label>
<br>
<?php echo $row['description']; ?>
</center>
</div>
<?php if(empty($_GET)) { ?>
<a href="seller_account1.php"><button class="btn btn-danger btn-block">
<span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>
Account Setting</button></a>
<?php } ?>
</div>
</div>
</div>
<?php
include("includes/footer.php");
$user_name=$_SESSION['user_name'];
$sellerid=$_SESSION['sellerid'];
?>
</body>
</html>