-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptions.php
More file actions
271 lines (172 loc) · 11.4 KB
/
Exceptions.php
File metadata and controls
271 lines (172 loc) · 11.4 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Exceptions extends CI_Controller {
protected $db_ref = 'BB4C03E6-BB3B-3455-7CEE-11C291DC5740';
public function index(){
// note: exceptions is a global model
$data['exceptions'] = $this->exceptions_data->get_exceptions_data();
$data['exceptionFlags'] = $this->exceptions_data->get_exception_flags();
$data['exceptionHasFlags'] = $this->exceptions_data->get_exception_has_flags();
$data['exceptionCategories'] = $this->exceptions_data->get_exception_categories();
$data['exceptionSeverity'] = $this->exceptions_data->get_exception_severity();
//get settingvalue from setting description FROM setting table
$data['exceptionSeverity_value'] = $this->exceptions_data->get_setting_value('exceptionSeverity');
$data['exceptionSeverity_value'] = $data['exceptionSeverity_value'][0]->settingvalue;
$this->load->view('header');
$this->load->view('exceptions_main',$data);
$this->load->view('exceptions_main_global',$data);
}
// ajax functions for Exception operations
public function update_exception_flag(){
$data = array('exceptionflagdescription' =>$this->input->post('exceptionflagdescription'));
$this->exceptions_data->update_exception_flag($this->input->post('exceptionflagid'),$data);
}
public function update_exception_flag_active(){
$data = array('exceptionflagactive' => $this->input->post('exceptionflagactive'));
$this->exceptions_data->update_exception_flag($this->input->post('exceptionflagid'),$data);
}
public function update_exception_category(){
$data = array('exceptioncategorydescription' =>$this->input->post('exceptioncategorydescription'));
$this->exceptions_data->update_exception_category($this->input->post('exceptioncategoryid'),$data);
}
public function update_exception_severity(){
$data = array('exceptionseverityvalue' =>$this->input->post('exceptionseverityvalue'));
$this->exceptions_data->update_exception_severity($this->input->post('exceptionseverityid'),$data);
}
// delete flags,categories and severities
public function delete_exception_others(){
//print_r($_POST);die;
switch($this->input->post('type')){
case "ex-flag-delete":
$this->exceptions_data->delete_exception_flag($this->input->post('id'));
break;
case "ex-cat-delete":
$this->exceptions_data->delete_exception_category($this->input->post('id'));
break;
case "ex-sev-delete":
$this->exceptions_data->delete_exception_severity($this->input->post('id'));
break;
}
}
public function process_exception_others_data(){
parse_str($this->input->post('data'), $output);
//print_r($output['ex-flag']);die;
//print_r($_POST);die;
switch($this->input->post('id')){
case "modal-form-ex-flag":
$id=$this->exceptions_data->get_table_max_id('exceptionflag','exceptionflagid');
$newid = $id[0]->exceptionflagid;
++$newid;
$data = array(
'db_ref' => $this->db_ref,
'exceptionflagdescription' => $output['ex-flag'],
'exceptionflagid' => $newid
);
$this->exceptions_data->add_exception_flag($data);
break;
case "modal-form-ex-cat":
$id=$this->exceptions_data->get_table_max_id('exceptioncategory','exceptioncategoryid');
$newid = $id[0]->exceptioncategoryid;
++$newid;
$data = array(
'db_ref' => $this->db_ref,
'exceptioncategorydescription' => $output['ex-cat'],
'exceptioncategoryid' => $newid
);
$this->exceptions_data->add_exception_category($data);
break;
case "modal-form-ex-sev":
$id=$this->exceptions_data->get_table_max_id('exceptionseverity','exceptionseverityid');
$newid = $id[0]->exceptionseverityid;
++$newid;
$data = array(
'db_ref' => $this->db_ref,
'exceptionseverityvalue' => $output['ex-sev'],
'exceptionseverityid' => $newid
);
$this->exceptions_data->addexception_severity($data);
break;
}
}
public function set_exception_severity_switch(){
$data = array('settingvalue' =>$this->input->post('settingvalue'));
//print_r($_POST);die;
$this->exceptions_data->set_exception_severity_switch(($this->input->post('settingdescription')),$data);
}
public function get_exception_severity_switch(){
$data['exceptionSeverity_value'] = $this->exceptions_data->get_setting_value('exceptionSeverity');
$data['exceptionSeverity_value'] = ($data['exceptionSeverity_value'][0]->settingvalue);
echo $data['exceptionSeverity_value'];
}
// EXCEPTION MANAGEMENT OPERATIONS - table Exceptions
public function update_exception_management_flag(){
// print_r($_POST);die;
if($this->input->post('status')==0){
//print_r($_POST);die;
$this->exceptions_data->delete_exception_management_flag($_POST);
}else{
$id=$this->exceptions_data->get_table_max_id('exception_has_flag','exceptionhasflagid');
$newid = $id[0]->exceptionhasflagid;
++$newid;
$data = array(
'db_ref' => $this->db_ref,
'exceptionhasflagid' => $newid,
'exceptionid' => $this->input->post('exceptionid'),
'exceptionflagid' => $this->input->post('exceptionflagid')
);
$this->exceptions_data->add_exception_management_flag($data);
}
}
public function update_default_wording(){ // it can also delete an exception + dependencies
parse_str($this->input->post('data'), $output);
//print_r($output);die;
if(isset($output['id']) && $output['id'] > 0){ // update def wording
$data = array('defaultwording' => $output['ex-default-wording']);
$output['id'] = $output['id'];
$this->exceptions_data->update_default_wording($output['id'],$data);
}else{ // insert new exception
$id=$this->exceptions_data->get_table_max_id('exception','exceptionid');
$newid = $id[0]->exceptionid;
++$newid;
$data = array(
'db_ref' => $this->db_ref,
'exceptionid' => $newid,
'exceptioncode' =>$output['cat_code'],
'exceptiondescription' => $output['cat_desc'],
'exceptioncategoryid' => $output['cat_name']
);
//print_r($data);die;
$this->exceptions_data->addexception($data);
// update exception_severity
$data = array('defaultexceptionseverity' => $output['select_sev']);
$this->exceptions_data->update_exception_severity_global($newid,$data);
// update_exception_management_flags ??
if(isset($output['check_flags'])){
$exceptionid = $newid; // back up
foreach ($output['check_flags'] as $val){
$id=$this->exceptions_data->get_table_max_id('exception_has_flag','exceptionhasflagid');
$newid = $id[0]->exceptionhasflagid;
++$newid;
$data2 = array(
'db_ref' => $this->db_ref,
'exceptionhasflagid' => $newid,
'exceptionid' => $exceptionid,
'exceptionflagid' => $val
);
$this->exceptions_data->add_exception_management_flag($data2);
} // end of loop
} // end of if
} // end of else
}
public function delete_exception_global(){
$this->exceptions_data->delete_exception_global($this->input->post('id'));
}
public function update_exception_category_global(){
$data = array('exceptioncategoryid' => $this->input->post('exceptioncategoryid'));
$this->exceptions_data->update_exception_category_global($this->input->post('exceptionid'),$data);
}
public function update_exception_severity_global(){
$data = array('defaultexceptionseverity' => $this->input->post('defaultexceptionseverity'));
$this->exceptions_data->update_exception_severity_global($this->input->post('exceptionid'),$data);
}
} // END OF CLASS