1
|
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
2
|
|
|
|
3
|
|
|
class Ownership_model extends CI_Model { |
4
|
|
|
|
5
|
|
|
public function __construct() { |
6
|
|
|
} |
7
|
|
|
|
8
|
|
View Code Duplication |
public function create($logged, $staff_full, $make, $model, $sn) { |
|
|
|
|
9
|
|
|
|
10
|
|
|
$data = array( |
11
|
|
|
'logged' => $this->input->post('logged'), |
12
|
|
|
'logged_at' => date("Y-m-d H:i:s", time()), |
13
|
|
|
'staff_full' => $this->input->post('staff_full'), |
14
|
|
|
'make' => $this->input->post('make'), |
15
|
|
|
'model' => $this->input->post('model'), |
16
|
|
|
'sn' => $this->input->post('sn'), |
17
|
|
|
); |
18
|
|
|
|
19
|
|
|
return $this->db->insert('ownership', $data); |
20
|
|
|
|
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function get_all_ownership() { |
24
|
|
|
$query = $this->db->get('ownership'); |
25
|
|
|
return $query->result_array(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function get_pending_ownership() { |
29
|
|
|
$this->db->where('status', '0')->or_where('status', '1'); |
30
|
|
|
$query = $this->db->get('ownership'); |
31
|
|
|
return $query->result_array(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function check_ownership() { |
35
|
|
|
$this->db->where('staff_full', $_SESSION['ldap']['full_name']); |
36
|
|
|
$query = $this->db->get('ownership'); |
37
|
|
|
return $query->result_array(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function match_id_user($id) { |
41
|
|
|
$this->db->select('staff_full'); |
42
|
|
|
$this->db->where('id', $id); |
43
|
|
|
$query = $this->db->get('ownership'); |
44
|
|
|
return $query->result_array(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
View Code Duplication |
public function email_id($staff_full) { |
|
|
|
|
48
|
|
|
$this->db->select('email'); |
49
|
|
|
$this->db->where('full_name', $staff_full); |
50
|
|
|
$query = $this->db->get('users_ad'); |
51
|
|
|
return $query->result_array(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
View Code Duplication |
public function approve($id) { |
|
|
|
|
55
|
|
|
|
56
|
|
|
$this->db->where('id', $id); |
57
|
|
|
$this->db->from('ownership'); |
58
|
|
|
$data = array( |
59
|
|
|
'status' => '3', |
60
|
|
|
'transfer' => date("Y-m-d H:i:s", time()), |
61
|
|
|
'transfer_by' => $_SESSION['ldap']['full_name'], |
62
|
|
|
); |
63
|
|
|
return $this->db->update('ownership', $data); |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
View Code Duplication |
public function reject($id) { |
|
|
|
|
68
|
|
|
|
69
|
|
|
$this->db->where('id', $id); |
70
|
|
|
$this->db->from('ownership'); |
71
|
|
|
$data = array( |
72
|
|
|
'status' => '2', |
73
|
|
|
'transfer' => date("Y-m-d H:i:s", time()), |
74
|
|
|
'transfer_by' => $_SESSION['ldap']['full_name'], |
75
|
|
|
); |
76
|
|
|
return $this->db->update('ownership', $data); |
77
|
|
|
|
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function cancel($id) { |
81
|
|
|
|
82
|
|
|
$this->db->where('id', $id); |
83
|
|
|
$this->db->from('ownership'); |
84
|
|
|
$data = array( |
85
|
|
|
'status' => '4', |
86
|
|
|
); |
87
|
|
|
return $this->db->update('ownership', $data); |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function terms($id) { |
92
|
|
|
|
93
|
|
|
$this->db->where('id', $id); |
94
|
|
|
$this->db->from('ownership'); |
95
|
|
|
$data = array( |
96
|
|
|
'status' => '1', |
97
|
|
|
'policy_accepted' => date("Y-m-d H:i:s", time()), |
98
|
|
|
); |
99
|
|
|
return $this->db->update('ownership', $data); |
100
|
|
|
|
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
?> |
|
|
|
|
104
|
|
|
|
105
|
|
|
|
106
|
|
|
|
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.