-
Notifications
You must be signed in to change notification settings - Fork 12
/
seller.php
125 lines (111 loc) · 4.2 KB
/
seller.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
<?php
require_once('configs/config.php');
$page_name = "seller";
$smarty->assign("page_name", $page_name);
$success = 0;
if($_SESSION['login']){
//For update
$seller_id = Check::getValue('seller_id');
$seller_name = Check::getValue('seller_name');
$seller_iban = Check::getValue('seller_iban');
$seller_address = Check::getValue('seller_address');
$seller_tel = Check::getValue('seller_tel');
$seller_mail = @$_POST["seller_mail"];
$seller_web = Check::getValue('seller_web');
//For add
$sellername = Check::getValue('sellerName');
$selleriban = Check::getValue('selleriban');
$selleraddress = Check::getValue('sellerAddress');
$sellertel = Check::getValue('sellerTel');
$sellermail = @$_POST["sellermail"];
$sellerweb = Check::getValue('sellerweb');
//For Delete
$delsellerid = Check::getValue("delsellerid");
//For add seller
if($sellername)
{
if($sellername == "" OR $sellername == "empty")
{
$infnotblank = $smarty->getVariable('_inf_not_valid');
echo $infnotblank."<script>$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');$('input[name=sellerName]').addClass('alert-danger');</script>";
echo "<script>return false</script>";
$vaname = 0;
exit();
}
else
{
echo "<script>$('textarea').removeClass('alert-danger');$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');</script>";
$vaname = 1;
}
if($vaname == 1)
{
if($selleriban == "")
{
$newiban = "";
echo "<script>$('textarea').removeClass('alert-danger');$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');</script>";
$viban = 1;
}
else
{
$newiban = str_replace(" ", "", $selleriban);
if(!is_numeric($newiban))
{
$infnumeric = $smarty->getVariable('_inf_numeric');
echo $infnumeric."<script>$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');$('input[name=selleriban]').addClass('alert-danger');</script>";
echo "<script>return false</script>";
$viban = 0;
exit();
}
else
{
echo "<script>$('textarea').removeClass('alert-danger');$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');</script>";
$viban = 1;
}
}
}
if($vaname == 1 and $viban == 1)
{
$selleradd = $db->prepare("INSERT INTO seller (seller_name, seller_iban, seller_address, seller_tel, seller_mail, seller_web) VALUES (:name, :iban, :address, :tel, :mail, :web)");
$selleradd->execute(array(
'name'=>$sellername,
'iban'=>$newiban,
'address'=>$selleraddress,
'tel'=>$sellertel,
'mail'=>$sellermail,
'web'=>$sellerweb,
));
$infaddentry = $smarty->getVariable('_inf_add_success');
echo $infaddentry.'<script>$("#seller").load(location.href + " #seller");$(".addsellerm").click()</script>';
}
}//add seller
else if($seller_name)
{
if(Check::email($seller_mail)==1)
{
$seller_update = $db->prepare("UPDATE seller SET seller_name=:sname, seller_iban=:siban, seller_address=:saddress, seller_tel=:stel, seller_mail=smail, seller_web=:sweb WHERE seller_id = sid");
$seller_update->execute(array(
'sname'=>$seller_name,
'siban'=>$seller_iban,
'saddress'=>$seller_address,
'stel'=>$seller_tel,
'smail'=>$seller_mail,
'sweb'=>$seller_web,
'sid'=>$seller_id,
));
echo "Satıcı bilgisi güncellendi";
}
else
{
echo "<script>$('input[name=seller_mail]').addClass('alert-danger');</script>";
echo "<script>return false;</script>";
}
}//update seller
else if($delsellerid)
{
$seller_delete = $db->query("DELETE FROM seller WHERE seller.seller_id = '$delsellerid' ");
echo "Satıcı başarıyla silindi";
}//delete seller
}//login
else{
$smarty->display(theme_base.'login.html');
}