-
Notifications
You must be signed in to change notification settings - Fork 0
/
deletecustomer.php
259 lines (178 loc) · 5.57 KB
/
deletecustomer.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
<?php
/**
* Make sure you started your'e sessions!
* You need to include su.inc.php to make SimpleUsers Work
* After that, create an instance of SimpleUsers and your'e all set!
*/
session_start();
require_once(dirname(__FILE__)."/simpleusers/su.inc.php");
$SimpleUsers = new SimpleUsers();
// This is a simple way of validating if a user is logged in or not.
// If the user is logged in, the value is (bool)true - otherwise (bool)false.
if( !$SimpleUsers->logged_in )
{
header("Location: login.php");
exit;
}
// If the user is logged in, we can safely proceed.
$users = $SimpleUsers->getUsers();
$resultt = mysqli_query($mysqli, "SELECT * FROM clientinfo ");
$client =1 ;
error_reporting(0);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="docsupport/style.css">
<link rel="stylesheet" href="docsupport/prism.css">
<link rel="stylesheet" href="chosen.css">
<style type="text/css">
* { margin: 0px; padding: 0px; }
body
{
padding: 30px;
font-family: Calibri, Verdana, "Sans Serif";
font-size: 20px;
}
table
{
width: 1500px;
margin: 0px auto;
}
.data th{
padding: 4px;
border: 1px solid #dddddd;
}
.data td{
padding: 4px;
border: 1px solid #dddddd;
}
.right
{
text-align: right;
}
h1
{
color: #FF0000;
border-bottom: 2px solid #000000;
margin-bottom: 15px;
}
p { margin: 10px 0px; }
p.faded { color: #A0A0A0; }
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
</style>
</head>
<body>
<div class="dropdown">
<button class="dropbtn">Users</button>
<div class="dropdown-content">
<a href="users.php">Uses List</a>
<a href="newuser.php">Add New</a>
<a href="createinvoice.php">Create Invoice</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Customer</button>
<div class="dropdown-content">
<a href="customer.php">Customer List</a>
<a href="addcus.php">Add Customer</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Ledger</button>
<div class="dropdown-content">
<a href="customerledger.php">Customer Ledger</a>
<a href="createinvoice.php">Create Invoice</a>
<a href="manual.php">Add Manual Payment</a>
<a href="manualhis.php">Manual Payment History</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">Back Account</button>
<div class="dropdown-content">
<a href="listacc.php">Account List</a>
<a href="showacc.php">Transactions</a>
<a href="addtrans.php">Add Transactions</a>
<a href="addacc.php">Add Account</a>
</div>
</div>
<h1>Customer Ledger</h1>
<a href="createinvoice.php">Add New Customer</a><br/><br/>
<form action="deletecustomer.php" method="post" name="form1">
<table width="25%" border="0">
<table class="data" width='100%' border=0>
<?php if(isset($_POST['Submit'])) {
$client = mysqli_real_escape_string($mysqli, $_POST['client_id']);
$deletecust= (mysqli_query($mysqli, "DELETE FROM `clientinfo` WHERE cid='$client'"));
$getinvoiceid=(mysqli_query($mysqli, "SELECT invoice_no FROM `ledger` WHERE client_id='$client'"));
while($getinvoicebycid = mysqli_fetch_array($getinvoiceid)){
$invoiceno=$getinvoicebycid['invoice_no'];
$deleteitems=(mysqli_query($mysqli, "DELETE FROM `items` WHERE invoice_no='$invoiceno'"));
$deleteledger==(mysqli_query($mysqli, "DELETE FROM `ledger` WHERE client_id='$client'"));
$deletemanualp==(mysqli_query($mysqli, "DELETE FROM `manualp` WHERE client_id='$client'"));
}
} ?>
</table>
<br />
<center> <tr>
<td>Select Client : </td>
<td><?php
echo "<select name='client_id' data-placeholder='Choose a Client...' class='chosen-select' tabindex='2'>";
echo "<option value=''></option>";
while ($rest = mysqli_fetch_array($resultt)) {
if($rest['cid'] == $client){
$isSelected = ' selected="selected"'; // if the option submited in form is as same as this row we add the selected tag
} else {
$isSelected = ''; // else we remove any tag
}
echo "<option value='" . $rest['cid']."'".$isSelected.">" . $rest['name']."-".$rest['company'] ."</option>";
}
echo "</select>";
?></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Select"></td>
</tr></center>
</table>
<script src="docsupport/jquery-3.2.1.min.js" type="text/javascript"></script>
<script src="chosen.jquery.js" type="text/javascript"></script>
<script src="docsupport/prism.js" type="text/javascript" charset="utf-8"></script>
<script src="docsupport/init.js" type="text/javascript" charset="utf-8"></script>
</form>
</body>
</html>