Skip to content

Commit a73103d

Browse files
committed
Class 15 added
1 parent 8c448a5 commit a73103d

File tree

7,131 files changed

+646168
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,131 files changed

+646168
-0
lines changed
23.2 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
68 Bytes
Binary file not shown.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
$filepath = realpath(dirname(__FILE__));
3+
include_once ($filepath .'/../lib/Database.php');
4+
include_once ($filepath .'/../lib/Format.php');
5+
?>
6+
7+
<?php
8+
9+
class Brand
10+
{
11+
12+
private $db;
13+
private $fm;
14+
15+
public function __construct()
16+
{
17+
$this->db = new Database();
18+
$this->fm = new Format();
19+
}
20+
21+
22+
public function insert($brandname,$status)
23+
{
24+
$brandname = $this->fm->validation($brandname);
25+
$brandname = mysqli_real_escape_string($this->db->link,$brandname);
26+
$status = $status;
27+
28+
if (empty($brandname) || empty($status))
29+
{
30+
$msg = '<div class="alert alert-danger fade in">
31+
<a href="#" class="close" data-dismiss="alert">&times;</a>
32+
<strong>Error!</strong> Brand field must not be empty !
33+
</div>';
34+
return $msg;
35+
}
36+
else
37+
{
38+
$insert ="INSERT INTO tbl_brand(brandname,status)VALUES('$brandname','$status')";
39+
40+
41+
$brandinsert = $this->db->insert($insert);
42+
if ($brandinsert)
43+
{
44+
$msg = '<div class="alert alert-success fade in">
45+
<a href="#" class="close" data-dismiss="alert">&times;</a>
46+
<strong>Success!</strong> Brand insert Successfully !
47+
</div>';
48+
return $msg;
49+
}
50+
else
51+
{
52+
$msg = '<div class="alert alert-danger fade in">
53+
<a href="#" class="close" data-dismiss="alert">&times;</a>
54+
<strong>Error!</strong> Brand insert failed !
55+
</div>';
56+
return $msg;
57+
}
58+
}
59+
}
60+
61+
public function show()
62+
{
63+
$query = "SELECT * FROM tbl_brand ORDER BY id DESC";
64+
$result = $this->db->select($query);
65+
return $result;
66+
}
67+
68+
69+
70+
public function edit($id){
71+
72+
$query = "SELECT * FROM tbl_brand WHERE id = '$id'";
73+
74+
$result = $this->db->select($query);
75+
return $result;
76+
77+
}
78+
79+
public function update($brandname,$status,$id){
80+
81+
$brandname = $this->fm->validation($brandname);
82+
$brandname = mysqli_real_escape_string($this->db->link,$brandname);
83+
84+
85+
if (empty($brandname))
86+
{
87+
$msg = '<div class="alert alert-danger fade in">
88+
<a href="#" class="close" data-dismiss="alert">&times;</a>
89+
<strong>Error!</strong> Brand field must not be empty !
90+
</div>';
91+
return $msg;
92+
}
93+
else
94+
{
95+
$update ="UPDATE tbl_brand SET brandname ='$brandname', status ='$status' WHERE id='$id'";
96+
97+
98+
$brandupdate = $this->db->update($update);
99+
if ($brandupdate)
100+
{
101+
$msg = '<div class="alert alert-success fade in">
102+
<a href="#" class="close" data-dismiss="alert">&times;</a>
103+
<strong>Success!</strong> Brand update Successfully !
104+
</div>';
105+
return $msg;
106+
}
107+
else
108+
{
109+
$msg = '<div class="alert alert-danger fade in">
110+
<a href="#" class="close" data-dismiss="alert">&times;</a>
111+
<strong>Error!</strong> Brand update failed !
112+
</div>';
113+
return $msg;
114+
}
115+
}
116+
}
117+
118+
119+
public function delete($id)
120+
{
121+
$query = "DELETE FROM tbl_brand WHERE id ='$id'";
122+
$brandDel = $this->db->delete($query);
123+
if ($brandDel)
124+
{
125+
$msg = '<div class="alert alert-success fade in">
126+
<a href="#" class="close" data-dismiss="alert">&times;</a>
127+
<strong>Success!</strong> Brand delete Successfully !
128+
</div>';
129+
return $msg;
130+
}
131+
else
132+
{
133+
$msg = '<div class="alert alert-danger fade in">
134+
<a href="#" class="close" data-dismiss="alert">&times;</a>
135+
<strong>Success!</strong> Brand delete Failed!
136+
</div>';
137+
return $msg;
138+
}
139+
140+
}
141+
142+
}
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
<?php
2+
$filepath = realpath(dirname(__FILE__));
3+
include_once ($filepath .'/../lib/Database.php');
4+
include_once ($filepath .'/../lib/Format.php');
5+
?>
6+
7+
<?php
8+
9+
class Cart
10+
{
11+
12+
private $db;
13+
private $fm;
14+
15+
public function __construct()
16+
{
17+
$this->db = new Database();
18+
$this->fm = new Format();
19+
}
20+
21+
22+
public function addToCart($quantity,$id)
23+
{
24+
25+
$quantity = $this->fm->validation($quantity);
26+
27+
$quantity = mysqli_real_escape_string($this->db->link,$quantity);
28+
$productId = mysqli_real_escape_string($this->db->link,$id);
29+
$sId = session_id();
30+
31+
if($quantity<=0){
32+
$msg ="Please enter quantity at least 1";
33+
return $msg;
34+
}
35+
36+
37+
$squery = "SELECT * FROM tbl_product WHERE id = '$productId'";
38+
$result = $this->db->select($squery)->fetch_assoc();
39+
40+
$productName = $result['product_name'];
41+
$price = $result['price'];
42+
$image = $result['image'];
43+
44+
$checkProduct = "SELECT * FROM tbl_cart WHERE product_id ='$productId' AND s_id='$sId'";
45+
46+
$result = $this->db->select($checkProduct);
47+
if ($result) {
48+
$msg ="This product already add to Cart";
49+
return $msg;
50+
}
51+
else
52+
{
53+
$query = "INSERT INTO tbl_cart(s_id,product_id,product_name,price,quantity,image)
54+
VALUES('$sId','$productId','$productName','$price','$quantity','$image')";
55+
56+
$inserted_row = $this->db->insert($query);
57+
if ($inserted_row)
58+
{
59+
echo '<script>window.location="cart.php"</script>';
60+
// $msg ="This product add to Cart Successfully";
61+
// return $msg;
62+
}
63+
else
64+
{
65+
66+
echo '<script>window.location="404.php"</script>';
67+
}
68+
}
69+
}
70+
71+
public function getCartProduct()
72+
{
73+
$sId = session_id();
74+
$query = "SELECT * FROM tbl_cart WHERE s_id = '$sId'";
75+
$result = $this->db->select($query);
76+
return $result;
77+
78+
79+
}
80+
81+
82+
public function UpdateCart($cartId,$quantity)
83+
{
84+
$cartId = mysqli_real_escape_string($this->db->link,$cartId);
85+
$quantity = mysqli_real_escape_string($this->db->link,$quantity);
86+
87+
if($quantity<=0){
88+
$msg ="Please enter quantity at least 1";
89+
return $msg;
90+
}
91+
92+
93+
$query ="UPDATE tbl_cart SET quantity='$quantity' WHERE cart_id='$cartId'";
94+
95+
$cartupdate = $this->db->insert($query);
96+
if ($cartupdate)
97+
{
98+
//header("Location:cart.php");
99+
echo '<script>window.location="cart.php"</script>';
100+
}
101+
else
102+
{
103+
$msg = "<span class='error'>Cart update Failed</span>";
104+
return $msg;
105+
}
106+
}
107+
108+
109+
public function delPorductByCart($delId)
110+
{
111+
$delId = mysqli_real_escape_string($this->db->link,$delId);
112+
113+
$query = "DELETE FROM tbl_cart WHERE cart_id ='$delId'";
114+
$deldata = $this->db->delete($query);
115+
if ($deldata)
116+
{
117+
echo "<script> window.location= cart.php</script>";
118+
119+
}
120+
else
121+
{
122+
$msg = "<span class='error'>Cart item not Deleted </span>";
123+
return $msg;
124+
}
125+
}
126+
127+
public function checkCartTable()
128+
{
129+
$sId = session_id();
130+
$query = "SELECT * FROM tbl_cart WHERE s_id = '$sId'";
131+
$result = $this->db->select($query);
132+
return $result;
133+
}
134+
135+
136+
137+
public function addCustomerOrder($cmrId){
138+
139+
$sId = session_id();
140+
141+
$query = "SELECT * FROM tbl_cart WHERE s_id = '$sId'";
142+
$getPro = $this->db->select($query);
143+
144+
if ($getPro) {
145+
while ($result = $getPro->fetch_assoc()) {
146+
147+
$productId = $result['product_id'];
148+
$productName = $result['product_name'];
149+
$quantity = $result['quantity'];
150+
$price = $result['price']*$quantity;
151+
$image = $result['image'];
152+
153+
154+
$query = "INSERT INTO tbl_order(cmrId,productId,productName,quantity,price,image,status,orderdate)
155+
VALUES('$cmrId','$productId','$productName','$quantity','$price','$image',0,now())";
156+
$inserted_row = $this->db->insert($query);
157+
}
158+
}
159+
160+
}
161+
162+
163+
public function delCustomerCart()
164+
{
165+
$sId = session_id();
166+
$query = "DELETE FROM tbl_cart WHERE s_id = '$sId'";
167+
$result = $this->db->delete($query);
168+
169+
}
170+
171+
172+
public function getCustomerOroder($cmrId){
173+
174+
$query = "SELECT * FROM tbl_order WHERE cmrId = '$cmrId'";
175+
$getOrder = $this->db->select($query);
176+
177+
return $getOrder;
178+
}
179+
180+
181+
public function getAllOrderProduct()
182+
{
183+
$query = "SELECT tbl_order.id,tbl_order.productName,tbl_order.quantity,tbl_order.price,tbl_order.orderdate,tbl_order.status,tbl_customer.id,tbl_customer.name FROM tbl_order INNER JOIN tbl_customer ON tbl_order.cmrId = tbl_customer.id ORDER BY tbl_order.id DESC";
184+
$result = $this->db->select($query);
185+
return $result;
186+
}
187+
188+
public function GetCustomerinfo($cmrId)
189+
{
190+
$query = "SELECT * FROM tbl_customer WHERE id = '$cmrId'";
191+
$getinfo = $this->db->select($query);
192+
193+
return $getinfo;
194+
}
195+
196+
public function GetCustomerProduct($cmrId)
197+
{
198+
$query = "SELECT * FROM tbl_order WHERE cmrId = '$cmrId'";
199+
$getinfo = $this->db->select($query);
200+
201+
return $getinfo;
202+
}
203+
204+
public function CustomerOderupdate($cmrId)
205+
{
206+
$query = "UPDATE tbl_order SET status='1' WHERE cmrId = '$cmrId'";
207+
$statusupdate = $this->db->update($query);
208+
209+
return $statusupdate;
210+
}
211+
212+
public function DeleteCoustomerOder($cmrId)
213+
{
214+
$query = "DELETE FROM tbl_order WHERE cmrId = '$cmrId'";
215+
$result = $this->db->delete($query);
216+
if ($result) {
217+
$msg = "<span class='text-success'>Oder delete Successfully</span>";
218+
return $msg;
219+
}else
220+
{
221+
$msg = "<span class='text-danger'>Oder delete failed</span>";
222+
return $msg;
223+
}
224+
225+
}
226+
227+
228+
}

0 commit comments

Comments
 (0)