Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------Controller-------------------
- function administrasi_tambah()
- {
- if(!$this->session->userdata('sudah_login_pelamar')){ redirect('index/index'); }
- $this->load->model('input_nilai_model');
- // upload dan save ke database
- $process = array( 'insert' => $this->pelamar_model->tambahkelengkapan(),
- 'query' => $this->input_nilai_model->input_nilai()
- );
- if (isset($process['upload_message']))
- {
- $array = array( 'content' => $this->load->view('akun_pelamar/gagal','',true) );
- $this->load->view('akun_pelamar/menu', $array);
- }
- else
- {
- $array = array( 'content' => $this->load->view('akun_pelamar/sukses','',true) );
- $this->load->view('akun_pelamar/menu', $array);
- }
- }
- -----------------Model--------------------
- <?php
- class Input_nilai_model extends CI_Model{
- function input_nilai() {
- //hitung value menurut kriteria penilaian
- //ambil data sub kriteria
- $q = $this->db->query("SELECT * FROM sub_kriteria");
- $res = $q->result();
- foreach ($res as $row)
- {
- //samakan data sub krietria dg inputan form
- if($row->nama == 'grade') {
- if($this->input->post($row->nama) == 'swasta'){
- $grade = 3;
- }else {
- $grade = 4;
- }
- }elseif($row->nama == 'strata') {
- if($this->input->post($row->nama) == 'DIII'){
- $strata = 1;
- }elseif($this->input->post($row->nama) == 'S1'){
- $strata = 2;
- }else {
- $strata = 4;
- }
- }elseif($row->nama == 'ipk') {
- if(1.5 <= $this->input->post($row->nama) AND $this->input->post($row->nama < 2.5)){
- $ipk = 1;
- }elseif(2.5 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 3.0) {
- $ipk = 2;
- }elseif(3.1 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 3.5) {
- $ipk = 3;
- }elseif(3.6 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 4.0) {
- $ipk = 4;
- }else {
- $ipk = 0;
- }
- }elseif($row->nama == 'toefl') {
- if($this->input->post($row->nama) < 350){
- $toefl = 1;
- }elseif(350 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 400) {
- $toefl = 2;
- }elseif(401 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 500) {
- $toefl = 3;
- }elseif(501 <= $this->input->post($row->nama) AND $this->input->post($row->nama) <= 600) {
- $toefl = 4;
- }else {
- $toefl = 5;
- }
- }elseif($row->nama == 's_autodesk') {
- if($this->input->post($row->nama)){
- $s_autodesk = 4;
- }else{
- $s_autodesk = 0;
- }
- }elseif($row->nama == 's_office') {
- if($this->input->post($row->nama)){
- $s_office = 2;
- }else{
- $s_office = 0;
- }
- }elseif($row->nama == 's_hakit') {
- if($this->input->post($row->nama)){
- $s_hakit = 2;
- }else{
- $s_hakit = 0;
- }
- }elseif($row->nama == 'jp') {
- if($this->input->post($row->nama) == 'PT'){
- $jp = 5;
- }else{
- $jp = 3;
- }
- }elseif($row->nama == 'lama_kerja') {
- if($this->input->post($row->nama) <= 6){
- $lama_kerja = 3;
- }elseif(6 > $this->input->post($row->nama) AND $this->input->post($row->nama) <= 12){
- $lama_kerja = 4;
- }else{
- $lama_kerja = 5;
- }
- }elseif($row->nama == 'jabatan') {
- if($this->input->post($row->nama)) {
- $jabatan = 3;
- }else {
- $jabatan = 0;
- }
- }elseif($row->nama == 's_skck') {
- if($this->input->post($row->nama)){
- $s_skck = 3;
- }else{
- $s_skck = 0;
- }
- }elseif($row->nama == 's_akte') {
- if($this->input->post($row->nama)){
- $s_akte = 2;
- }else{
- $s_akte = 0;
- }
- }elseif($row->nama == 's_kesehatan') {
- if($this->input->post($row->nama)){
- $s_kesehatan = 3;
- }else{
- $s_kesehatan = 0;
- }
- }
- } //tutup cari nilai
- //insert ke tabel
- $k = $this->db->query("SELECT * FROM kriteria");
- $emp = $k->result();
- foreach ($emp as $row2)
- {
- if($row2->id_kriteria == '3'){
- $k1 = $this->db->query("SELECT * FROM sub_kriteria WHERE id_kriteria = '3'");
- $query = $k1->result();
- $insert_data = array(
- 'no_urut' => $this->input->post('no_urut')
- );
- foreach($query as $row){
- $insert_data[$row->nama] = "$".$row->nama;
- }
- $insert = $this->db->insert('nilai_gap_3', $insert_data);
- }elseif($row2->kriteria == '5') {
- $k2 = $this->db->query("SELECT * FROM sub_kriteria WHERE id_kriteria = '5'");
- $query = $k2->result();
- $insert_data = array(
- 'no_urut' => $this->input->post('no_urut')
- );
- foreach($query as $row){
- $insert_data[$row->nama] = "$".$row->nama;
- }
- $insert = $this->db->insert('nilai_gap_5', $insert_data);
- }elseif($row2->kriteria == '6') {
- $k3 = $this->db->query("SELECT * FROM sub_kriteria WHERE id_kriteria = '6'");
- $query = $k3->result();
- $insert_data = array(
- 'no_urut' => $this->input->post('no_urut')
- );
- foreach($query as $row){
- $insert_data[$row->nama] = "$".$row->nama;
- }
- $insert = $this->db->insert('nilai_gap_6', $insert_data);
- }
- return $insert;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment