Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class operator extends CI_Controller {
- public function __construct() {
- parent::__construct();
- if($this->session->userdata('level') != 'Operator' and $this->session->userdata('isLogin') != 1)
- {
- $this->session->set_flashdata('msg', 'Anda harus login terlebih dahulu !!!');
- redirect('log');
- }
- $this->load->library('excel_reader.php');
- $this->load->model('Train_model');
- $this->load->model('user_model','us');
- $this->load->model('View_training','VT');
- }
- public function index()
- {
- //$this->load->view('welcome_message');
- //$this->load->view('tampilan');
- $isi['isi']='Home';
- $this->load->view('template_ope',$isi);
- }
- public function view(){
- $data['View_training'] = $this->VT->selectAll();
- $data['isi']='opp/Data_view';
- $this->load->view('template_ope', $data);
- }
- public function upload(){
- $data['View_training'] = $this->VT->selectAll();
- $data['isi']='opp/upload_form';
- $this->load->view('template_ope', $data);
- }
- public function user(){
- $data['user']=$this->us->show_user();
- $data['isi']='opp/tampil_user';
- $this->load->view('template_ope',$data);
- }
- public function cari(){
- $cat = $this->input->post('pilih');
- if ($cat == 1) {
- $tgl_awal = $this->input->post('tanggal');
- $tgl_akhir = $this->input->post('tanggal_2');
- $data['View_training'] = $this->VT->cari_plan_tgl($tgl_awal,$tgl_akhir);
- $data['isi']='opp/Data_view';
- $this->load->view('template_ope', $data);
- }
- elseif ($cat == 2){
- $judul=$this->input->post('materi');
- if ($judul == "") {
- redirect ("view" , "refresh");
- }
- else {
- $data['View_training'] = $this->VT->cari_plan_judul($judul);
- $data['isi']='opp/Data_view';
- $this->load->view('template_ope', $data);
- }
- }
- else {
- redirect ("view" , "refresh");
- }
- }
- public function do_upload() {
- $config['upload_path'] = './temp_upload/';
- $config['allowed_types'] = 'xls';
- $this->load->library('upload', $config);
- if ( ! $this->upload->do_upload()) {
- $data = array('error' => $this->upload->display_errors());
- }
- else {
- $upload_data = $this->upload->data();
- //$this->load->library('excel_reader.php');
- $this->excel_reader->setOutputEncoding('CP1251');
- $data = new excel_reader($_FILES['userfile']['tmp_name']);
- $file = $upload_data['full_path'];
- $this->excel_reader->read($file);
- error_reporting(E_ALL ^ E_NOTICE);
- // Sheet 1
- $data = $this->excel_reader->sheets[0] ;
- $dataexcel = Array();
- for ($i = 1; $i <= $data['numRows']; $i++) {
- if($data['cells'][$i][1] == '') break;
- $dataexcel[$i-1]['KODE_PLAN'] = $data['cells'][$i][1];
- $dataexcel[$i-1]['ANGKATAN'] = $data['cells'][$i][2];
- $dataexcel[$i-1]['TGL_MULAI'] = $data['cells'][$i][3];
- $dataexcel[$i-1]['TGL_AKHIR'] = $data['cells'][$i][4];
- $dataexcel[$i-1]['ANGGARAN'] = $data['cells'][$i][5];
- $dataexcel[$i-1]['PST_A'] = $data['cells'][$i][6];
- $dataexcel[$i-1]['TGL_AWAL_REAL'] = $data['cells'][$i][7];
- $dataexcel[$i-1]['TGL_AKHIR_REAL'] = $data['cells'][$i][8];
- $dataexcel[$i-1]['ANGGARAN_REAL'] = $data['cells'][$i][9];
- $dataexcel[$i-1]['PST_REAL'] = $data['cells'][$i][10];
- $dataexcel[$i-1]['KODE_M'] = $data['cells'][$i][11];
- $dataexcel[$i-1]['KODE_INST'] = $data['cells'][$i][12];
- $dataexcel[$i-1]['KODE_UBIS'] = $data['cells'][$i][13];
- $dataexcel[$i-1]['KODE_LC'] = $data['cells'][$i][14];
- $dataexcel[$i-1]['Terlaksana'] = $data['cells'][$i][15];
- $dataexcel[$i-1]['Komen'] = $data['cells'][$i][16];
- }
- delete_files($upload_data['file_path']);
- //$this->load->model('View_training');
- $this->View_training->tambahdata($dataexcel);
- //data['plan'] = $this->VT->getupload();
- }
- //$data['View_training'] = $this->View_training->getupload();
- $data['plan'] = $this->VT->getupload();
- $this->load->view('opp/view_upload','template_ope', $data);
- $this->session->set_flashdata('msg', 'Data Berhasil Disimpan !!!');
- //redirect('operator/view');
- }
- public function delete($id){
- $this->us->delete($id);
- redirect('operator/user');
- }
- public function Adduser(){
- $data['akses']=$this->us->Get_akses('user','Akses');
- foreach($data as $key=>$r){
- }
- $data['isi']='opp/add_user';
- $this->load->view('template_ope',$data);
- }
- public function tambah_user(){
- $nik=$this->input->post('nik');
- $nama=$this->input->post('nama');
- $almt=$this->input->post('almt');
- $user=$this->input->post('user');
- $pass=$this->input->post('pass');
- $akses=$this->input->post('akses');
- $this->form_validation->set_rules('nik', 'Nik', 'required|alpha_dash|min_length[7]|max_length[7]|callback_username_check');
- $this->form_validation->set_rules('nama', 'nama', 'required');
- $this->form_validation->set_rules('almt', 'Alamat', 'required');
- $this->form_validation->set_rules('user', 'Username', 'required');
- $this->form_validation->set_rules('pass', 'Password', 'required');
- if ($this->form_validation->run() == FALSE)
- {
- $this->session->set_flashdata('msg', 'Periksa Kembali Semua Data !!!');
- redirect('operator/Adduser','refresh');".";
- }
- else
- {
- $data_user=$this->us->lihat_user($nik);
- if ($data_user['NIK']==$nik and $data_user['username']==$user) {
- $this->session->set_flashdata('msg', 'Duplikat NIK dan Username!!!');
- redirect('operator/Adduser','refresh');".";
- }
- elseif($data_user['NIK']== $nik or $data_user['username']==$user){
- $this->session->set_flashdata('msg', 'Duplikat NIK atau Username!!!');
- redirect('operator/Adduser','refresh');".";
- }
- else {
- $this->us->tambah( $nik,$nama,$almt,$user,$pass,$akses);
- $this->session->set_flashdata('msg', 'Data Berhasil Disimpan !!!');
- redirect('operator/user','refresh');".";
- }
- }
- }
- public function edit($nik){
- $data['akses']=$this->us->Get_akses('user','Akses');
- foreach($data as $key=>$r){
- }
- $data['m'] = $this->us->show_user_by($nik);
- $data['isi']='opp/Edit_User';
- $this->load->view('template_ope',$data);
- }
- public function update_user(){
- $nik=$this->input->post('nik');
- $nama=$this->input->post('nama');
- $almt=$this->input->post('almt');
- $user=$this->input->post('user');
- $pass=$this->input->post('pass');
- $akses=$this->input->post('akses');
- $this->form_validation->set_rules('nik', 'Nik', 'required|alpha_dash|min_length[7]|max_length[7]|callback_username_check');
- $this->form_validation->set_rules('nama', 'nama', 'required');
- $this->form_validation->set_rules('almt', 'Alamat', 'required');
- $this->form_validation->set_rules('user', 'Username', 'required');
- if ($this->form_validation->run() == FALSE)
- {
- redirect('operator/user','refresh');
- }
- else
- {
- if($pass != "")
- {
- $this->us->update($nik,$nama,$almt,$user,$pass,$akses);
- }else{
- $this->us->update_no_pass($nik,$nama,$almt,$user,$akses);
- }
- $this->session->set_flashdata('msg', 'Data Berhasil Diupdate !!!');
- redirect('operator/user','refresh');
- }
- }
- }
Add Comment
Please, Sign In to add comment