|
1
|
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2
|
|
|
|
|
3
|
|
|
class Address_book_model extends CI_Model { |
|
4
|
|
|
|
|
5
|
|
|
public function __construct() { |
|
6
|
|
|
} |
|
7
|
|
|
|
|
8
|
|
|
public function change($faculty, $department, $name, $room, $phone, $position) { |
|
9
|
|
|
|
|
10
|
|
|
$data = array( |
|
11
|
|
|
'requested' => date("Y-m-d H:i:s", time()), |
|
12
|
|
|
'by' => $_SESSION['ldap']['full_name'], |
|
13
|
|
|
'new_faculty' => $faculty[0]['faculty'], |
|
14
|
|
|
'new_department' => $department[0]['subfaculty'], |
|
15
|
|
|
'new_name' => $this->input->post('name'), |
|
16
|
|
|
'new_room' => $this->input->post('room'), |
|
17
|
|
|
'new_phone' => $this->input->post('phone'), |
|
18
|
|
|
'new_position' => $this->input->post('position'), |
|
19
|
|
|
); |
|
20
|
|
|
|
|
21
|
|
|
return $this->db->insert('address_book', $data); |
|
22
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
View Code Duplication |
function get_faculty() { |
|
|
|
|
|
|
26
|
|
|
$this->db->from('faculty'); |
|
27
|
|
|
$this->db->order_by('faculty'); |
|
28
|
|
|
$result = $this->db->get(); |
|
29
|
|
|
$return = array(); |
|
30
|
|
|
if ($result->num_rows() > 0) { |
|
31
|
|
|
foreach ($result->result_array() as $row) { |
|
32
|
|
|
$return[$row['cat_id']] = $row['faculty']; |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $return; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
View Code Duplication |
function get_department() { |
|
|
|
|
|
|
40
|
|
|
if (!isset($_GET['cat'])) { |
|
41
|
|
|
$_GET['cat'] = '1'; |
|
42
|
|
|
} |
|
43
|
|
|
$result = $this->db->get_where('facultysub', array('cat_id' => $_GET['cat'])); |
|
44
|
|
|
$return = array(); |
|
45
|
|
|
if ($result->num_rows() > 0) { |
|
46
|
|
|
foreach ($result->result_array() as $row) { |
|
47
|
|
|
$return[$row['cat_key']] = $row['subfaculty']; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
return $return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
function get_faculty_from_number($faculty) { |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
$this->db->select('faculty'); |
|
57
|
|
|
$this->db->where('cat_id', $faculty); |
|
58
|
|
|
$this->db->from('faculty'); |
|
59
|
|
|
return $this->db->get()->result_array(); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
function get_department_from_number($department) { |
|
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
$this->db->select('subfaculty'); |
|
65
|
|
|
$this->db->where('cat_key', $department); |
|
66
|
|
|
$this->db->from('facultysub'); |
|
67
|
|
|
return $this->db->get()->result_array(); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
?> |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.