-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions_data.php
More file actions
251 lines (159 loc) · 8.46 KB
/
exceptions_data.php
File metadata and controls
251 lines (159 loc) · 8.46 KB
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
class Exceptions_data extends CI_Model {
protected $db_ref = 'BB4C03E6-BB3B-3455-7CEE-11C291DC5740';
public function __construct()
{
parent::__construct();
}
public function get_exceptions_data()
{
$sql="SELECT
a.exceptionid,
a.exceptioncategoryid,
b.exceptioncategorydescription,
a.exceptioncode,
a.exceptiondescription,
a.defaultexceptionseverity,
c.exceptionseverityid,
a.defaultwording
FROM exception a
LEFT JOIN exceptioncategory b ON a.exceptioncategoryid = b.exceptioncategoryid
LEFT JOIN exceptionseverity c ON a.defaultexceptionseverity = c.exceptionseverityid
WHERE a.db_ref=b.db_ref AND a.db_ref='".$this->db_ref."' ORDER BY b.exceptioncategorydescription ASC;";
$query = $this->db->query($sql);
return $query->result(); // returns an array
}
public function get_exception_has_flags(){
$this->db->order_by('exceptionflagid', 'ASC');
$this->db->where('db_ref',$this->db_ref);
$query = $this->db->get('exception_has_flag');
return $query->result(); // returns an array
}
public function get_exception_flags(){
$this->db->order_by('exceptionflagid', 'ASC');
$this->db->where('db_ref',$this->db_ref);
$query = $this->db->get('exceptionflag');
return $query->result(); // returns an array
}
public function get_exception_categories(){
$this->db->order_by('exceptioncategorydescription', 'ASC');
$this->db->where('db_ref',$this->db_ref);
$query = $this->db->get('exceptioncategory');
return $query->result(); // returns an array
}
public function get_exception_severity(){
$this->db->order_by('exceptionseverityvalue', 'ASC');
$this->db->where('db_ref',$this->db_ref);
$query = $this->db->get('exceptionseverity');
return $query->result(); // returns an array
}
// ajax functions for Exception operations
// UPDATES
public function update_exception_flag($id,$data){
$this->db->where('exceptionflagid', $id);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('exceptionflag', $data);
}
public function update_exception_category($id,$data){
$this->db->where('exceptioncategoryid', $id);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('exceptioncategory', $data);
}
public function update_exception_severity($id,$data){
$this->db->where('exceptionseverityid', $id);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('exceptionseverity', $data);
}
// DELETIONS
public function delete_exception_severity($id){
$this->db->where('exceptionseverityid',$id);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exceptionseverity');
}
public function delete_exception_flag($id){
$this->db->where('exceptionflagid',$id);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exceptionflag');
// update table exception_has_flag
$this->db->where('exceptionflagid',$id);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exception_has_flag');
}
public function delete_exception_category($id){
$this->db->where('exceptioncategoryid',$id);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exceptioncategory');
}
// CREATE
public function add_exception_flag($data){
$this->db->insert('exceptionflag', $data);
}
public function add_exception_category($data){
$this->db->insert('exceptioncategory', $data);
}
public function addexception_severity($data){
$this->db->insert('exceptionseverity', $data);
}
public function get_table_max_id($tablename,$idname){
$this->db->select_max($idname);
$this->db->where('db_ref',$this->db_ref);
$this->db->from($tablename);
$query = $this->db->get();
return $query->result();
}
public function set_exception_severity_switch($settingdescription,$data){
$this->db->where('settingdescription', $settingdescription);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('setting', $data);
}
//get settingvalue from setting description - a generic function
public function get_setting_value($settingdescription){
$this->db->select('settingvalue');
$this->db->where('db_ref',$this->db_ref);
$this->db->where('settingdescription', $settingdescription);
$query = $this->db->get('setting');
return $query->result(); // returns an array
}
// EXCEPTION MANAGEMENT OPERATIONS
public function add_exception_management_flag($data){
$this->db->insert('exception_has_flag', $data);
}
public function delete_exception_management_flag($data){
$this->db->where('exceptionid',$data['exceptionid']);
$this->db->where('exceptionflagid',$data['exceptionflagid']);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exception_has_flag');
}
public function update_default_wording($id,$data){
$this->db->where('exceptionid', $id);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('exception', $data);
}
public function addexception($data){
$this->db->insert('exception', $data);
}
public function delete_exception_global($id){
$this->db->where('exceptionid',$id);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exception');
// update table exception_has_flag
$this->db->where('exceptionid',$id);
$this->db->where('db_ref',$this->db_ref);
$this->db->delete('exception_has_flag');
}
public function update_exception_severity_global($id,$data){
$this->db->where('exceptionid', $id);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('exception', $data);
}
public function update_exception_category_global($id,$data){
$this->db->where('exceptionid', $id);
$this->db->where('db_ref',$this->db_ref);
$this->db->update('exception', $data);
}
} // END OF CLASS