Guest User

Untitled

a guest
Nov 26th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.86 KB | None | 0 0
  1. <?php
  2.  
  3. class operator extends CI_Controller {
  4.  
  5. public function __construct() {
  6. parent::__construct();
  7. if($this->session->userdata('level') != 'Operator' and $this->session->userdata('isLogin') != 1)
  8. {
  9. $this->session->set_flashdata('msg', 'Anda harus login terlebih dahulu !!!');
  10. redirect('log');
  11. }
  12. $this->load->library('excel_reader.php');
  13. $this->load->model('Train_model');
  14. $this->load->model('user_model','us');
  15. $this->load->model('View_training','VT');
  16. }
  17. public function index()
  18. {
  19. //$this->load->view('welcome_message');
  20. //$this->load->view('tampilan');
  21. $isi['isi']='Home';
  22. $this->load->view('template_ope',$isi);
  23. }
  24.  
  25. public function view(){
  26. $data['View_training'] = $this->VT->selectAll();
  27. $data['isi']='opp/Data_view';
  28. $this->load->view('template_ope', $data);
  29. }
  30.  
  31. public function upload(){
  32. $data['View_training'] = $this->VT->selectAll();
  33. $data['isi']='opp/upload_form';
  34. $this->load->view('template_ope', $data);
  35. }
  36.  
  37. public function user(){
  38. $data['user']=$this->us->show_user();
  39. $data['isi']='opp/tampil_user';
  40. $this->load->view('template_ope',$data);
  41.  
  42. }
  43.  
  44. public function cari(){
  45. $cat = $this->input->post('pilih');
  46.  
  47. if ($cat == 1) {
  48. $tgl_awal = $this->input->post('tanggal');
  49. $tgl_akhir = $this->input->post('tanggal_2');
  50.  
  51. $data['View_training'] = $this->VT->cari_plan_tgl($tgl_awal,$tgl_akhir);
  52. $data['isi']='opp/Data_view';
  53. $this->load->view('template_ope', $data);
  54. }
  55. elseif ($cat == 2){
  56. $judul=$this->input->post('materi');
  57. if ($judul == "") {
  58. redirect ("view" , "refresh");
  59. }
  60. else {
  61. $data['View_training'] = $this->VT->cari_plan_judul($judul);
  62. $data['isi']='opp/Data_view';
  63. $this->load->view('template_ope', $data);
  64. }
  65. }
  66. else {
  67. redirect ("view" , "refresh");
  68. }
  69. }
  70.  
  71. public function do_upload() {
  72. $config['upload_path'] = './temp_upload/';
  73. $config['allowed_types'] = 'xls';
  74. $this->load->library('upload', $config);
  75.  
  76.  
  77. if ( ! $this->upload->do_upload()) {
  78. $data = array('error' => $this->upload->display_errors());
  79. }
  80. else {
  81. $upload_data = $this->upload->data();
  82.  
  83. //$this->load->library('excel_reader.php');
  84. $this->excel_reader->setOutputEncoding('CP1251');
  85.  
  86. $data = new excel_reader($_FILES['userfile']['tmp_name']);
  87. $file = $upload_data['full_path'];
  88. $this->excel_reader->read($file);
  89. error_reporting(E_ALL ^ E_NOTICE);
  90.  
  91. // Sheet 1
  92. $data = $this->excel_reader->sheets[0] ;
  93. $dataexcel = Array();
  94. for ($i = 1; $i <= $data['numRows']; $i++) {
  95.  
  96. if($data['cells'][$i][1] == '') break;
  97. $dataexcel[$i-1]['KODE_PLAN'] = $data['cells'][$i][1];
  98. $dataexcel[$i-1]['ANGKATAN'] = $data['cells'][$i][2];
  99. $dataexcel[$i-1]['TGL_MULAI'] = $data['cells'][$i][3];
  100. $dataexcel[$i-1]['TGL_AKHIR'] = $data['cells'][$i][4];
  101. $dataexcel[$i-1]['ANGGARAN'] = $data['cells'][$i][5];
  102. $dataexcel[$i-1]['PST_A'] = $data['cells'][$i][6];
  103. $dataexcel[$i-1]['TGL_AWAL_REAL'] = $data['cells'][$i][7];
  104. $dataexcel[$i-1]['TGL_AKHIR_REAL'] = $data['cells'][$i][8];
  105. $dataexcel[$i-1]['ANGGARAN_REAL'] = $data['cells'][$i][9];
  106. $dataexcel[$i-1]['PST_REAL'] = $data['cells'][$i][10];
  107. $dataexcel[$i-1]['KODE_M'] = $data['cells'][$i][11];
  108. $dataexcel[$i-1]['KODE_INST'] = $data['cells'][$i][12];
  109. $dataexcel[$i-1]['KODE_UBIS'] = $data['cells'][$i][13];
  110. $dataexcel[$i-1]['KODE_LC'] = $data['cells'][$i][14];
  111. $dataexcel[$i-1]['Terlaksana'] = $data['cells'][$i][15];
  112. $dataexcel[$i-1]['Komen'] = $data['cells'][$i][16];
  113. }
  114.  
  115.  
  116. delete_files($upload_data['file_path']);
  117. //$this->load->model('View_training');
  118. $this->View_training->tambahdata($dataexcel);
  119. //data['plan'] = $this->VT->getupload();
  120. }
  121. //$data['View_training'] = $this->View_training->getupload();
  122. $data['plan'] = $this->VT->getupload();
  123. $this->load->view('opp/view_upload','template_ope', $data);
  124. $this->session->set_flashdata('msg', 'Data Berhasil Disimpan !!!');
  125. //redirect('operator/view');
  126. }
  127.  
  128.  
  129. public function delete($id){
  130. $this->us->delete($id);
  131. redirect('operator/user');
  132. }
  133.  
  134. public function Adduser(){
  135. $data['akses']=$this->us->Get_akses('user','Akses');
  136. foreach($data as $key=>$r){
  137.  
  138. }
  139. $data['isi']='opp/add_user';
  140. $this->load->view('template_ope',$data);
  141. }
  142.  
  143. public function tambah_user(){
  144. $nik=$this->input->post('nik');
  145. $nama=$this->input->post('nama');
  146. $almt=$this->input->post('almt');
  147. $user=$this->input->post('user');
  148. $pass=$this->input->post('pass');
  149. $akses=$this->input->post('akses');
  150.  
  151. $this->form_validation->set_rules('nik', 'Nik', 'required|alpha_dash|min_length[7]|max_length[7]|callback_username_check');
  152. $this->form_validation->set_rules('nama', 'nama', 'required');
  153. $this->form_validation->set_rules('almt', 'Alamat', 'required');
  154. $this->form_validation->set_rules('user', 'Username', 'required');
  155. $this->form_validation->set_rules('pass', 'Password', 'required');
  156. if ($this->form_validation->run() == FALSE)
  157. {
  158. $this->session->set_flashdata('msg', 'Periksa Kembali Semua Data !!!');
  159. redirect('operator/Adduser','refresh');".";
  160. }
  161. else
  162. {
  163. $data_user=$this->us->lihat_user($nik);
  164. if ($data_user['NIK']==$nik and $data_user['username']==$user) {
  165. $this->session->set_flashdata('msg', 'Duplikat NIK dan Username!!!');
  166. redirect('operator/Adduser','refresh');".";
  167. }
  168. elseif($data_user['NIK']== $nik or $data_user['username']==$user){
  169. $this->session->set_flashdata('msg', 'Duplikat NIK atau Username!!!');
  170. redirect('operator/Adduser','refresh');".";
  171. }
  172. else {
  173. $this->us->tambah( $nik,$nama,$almt,$user,$pass,$akses);
  174. $this->session->set_flashdata('msg', 'Data Berhasil Disimpan !!!');
  175. redirect('operator/user','refresh');".";
  176. }
  177. }
  178. }
  179. public function edit($nik){
  180. $data['akses']=$this->us->Get_akses('user','Akses');
  181. foreach($data as $key=>$r){
  182.  
  183. }
  184. $data['m'] = $this->us->show_user_by($nik);
  185.  
  186. $data['isi']='opp/Edit_User';
  187. $this->load->view('template_ope',$data);
  188. }
  189.  
  190. public function update_user(){
  191. $nik=$this->input->post('nik');
  192. $nama=$this->input->post('nama');
  193. $almt=$this->input->post('almt');
  194. $user=$this->input->post('user');
  195. $pass=$this->input->post('pass');
  196. $akses=$this->input->post('akses');
  197.  
  198. $this->form_validation->set_rules('nik', 'Nik', 'required|alpha_dash|min_length[7]|max_length[7]|callback_username_check');
  199. $this->form_validation->set_rules('nama', 'nama', 'required');
  200. $this->form_validation->set_rules('almt', 'Alamat', 'required');
  201. $this->form_validation->set_rules('user', 'Username', 'required');
  202. if ($this->form_validation->run() == FALSE)
  203. {
  204. redirect('operator/user','refresh');
  205. }
  206. else
  207. {
  208. if($pass != "")
  209. {
  210. $this->us->update($nik,$nama,$almt,$user,$pass,$akses);
  211. }else{
  212. $this->us->update_no_pass($nik,$nama,$almt,$user,$akses);
  213. }
  214. $this->session->set_flashdata('msg', 'Data Berhasil Diupdate !!!');
  215. redirect('operator/user','refresh');
  216. }
  217.  
  218. }
  219. }
Add Comment
Please, Sign In to add comment