-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate_payment.php
291 lines (244 loc) · 12.8 KB
/
update_payment.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
<?php
include_once("init.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PDV Web - Update Payment</title>
<!-- Stylesheets -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="js/date_pic/date_input.css">
<!-- Optimize for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- jQuery & JS files -->
<?php include_once("tpl/common_js.php"); ?>
<script src="js/date_pic/jquery.date_input.js"></script>
<script src="js/script.js"></script>
<script src="js/update_payment.js"></script>
</head>
<body>
<!-- TOP BAR -->
<?php include_once("tpl/top_bar.php"); ?>
<!-- end top-bar -->
<!-- HEADER -->
<div id="header-with-tabs">
<div class="page-full-width cf">
<ul id="tabs" class="fl">
<li><a href="dashboard.php" class="dashboard-tab">Dashboard</a></li>
<li><a href="view_sales.php" class="sales-tab">Sales</a></li>
<li><a href="view_customers.php" class=" customers-tab">Customers</a></li>
<li><a href="view_purchase.php" class="purchase-tab">Purchase</a></li>
<li><a href="view_supplier.php" class=" supplier-tab">Supplier</a></li>
<li><a href="view_product.php" class="stock-tab">Stocks / Products</a></li>
<li><a href="view_payments.php" class="active-tab payment-tab">Payments / Outstandings</a></li>
<li><a href="view_report.php" class="Relatórios-tab">Relatórioss</a></li>
</ul>
<!-- end tabs -->
<!-- Change this image to your own company's logo -->
<!-- The logo will automatically be resized to 30px height. -->
<a href="#" id="company-branding-small" class="fr"><img src="<?php if (isset($_SESSION['logo'])) {
echo "upload/" . $_SESSION['logo'];
} else {
echo "upload/posnic.png";
} ?>" alt="PDV Web"/></a>
</div>
<!-- end full-width -->
</div>
<!-- end header -->
<!-- MAIN CONTENT -->
<div id="content">
<div class="page-full-width cf">
<div class="side-menu fl">
<h3>Payment</h3>
<ul>
<li><a href="view_payments.php">Payments</a></li>
<li><a href="view_out_standing.php">Out standings</a></li>
</ul>
<div style="width: auto;height: 300px;background: #ffffff">
<br><br>
<table>
<tr>
<td width="183">Total de Produtos Cadastrados</td>
</tr>
<tr>
<td width="84"><strong><?php echo $count = $db->countOfAll("stock_avail"); ?> </strong>
</td>
</tr>
<tr>
<tr>
<td> </td>
</tr>
<tr>
<td width="110">Payment Pending:</td>
</tr>
<tr>
<td width="110"><strong><?php
echo $db->queryUniqueValue("select sum(balance) FROM stock_entries where count1=1 and type='entry'");
?></strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Tatal Sales:</td>
</tr>
<tr>
<td>
<strong><?php echo $age = $db->queryUniqueValue("SELECT sum(subtotal) FROM stock_sales where count1=1 "); ?></strong>
</td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Outstanding Amount:</td>
</tr>
<tr>
<td>
<strong><?php echo $db->queryUniqueValue("select sum(balance) FROM stock_sales where count1=1 ");
?></strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Total de Fornecedores Cadastrados</td>
</tr>
<tr>
<td><strong><?php echo $count = $db->countOfAll("supplier_details"); ?></strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>Total de Clientes Cadastrados</td>
</tr>
<tr>
<td><strong><?php echo $count = $db->countOfAll("customer_details"); ?></strong></td>
</tr>
</table>
<br><br>
</div>
</div>
<!-- end side-menu -->
<div class="side-content fr">
<div class="content-module">
<div class="content-module-heading cf">
<h3 class="fl">Update Payment</h3>
<span class="fr expand-collapse-text">CLIQUE PARA FECHAR</span>
<span class="fr expand-collapse-text initial-expand">CLIQUE PARA ABRIR</span>
</div>
<!-- end content-module-heading -->
<div class="content-module-main cf">
<form name="form1" method="post" id="form1" action="">
<table class="form" border="0" cellspacing="0" cellpadding="0">
<?php
if (isset($_POST['id'])) {
$id = mysqli_real_escape_string($db->connection, $_POST['id']);
$balance = mysqli_real_escape_string($db->connection, $_POST['balance']);
$payment = mysqli_real_escape_string($db->connection, $_POST['paid']);
$customer = mysqli_real_escape_string($db->connection, $_POST['customer']);
$subtotal = mysqli_real_escape_string($db->connection, $_POST['total']);
$newpayment = mysqli_real_escape_string($db->connection, $_POST['new_payment']);
$newpayment = empty($_POST['new_payment']) ? 0:$newpayment;
$selected_date = $_POST['date'];
$selected_date = strtotime($selected_date);
$mysqldate = date('Y-m-d', $selected_date);
$due = $mysqldate;
$balance = (int)$balance - (int)$newpayment;
$payment = (int)$payment + (int)$newpayment;
$max = $db->maxOfAll("id", "transactions");
$receiptid = "RCPT" . $max;
if ($db->query("UPDATE stock_sales SET balance=$balance,payment=$payment,due='$due' where transactionid='$id'")) {
$db->query("INSERT INTO transactions(type,customer,payment,balance,rid,due,subtotal,receiptid) values('sales','$customer','$newpayment','$balance','$id','$due','$subtotal','$receiptid')");
$max = $db->maxOfAll("id", "transactions");
echo "<br><font color=green size=+1 > [ $id ] Customer Details Updated!</font>";
echo "<script>window.open('payment_receipt_print.php?sid=$max','myNewWinsr','width=620,height=800,toolbar=0,menubar=no,status=no,resizable=yes,location=no,directories=no');</script>";
} else
echo "<br><font color=red size=+1 >Erro ao Gravar !</font>";
}
?>
<?php
if (isset($_GET['sid']))
$id = $_GET['sid'];
$line = $db->queryUniqueObject("SELECT * FROM stock_sales WHERE transactionid='$id'");
?>
<form name="form1" method="post" id="form1" action="">
<input name="id" type="hidden" value="<?php echo $_GET['sid']; ?>">
<tr>
<td> </td>
<td>Sales ID</td>
<td><input name="stock_id" type="text" readonly="readonly" readonly="readonly"
id="stockid" maxlength="200" class="round default-width-input"
value="<?php echo $line->transactionid; ?> "/>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Customer</td>
<td><input name="customer" type="text" id="customer" maxlength="200"
readonly="readonly" class="round default-width-input"
value="<?php echo $line->customer_id; ?> "/></td>
<td>Total</td>
<td><input name="total" type="text" id="tatal" maxlength="20" readonly="readonly"
class="round default-width-input"
value="<?php echo $line->subtotal; ?>"/></td>
</tr>
<tr>
<td> </td>
<td>Paid</td>
<td><input name="paid" type="text" id="paid" maxlength="20" readonly="readonly"
class="round default-width-input"
value="<?php echo $line->payment; ?>"
onkeypress="return numbersonly(event)"/></td>
<td>Balance</td>
<td><input name="balance" type="text" id="balance" readonly="readonly"
maxlength="20" class="round default-width-input"
value="<?php echo $line->balance; ?>"
onkeypress="return numbersonly(event)"/></td>
</tr>
<tr>
<td></td>
<td>New Date</td>
<td><input name="date" type="text" id="test1" maxlength="20"
class="round default-width-input"
value="<?php echo date("Y/m/d") ?>"/></td>
<td>New Payment</td>
<td><input name="new_payment" id="new_payment" type="text"
onkeypress="return numbersonly(event)" maxlength="20"
onkeyup="change_balance()" class="round default-width-input"
/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<input class="button round blue image-right ic-add text-upper" type="submit"
name="Submit" value="Gravar">
(Control + S)
</td>
<td align="right"><input class="button round red text-upper" type="reset"
name="Reset" value="Reset">
</td>
<td> </td>
</tr>
</table>
</form>
</div>
<!-- end content-module-main -->
</div>
<!-- end content-module -->
</div>
<!-- end full-width -->
</div>
<!-- end content -->
<!-- FOOTER -->
<div id="footer">
<p>Nome da Empresa - www.nomedaempresa.com.br</a>.
</p>
</div>
<!-- end footer -->
</body>
</html>