Advertisement
sanca

method inputsiswa

Sep 23rd, 2014
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. public function inputsiswa(){          
  2.    
  3.         $hitung=$this->siswa->hitung()+1;
  4.         $noreg=date('dmY').'-'.$hitung;
  5.         $nama_lengkap=strtoupper($this->request->post('nama_lengkap'));
  6.         $asal_sekolah=strtoupper($this->request->post('asal_sekolah'));
  7.         $kelamin=$this->request->post('kelamin');
  8.         $tmpt_lhr=strtoupper($this->request->post('tmpt_lhr'));
  9.         $tgl_lhr=$this->request->post('tgl_lhr');
  10.         $alamat=ucwords($this->request->post('alamat'));
  11.         $email=$this->request->post('email');
  12.         $telpon=$this->request->post('telpon');
  13.         $jurusan=$this->request->post('jurusan');
  14.         $tgl_masuk=$this->request->post('tgl_masuk');
  15.         $keterangan=ucfirst($this->request->post('keterangan'));
  16.         $user_id=$this->user->hitung()+1;
  17.         $status=$this->request->post('status');
  18.        
  19.         $this->upload->setOption(
  20.             array(
  21.                 'folderLocation' => 'public/img_siswa',
  22.                 'autoCreateFolder' => true,
  23.                 'permittedFileType' => 'gif|png|jpg|jpeg',
  24.                 'maximumSize' => 5000000,
  25.                 'setFileName'=>$noreg,
  26.             )
  27.         );
  28.         $this->upload->setErrorMessage(
  29.                 array(
  30.                     10 => 'Folder tidak tersedia.',
  31.                     3 => 'File yang anda upload terlalu besar.'
  32.                 )
  33.         );
  34.    
  35.     $data['messages'] = '';
  36.    
  37.     if(isset($_FILES['foto'])){
  38.        
  39.         $file = $this->upload->now($_FILES['foto']);       
  40.         if($file){     
  41.         $foto = $this->upload->getFileInfo();
  42.         $foto=$foto['name'];
  43.        
  44.         }else {    
  45.         $data['messages'] = $this->upload->getError('message');
  46.         $foto='';
  47.         }
  48.     }
  49.         $username=strtolower($this->request->post('username'));
  50.         $password=md5($this->request->post('password'));
  51.        
  52.         $db_siswa=array(
  53.             'noreg'=>$noreg,
  54.             'nama_lengkap'=>$nama_lengkap,
  55.             'asal_sekolah'=>$asal_sekolah,
  56.             'kelamin'=>$kelamin,
  57.             'tmpt_lhr'=>$tmpt_lhr,
  58.             'tgl_lhr'=>$tgl_lhr,
  59.             'alamat'=>$alamat,
  60.             'email'=>$email,
  61.             'telpon'=>$telpon,
  62.             'jurusan'=>$jurusan,
  63.             'tgl_masuk'=>$tgl_masuk,
  64.             'keterangan'=>$keterangan,
  65.             'status'=>$status,
  66.             'foto'=>$foto,
  67.             'user_id'=>$user_id,
  68.            
  69.         );
  70.        
  71.         $db_user=array(
  72.             'username'=>$username,
  73.             'password'=>$password,
  74.             'level'=>'siswa',
  75.         );
  76.         $this->user->input($db_user);      
  77.         $this->siswa->input($db_siswa);
  78.         $data['title'] = 'Input Siswa';
  79.         $data['konten'] = 'konten/view_siswa';
  80.         $data['message']='Anda berhasil input siswa';
  81.         $data['data_siswa']=$this->siswa->viewall();
  82.         $data['data_jurusan']=$this->jurusan->viewall();
  83.        
  84.         $this->output('home', $data);  
  85.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement