-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnew
116 lines (98 loc) · 3.32 KB
/
new
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
<?php
namespace App\Classes;
use PDO;
use PHPMailer\PHPMailer\Exception;
class QueryClass extends Baseclass{
protected $db_conn;
protected $base;
protected $errors;
function __construct(){
require("db.php");
//Initialize Baseclass
$this->base = new Baseclass();
}
public function displayProductsById($id){
$query = "SELECT `id`,`product`,`category`,`price`,`quantity`,`time` FROM `products`";
$where = [
'id' => $id
];
try{
$products = $this->base->pdoquery($query,$fetch="",$extra_query="",$where);
}catch(Exception $e){
$this->errors = $e->getMessage();
}
return ($products) ? $products : $this->errors;
}
public function displayItems($category){
$query = "SELECT `id`,`product`,`category`,`price`,`quantity`,`time` FROM `products`";
//$extra_query = "GROUP BY product ORDER BY time desc";
$where = [
'category' => $category
];
try{
$products = $this->base->pdoquery($query,$fetch="all",$extra_query,$where);
}catch(Exception $e){
$this->errors = $e->getMessage();
}
return ($products) ? $products : $this->errors;
}
public function relatedItems($category){
$query = "SELECT `id`,`product`,`category`,`price`,`quantity`,`time` FROM `products`";
$extra_query = "GROUP BY product ORDER BY time asc";
$where = [
'category' => $category
];
try{
$products = $this->base->pdoquery($query,$fetch="all",$extra_query,$where);
}catch(Exception $e){
$this->errors = $e->getMessage();
}
return ($products) ? $products : $this->errors;
}
public function getAllCategories(){
$query = "SELECT category FROM `products`";
$extra_query = "GROUP BY category";
$categories = $this->base->pdoquery($query,$fetch="all",$extra_query);
return $categories;
}
public function getImage($category)
{
switch($category){
case 'ANALGESIC':
$image = '../imgfiles/analgesics.jpg';
break;
case 'ANTIBIOTICS':
$image = '../imgfiles/antibiotics.png';
break;
case 'ANTICONVULSANT':
$image = '../imgfiles/anticonvulse.png';
break;
case 'B.P. DRUGS':
$image = '../imgfiles/antibiotics.png';
break;
case 'COUGH/COLD':
$image = '../imgfiles/syrups.jpg';
break;
case 'GENERAL':
$image = '../imgfiles/general.jpeg';
break;
case 'GROCERY':
$image = '../imgfiles/grocery.png';
break;
case 'OINTMENT / CREAM':
$image = '../imgfiles/ointments.jpg';
break;
case 'SUPPLEMENTS':
$image = '../imgfiles/supplements.gif';
break;
case 'VITAMINS':
$image = '../imgfiles/vitamins.gif';
break;
default:
$image = '../imgfiles/general.jpeg';
break;
}
return $image;
}
//public function
}