sebuahhobi

create_action_mhs

Oct 13th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. public function create_action_mhs()
  2. {
  3. $config['upload_path'] = './gambar/';
  4. $config['allowed_types'] = 'gif|jpg|png';
  5. $config['max_size'] = 10;
  6. //$config['max_width'] = 1024;
  7. //$config['max_height'] = 768;
  8.  
  9. $this->load->library('upload', $config);
  10.  
  11. $this->rules_mhs();
  12.  
  13. if ($this->form_validation->run() == FALSE) {
  14. $this->create_mhs();
  15. }
  16. elseif(! $this->upload->do_upload('foto')){
  17. $error = array('error' => $this->upload->display_errors());
  18. $this->session->set_flashdata('msg',$error);
  19. $this->create_mhs();
  20. }
  21. else {
  22. unset($_SESSION['msg']);
  23. date_default_timezone_set('Asia/jakarta');
  24. $user=$this->ion_auth->user()->row();
  25. if(empty($this->input->post('tgl_lahir',TRUE)))
  26. $tgl="";
  27. else
  28. $tgl=date('Y-m-d', strtotime($this->input->post('tgl_lahir',TRUE)));
  29.  
  30. $data1 = array('upload_data' => $this->upload->data());
  31. $data = array(
  32. 'nama' => $this->input->post('nama',TRUE),
  33. 'npm' => $this->input->post('npm',TRUE),
  34. 'fakultas' => $this->input->post('fakultas',TRUE),
  35. 'jurusan' => $this->input->post('jurusan',TRUE),
  36. 'semester' => $this->input->post('semester',TRUE),
  37. //'kamar' => $this->input->post('kamar',TRUE),
  38. //'operator' => $this->input->post('operator',TRUE),
  39. 'operator' => $user->first_name.' '.$user->last_name,
  40. 'noHP' => $this->input->post('noHP',TRUE),
  41. 'j_k' => $this->input->post('j_k',TRUE),
  42. 'ttl' => $this->input->post('ttl',TRUE),
  43. 'sertifikat_ldik' => $this->input->post('sertifikat_ldik',TRUE),
  44. 'foto' => $data1['upload_data']['full_path'],
  45. 'bahasa' => implode(" ",$this->input->post('bahasa',TRUE)),
  46. 'hobi' => $this->input->post('hobi',TRUE),
  47. 'keahlian' => $this->input->post('keahlian',TRUE),
  48. 'cita_cita' => $this->input->post('cita_cita',TRUE),
  49. 'tgl_lahir' => $tgl,
  50. );
  51. $this->admin_model->insert($data);
  52. //kamar_mhs
  53. /*$ambil_id_mhs = $this->db->get_where('daftar_mhs',array('npm'=>$this->input->post('npm',TRUE)));
  54. $ambil_id_kamar = $this->db->get_where('kamar',array('kamar'=>$this->input->post('kamar',TRUE)));
  55. foreach ($ambil_id_mhs->result() as $main){
  56. foreach ($ambil_id_kamar->result() as $mhs){
  57. $kamar_id=$mhs->id;
  58. $mhs_id=$main->id;
  59.  
  60. }
  61. }
  62.  
  63. $data_kamar=array(
  64. 'id_mhs' => $mhs_id,
  65. 'id_kamar' => $kamar_id
  66. );
  67. $this->mhs_kamar_model->insert($data_kamar);
  68. */
  69. //Data orang tua
  70. $ambil_id_mhs = $this->db->get_where('daftar_mhs',array('npm'=>$this->input->post('npm',TRUE)));
  71. foreach ($ambil_id_mhs->result() as $mhs1){
  72. $mhs_id=$mhs1->id;
  73. }
  74. $data_orang_tua = array(
  75. 'nama_Ayah' => $this->input->post('nama_Ayah',TRUE),
  76. 'noHP_Ayah' => $this->input->post('noHP_Ayah',TRUE),
  77. 'nama_Ibu' => $this->input->post('nama_Ibu',TRUE),
  78. 'noHP_Ibu' => $this->input->post('noHP_Ibu',TRUE),
  79. 'provinsi' => $this->input->post('provinsi',TRUE),
  80. 'kab' => $this->input->post('kab',TRUE),
  81. 'kec' => $this->input->post('kec',TRUE),
  82. 'desa' => $this->input->post('desa',TRUE),
  83. 'rt' => $this->input->post('rt',TRUE),
  84. 'id_mhs' => $mhs_id
  85. );
  86.  
  87. $this->Data_orang_tua_model->insert($data_orang_tua);
  88. //END data orang tua
  89.  
  90. $this->session->set_flashdata('message', 'Create Record Success');
  91. redirect(site_url('super_admin/mhs_list_ikhwan'));
  92. }
  93. }
Add Comment
Please, Sign In to add comment