Advertisement
Guest User

Untitled

a guest
Nov 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit ('No direct script access allowed');
  3.  
  4. Class Admin extends CI_Controller
  5. {
  6. public function __construct()
  7. {
  8. parent:: __construct();
  9. $this->load->model('auth_model');
  10. if(!isset($_SESSION['user_logged'])){
  11. $this->session->set_flashdata("error","please login");
  12. redirect ("auth/login");
  13. }
  14. }
  15. public function index()
  16. {
  17. $data_content['view_isi'] = "admins/profile";
  18. $this->load->view('admins/beranda_admin',$data_content);
  19.  
  20. }
  21. public function datasiswa()
  22. {
  23. $data_content['view_isi'] = "admins/datasiswa";
  24. $this->load->view('admins/beranda_admin',$data_content);
  25. }
  26. public function do_upload()
  27. {
  28. $username = $this->input->post('username');
  29. $namauser = $this->input->post('namauser');
  30. $password = $this->input->post('password');
  31. $email = $this->input->post('email');
  32. $config = array(
  33. 'upload_path' =>'./assets/dist/img/',
  34. 'allowed_types' => 'gif|jpg|png',
  35. 'max_size' => 100,
  36. 'max_width' => 1024,
  37. 'max_height' => 768,
  38. );
  39. $this->load->library('upload',$config);
  40. $data_gbr = $_FILES['changepic']['name'];
  41. if ( ! $this->upload->do_upload('changepic'))
  42. {
  43. echo "gagal";
  44. }
  45. else
  46. {
  47. $data = array (
  48. 'username' => $username,
  49. 'nama_user' => $namauser,
  50. 'password' => $password,
  51. 'email'=> $email,
  52. 'gambar' => $data_gbr
  53. );
  54.  
  55. $this->db->where('username', $username);
  56.  
  57. $this->db->update('m_user',$data);
  58. }
  59.  
  60. }
  61. public function showAllSiswa()
  62. {
  63. $result = $this->auth_model->showAllSiswa();
  64.  
  65. $datasiswa = [];
  66. $datasiswa['data'] = [];
  67. foreach($result as $index => $value) {
  68. $datasiswa['data'][$index] = array(
  69. $value->NIS,
  70. $value->NAMA,
  71. $value->KELAS,
  72. $value->JURUSAN,
  73. $value->ALAMAT
  74. );
  75. };
  76.  
  77. echo json_encode($datasiswa);
  78. }
  79. //......................... I N D U S T R I ...............................
  80. public function dataindustri()
  81. {
  82. $data_content['view_isi'] = "admins/dataindustri";
  83. $this->load->view('admins/beranda_admin',$data_content);
  84. }
  85. public function showDataIndustri()
  86. {
  87. $result = $this->auth_model->showDataIndustri();
  88. $dataindustri = [];
  89. $dataindustri['data'] = [];
  90.  
  91. foreach($result as $index => $value) {
  92. $dataindustri['data'][$index] = array (
  93. $value->nama_industri,
  94. $value->alamat_industri,
  95. $value->telepon_industri,
  96. $value->jurusan,
  97. '<input type="button" class="btn btn-default" onclick="editIndustri('.$value->kode_industri.')" value="Edit" data-target="#editIndustriModal">'
  98. );
  99. };
  100.  
  101. echo json_encode($dataindustri);
  102. }
  103.  
  104.  
  105. public function add_industri()
  106.  
  107. {
  108. $data = array(
  109. 'nama_industri' => $this->input->post('nama'),
  110. 'alamat_industri' => $this->input->post('alamat'),
  111. 'telepon_industri' => $this->input->post('telepon'),
  112. 'jurusan' => $this->input->post('jurusan'),
  113. );
  114. $insert = $this->auth_model->saveIndustri($data);
  115. echo json_encode(array("status" => TRUE));
  116.  
  117.  
  118. }
  119.  
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement