-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathaddproduct.php
117 lines (109 loc) · 3.55 KB
/
addproduct.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
<?php
require_once('configs/config.php');
$page_name = "addproduct";
$smarty->assign("page_name", $page_name);
if(isset($_SESSION['login']))
{
//Connect tax db
$categories = $db->query("SELECT * FROM category WHERE category_sub = 0");
//Connect category db
$category = $db->query("SELECT * FROM category WHERE category_sub <> 0");
//Connect seller db
$seller = $db->query("SELECT * FROM seller");
//Add Products
$product_name = Check::getValue("product_name");
$short_desc = Check::getValue("short_desc");
if($short_desc == "")
{
$short_desc = $product_name;
}
$product_detail = @$_POST["product_detail"];
if(Check::isCleanHtml($product_detail) != 1)
{
$product_detail = strip_tags($product_detail);
}
$product_no = Check::getValue("product_no");
$product_price = Check::getValue("product_price");
$product_amount = Check::getValue("product_amount");
$product_category = Check::getValue("product_category");
/*
------------------------------------------------------------------------------------------
Add products
------------------------------------------------------------------------------------------
*/
if($product_name)
{
if($product_name == "")
{
echo "<script>$('input').removeClass('alert-danger');$('input[name=product_name]').addClass('alert-danger');</script>";
echo "<script>return false</script>";
$vname = 0;
exit();
}
else
{
$vname = 1;
}
if($vname == 1)
{
$checknoexist = $db->query("SELECT COUNT(stock_no) AS stockno FROM stock WHERE stock_no = '".$product_no."' ");
foreach($checknoexist as $sn)
{
$nototal = $sn["stockno"];
}
if($nototal > 0)
{
$infnotakebefore = $smarty->getVariable('_inf_number_take_before');
echo $infnotakebefore."<script>$('input').removeClass('alert-danger');$('input[name=product_no]').addClass('alert-danger');</script>";
echo "<script>return false</script>";
$vno = 0;
exit();
}
if($product_no == "")
{
$infnotblank = $smarty->getVariable('_inf_not_valid');
echo $infnotblank."<script>$('input').removeClass('alert-danger');$('input[name=product_no]').addClass('alert-danger');</script>";
echo "<script>return false</script>";
$vno = 0;
exit();
}
else
{
echo "<script>$('input').removeClass('alert-danger');</script>";
$vno = 1;
}
}
if($vname == 1 and $vno == 1)
{
if($product_category == "empty" OR $product_category == "")
{
echo "<script>$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');$('select[name=product_category]').addClass('alert-danger');</script>";
echo "<script>return false</script>";
$vcategory = 0;
exit();
}
else
{
echo "<script>$('input').removeClass('alert-danger');$('select').removeClass('alert-danger');</script>";
$vcategory = 1;
}
}
if($vname == 1 and $vno == 1 and $vcategory == 1)
{
require_once('product/addproduct.php');
}
}
else
{
$smarty->assign(array(
"categories" => $categories,
"category" => $category,
"seller" => $seller,
));
$smarty->display(theme_base.'addproduct.html');
}
}// if login
else
{
$smarty->display(theme_base.'login.html');
}