-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory_header1.php
207 lines (192 loc) · 6.04 KB
/
category_header1.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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!-- CONNECTION / CLASSES / GLOBAL FUNCTIONS -->
<?php
/* CLASSES */
class sqlCONNECTION
{
private $link;
//constructor connnects to db
/* CHANGE INFO TO APN DB (ONLY NEED TO LOGIN CREDENTIALS HERE)*/
function __construct()
{
$servername = '127.0.0.1:3307';
$username = 'root';
$database = 'apnbackup';
$this->link = mysql_connect($servername, $username);
if (!$this->link)
{
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db($database, $this->link))
{
die('Unable to connect to DB: ' . mysql_error());
}
}
//simplified query function
function newQuery($sqlString)
{
$q_uery = mysql_query($sqlString, $this->link);
if (!$q_uery)
{
die("Could not run query from DB: " . mysql_error());
}
return $q_uery;
}
//returns category and subcategory as an array given a style as a parameter
function getCategoryInfo($style)
{
$q_uery = mysql_query("SELECT style_no, styletype, sub_type FROM chastestdb.style WHERE style_no = '$style'", $this->link);
if (!$q_uery)
{
die("Could not run query from DB: " . mysql_error());
}
$row = mysql_fetch_assoc($q_uery);
$temp = Array();
$temp['category'] = $row["styletype"];
$temp['subCategory'] = $row["sub_type"];
if (!strcmp($temp['category'],'0') || $temp['category'] === NULL )
{
$q_uery = mysql_query("SELECT Category FROM chastestdb.category_sub", $this->link);
if (!$q_uery)
{
die("Could not run query from DB: " . mysql_error());
}
$temp['category'] = mysql_fetch_assoc($q_uery)["Category"];
}
if (!strcmp($temp['subCategory'],'0') || $temp['subCategory'] === NULL)
{
$test = $temp['category'];
$q_uery = mysql_query("SELECT Category, subCat1 FROM chastestdb.category_sub WHERE Category = '$test'", $this->link);
if (!$q_uery)
{
die("Could not run query from DB: " . mysql_error());
}
$temp['subCategory'] = mysql_fetch_assoc($q_uery)["subCat1"];
}
return $temp;
}
//returns a string to the image path on chastest of a particular style
function getImage($style)
{
$q_uery = mysql_query("SELECT style_no, style_image1 FROM chastestdb.style WHERE style_no = '$style'", $this->link);
if (!$q_uery)
{
die("Could not run query from DB: " . mysql_error());
}
return "http://chastest.apnedi.com/images/style/" . mysql_fetch_assoc($q_uery)["style_image1"];
}
//destructor disconnects from db
function __destruct()
{
mysql_close($this->link);
}
}
/* SEASON class designed to be a class of arrays to hold information based on seasons */
class seasons
{
//array for holding sales order info
public $seasonalArraysOrder = [
"winterArr" => array(),
"springArr" => array(),
"summerArr" => array(),
"fallArr" => array()
];
//array for holding style info
public $seasonalArraysStyle = [
"winterArr" => array(),
"springArr" => array(),
"summerArr" => array(),
"fallArr" => array()
];
//categorizes the different sales order based on seasons
function categorizeOrder($date,$keyOrder)
{
if ($date >= 3 && $date <=5)
{
array_push($this->seasonalArraysOrder["springArr"], $keyOrder);
}
else if ($date >=6 && $date <=8)
{
array_push($this->seasonalArraysOrder["summerArr"], $keyOrder);
}
else if ($date >=9 && $date <=11)
{
array_push($this->seasonalArraysOrder["fallArr"], $keyOrder);
}
else
{
array_push($this->seasonalArraysOrder["winterArr"], $keyOrder);
}
}
}
/* GLOBAL FUNCTIONS */
//concatenates and returns the optimal mysql string query given the conditions passed along from the filter page
//if check is if condition is not given: default value
function stringRunner($store, $division, $orderType, $status, $salesRep)
{
$query_part1 = "SELECT order_no, order_date";
$query_part2 = " FROM chastestdb.xorder";
$boolVar = true;
if ($store != 0 )
{
$query_part1 .= ", store_id";
$query_part2 .= " WHERE store_id = '$store'";
$boolVar = false;
}
if ($division != 0)
{
$query_part1 .= ", company_id";
if ($boolVar)
{
$query_part2 .= " WHERE company_id = '$division'";
$boolVar = false;
}
else
{
$query_part2 .= " AND company_id = '$division'";
}
}
if (strcmp($orderType,"temp"))
{
$query_part1 .= ", business_type";
if ($boolVar)
{
$query_part2 .= " WHERE business_type = '$orderType'";
$boolVar = false;
}
else
{
$query_part2 .= " AND business_type = '$orderType'";
}
}
if ($status != 6)
{
$query_part1 .= ", `status`";
if ($boolVar)
{
$query_part2 .= " WHERE `status` = '$status'";
$boolVar = false;
}
else
{
$query_part2 .= " AND `status` = '$status'";
}
}
if ($salesRep != 2 && $salesRep != 0)
{
{
$query_part1 .= ", salesman_idx";
if ($boolVar)
{
$query_part2 .= " WHERE salesman_idx = '$salesRep'";
$boolVar = false;
}
else
{
$query_part2 .= " AND salesman_idx = '$salesRep'";
}
}
}
$strQuery = $query_part1 . $query_part2;
return $strQuery;
}
?>