Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit ('No direct script access allowed');
- Class Admin extends CI_Controller
- {
- public function __construct()
- {
- parent:: __construct();
- $this->load->model('auth_model');
- if(!isset($_SESSION['user_logged'])){
- $this->session->set_flashdata("error","please login");
- redirect ("auth/login");
- }
- }
- public function index()
- {
- $data_content['view_isi'] = "admins/profile";
- $this->load->view('admins/beranda_admin',$data_content);
- }
- public function datasiswa()
- {
- $data_content['view_isi'] = "admins/datasiswa";
- $this->load->view('admins/beranda_admin',$data_content);
- }
- public function do_upload()
- {
- $username = $this->input->post('username');
- $namauser = $this->input->post('namauser');
- $password = $this->input->post('password');
- $email = $this->input->post('email');
- $config = array(
- 'upload_path' =>'./assets/dist/img/',
- 'allowed_types' => 'gif|jpg|png',
- 'max_size' => 100,
- 'max_width' => 1024,
- 'max_height' => 768,
- );
- $this->load->library('upload',$config);
- $data_gbr = $_FILES['changepic']['name'];
- if ( ! $this->upload->do_upload('changepic'))
- {
- echo "gagal";
- }
- else
- {
- $data = array (
- 'username' => $username,
- 'nama_user' => $namauser,
- 'password' => $password,
- 'email'=> $email,
- 'gambar' => $data_gbr
- );
- $this->db->where('username', $username);
- $this->db->update('m_user',$data);
- }
- }
- public function showAllSiswa()
- {
- $result = $this->auth_model->showAllSiswa();
- $datasiswa = [];
- $datasiswa['data'] = [];
- foreach($result as $index => $value) {
- $datasiswa['data'][$index] = array(
- $value->NIS,
- $value->NAMA,
- $value->KELAS,
- $value->JURUSAN,
- $value->ALAMAT
- );
- };
- echo json_encode($datasiswa);
- }
- //......................... I N D U S T R I ...............................
- public function dataindustri()
- {
- $data_content['view_isi'] = "admins/dataindustri";
- $this->load->view('admins/beranda_admin',$data_content);
- }
- public function showDataIndustri()
- {
- $result = $this->auth_model->showDataIndustri();
- $dataindustri = [];
- $dataindustri['data'] = [];
- foreach($result as $index => $value) {
- $dataindustri['data'][$index] = array (
- $value->nama_industri,
- $value->alamat_industri,
- $value->telepon_industri,
- $value->jurusan,
- '<input type="button" class="btn btn-default" onclick="editIndustri('.$value->kode_industri.')" value="Edit" data-target="#editIndustriModal">'
- );
- };
- echo json_encode($dataindustri);
- }
- public function add_industri()
- {
- $data = array(
- 'nama_industri' => $this->input->post('nama'),
- 'alamat_industri' => $this->input->post('alamat'),
- 'telepon_industri' => $this->input->post('telepon'),
- 'jurusan' => $this->input->post('jurusan'),
- );
- $insert = $this->auth_model->saveIndustri($data);
- echo json_encode(array("status" => TRUE));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement