Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //views
- <div class="form-group">
- <label class="control-label col-md-3 col-sm-3 col-xs-12" for="char">Foto <?php echo form_error('foto'); echo $this->session->flashdata('foto');?> </label>
- <div class="col-md-6 col-sm-6 col-xs-12">
- <input type="file" name="foto" id="foto" required onchange="previewImage();" value="<?php echo $foto;?>">
- <img id="image-preview" alt="image preview"/>
- </div>
- </div>
- <style type="text/css">
- #image-preview{
- display:none;
- width : 100px;
- height:120px;
- }
- </style>
- <script>
- function previewImage() {
- document.getElementById("image-preview").style.display = "block";
- var oFReader = new FileReader();
- oFReader.readAsDataURL(document.getElementById("foto").files[0]);
- oFReader.onload = function(oFREvent) {
- document.getElementById("image-preview").src = oFREvent.target.result;
- };
- };
- </script>
- //controllel
- public function create_action_mhs()
- {
- $config['upload_path'] = './gambar/';
- $config['allowed_types'] = 'gif|jpg|png';
- $config['max_size'] = 10;
- //$config['max_width'] = 1024;
- //$config['max_height'] = 768;
- $this->load->library('upload', $config);
- $this->rules_mhs();
- if ($this->form_validation->run() == FALSE) {
- $this->create_mhs();
- }
- elseif(! $this->upload->do_upload($this->input->post('foto',TRUE))){
- $error9 = array('foto' => $this->upload->display_errors());
- $this->session->set_flashdata($error9);
- //redirect(site_url('super_admin/create_mhs'));
- $this->create_mhs();
- }
- else {
- date_default_timezone_set('Asia/jakarta');
- $user=$this->ion_auth->user()->row();
- if(empty($this->input->post('tgl_lahir',TRUE)))
- $tgl="";
- else
- $tgl=date('Y-m-d', strtotime($this->input->post('tgl_lahir',TRUE)));
- $this->upload->data();
- $data = array(
- 'nama' => $this->input->post('nama',TRUE),
- 'npm' => $this->input->post('npm',TRUE),
- 'fakultas' => $this->input->post('fakultas',TRUE),
- 'jurusan' => $this->input->post('jurusan',TRUE),
- 'semester' => $this->input->post('semester',TRUE),
- //'kamar' => $this->input->post('kamar',TRUE),
- //'operator' => $this->input->post('operator',TRUE),
- 'operator' => $user->first_name.' '.$user->last_name,
- 'noHP' => $this->input->post('noHP',TRUE),
- 'j_k' => $this->input->post('j_k',TRUE),
- 'ttl' => $this->input->post('ttl',TRUE),
- 'sertifikat_ldik' => $this->input->post('sertifikat_ldik',TRUE),
- 'foto' => $this->input->post('foto',TRUE),
- 'bahasa' => implode(" ",$this->input->post('bahasa',TRUE)),
- 'hobi' => $this->input->post('hobi',TRUE),
- 'keahlian' => $this->input->post('keahlian',TRUE),
- 'cita_cita' => $this->input->post('cita_cita',TRUE),
- 'tgl_lahir' => $tgl,
- );
- $this->admin_model->insert($data);
- //kamar_mhs
- /*$ambil_id_mhs = $this->db->get_where('daftar_mhs',array('npm'=>$this->input->post('npm',TRUE)));
- $ambil_id_kamar = $this->db->get_where('kamar',array('kamar'=>$this->input->post('kamar',TRUE)));
- foreach ($ambil_id_mhs->result() as $main){
- foreach ($ambil_id_kamar->result() as $mhs){
- $kamar_id=$mhs->id;
- $mhs_id=$main->id;
- }
- }
- $data_kamar=array(
- 'id_mhs' => $mhs_id,
- 'id_kamar' => $kamar_id
- );
- $this->mhs_kamar_model->insert($data_kamar);
- */
- //Data orang tua
- $ambil_id_mhs = $this->db->get_where('daftar_mhs',array('npm'=>$this->input->post('npm',TRUE)));
- foreach ($ambil_id_mhs->result() as $mhs1){
- $mhs_id=$mhs1->id;
- }
- $data_orang_tua = array(
- 'nama_Ayah' => $this->input->post('nama_Ayah',TRUE),
- 'noHP_Ayah' => $this->input->post('noHP_Ayah',TRUE),
- 'nama_Ibu' => $this->input->post('nama_Ibu',TRUE),
- 'noHP_Ibu' => $this->input->post('noHP_Ibu',TRUE),
- 'provinsi' => $this->input->post('provinsi',TRUE),
- 'kab' => $this->input->post('kab',TRUE),
- 'kec' => $this->input->post('kec',TRUE),
- 'desa' => $this->input->post('desa',TRUE),
- 'rt' => $this->input->post('rt',TRUE),
- 'id_mhs' => $mhs_id
- );
- $this->Data_orang_tua_model->insert($data_orang_tua);
- //END data orang tua
- $this->session->set_flashdata('message', 'Create Record Success');
- redirect(site_url('super_admin/mhs_list_ikhwan'));
- }
- }
Add Comment
Please, Sign In to add comment