-
Notifications
You must be signed in to change notification settings - Fork 192
/
Petugas.php
260 lines (226 loc) · 11 KB
/
Petugas.php
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
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Petugas extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('petugas_model');
}
public function index()
{
$data['title'] = 'Petugas Ukur';
$data['petugas'] = $this->petugas_model->get_data('petugas_ukur')->result();
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/index', $data);
$this->load->view('templates/footer');
}
public function surat_tugas()
{
$data['title'] = 'Surat Tugas';
$data['petugas'] = $this->petugas_model->get_data('petugas_ukur')->result();
$data['surat_tugas'] = $this->petugas_model->get_data('surat_tugas')->result();
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$data['laporan'] = $this->petugas_model->getdatawithstatus('surat_tugas')->result();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/surat_tugas', $data);
$this->load->view('templates/footer');
}
public function laporan()
{
$data['title'] = 'Laporan Ukur';
$data['petugas'] = $this->petugas_model->get_data('petugas_ukur')->result();
$data['surat_tugas'] = $this->petugas_model->get_data('surat_tugas')->result();
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$data['laporan'] = $this->petugas_model->getdatawithstatus('pengukuran')->result();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/laporan', $data);
$this->load->view('templates/footer');
}
public function penugasan()
{ {
$data['title'] = 'Petugas Ukur';
$data['petugas'] = $this->petugas_model->get_data('petugas_ukur')->result();
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/penugasan', $data);
$this->load->view('templates/footer');
}
}
public function tambah()
{
$data['title'] = 'Tambah Petugas';
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/tambah');
$this->load->view('templates/footer');
}
public function input_laporan()
{
$data['title'] = 'Input Laporan';
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/input_laporan', $data);
$this->load->view('templates/footer');
}
public function edit_laporan()
{
$data['title'] = 'Edit Laporan';
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/edit_laporan', $data);
$this->load->view('templates/footer');
}
public function edit_data($id)
{
$data['title'] = 'Edit Data Petugas';
$data['user'] = $this->db->get_where('user', ['username' => $this->session->userdata('username')])->row_array();
$data['petugas'] = $this->petugas_model->ambil_id($id)->result()[0];
// var_dump($data['petugas']);
$this->load->view('templates/header', $data);
$this->load->view('templates/sidebar', $data);
$this->load->view('templates/topbar', $data);
$this->load->view('petugas/edit_data', $data);
$this->load->view('templates/footer');
}
public function tambah_aksi()
{
$this->_rules();
if ($this->form_validation->run() == false) {
$this->tambah();
} else {
$data = array(
'nama_petugas' => $this->input->post('nama_petugas'),
'no_telp' => $this->input->post('no_telp'),
'alamat' => $this->input->post('alamat'),
'id_berkas' => $this->input->post('id_berkas'),
'nip_petugas' => $this->input->post('nip_petugas'),
'jabatan' => $this->input->post('jabatan'),
);
$this->petugas_model->insert_data($data, 'petugas_ukur');
$this->session->set_flashdata('pesan', '<div class="alert alert-success alert-dismissible fade show" role="alert">
Data Berhasil Ditambahkan!<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
redirect('petugas');
}
}
public function tambah_laporan()
{
$config['upload_path'] = './assets/img/';
$config['allowed_types'] = 'gif|jpg|png|PNG';
$config['max_size'] = 2048;
$config['max_width'] = 1980;
$config['max_height'] = 1080;
$this->load->library('upload', $config);
if (!$this->upload->do_upload('userfile')) {
$gambar = $this->upload->data();
$gambar = $gambar['file_name'];
$tanggal = date('Y-m-d');
$no_surat = $this->input->post('no_surat', TRUE);
$nip = $this->input->post('nip_petugas', TRUE);
$no_berkas = $this->input->post('no_berkas', TRUE);
$volume_awal = $this->input->post('volume_awal', TRUE);
$volume_akhir = $this->input->post('volume_akhir', TRUE);
$status = $this->input->post('status', TRUE);
$data = array(
'tgl_pengerjaan' => $tanggal,
'no_surat' => $no_surat,
'nip_petugas' => $nip,
'no_berkas' => $no_berkas,
'volume_awal' => $volume_awal,
'volume_akhir' => $volume_akhir,
'status' => $status,
);
$this->db->insert('pengukuran', $data);
$this->session->set_flashdata('pesan', '<div class="alert alert-success alert-dismissible fade show" role="alert">
Data Berhasil Diupload!<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
redirect('petugas/surat_tugas');
} else {
$gambar = $this->upload->data();
$gambar = $gambar['file_name'];
$tanggal = $this->input->post('tgl_pengerjaan', TRUE);
$no_surat = $this->input->post('no_surat', TRUE);
$nip = $this->input->post('nip_petugas', TRUE);
$no_berkas = $this->input->post('no_berkas', TRUE);
$volume_awal = $this->input->post('volume_awal', TRUE);
$volume_akhir = $this->input->post('volume_akhir', TRUE);
$status = $this->input->post('status', TRUE);
$data = array(
'tgl_pengerjaan' => $tanggal,
'no_surat' => $no_surat,
'nip_petugas' => $nip,
'no_berkas' => $no_berkas,
'volume_awal' => $volume_awal,
'volume_akhir' => $volume_akhir,
'status' => $status,
);
$this->db->insert('pengukuran', $data);
$this->session->set_flashdata('pesan', '<div class="alert alert-success alert-dismissible fade show" role="alert">
Data Berhasil Ditambahkan!<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
redirect('petugas/laporan');
}
}
// public function edit($id_petugas)
// {
// $this->_rules();
// if ($this->form_validation->run() == false) {
// $this->index();
// } else {
// $data = array(
// 'nama_petugas' => $this->input->post('nama_petugas'),
// 'no_telp' => $this->input->post('no_telp'),
// 'alamat' => $this->input->post('alamat'),
// 'id_berkas' => $this->input->post('id_berkas'),
// 'nip_petugas' => $this->input->post('nip_petugas'),
// 'jabatan' => $this->input->post('jabatan'),
// );
// $this->petugas_model->update_data($data, 'petugas_ukur');
// $this->session->set_flashdata('pesan', '<div class="alert alert-success alert-dismissible fade show" role="alert">
// Data Berhasil Ditambah!<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
// redirect('petugas');
// }
// }
public function _rules()
{
$this->form_validation->set_rules('nama_petugas', 'Nama Petugas', 'required', array(
'required' => '%s harus diisi !!'
));
$this->form_validation->set_rules('no_telp', 'Nomor Telepon', 'required', array(
'required' => '%s harus diisi !!'
));
$this->form_validation->set_rules('alamat', 'Alamat', 'required', array(
'required' => '%s harus diisi !!'
));
$this->form_validation->set_rules('id_berkas', 'Nomor Berkas', 'required', array(
'required' => '%s harus diisi !!'
));
$this->form_validation->set_rules('nip_petugas', 'NIP Petugas', 'required', array(
'required' => '%s harus diisi !!'
));
$this->form_validation->set_rules('jabatan', 'Jabatan', 'required', array(
'required' => '%s harus diisi !!'
));
}
public function delete($id)
{
$where = array('id_petugas' => $id);
$this->petugas_model->delete($where, 'petugas_ukur');
$this->session->set_flashdata('pesan', '<div class="alert alert-danger alert-dismissible fade show" role="alert">
Data Berhasil Dihapus!<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div>');
redirect('petugas');
}
}