-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcancelinvoice.php
187 lines (181 loc) · 5.93 KB
/
cancelinvoice.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
<?php
require_once('configs/config.php');
$page_name = "cancelinvoice";
$smarty->assign("page_name", $page_name);
if(isset($_SESSION['login']))
{
$refund = Check::getValue("refund");
$date = @$_POST["date"];
$due = Check::getValue("cancdue");
$paycancdesc = Check::getValue("paycancdesc");
$password = Check::getValue("password");
$id = Check::getValue("invoiceid");
$seid = Check::getValue("serviceid");
$buyid = Check::getValue("buyid");
$paytype = Check::getValue("paytype");
//Get paytotal
if($id)
{
$invoiceamount = $db->query("SELECT *, (SELECT TRUNCATE(SUM(payment_amount), 2) FROM payments WHERE payment_invoice_id = invoice_id AND payment_invoice_id <> 0 AND payment_in_out = 'in' ) AS paytotal FROM invoice LEFT JOIN payments ON payment_invoice_id = invoice_id WHERE invoice_id = '".$id."' GROUP BY invoice_id");
foreach($invoiceamount as $inv)
{
$paytotal = $inv["paytotal"];
$bankid = $inv["payment_bank_id"];
$custid = $inv["invoice_customer_id"];
$iscanc = $inv["invoice_cancelled"];
$bdesc = $inv["payment_desc"];
}
}
else if($seid)
{
$invoiceamount = $db->query("SELECT *, (SELECT TRUNCATE(SUM(payment_amount), 2) FROM payments WHERE payment_service_id = invoice_id AND payment_service_id <> 0 AND payment_in_out = 'in' ) AS paytotal, (SELECT TRUNCATE(SUM(payment_amount), 2) FROM payments WHERE payment_service_id = invoice_id AND payment_service_id <> 0 AND payment_in_out = 'out' ) AS paytoproviders FROM invoice LEFT JOIN providerspyments ON pp_providers_id = invoice_providers LEFT JOIN payments ON payment_service_id = invoice_id WHERE invoice_id = '".$seid."' GROUP BY invoice_id");
foreach($invoiceamount as $inv)
{
$paytotal = $inv["paytotal"];
$bankid = $inv["payment_bank_id"];
$custid = $inv["invoice_customer_id"];
$iscanc = $inv["invoice_cancelled"];
$bdesc = $inv["invoice_description"];
$paymentsdesc = $inv["payment_desc"];
$paytoproviders = $inv["paytoproviders"];
$pp_ok = $inv["pp_ok"];
$bproviders = $inv["invoice_providers"];
}
}
else if($buyid)
{
$invoiceamount = $db->query("SELECT *, TRUNCATE(SUM(payment_amount), 2) AS paytotal FROM payments INNER JOIN buyinvoice ON bi_id = payment_bi_id WHERE payment_bi_id = '".$buyid."' ");
foreach($invoiceamount as $inv)
{
$paytotal = $inv["paytotal"];
$iscanc = $inv["bi_cancel"];
$bankid = $inv["payment_bank_id"];
$sid = $inv["payment_seller_id"];
$bdesc = $inv["bi_desc"];
}
}
if($refund <= $paytotal OR $paytotal == NULL)
{
echo "<script>$('.refund').removeClass('alert-danger')</script>";
$vrefund = 1;
}
else
{
$infmax = $smarty->getVariable('_inf_maximum_amount');
echo $infmax.$paytotal."<script>$('.refund').addClass('alert-danger')</script>";
echo "<script>return false</script>";
$vrefund = 0;
exit();
}
if($vrefund == 1)
{
if(Check::dateCheck($date)==1)
{
echo "<script>$('.cidate').removeClass('alert-danger')</script>";
$vdate=1;
}
else
{
$infnotblank = $smarty->getVariable('_inf_not_valid');
echo $infnotblank."!<script>$('.cidate').addClass('alert-danger')</script>";
echo "<script>return false</script>";
$vdate = 0;
exit();
}
}
if($vrefund == 1 AND $vdate ==1)
{
if($paytype == "empty" OR $paytype == "")
{
$infnotblank = $smarty->getVariable('_inf_not_valid');
echo $infnotblank."<script>$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');$('.radioBtn').css('border', '2px solid red');</script>";
echo "<script>return false</script>";
$vype = 0;
exit();
}
else
{
echo "<script>$('textarea').removeClass('alert-danger');$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');$('.radioBtn').css('border', '')</script>";
$vype = 1;
}
}
if($vrefund == 1 AND $vdate ==1 AND $vype == 1)
{
if($due == "")
{
$infadddesc = $smarty->getVariable('_inf_add_desc');
echo $infadddesc."<script>$('.cidue').addClass('alert-danger')</script>";
echo "<script>return false</script>";
$vdue = 0;
exit();
}
else
{
echo "<script>$('.cidue').removeClass('alert-danger')</script>";
$vdue = 1;
}
}
if($vrefund == 1 AND $vdate ==1 AND $vype == 1 AND $vdue == 1)
{
if($password == "")
{
$infpassword = $smarty->getVariable('_inf_password');
echo $infpassword."<script>$('.cipasswd').addClass('alert-danger')</script>";
echo "<script>return false</script>";
$vpass = 0;
exit();
}
if ($password != "")
{
if(md5($password) != $admin_password)
{
$_SESSION["login"]++;
$infnotvalidpassword = $smarty->getVariable('_inf_not_valid_password');
echo $infnotvalidpassword.(4-$_SESSION["login"]).'<br />';
echo "<script>return false</script>";
$vpass = 0;
}
else
{
$_SESSION["login"] = 1;
echo "<script>$('.cipasswd').removeClass('alert-danger')</script>";
$vpass = 1;
}
if ($_SESSION["login"] > 3)
{
unset($_SESSION['login']);
header("location: index.php");
exit();
}
}
}
if($vrefund == 1 AND $vdate ==1 AND $vype == 1 AND $vdue == 1 AND $vpass == 1)
{
if($iscanc == 0)
{
if($id)
{
require_once('invoice/cancelinvoice/cancelinvoice.php');
}
else if($buyid)
{
require_once('invoice/cancelinvoice/cancelbuyinvoice.php');
}
else if($seid)
{
require_once('invoice/cancelinvoice/cancelservice.php');
}
$infworksuccess = $smarty->getVariable('_inf_work_success');
echo $infworksuccess;
}
else
{
$infcancelagain = $smarty->getVariable('_inf_invoice_cancelled_again');
echo $infcancelagain;
}
}
}//login
else
{
$smarty->display(theme_base.'login.html');
} //else login