1
|
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
2
|
|
|
|
3
|
|
|
class Room_move_model extends CI_Model { |
4
|
|
|
|
5
|
|
|
public function __construct() { |
6
|
|
|
parent::__construct(); |
7
|
|
|
} |
8
|
|
|
|
9
|
|
|
public function create($requester, $move, $from, $to, $furniture, $reason, $full_name, $full_name2, $full_name3, $full_name4, $full_name5, $full_name6, $full_name7, $full_name8, $full_name9, $full_name10) { |
10
|
|
|
|
11
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name'), $user_un); |
12
|
|
|
$user_un = $user_un[1]; |
13
|
|
View Code Duplication |
if (isset($full_name2)) { |
|
|
|
|
14
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name2'), $user_un2); |
15
|
|
|
$user_un2 = $user_un2[1]; |
16
|
|
|
} else { $user_un2 = NULL; } if (isset($full_name3)) { |
17
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name3'), $user_un3); |
18
|
|
|
$user_un3 = $user_un3[1]; |
19
|
|
View Code Duplication |
} else { $user_un3 = NULL; } if (isset($full_name4)) { |
|
|
|
|
20
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name4'), $user_un4); |
21
|
|
|
$user_un4 = $user_un4[1]; |
22
|
|
|
} else { $user_un4 = NULL; } if (isset($full_name5)) { |
23
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name5'), $user_un5); |
24
|
|
|
$user_un5 = $user_un5[1]; |
25
|
|
View Code Duplication |
} else { $user_un5 = NULL; } if (isset($full_name6)) { |
|
|
|
|
26
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name6'), $user_un6); |
27
|
|
|
$user_un6 = $user_un6[1]; |
28
|
|
|
} else { $user_un6 = NULL; } if (isset($full_name7)) { |
29
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name7'), $user_un7); |
30
|
|
|
$user_un7 = $user_un7[1]; |
31
|
|
View Code Duplication |
} else { $user_un7 = NULL; } if (isset($full_name8)) { |
|
|
|
|
32
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name8'), $user_un8); |
33
|
|
|
$user_un8 = $user_un8[1]; |
34
|
|
|
} else { $user_un8 = NULL; } if (isset($full_name9)) { |
35
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name9'), $user_un9); |
36
|
|
|
$user_un9 = $user_un9[1]; |
37
|
|
View Code Duplication |
} else { $user_un9 = NULL; } if (isset($full_name10)) { |
|
|
|
|
38
|
|
|
preg_match('#\((.*?)\)#', $this->input->post('full_name10'), $user_un10); |
39
|
|
|
$user_un10 = $user_un10[1]; |
40
|
|
|
} else { $user_un10 = NULL; } |
41
|
|
|
|
42
|
|
|
if ($furniture == "No Furniture"){ |
43
|
|
|
$status = "1"; |
44
|
|
|
} else { |
45
|
|
|
$status = "0"; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
$data = array( |
49
|
|
|
'requester' => $_SESSION['ldap']['full_name'], |
50
|
|
|
'requester_un' => $_SESSION['username'], |
51
|
|
|
'requested_at' => date("Y-m-d H:i:s", time()), |
52
|
|
|
'move' => $this->input->post('move'), |
53
|
|
|
'from' => $this->input->post('from'), |
54
|
|
|
'to' => $this->input->post('to'), |
55
|
|
|
'furniture' => $this->input->post('furniture'), |
56
|
|
|
'reason' => $this->input->post('reason'), |
57
|
|
|
'staff_involved' => $this->input->post('full_name'), |
58
|
|
|
'staff_involved_un' => $user_un, |
59
|
|
|
'staff_involved2' => $this->input->post('full_name2'), |
60
|
|
|
'staff_involved_un2' => $user_un2, |
61
|
|
|
'staff_involved3' => $this->input->post('full_name3'), |
62
|
|
|
'staff_involved_un3' => $user_un3, |
63
|
|
|
'staff_involved4' => $this->input->post('full_name4'), |
64
|
|
|
'staff_involved_un4' => $user_un4, |
65
|
|
|
'staff_involved5' => $this->input->post('full_name5'), |
66
|
|
|
'staff_involved_un5' => $user_un5, |
67
|
|
|
'staff_involved6' => $this->input->post('full_name6'), |
68
|
|
|
'staff_involved_un6' => $user_un6, |
69
|
|
|
'staff_involved7' => $this->input->post('full_name7'), |
70
|
|
|
'staff_involved_un7' => $user_un7, |
71
|
|
|
'staff_involved8' => $this->input->post('full_name8'), |
72
|
|
|
'staff_involved_un8' => $user_un8, |
73
|
|
|
'staff_involved9' => $this->input->post('full_name9'), |
74
|
|
|
'staff_involved_un9' => $user_un9, |
75
|
|
|
'staff_involved10' => $this->input->post('full_name10'), |
76
|
|
|
'staff_involved_un10' => $user_un10, |
77
|
|
|
'status' => $status, |
78
|
|
|
); |
79
|
|
|
|
80
|
|
|
return $this->db->insert('room_move', $data); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function get_pending() { |
84
|
|
|
$this->db->where('status', '0')->or_where('status', '1'); |
85
|
|
|
$query = $this->db->get('room_move'); |
86
|
|
|
return $query->result_array(); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function get_all() { |
90
|
|
|
$query = $this->db->get('room_move'); |
91
|
|
|
return $query->result_array(); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
public function check_status() { |
95
|
|
|
$this->db->where('requester_un', $_SESSION['username']) |
96
|
|
|
->or_where('staff_involved_un', $_SESSION['username']) |
97
|
|
|
->or_where('staff_involved_un2', $_SESSION['ldap']['full_name']) |
98
|
|
|
->or_where('staff_involved_un3', $_SESSION['ldap']['full_name']) |
99
|
|
|
->or_where('staff_involved_un4', $_SESSION['ldap']['full_name']) |
100
|
|
|
->or_where('staff_involved_un5', $_SESSION['ldap']['full_name']) |
101
|
|
|
->or_where('staff_involved_un6', $_SESSION['ldap']['full_name']) |
102
|
|
|
->or_where('staff_involved_un7', $_SESSION['ldap']['full_name']) |
103
|
|
|
->or_where('staff_involved_un8', $_SESSION['ldap']['full_name']) |
104
|
|
|
->or_where('staff_involved_un9', $_SESSION['ldap']['full_name']) |
105
|
|
|
->or_where('staff_involved_un10', $_SESSION['ldap']['full_name']); |
106
|
|
|
$query = $this->db->get('room_move'); |
107
|
|
|
return $query->result_array(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function match_id_user($id) { |
111
|
|
|
$this->db->where('id', $id); |
112
|
|
|
$query = $this->db->get('room_move'); |
113
|
|
|
return $query->result_array(); |
114
|
|
|
} |
115
|
|
|
|
116
|
|
View Code Duplication |
public function get_email_username($username) { |
|
|
|
|
117
|
|
|
|
118
|
|
|
$this->db->select('email'); |
119
|
|
|
$this->db->from('users_ad'); |
120
|
|
|
$this->db->where('username', $username); |
121
|
|
|
return $this->db->get()->row('email'); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
public function get_request($id) { |
125
|
|
|
$this->db->where('id', $id); |
126
|
|
|
$query = $this->db->get('room_move'); |
127
|
|
|
return $query->result_array(); |
128
|
|
|
} |
129
|
|
|
|
130
|
|
View Code Duplication |
public function cancel($id) { |
|
|
|
|
131
|
|
|
|
132
|
|
|
$this->db->where('id', $id); |
133
|
|
|
$this->db->from('room_move'); |
134
|
|
|
$data = array( |
135
|
|
|
'status' => '4', |
136
|
|
|
'canceled_by' => $_SESSION['ldap']['full_name'], |
137
|
|
|
'canceled_at' => date("Y-m-d H:i:s", time()), |
138
|
|
|
); |
139
|
|
|
return $this->db->update('room_move', $data); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
View Code Duplication |
public function eh_reject($id) { |
|
|
|
|
143
|
|
|
|
144
|
|
|
$this->db->where('id', $id); |
145
|
|
|
$this->db->from('room_move'); |
146
|
|
|
$data = array( |
147
|
|
|
'status' => '2', |
148
|
|
|
'estates_at' => date("Y-m-d H:i:s", time()), |
149
|
|
|
'estates_by' => $_SESSION['ldap']['full_name'], |
150
|
|
|
); |
151
|
|
|
return $this->db->update('room_move', $data); |
152
|
|
|
} |
153
|
|
|
|
154
|
|
View Code Duplication |
public function eh_approve($id) { |
|
|
|
|
155
|
|
|
|
156
|
|
|
$this->db->where('id', $id); |
157
|
|
|
$this->db->from('room_move'); |
158
|
|
|
$data = array( |
159
|
|
|
'status' => '1', |
160
|
|
|
'estates_at' => date("Y-m-d H:i:s", time()), |
161
|
|
|
'estates_by' => $_SESSION['ldap']['full_name'], |
162
|
|
|
); |
163
|
|
|
|
164
|
|
|
return $this->db->update('room_move', $data); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
View Code Duplication |
public function cs_reject($id) { |
|
|
|
|
168
|
|
|
|
169
|
|
|
$this->db->where('id', $id); |
170
|
|
|
$this->db->from('room_move'); |
171
|
|
|
$data = array( |
172
|
|
|
'status' => '3', |
173
|
|
|
'cs_at' => date("Y-m-d H:i:s", time()), |
174
|
|
|
'cs_by' => $_SESSION['ldap']['full_name'], |
175
|
|
|
); |
176
|
|
|
return $this->db->update('room_move', $data); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
View Code Duplication |
public function cs_approve($id) { |
|
|
|
|
180
|
|
|
|
181
|
|
|
$this->db->where('id', $id); |
182
|
|
|
$this->db->from('room_move'); |
183
|
|
|
$data = array( |
184
|
|
|
'status' => '5', |
185
|
|
|
'cs_at' => date("Y-m-d H:i:s", time()), |
186
|
|
|
'cs_by' => $_SESSION['ldap']['full_name'], |
187
|
|
|
); |
188
|
|
|
|
189
|
|
|
return $this->db->update('room_move', $data); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
View Code Duplication |
public function cs_complete($id) { |
|
|
|
|
193
|
|
|
|
194
|
|
|
$this->db->where('id', $id); |
195
|
|
|
$this->db->from('room_move'); |
196
|
|
|
$data = array( |
197
|
|
|
'status' => '6', |
198
|
|
|
'completed_at' => date("Y-m-d H:i:s", time()), |
199
|
|
|
'completed_by' => $_SESSION['ldap']['full_name'], |
200
|
|
|
); |
201
|
|
|
|
202
|
|
|
return $this->db->update('room_move', $data); |
203
|
|
|
} |
204
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.