forked from fotosentez/mutasyon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayments.php
137 lines (126 loc) · 4.56 KB
/
payments.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
<?php
require_once('configs/config.php');
$page_name = "payments";
$smarty->assign("page_name", $page_name);
if(isset($_SESSION['login']))
{
//Add payment
$payment = Check::getValue("payment");
$banklist = Check::getValue("banklist");
$invoiceid = Check::getValue("invoiceid");
$invoiceid1 = Check::getValue("invoiceid1");
$customerid = Check::getValue("customerid");
$date = @$_POST["date"];
$getremain = Check::getValue("getremain");
$ptype = Check::getValue("paytype");
$invoiceno = Check::getValue("invoiceno");
$desc = Check::getValue("desc");
//Add buy payments
$buypayment = Check::getValue("buypayment");
$buyinvoiceid = Check::getValue("buyinvoiceid");
$buyseller = Check::getValue("buyseller");
$buydate = @$_POST["buydate"];
$buybank = Check::getValue("buybank");
$buyremain = Check::getValue("buyremain");
//For transfer
$transfer = Check::getValue("tpayment");
//For add service payments
$serviceid = Check::getValue("serviceid");
$servicepay = Check::getValue("payment");
$servicecust = Check::getValue("custid");
$servicetype = Check::getValue("paytype");
$servicedate = @$_POST["date"];
$serviceremain = Check::getValue("getremain");
$servicebank = Check::getValue("banklist");
$payinvoiceno = Check::getValue("invoiceno");
//For pay to providers
$ppserviceid = Check::getValue("ppserviceid");
$ppayment = Check::getValue("ppayment");
$providersid = Check::getValue("providersid");
$serviceinvoiceno = Check::getValue("serviceinvoiceno");
$ppremain = Check::getValue("ppremain");
$ppbanklist = Check::getValue("ppbanklist");
$ptotalpayment = Check::getValue("ptotalpayment");
$ptotalpayment2 = Check::getValue("ptotalpayment2");
$ppdate = @$_POST["ppdate"];
if($_POST)
{
//Add payments
if($payment OR $invoiceid1)
{
require_once('payments/addpayments.php');
}
if($buypayment)
{
require_once('payments/addbuypayments.php');
}
if($transfer)
{
require_once('payments/transfer.php');
}
if($serviceid and $servicedate)
{
require_once('service/addservicepayments.php');
}
if($ppserviceid OR $providersid)
{
require_once('providers/addproviderspayments.php');
}
}
else
{
$page = Check::getValue("page");
$totalinv = $db->query("SELECT * FROM payments");
$countinv = $totalinv->rowCount();
//Total page
$pp = 20;
$pagetotal = ceil($countinv/$pp);
if($page)
{
$start = ($page-1)*$pp;
}
else
{
$start = 0;
}
if(!$page)
{
echo '<script type="text/javascript">window.location.href="payments.php?page=1";</script>';
}
$paymentlist = $db->query('
SELECT *, (SELECT bank_name FROM bank WHERE bank.bank_id = payments.payment_bankto_id) AS bankto FROM payments
LEFT JOIN customer ON payment_customer_id = cust_id
LEFT JOIN invoice ON payment_invoice_id = invoice_id
LEFT JOIN providerspyments ON pp_id = payment_pp_id
LEFT JOIN providers ON providers_id = pp_providers_id
LEFT JOIN seller ON seller_id = payment_seller_id
INNER JOIN bank ON payment_bank_id = bank_id
INNER JOIN admin ON payment_admin_id = admin_id
ORDER BY payment_id DESC LIMIT '.$start.', '.$pp.'');
$bank = $db->query("SELECT * FROM bank WHERE bank_active <> 0");
$banks = array();
foreach($bank as $c)
{
$banks[] = $c;
}
$type = $db->query("SELECT * FROM paytype");
$invoice = $db->query("
SELECT *, (SELECT TRUNCATE(SUM(ip_total), 2) FROM invoicedproducts WHERE ip_invoice_id = invoice.invoice_id) AS invtotal, (SELECT TRUNCATE(SUM(payment_amount), 2) FROM payments WHERE payments.payment_invoice_id = invoice.invoice_id) AS paytotal, (SELECT TRUNCATE(SUM(payment_amount), 2) FROM payments WHERE payments.payment_service_id = invoice.invoice_id) AS servicetotal FROM invoice
LEFT JOIN payments ON payments.payment_invoice_id = invoice.invoice_id
LEFT JOIN bank ON bank.bank_id = payments.payment_bank_id
WHERE invoice.invoice_cancelled <> 1 GROUP BY invoice_id
");
$smarty->assign(array(
"paymentlist" => $paymentlist,
"bank" => $banks,
"paytype" => $type,
"invoice" => $invoice,
"pagetotal" => $pagetotal,
));
$smarty->display(theme_base.'payments.html');
}
}// login
else
{
$smarty->display(theme_base.'login.html');
}