1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Equipment_loan extends My_Force_Login { |
4
|
|
|
|
5
|
|
|
public function __construct() { |
6
|
|
|
parent::__construct(); |
7
|
|
|
$this->load->library('grocery_CRUD'); |
8
|
|
|
$this->load->model('computing-support/Equipment_loan_model', 'equipment_loan_model'); |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
public function index() { |
12
|
|
|
|
13
|
|
|
if (in_array('CN=DG06,OU=Distribution Groups,OU=Email Groups,OU=Accounts,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
14
|
|
|
|
15
|
|
|
$this->load->helper('form'); |
16
|
|
|
$this->load->library('form_validation'); |
17
|
|
|
|
18
|
|
|
// validation rules |
19
|
|
|
$this->form_validation->set_rules('full_name', 'First Name', 'trim|required|min_length[3]'); |
20
|
|
|
$this->form_validation->set_rules('ern', 'ERN', 'trim|required|min_length[7]'); |
21
|
|
|
$this->form_validation->set_rules('make', 'Make', 'trim|required|min_length[3]'); |
22
|
|
|
$this->form_validation->set_rules('model', 'Model', 'trim|required|min_length[3]'); |
23
|
|
|
$this->form_validation->set_rules('sn', 'Serial Number', 'trim|required|min_length[3]'); |
24
|
|
|
|
25
|
|
|
if ($this->form_validation->run() === false) { |
26
|
|
|
|
27
|
|
|
$this->load->view('templates/header'); |
28
|
|
|
$this->load->view('computing-support/equipment-loan/view'); |
29
|
|
|
$this->load->view('templates/footer'); |
30
|
|
|
} else { |
31
|
|
|
|
32
|
|
|
$logged = $this->input->post('logged'); |
33
|
|
|
$first_name = $this->input->post('full_name'); |
|
|
|
|
34
|
|
|
$ern = $this->input->post('ern'); |
35
|
|
|
$make = $this->input->post('make'); |
36
|
|
|
$model = $this->input->post('model'); |
37
|
|
|
$sn = $this->input->post('sn'); |
38
|
|
|
|
39
|
|
View Code Duplication |
if ($this->equipment_loan_model->loan($logged, $full_name, $ern, $make, $model, $sn)) { |
|
|
|
|
40
|
|
|
|
41
|
|
|
$function = 'new_loan'; |
42
|
|
|
$this->user_model->function_log($function); |
43
|
|
|
|
44
|
|
|
// user created |
45
|
|
|
$this->load->view('templates/header'); |
46
|
|
|
$this->load->view('computing-support/equipment-loan/complete'); |
47
|
|
|
$this->load->view('templates/footer'); |
48
|
|
|
} else { |
49
|
|
|
|
50
|
|
|
$function = 'new_loan_error'; |
51
|
|
|
$this->user_model->function_log($function); |
52
|
|
|
|
53
|
|
|
$data = new stdClass(); |
54
|
|
|
$data->error = 'There was a problem accepting the terms. Please try again.'; |
55
|
|
|
|
56
|
|
|
// failed to create user |
57
|
|
|
$this->load->view('templates/header'); |
58
|
|
|
$this->load->view('computing-support/equipment-loan/view', $data); |
59
|
|
|
$this->load->view('templates/footer'); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} else { |
63
|
|
|
redirect('permissions'); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function history() { |
68
|
|
|
|
69
|
|
|
if (in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups']) || |
70
|
|
|
in_array('CN=DG06,OU=Distribution Groups,OU=Email Groups,OU=Accounts,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
71
|
|
|
|
72
|
|
|
$crud = new grocery_CRUD(); |
73
|
|
|
$crud->set_table('equipment_loan'); |
74
|
|
|
$crud->set_subject('Equipment Loan', 'Equipment Loan'); |
75
|
|
|
$crud->unset_columns('id'); |
76
|
|
|
$crud->display_as('ern','ER no.') |
77
|
|
|
->display_as('sn','Serial Number'); |
78
|
|
|
$crud->unset_edit_fields('logged', 'date'); |
79
|
|
|
$crud->unset_add(); |
80
|
|
|
$crud->unset_read(); |
81
|
|
|
$output = $crud->render(); |
82
|
|
|
|
83
|
|
|
$this->load->view('templates/header.php'); |
84
|
|
|
$this->load->view('computing-support/equipment-loan/history', $output); |
85
|
|
|
$this->load->view('templates/footer.php'); |
86
|
|
|
$this->load->view('templates/table_assets.php', $output); |
87
|
|
|
|
88
|
|
|
} else { |
89
|
|
|
redirect('permissions'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.