emprit

input_niai

Dec 11th, 2012
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.99 KB | None | 0 0
  1. ------------Controller-------------------
  2. function administrasi_tambah()
  3. {
  4.     if(!$this->session->userdata('sudah_login_pelamar')){ redirect('index/index'); }
  5.     $this->load->model('input_nilai_model');
  6.     // upload dan save ke database
  7.     $process = array( 'insert' => $this->pelamar_model->tambahkelengkapan(),
  8.               'query' => $this->input_nilai_model->input_nilai()  
  9.             );
  10.  
  11.     if (isset($process['upload_message']))
  12.     {
  13.         $array = array( 'content' => $this->load->view('akun_pelamar/gagal','',true) );
  14.         $this->load->view('akun_pelamar/menu', $array);
  15.     }
  16.     else
  17.     {
  18.         $array = array( 'content' => $this->load->view('akun_pelamar/sukses','',true) );
  19.         $this->load->view('akun_pelamar/menu', $array);
  20.     }
  21.    }
  22.  
  23. -----------------Model--------------------
  24. <?php
  25. class  Input_nilai_model extends  CI_Model{
  26.         function input_nilai() {
  27.             //hitung value menurut kriteria penilaian
  28.             //ambil data sub kriteria      
  29.             $q = $this->db->query("SELECT * FROM sub_kriteria");
  30.             $res = $q->result();
  31.             foreach ($res as $row)
  32.             {              
  33.                 //samakan data sub krietria dg inputan form
  34.                
  35.                         if($row->nama == 'grade') {
  36.                            
  37.                                 if($this->input->post($row->nama) == 'swasta'){
  38.                                     $grade = 3;
  39.                                 }else {
  40.                                     $grade = 4;
  41.                                     }
  42.                                    
  43.                         }elseif($row->nama == 'strata') {
  44.                            
  45.                                 if($this->input->post($row->nama) == 'DIII'){
  46.                                     $strata = 1;
  47.                                 }elseif($this->input->post($row->nama) == 'S1'){
  48.                                     $strata = 2;
  49.                                 }else {
  50.                                     $strata = 4;
  51.                                     }
  52.                        
  53.                         }elseif($row->nama == 'ipk') {
  54.                            
  55.                                 if(1.5 <= $this->input->post($row->nama) AND $this->input->post($row->nama < 2.5)){
  56.                                     $ipk = 1;
  57.                                 }elseif(2.5 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 3.0) {
  58.                                     $ipk = 2;
  59.                                 }elseif(3.1 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 3.5) {
  60.                                     $ipk = 3;
  61.                                 }elseif(3.6 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 4.0) {
  62.                                     $ipk = 4;
  63.                                 }else {
  64.                                     $ipk = 0;
  65.                                     }
  66.                                    
  67.                         }elseif($row->nama == 'toefl') {
  68.                            
  69.                                 if($this->input->post($row->nama) < 350){
  70.                                     $toefl = 1;
  71.                                 }elseif(350 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 400) {
  72.                                     $toefl = 2;
  73.                                 }elseif(401 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 500) {
  74.                                     $toefl = 3;
  75.                                 }elseif(501 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 600) {
  76.                                     $toefl = 4;
  77.                                 }else {
  78.                                     $toefl = 5;
  79.                                     }
  80.                                    
  81.                         }elseif($row->nama == 's_autodesk') {
  82.                            
  83.                                 if($this->input->post($row->nama)){
  84.                                     $s_autodesk = 4;
  85.                                 }else{
  86.                                     $s_autodesk = 0;
  87.                                     }
  88.                                    
  89.                         }elseif($row->nama == 's_office') {
  90.                            
  91.                                 if($this->input->post($row->nama)){
  92.                                     $s_office = 2;
  93.                                 }else{
  94.                                     $s_office = 0;
  95.                                     }
  96.                                    
  97.                         }elseif($row->nama == 's_hakit') {
  98.                            
  99.                                 if($this->input->post($row->nama)){
  100.                                     $s_hakit = 2;
  101.                                 }else{
  102.                                     $s_hakit = 0;
  103.                                     }
  104.                                    
  105.                         }elseif($row->nama == 'jp') {
  106.                            
  107.                                 if($this->input->post($row->nama) == 'PT'){
  108.                                     $jp = 5;
  109.                                 }else{
  110.                                     $jp = 3;
  111.                                     }
  112.                                    
  113.                         }elseif($row->nama == 'lama_kerja') {
  114.                            
  115.                                 if($this->input->post($row->nama) <= 6){
  116.                                     $lama_kerja = 3;
  117.                                 }elseif(6 > $this->input->post($row->nama) AND $this->input->post($row->nama) <= 12){
  118.                                     $lama_kerja = 4;
  119.                                 }else{
  120.                                     $lama_kerja = 5;
  121.                                     }
  122.                                    
  123.                         }elseif($row->nama == 'jabatan') {
  124.                                
  125.                                 if($this->input->post($row->nama)) {
  126.                                     $jabatan = 3;
  127.                                 }else {
  128.                                     $jabatan = 0;
  129.                                     }
  130.                                    
  131.                         }elseif($row->nama == 's_skck') {
  132.                            
  133.                                 if($this->input->post($row->nama)){
  134.                                     $s_skck = 3;
  135.                                 }else{
  136.                                     $s_skck = 0;
  137.                                     }
  138.                                    
  139.                         }elseif($row->nama == 's_akte') {
  140.                            
  141.                                 if($this->input->post($row->nama)){
  142.                                     $s_akte = 2;
  143.                                 }else{
  144.                                     $s_akte = 0;
  145.                                     }
  146.                                    
  147.                         }elseif($row->nama == 's_kesehatan') {
  148.                            
  149.                                 if($this->input->post($row->nama)){
  150.                                     $s_kesehatan = 3;
  151.                                 }else{
  152.                                     $s_kesehatan = 0;
  153.                                     }
  154.                         }
  155.                 } //tutup cari nilai
  156.                
  157.                 //insert ke tabel
  158.                 $k = $this->db->query("SELECT * FROM kriteria");       
  159.                 $emp = $k->result();
  160.             foreach ($emp as $row2)
  161.             {  
  162.                     if($row2->id_kriteria == '3'){
  163.                        
  164.                         $k1 = $this->db->query("SELECT * FROM sub_kriteria WHERE id_kriteria = '3'");
  165.                         $query = $k1->result();
  166.                         $insert_data = array(
  167.                                                 'no_urut' => $this->input->post('no_urut')
  168.                                          );
  169.                                         foreach($query as $row){
  170.                                         $insert_data[$row->nama] = "$".$row->nama;      
  171.                                         }
  172.                         $insert = $this->db->insert('nilai_gap_3', $insert_data);
  173.                        
  174.                     }elseif($row2->kriteria == '5') {
  175.                        
  176.                         $k2 = $this->db->query("SELECT * FROM sub_kriteria WHERE id_kriteria = '5'");
  177.                         $query = $k2->result();
  178.                         $insert_data = array(
  179.                                                 'no_urut' => $this->input->post('no_urut')
  180.                                          );
  181.                                         foreach($query as $row){
  182.                                         $insert_data[$row->nama] = "$".$row->nama;      
  183.                                         }
  184.                         $insert = $this->db->insert('nilai_gap_5', $insert_data);
  185.                        
  186.                     }elseif($row2->kriteria == '6') {
  187.                        
  188.                         $k3 = $this->db->query("SELECT * FROM sub_kriteria WHERE id_kriteria = '6'");
  189.                         $query = $k3->result();
  190.                         $insert_data = array(
  191.                                                 'no_urut' => $this->input->post('no_urut')
  192.                                          );
  193.                                         foreach($query as $row){
  194.                                         $insert_data[$row->nama] = "$".$row->nama;      
  195.                                         }
  196.                         $insert = $this->db->insert('nilai_gap_6', $insert_data);
  197.                        
  198.                         }
  199.                     return $insert;
  200.             }                              
  201.     }
  202. }
  203. ?>
Advertisement
Add Comment
Please, Sign In to add comment