-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_display.php
156 lines (132 loc) · 5.04 KB
/
client_display.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/db.php';
include 'includes/header.php';
include 'includes/navbar.php';
$sql= "SELECT * FROM users WHERE email = '$username'";
$sql_run = mysqli_query($con, $sql);
$row_a = mysqli_fetch_assoc($sql_run);
$user_id= $row_a['id'];
?>
<div class="app-main__outer">
<div class="app-main__inner">
<div class="app-page-title">
<div class="page-title-wrapper">
<div class="page-title-heading">
<div class="page-title-icon">
<i class="pe-7s-global text-success">
</i>
</div>
<div>Clients
<div class="page-title-subheading">Add, Edit, Delete client data here
</div>
</div>
</div>
<div class="page-title-actions">
<button style="font-size:14px;" type="button" class="btn mr-3 mb-3 btn-primary" data-toggle="modal" data-target="#addclient">
<i class="fa fa-plus"></i> Add Client
</button>
</div>
</div>
</div>
<div class="tab-content">
<div class="tab-pane tabs-animation fade show active" id="tab-content-0" role="tabpanel">
<?php
if(isset($_SESSION['SUCCESS']) && $_SESSION['SUCCESS'] !=''){
echo '<div class="alert alert-success" role="alert"> '.$_SESSION['SUCCESS']. '</div>';
unset($_SESSION['SUCCESS']);
}
if(isset($_SESSION['Failure']) && $_SESSION['Failure'] !=''){
echo '<div class="alert alert-danger" role="alert"> '.$_SESSION['Failure']. '</div>';
unset($_SESSION['Failure']);
}
?>
<div class="main-card mb-3 card">
<div class="card-body">
<?php
$query = "SELECT * FROM buyer_details WHERE user_id='$user_id' ORDER BY `buyer_details`.`buyer_id` DESC ";
$query_run = mysqli_query($con, $query);
?>
<table class="table table-striped table-bordered" id="table" >
<thead align="center">
<tr>
<th> ID </th>
<th>Company Name</th>
<th>Contact</th>
<th>State Code</th>
<th>Edit</th>
<th>Delete</th>
<th>GSTIN</th>
<th>PAN</th>
<th>CIN</th>
</tr>
</thead>
<tbody align="center">
<?php
while($row = mysqli_fetch_assoc($query_run))
{
$x=$row['code'];
$query1 = mysqli_query($con, "SELECT * FROM statecode WHERE state_id='$x'");
$row1 = mysqli_fetch_assoc($query1);
?>
<tr>
<td><?php echo $row['buyer_id'] ?></td>
<td data-toggle="tooltip" title="Address: <?php echo $row['address']; ?>"><?php echo $row['company_name']; ?></td>
<td><?php echo $row['buyer_name']; ?></td>
<td><?php echo $row1['code']; ?></td>
<td>
<form action="client_edit.php" method="post">
<input type="hidden" name="edit_id" value="<?php echo $row['buyer_id']; ?>">
<button type="submit" name="edit_btn" class="btn btn-success"><i class="fa fa-pen"></i></button>
</form>
</td>
<td>
<button type="button" data-id1="<?php echo $row['buyer_id']; ?>" id="deleteclient" class="btn btn-danger"><i class="fa fa-trash"></i></button>
</td>
<td><?php if (empty($row['gst'])){ echo"-"; } else { echo $row['gst']; } ?></td>
<td><?php if (empty($row['pan'])){ echo"-"; } else { echo $row['pan']; } ?></td>
<td><?php if (empty($row['cin'])){ echo"-"; } else { echo $row['cin']; } ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<?php
include('includes/footer.php');
?>
<script>
$(document).ready(function() {
$('#table').DataTable({
"lengthMenu": [[25, 200, 300, -1], [25, 200, 300, "All"]],
"order": [[ 0, "desc" ]],
"columnDefs": [
{
"targets": [ 0 ],
"visible": false,
"searchable": false
},
]
});
});
$(document).on('click', '#deleteclient', function(){
var id=$(this).data("id1");
if(confirm("Are you sure you want to delete this?"))
{
$.ajax({
url:"deleteclient.php",
method:"POST",
data:{id:id},
dataType:"text",
success:function(data){
alert(data);
location.reload();
}
});
}
});
</script>