cod3yoda

controller_ppdb

Jul 23rd, 2021
1,074
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. class Pendaftar extends ci_controller{
  3.     function __construct(){
  4.         parent::__construct();
  5.  
  6.         if($this->session->userdata('hakakses') != 'admin' and $this->session->userdata('hakakses') != 'operator' and $this->session->userdata('hakakses') != 'pendaftar'){
  7.             redirect('Login');
  8.         }
  9.  
  10.         date_default_timezone_set('Asia/Jakarta');
  11.     }
  12.     function index(){
  13.         redirect('Login');
  14.     }
  15.  
  16.     function NextId(){
  17.         $nextid=$this->db->query("select ifnull(max(no_pendaftar),0) as nextid from t_pendaftar")->row()->nextid;
  18.         if($nextid=='0'){
  19.             $nextid='CP0001';
  20.         }else{
  21.             $nextid=substr($nextid,2,4)+1;
  22.             $nextid="CP".substr("0000",0,4 - strlen($nextid)) . $nextid;
  23.         }
  24.        
  25.         return $nextid;
  26.     }
  27.  
  28.     function next_no_antrian($tgl){
  29.         $hasil=$this->db->query("select ifnull(max(no_antrian),0)+1 as nextno from t_pendaftar where tgl_penyerahan='$tgl'")->row()->nextno;
  30.         return $hasil;
  31.     }
  32.  
  33.     function cari_jml_penyerahan(){
  34.         $tgl=$this->input->post('cariisi');
  35.         $jml=$this->db->query("select count(*) as jml from t_pendaftar where tgl_penyerahan='".$tgl."'")->row()->jml;
  36.         $temp="";
  37.         if($jml<=150){
  38.             $temp=true;
  39.         }else{
  40.             $temp=false;
  41.         }
  42.  
  43.         echo $temp;
  44.     }
  45.  
  46.  
  47.     function cari_isi_juara(){
  48.         $id=$this->input->post('cariisi');
  49.         if($id==4){
  50.             $temp="<option value=''>- Pilih -</option>
  51.            <option value='4'>Rangking 1</option>
  52.            <option value='5'>Rangking 2</option>
  53.            <option value='6'>Rangking 3</option>";
  54.         }else{
  55.             $temp="<option value=''>- Pilih -</option>
  56.            <option value='1'>Juara 1</option>
  57.            <option value='2'>Juara 2</option>
  58.            <option value='3'>Juara 3</option>";
  59.         }
  60.         echo $temp;
  61.     }
  62.  
  63.     function cari_isi_kabupaten(){
  64.         $id=$this->input->post('cariisi');
  65.         $data=$this->db->query("select * from t_kabupaten where id_provinsi='".$id."'")->result();
  66.         $temp="<option value=''>- Pilih -</option>";
  67.         foreach($data as $d){
  68.             $temp=$temp."<option value='".$d->id_kabupaten."'>".$d->nama_kabupaten."</option>";
  69.         }
  70.         echo $temp;
  71.     }
  72.  
  73.     function cari_isi_kecamatan(){
  74.         $id=$this->input->post('cariisi');
  75.         $data=$this->db->query("select * from t_kecamatan where id_kabupaten='".$id."'")->result();
  76.         $temp="<option value=''>- Pilih -</option>";
  77.         foreach($data as $d){
  78.             $temp=$temp."<option value='".$d->id_kecamatan."'>".$d->nama_kecamatan."</option>";
  79.         }
  80.         echo $temp;
  81.     }
  82.  
  83.     function cari_isi_kelurahan(){
  84.         $id=$this->input->post('cariisi');
  85.         $data=$this->db->query("select * from t_kelurahan where id_kecamatan='".$id."'")->result();
  86.         $temp="<option value=''>- Pilih -</option>";
  87.         foreach($data as $d){
  88.             $temp=$temp."<option value='".$d->id_kelurahan."'>".$d->nama_kelurahan."</option>";
  89.         }
  90.         echo $temp;
  91.     }
  92.  
  93.     function zonasi(){
  94.         $data['title'] = 'Jalur Zonasi';
  95.         $data['pendaftar'] = $this->db->query("select p.*,avg(n.rerata) as na from t_pendaftar p left join t_nilai n on p.no_pendaftar=n.no_pendaftar where jalur='1' group by no_pendaftar order by no_pendaftar ")->result();
  96.         $data['quota']=$this->db->query("select quota from t_jalur where id_jalur='1'")->row()->quota;
  97.         $data['file']='Admin/Pendaftar/data_zonasi';
  98.         $this->load->view('Admin/Main',$data);
  99.     }
  100.  
  101.     function prestasi(){
  102.         $data['title'] = 'Jalur Prestasi';
  103.         $data['pendaftar'] = $this->db->query("select p.*,avg(n.rerata) as na from t_pendaftar p left join t_nilai n on p.no_pendaftar=n.no_pendaftar where jalur='2' group by no_pendaftar order by no_pendaftar")->result();
  104.         $data['quota']=$this->db->query("select quota from t_jalur where id_jalur='2'")->row()->quota;
  105.         $data['file']='Admin/Pendaftar/data_prestasi';
  106.         $this->load->view('Admin/Main',$data);
  107.     }
  108.  
  109.     function afirmasi(){
  110.         $data['title'] = 'Jalur Afirmasi';
  111.         $data['pendaftar'] = $this->db->query("select p.*,avg(n.rerata) as na from t_pendaftar p left join t_nilai n on p.no_pendaftar=n.no_pendaftar where jalur='3' group by no_pendaftar order by no_pendaftar")->result();
  112.         $data['quota']=$this->db->query("select quota from t_jalur where id_jalur='3'")->row()->quota;
  113.         $data['file']='Admin/Pendaftar/data_afirmasi';
  114.         $this->load->view('Admin/Main',$data);
  115.     }
  116.  
  117.     function perpindahan(){
  118.         $data['title'] = 'Jalur Perpindahan';
  119.         $data['pendaftar'] = $this->db->query("select p.*,avg(n.rerata) as na from t_pendaftar p left join t_nilai n on p.no_pendaftar=n.no_pendaftar where jalur='4' group by no_pendaftar order by no_pendaftar")->result();
  120.         $data['quota']=$this->db->query("select quota from t_jalur where id_jalur='4'")->row()->quota;
  121.         $data['file']='Admin/Pendaftar/data_perpindahan';
  122.         $this->load->view('Admin/Main',$data);
  123.     }
  124.  
  125.     function prestasi_akademik(){
  126.         $data['title'] = 'Jalur Prestasi Akademik';
  127.         $data['pendaftar'] = $this->db->query("select p.*,avg(n.rerata) as na from t_pendaftar p left join t_nilai n on p.no_pendaftar=n.no_pendaftar where jalur='5' group by no_pendaftar order by no_pendaftar")->result();
  128.         $data['quota']=$this->db->query("select quota from t_jalur where id_jalur='5'")->row()->quota;
  129.         $data['file']='Admin/Pendaftar/data_prestasi_akademik';
  130.         $this->load->view('Admin/Main',$data);
  131.     }
  132.  
  133.     function abk(){
  134.         $data['title'] = 'Jalur Anak Berkebutuhan Khusus';
  135.         $data['pendaftar'] = $this->db->query("select p.*,avg(n.rerata) as na from t_pendaftar p left join t_nilai n on p.no_pendaftar=n.no_pendaftar where jalur='6' group by no_pendaftar order by no_pendaftar")->result();
  136.         $data['quota']=$this->db->query("select quota from t_jalur where id_jalur='6'")->row()->quota;
  137.         $data['file']='Admin/Pendaftar/data_abk';
  138.         $this->load->view('Admin/Main',$data);
  139.     }
  140.    
  141.     function import_pendaftar(){
  142.         $data['title'] = 'Import Data Pendaftar';
  143.         $data['file']='Admin/Pendaftar/Pendaftar_import';
  144.         $this->load->view('Admin/Main',$data);
  145.     }
  146.    
  147.     function import_pendaftar_proses(){
  148.         $this->load->library(array('PHPExcel','PHPExcel/IOFactory'));
  149.         delete_files('./assets/files/temp/',TRUE);
  150.         $config['upload_path'] = './assets/files/temp/';
  151.         $config['allowed_types'] = '*';
  152.         $config['file_name']='pendaftar';
  153.         $this->upload->initialize($config);
  154.         if(!$this->upload->do_upload('userfile')){
  155.             $hasil=0;
  156.         }
  157.         else{
  158.             $file=$this->upload->data('userfile');
  159.             $dbName = $file['full_path'];
  160.             ini_set('memory_limit', '-1');
  161.             ini_set('max_execution_time', 1000);
  162.             ini_set('post_max_size', '128M');
  163.             ini_set('upload_max_filesize', '128M');
  164.             if (!file_exists($dbName)) {
  165.                 die("Could not find database file.");
  166.             }else{
  167.                 $hasil=1;
  168.             }
  169.                     //baca data excel
  170.             try {
  171.                 $inputFileType = IOFactory::identify($dbName);
  172.                 $objReader = IOFactory::createReader($inputFileType);
  173.                 $objPHPExcel = $objReader->load($dbName);
  174.             } catch(Exception $e) {
  175.                 die('Error loading file "'.pathinfo($dbName,PATHINFO_BASENAME).'": '.$e->getMessage());
  176.             }
  177.  
  178.                     //  Get worksheet dimensions
  179.             $sheet = $objPHPExcel->getSheet(0);
  180.             $highestRow = $sheet->getHighestRow();
  181.             $highestColumn = $sheet->getHighestColumn();
  182.  
  183.                     //  Loop through each row of the worksheet in turn
  184.                 for ($row = 2; $row <= $highestRow; $row++){                  //  Read a row of data into an array                
  185.                     $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row,
  186.                         NULL,
  187.                         TRUE,
  188.                         FALSE);
  189.  
  190.                     $nisn=$rowData[0][0] == null?' ':$rowData[0][0];
  191.                     $nama=$rowData[0][1] == null?' ':$rowData[0][1];
  192.                     $jk=$rowData[0][2] == null?' ':$rowData[0][2];
  193.                     $tahun_keluar=$rowData[0][3] == null?' ':$rowData[0][3];
  194.                     $status=$rowData[0][4] == null?' ':$rowData[0][4];
  195.                     $data = array(
  196.                         'nisn'=> strtoupper($nisn),
  197.                         'nama'=> strtoupper($nama),
  198.                         'jk'=> strtoupper($jk),
  199.                         'tahun_keluar'=> strtoupper($tahun_keluar),
  200.                         'status'=> strtoupper($status),
  201.                     );
  202.  
  203.                         //import data pendaftar
  204.                     $cek = $this->db->query("select * from t_pendaftar where nisn='".$nisn."'");
  205.                     if($cek->num_rows() == 0){
  206.                         $hasil=$this->db->insert("t_pendaftar",$data);
  207.                     }
  208.                     else{
  209.                         $this->db->where(array('nisn'=>$nisn));
  210.                         $hasil=$this->db->update('t_pendaftar',$data);
  211.                     }
  212.  
  213.  
  214.                 }
  215.             }
  216.             $this->session->set_flashdata('alert',$hasil);
  217.             redirect('Admin/Pendaftar/index');
  218.         }
  219.  
  220.         function delete_pendaftar($jalur,$id){
  221.             if($id != null){
  222.             // delete file, if exists...
  223.                 $row=$this->db->query("select * from t_pendaftar where no_pendaftar='".$id."'")->row();
  224.                 $image_path = 'assets/images/pendaftar/';
  225.                 //hapus foto
  226.                 if($row->foto){
  227.                     $filename = $image_path . $row->foto;
  228.                     if (file_exists($filename))
  229.                     {
  230.                         unlink($filename);
  231.                     }
  232.                 }
  233.                
  234.  
  235.                 //hapus scan_skhun
  236.                 if($row->scan_skhun){
  237.                     $filename = $image_path . $row->scan_skhun;
  238.                     if (file_exists($filename))
  239.                     {
  240.                         unlink($filename);
  241.                     }
  242.                 }
  243.  
  244.                 //hapus scan_dta
  245.                 if($row->scan_dta){
  246.                     $filename = $image_path . $row->scan_dta;
  247.                     if (file_exists($filename))
  248.                     {
  249.                         unlink($filename);
  250.                     }
  251.                 }
  252.                
  253.  
  254.                 //hapus scan_akta
  255.                 if($row->scan_akta){
  256.                  $filename = $image_path . $row->scan_akta;
  257.                  if (file_exists($filename))
  258.                  {
  259.                     unlink($filename);
  260.                 }
  261.             }
  262.  
  263.  
  264.                 //hapus scan_kk
  265.             if($row->scan_kk){
  266.                 $filename = $image_path . $row->scan_kk;
  267.                 if (file_exists($filename))
  268.                 {
  269.                     unlink($filename);
  270.                 }
  271.             }
  272.  
  273.  
  274.                 //hapus scan_nisn
  275.             if( $row->scan_nisn){
  276.               $filename = $image_path . $row->scan_nisn;
  277.               if (file_exists($filename))
  278.               {
  279.                 unlink($filename);
  280.             }  
  281.         }
  282.  
  283.  
  284.                 //hapus scan_ketm
  285.         if($row->scan_ketm){
  286.             $filename = $image_path . $row->scan_ketm;
  287.             if (file_exists($filename))
  288.             {
  289.                 unlink($filename);
  290.             }
  291.         }
  292.  
  293.  
  294.                 //hapus scan_prestasi
  295.         if($row->scan_prestasi){
  296.           $filename = $image_path . $row->scan_prestasi;
  297.           if (file_exists($filename))
  298.           {
  299.             unlink($filename);
  300.         }  
  301.     }
  302.  
  303.  
  304.                 //hapus scan_perpindahan
  305.     if($row->scan_perpindahan){
  306.         $filename = $image_path . $row->scan_perpindahan;
  307.         if (file_exists($filename))
  308.         {
  309.             unlink($filename);
  310.         }
  311.     }
  312.  
  313.             //end
  314.  
  315.  
  316.     $this->db->where(array('no_pendaftar'=>$id));
  317.     $hasil=$this->db->delete('t_pendaftar');
  318. }
  319. $this->session->set_flashdata('alert', $hasil);
  320.  
  321. switch($jalur){
  322.     case 1:redirect('Admin/Pendaftar/zonasi');break;
  323.     case 2:redirect('Admin/Pendaftar/prestasi');break;
  324.     case 3:redirect('Admin/Pendaftar/afirmasi');break;
  325.     case 4:redirect('Admin/Pendaftar/perpindahan');break;
  326.     default :redirect('Admin/Pendaftar');break;         }
  327.  
  328. }
  329.  
  330. function input_pendaftar($getpemanggil=null,$getnopendaftar=null){
  331.  
  332.     if($this->input->post('getpemanggil')){
  333.         $getpemanggil=$this->input->post('getpemanggil');
  334.     }
  335.  
  336.  
  337.     if($this->input->post('nama')){
  338.  
  339.         if($this->input->post('no_pendaftar')){
  340.             $no_pendaftar=$this->input->post('no_pendaftar');
  341.             $pendaftar=$this->db->query("select * from t_pendaftar where no_pendaftar='$no_pendaftar'")->row();
  342.             $image_path="assets/images/pendaftar/";
  343.             $filenamefoto = $image_path . $pendaftar->foto;
  344.             $filenameskhun = $image_path . $pendaftar->scan_skhun;
  345.             $filenamedta = $image_path . $pendaftar->scan_dta;
  346.             $filenameakta = $image_path . $pendaftar->scan_akta;
  347.             $filenamekk = $image_path . $pendaftar->scan_kk;
  348.             $filenamenisn = $image_path . $pendaftar->scan_nisn;
  349.             $filenameketm = $image_path . $pendaftar->scan_ketm;
  350.             $filenameprestasi = $image_path . $pendaftar->scan_prestasi;
  351.             $filenameperpindahan = $image_path . $pendaftar->scan_perpindahan;
  352.         }else{
  353.             $no_pendaftar=$this->NextId();
  354.             $filenamefoto = "";
  355.             $filenameskhun = "";
  356.             $filenamedta = "";
  357.             $filenameakta ="";
  358.             $filenamekk = "";
  359.             $filenamenisn ="";
  360.             $filenameketm = "";
  361.             $filenameprestasi = "";
  362.             $filenameperpindahan = "";
  363.         }
  364.             //upload foto
  365.         $foto=null;
  366.         $scan_skhun=null;
  367.         $scan_dta=null;
  368.         $scan_akta=null;
  369.         $scan_kk=null;
  370.         $scan_nisn=null;
  371.         $scan_ketm=null;
  372.         $scan_prestasi=null;
  373.         $scan_perpindahan=null;
  374.  
  375.         $config['upload_path'] = './assets/images/pendaftar/';
  376.         $config['allowed_types'] = '*';
  377.         $config['file_name']=$no_pendaftar."_foto";
  378.         $this->upload->initialize($config);
  379.         if(!$this->upload->do_upload('foto')){
  380.                     // $error = $this->upload->display_errors();
  381.                     // // menampilkan pesan error
  382.                     // print_r($error);
  383.         }
  384.         else{
  385.                     //echo "<script>alert('sukses')</script>";
  386.             if (file_exists($filenamefoto))
  387.             {
  388.                 unlink($filenamefoto);
  389.             }
  390.             $file=$this->upload->data('foto');
  391.             $foto = $this->upload->data('file_name');
  392.             ini_set('memory_limit', '-1');
  393.             ini_set('max_execution_time', 1000);
  394.             ini_set('post_max_size', '128M');
  395.             ini_set('upload_max_filesize', '128M');
  396.         }
  397.             //upload SKHUN
  398.  
  399.         $config['upload_path'] = './assets/images/pendaftar/';
  400.         $config['allowed_types'] = '*';
  401.         $config['file_name']=$no_pendaftar."_scan_skhun";
  402.         $this->upload->initialize($config);
  403.         if(!$this->upload->do_upload('scan_skhun')){
  404.         }
  405.         else{
  406.             if (file_exists($filenameskhun))
  407.             {
  408.                 unlink($filenameskhun);
  409.             }
  410.             $file=$this->upload->data('scan_skhun');
  411.             $scan_skhun =  $this->upload->data('file_name');
  412.             ini_set('memory_limit', '-1');
  413.             ini_set('max_execution_time', 1000);
  414.             ini_set('post_max_size', '128M');
  415.             ini_set('upload_max_filesize', '128M');
  416.         }
  417.                 //end
  418.  
  419.             //upload DTA
  420.  
  421.         $config['upload_path'] = './assets/images/pendaftar/';
  422.         $config['allowed_types'] = '*';
  423.         $config['file_name']=$no_pendaftar."_scan_dta";
  424.         $this->upload->initialize($config);
  425.         if(!$this->upload->do_upload('scan_dta')){
  426.         }
  427.         else{
  428.            if (file_exists($filenamedta))
  429.            {
  430.             unlink($filenamedta);
  431.         }
  432.         $file=$this->upload->data('scan_dta');
  433.         $scan_dta =  $this->upload->data('file_name');
  434.         ini_set('memory_limit', '-1');
  435.         ini_set('max_execution_time', 1000);
  436.         ini_set('post_max_size', '128M');
  437.         ini_set('upload_max_filesize', '128M');
  438.     }
  439.                 //end    
  440.  
  441.             // //upload scan_akta
  442.  
  443.     $config['upload_path'] = './assets/images/pendaftar/';
  444.     $config['allowed_types'] = '*';
  445.     $config['file_name']=$no_pendaftar."_scan_akta";
  446.     $this->upload->initialize($config);
  447.     if(!$this->upload->do_upload('scan_akta')){
  448.     }
  449.     else{
  450.         if (file_exists($filenameakta))
  451.         {
  452.             unlink($filenameakta);
  453.         }
  454.         $file=$this->upload->data('scan_akta');
  455.         $scan_akta =  $this->upload->data('file_name');
  456.         ini_set('memory_limit', '-1');
  457.         ini_set('max_execution_time', 1000);
  458.         ini_set('post_max_size', '128M');
  459.         ini_set('upload_max_filesize', '128M');
  460.     }
  461.                 //end
  462.  
  463.                 //upload scan_kk
  464.  
  465.     $config['upload_path'] = './assets/images/pendaftar/';
  466.     $config['allowed_types'] = '*';
  467.     $config['file_name']=$no_pendaftar."_scan_kk";
  468.     $this->upload->initialize($config);
  469.     if(!$this->upload->do_upload('scan_kk')){
  470.     }
  471.     else{
  472.         if (file_exists($filenamekk))
  473.         {
  474.             unlink($filenamekk);
  475.         }
  476.         $file=$this->upload->data('scan_kk');
  477.         $scan_kk =  $this->upload->data('file_name');
  478.         ini_set('memory_limit', '-1');
  479.         ini_set('max_execution_time', 1000);
  480.         ini_set('post_max_size', '128M');
  481.         ini_set('upload_max_filesize', '128M');
  482.     }
  483.                 //end
  484.  
  485.                     //upload scan_nisn
  486.  
  487.     $config['upload_path'] = './assets/images/pendaftar/';
  488.     $config['allowed_types'] = '*';
  489.     $config['file_name']=$no_pendaftar."_scan_nisn";
  490.     $this->upload->initialize($config);
  491.     if(!$this->upload->do_upload('scan_nisn')){
  492.     }
  493.     else{
  494.      if (file_exists($filenamenisn))
  495.      {
  496.         unlink($filenamenisn);
  497.     }
  498.     $file=$this->upload->data('scan_nisn');
  499.     $scan_nisn = $this->upload->data('file_name');
  500.     ini_set('memory_limit', '-1');
  501.     ini_set('max_execution_time', 1000);
  502.     ini_set('post_max_size', '128M');
  503.     ini_set('upload_max_filesize', '128M');
  504. }
  505.                 //end
  506.  
  507.                     //upload scan_ketm
  508.  
  509. $config['upload_path'] = './assets/images/pendaftar/';
  510. $config['allowed_types'] = '*';
  511. $config['file_name']=$no_pendaftar."_scan_ketm";
  512. $this->upload->initialize($config);
  513. if(!$this->upload->do_upload('scan_ketm')){
  514. }
  515. else{
  516.  if (file_exists($filenameketm))
  517.  {
  518.     unlink($filenameketm);
  519. }
  520. $file=$this->upload->data('scan_ketm');
  521. $scan_ketm =  $this->upload->data('file_name');
  522. ini_set('memory_limit', '-1');
  523. ini_set('max_execution_time', 1000);
  524. ini_set('post_max_size', '128M');
  525. ini_set('upload_max_filesize', '128M');
  526. }
  527.                 //end
  528.  
  529.                     //upload scan_prestasi
  530.  
  531. $config['upload_path'] = './assets/images/pendaftar/';
  532. $config['allowed_types'] = '*';
  533. $config['file_name']=$no_pendaftar."_scan_prestasi";
  534. $this->upload->initialize($config);
  535. if(!$this->upload->do_upload('scan_prestasi')){
  536. }
  537. else{
  538.     if (file_exists($filenameprestasi))
  539.     {
  540.         unlink($filenameprestasi);
  541.     }
  542.     $file=$this->upload->data('scan_prestasi');
  543.     $scan_prestasi =  $this->upload->data('file_name');
  544.     ini_set('memory_limit', '-1');
  545.     ini_set('max_execution_time', 1000);
  546.     ini_set('post_max_size', '128M');
  547.     ini_set('upload_max_filesize', '128M');
  548. }
  549.                 //end
  550.  
  551.                     //upload scan_perpindahan
  552.  
  553. $config['upload_path'] = './assets/images/pendaftar/';
  554. $config['allowed_types'] = '*';
  555. $config['file_name']=$no_pendaftar."_scan_perpindahan";
  556. $this->upload->initialize($config);
  557. if(!$this->upload->do_upload('scan_perpindahan')){
  558. }
  559. else{
  560.  if (file_exists($filenameperpindahan))
  561.  {
  562.     unlink($filenameperpindahan);
  563. }
  564. $file=$this->upload->data('scan_perpindahan');
  565. $scan_perpindahan =  $this->upload->data('file_name');
  566. ini_set('memory_limit', '-1');
  567. ini_set('max_execution_time', 1000);
  568. ini_set('post_max_size', '128M');
  569. ini_set('upload_max_filesize', '128M');
  570. }
  571.                 //end
  572.  
  573.                 //olah score
  574. $score_ketm=null;
  575. if($this->input->post('jenis_ketm')){
  576.     $jenis_ketm=$this->input->post('jenis_ketm');  
  577.     $score_ketm=$this->db->query("select score_ketm from t_ketm where id_ketm='$jenis_ketm'")->row()->score_ketm;
  578. }
  579. $score_prestasi=null;
  580. if($this->input->post('tingkat_prestasi') && $this->input->post('juara_prestasi') ){
  581.     $tingkat_prestasi=$this->input->post('tingkat_prestasi');
  582.     $juara_prestasi=$this->input->post('juara_prestasi');
  583.     $score_prestasi=$this->db->query("select score_prestasi from t_prestasi where tingkat_prestasi='$tingkat_prestasi' and juara_prestasi='$juara_prestasi'")->row()->score_prestasi;
  584.  
  585. }
  586.  
  587.  
  588.  
  589.                 //input sekolah baru ke table sekolah
  590. if($this->input->post('sekolah_lain')){
  591.     $new_sekolah=$this->input->post('sekolah_lain');
  592.     $data=array(
  593.         'nama_sekolah'=>$new_sekolah,
  594.     );
  595.     $hasil=$this->db->insert('t_asal_sekolah',$data);
  596.     $asal_sekolah=$this->db->query("select max(id_sekolah) as id from t_asal_sekolah")->row()->id;
  597. }else{
  598.     $asal_sekolah=$this->input->post('asal_sekolah');
  599. }
  600.  
  601.                 //input data ke array  
  602. $data=array(
  603.     'no_pendaftar' => $no_pendaftar,
  604.     'perlengkapan'=> implode(',',$this->input->post('perlengkapan')),
  605.     'nama' => $this->input->post('nama'),
  606.     'jalur' => $this->input->post('jalur'),
  607.     'nisn' => $this->input->post('nisn'),
  608.     'nik' => $this->input->post('nik'),
  609.     'jk' => $this->input->post('jk'),
  610.     'tahun_lulus' => $this->input->post('tahun_lulus'),
  611.     'asal_sekolah' => $asal_sekolah,
  612.     'tempat_lahir' => $this->input->post('tempat_lahir'),
  613.     'tgl_lahir' => $this->input->post('tgl_lahir'),
  614.     'agama' => $this->input->post('agama'),
  615.     'no_hp' => $this->input->post('no_hp'),
  616.     'provinsi' => $this->input->post('provinsi'),
  617.     'provinsi_wali' => $this->input->post('provinsi_wali'),
  618.     'kabupaten' => $this->input->post('kabupaten'),
  619.     'kabupaten_wali' => $this->input->post('kabupaten_wali'),
  620.     'kecamatan' => $this->input->post('kecamatan'),
  621.     'kecamatan_wali' => $this->input->post('kecamatan_wali'),
  622.     'kelurahan' => $this->input->post('kelurahan'),
  623.     'kelurahan_wali' => $this->input->post('kelurahan_wali'),
  624.     'rt' => $this->input->post('rt'),
  625.     'rt_wali' => $this->input->post('rt_wali'),
  626.     'rw_wali' => $this->input->post('rw_wali'),
  627.     'rw' => $this->input->post('rw'),
  628.     'alamat' => $this->input->post('alamat'),
  629.     'jarak' => $this->input->post('jarak'),
  630.     'nama_wali' => $this->input->post('nama_wali'),
  631.     'pekerjaan_wali' => $this->input->post('pekerjaan_wali'),
  632.     'agama_wali' => $this->input->post('agama_wali'),
  633.     'alamat_wali' => $this->input->post('alamat_wali'),
  634.     'no_hp_wali' => $this->input->post('no_hp_wali'),
  635.  
  636.     'jenis_ketm' => $this->input->post('jenis_ketm'),
  637.     'score_ketm' => $score_ketm,
  638.     'nama_prestasi' => $this->input->post('nama_prestasi'),
  639.     'tingkat_prestasi' => $this->input->post('tingkat_prestasi'),
  640.     'juara_prestasi' => $this->input->post('juara_prestasi'),
  641.     'score_prestasi' => $score_prestasi,
  642.  
  643.     'jurusan_1'=>$this->input->post('jurusan_1'),
  644.     'jurusan_2'=>$this->input->post('jurusan_2'),
  645.     'jurusan_3'=>$this->input->post('jurusan_3'),
  646.  
  647.     'tgl_penyerahan'=>$this->input->post('tgl_penyerahan'),
  648.     'no_antrian'=> $this->next_no_antrian($this->input->post('tgl_penyerahan')),
  649. );
  650.  
  651.                 //print_r($foto." ".$scan_skhun." ".$scan_akta." ".$scan_kk." ".$scan_nisn." ".$scan_ketm." ".$scan_prestasi." ". $scan_perpindahan);
  652.  
  653. if(!empty($foto)){
  654.     $data['foto'] = $foto;
  655. }
  656. if(!empty($scan_skhun)){
  657.     $data['scan_skhun'] = $scan_skhun;
  658. }
  659. if(!empty($scan_dta)){
  660.     $data['scan_dta'] = $scan_dta;
  661. }
  662. if(!empty($scan_akta)){
  663.     $data['scan_akta'] = $scan_akta;
  664. }
  665. if(!empty($scan_kk)){
  666.     $data['scan_kk'] = $scan_kk;
  667. }
  668. if(!empty($scan_nisn)){
  669.     $data['scan_nisn'] = $scan_nisn;
  670. }
  671. if(!empty($scan_ketm)){
  672.     $data['scan_ketm'] = $scan_ketm;
  673. }
  674. if(!empty($scan_prestasi)){
  675.     $data['scan_prestasi'] = $scan_prestasi;
  676. }
  677. if(!empty($scan_perpindahan)){
  678.     $data['scan_perpindahan'] = $scan_perpindahan;
  679. }
  680.  
  681. //input nilai
  682. //echo '<pre>';print_r($_POST);'</pre>';
  683.  
  684. /*$id_mapel=$this->input->post('id_mapel');
  685. $s1=$this->input->post('s1');
  686. $s2=$this->input->post('s2');
  687. $s3=$this->input->post('s3');
  688. $s4=$this->input->post('s4');
  689. $s5=$this->input->post('s5');
  690. $us=$this->input->post('us');
  691.  
  692. $jml_mapel=$this->db->query("select count(*) as jml_mapel from t_mapel")->row()->jml_mapel;
  693. $i=1;
  694. for($i=0;$i<$jml_mapel;$i++){
  695.     $data2['no_pendaftar'] = $no_pendaftar;
  696.     $data2['id_mapel'] = $id_mapel[$i];
  697.     $data2['s1'] = $s1[$i];
  698.     $data2['s2'] = $s2[$i];
  699.     $data2['s3'] = $s3[$i];
  700.     $data2['s4'] = $s4[$i];
  701.     $data2['s5'] = $s5[$i];
  702.     $data2['us'] = $us[$i];
  703.     $data2['rerata'] = round(($s1[$i]+$s2[$i]+$s3[$i]+$s4[$i]+$s5[$i]+$us[$i])/6,2);
  704.     $this->db->where(array('id_mapel'=>$id_mapel[$i],'no_pendaftar'=>$no_pendaftar));
  705.     $hasil=$this->db->delete('t_nilai');
  706.     $hasil=$this->db->insert('t_nilai',$data2);
  707. }*/
  708.  
  709.  
  710.  
  711. //proses simpan
  712. if($this->input->post('no_pendaftar')){
  713.     $this->db->where(array('no_pendaftar'=>$no_pendaftar));
  714.     $hasil=$this->db->update('t_pendaftar',$data);
  715. }else{
  716.     $hasil=$this->db->insert('t_pendaftar',$data);
  717. }
  718.  
  719. $this->session->set_flashdata('alert', $hasil);
  720.  
  721. switch($getpemanggil){
  722.     case 1;redirect('Admin/Pendaftar/zonasi');break;
  723.     case 2;redirect('Admin/Pendaftar/prestasi');break;
  724.     case 3;redirect('Admin/Pendaftar/afirmasi');break;
  725.     case 4;redirect('Admin/Pendaftar/perpindahan');break;
  726.     case 5;redirect('Admin/Pendaftar/prestasi_akademik');break;
  727.     case 6;redirect('Admin/Pendaftar/abk');break;
  728.     case 10;redirect('Admin/Pendaftar/input_pendaftar/10/'.$no_pendaftar);break;
  729.     default :break;
  730. }
  731.  
  732.  
  733. }
  734. else{
  735.  
  736.     $data['title'] = 'Data Pendaftar';
  737.  
  738.     if($getpemanggil != null && $getnopendaftar!=null){
  739.                 //echo "<script>alert('masuk')</script>";
  740.         $p=$this->db->get_where('t_pendaftar',array('no_pendaftar'=>$getnopendaftar))->row();
  741.         $data['pendaftar'] = $p;
  742.  
  743.         $data['data_kabupaten']=$this->db->get_where("t_kabupaten",array('id_provinsi'=>$p->provinsi))->result();
  744.         $data['data_kecamatan']=$this->db->get_where("t_kecamatan",array('id_kabupaten'=>$p->kabupaten))->result();
  745.         $data['data_kelurahan']=$this->db->get_where("t_kelurahan",array('id_kecamatan'=>$p->kecamatan))->result();
  746.  
  747.          $data['data_kabupaten_wali']=$this->db->get_where("t_kabupaten",array('id_provinsi'=>$p->provinsi_wali))->result();
  748.         $data['data_kecamatan_wali']=$this->db->get_where("t_kecamatan",array('id_kabupaten'=>$p->kabupaten_wali))->result();
  749.         $data['data_kelurahan_wali']=$this->db->get_where("t_kelurahan",array('id_kecamatan'=>$p->kecamatan_wali))->result();
  750.  
  751.     }
  752.  
  753.     $data['data_sekolah']=$this->db->get("t_asal_sekolah")->result();
  754.     $data['data_agama']=$this->db->get("t_agama")->result();
  755.     $data['data_provinsi']=$this->db->get("t_provinsi")->result();
  756.     $data['data_pekerjaan']=$this->db->get("t_pekerjaan")->result();
  757.     $data['data_agama']=$this->db->get("t_agama")->result();
  758.     $data['data_jalur']=$this->db->get("t_jalur")->result();
  759.     $data['data_ketm']=$this->db->get("t_ketm")->result();
  760.     $data['data_jurusan']=$this->db->get("t_jurusan")->result();
  761.     $data['data_mapel']=$this->db->get("t_mapel")->result();
  762.     $data['data_tgl_penyerahan']=$this->db->query("select tgl_penyerahan, count(*) as jml from t_pendaftar where not tgl_penyerahan is null group by tgl_penyerahan")->result();
  763.     $data['getpemanggil']=$getpemanggil;
  764.     $data['file']='Admin/Pendaftar/pendaftar_form';
  765.     $this->load->view('Admin/Main',$data);
  766. }
  767. }
  768.  
  769.  
  770. function cetak_kartu($getpemanggil=null,$getnopendaftar=null){
  771.    $data['title'] = 'Bukti Pendaftaran';
  772.    $sql="SELECT p.no_pendaftar,p.nama,j.nama_jalur,p.nisn,p.nik,p.jk,p.tahun_lulus,s.nama_sekolah,p.tempat_lahir,p.tgl_lahir,a.nama_agama,p.no_hp,pr.nama_provinsi,kb.nama_kabupaten,kc.nama_kecamatan,kl.nama_kelurahan,p.rt,p.rw,p.alamat,p.jarak,p.nama_wali,pk.nama_pekerjaan,p.alamat_wali,p.no_hp_wali,ketm.jenis_ketm,p.score_ketm,p.nama_prestasi,p.tingkat_prestasi,p.juara_prestasi,p.score_prestasi,avg(n.rerata)as rerata,p.status,p.foto,p.tgl_penyerahan,p.no_antrian ,p.no_antrian,p.jurusan_1,p.jurusan_2,p.jurusan_3,p.diterima_jurusan    
  773.   FROM t_pendaftar p left join t_jalur j on p.jalur=j.id_jalur left join t_asal_sekolah s on p.asal_sekolah=s.id_sekolah
  774.   left join t_agama a on p.agama=a.id_agama left join t_provinsi pr on p.provinsi=pr.id_provinsi
  775.   left join t_kabupaten kb on p.kabupaten=kb.id_kabupaten left join t_kecamatan kc on p.kecamatan=kc.id_kecamatan
  776.   left join t_kelurahan kl on p.kelurahan=kl.id_kelurahan left join t_ketm ketm on p.jenis_ketm=ketm.id_ketm
  777.   left join t_pekerjaan pk on p.pekerjaan_wali=pk.id_pekerjaan
  778.   left join t_nilai n on p.no_pendaftar=n.no_pendaftar
  779.   where p.no_pendaftar='$getnopendaftar'
  780.   group by no_pendaftar
  781.   order by no_pendaftar";
  782.    $data['pendaftar'] = $this->db->query($sql)->row();
  783.    $data['data_mapel']=$this->db->get('t_mapel')->result();
  784.    $data['getpemanggil']=$getpemanggil;
  785.    $data['file']='Admin/Pendaftar/pendaftar_kartu';
  786.    $this->load->view('Admin/Main',$data);
  787. }
  788.  
  789. function info_penerimaan($getnopendaftar=null){
  790.  
  791.   $data['title'] = 'Informasi Kelulusan';
  792.   $sql="SELECT p.no_pendaftar,p.nama,j.nama_jalur,p.nisn,p.nik,p.jk,p.tahun_lulus,s.nama_sekolah,p.tempat_lahir,p.tgl_lahir,a.nama_agama,p.no_hp,pr.nama_provinsi,kb.nama_kabupaten,kc.nama_kecamatan,kl.nama_kelurahan,p.rt,p.rw,p.alamat,p.jarak,p.nama_wali,pk.nama_pekerjaan,p.alamat_wali,p.no_hp_wali,ketm.jenis_ketm,p.score_ketm,p.nama_prestasi,p.tingkat_prestasi,p.juara_prestasi,p.score_prestasi,avg(n.rerata)as rerata,p.status,p.foto,p.tgl_penyerahan,p.no_antrian ,p.no_antrian,p.jurusan_1,p.jurusan_2,p.jurusan_3,p.diterima_jurusan    
  793.  FROM t_pendaftar p left join t_jalur j on p.jalur=j.id_jalur left join t_asal_sekolah s on p.asal_sekolah=s.id_sekolah
  794.  left join t_agama a on p.agama=a.id_agama left join t_provinsi pr on p.provinsi=pr.id_provinsi
  795.  left join t_kabupaten kb on p.kabupaten=kb.id_kabupaten left join t_kecamatan kc on p.kecamatan=kc.id_kecamatan
  796.  left join t_kelurahan kl on p.kelurahan=kl.id_kelurahan left join t_ketm ketm on p.jenis_ketm=ketm.id_ketm
  797.  left join t_pekerjaan pk on p.pekerjaan_wali=pk.id_pekerjaan
  798.  left join t_nilai n on p.no_pendaftar=n.no_pendaftar
  799.  where p.no_pendaftar='$getnopendaftar'
  800.  group by no_pendaftar
  801.  order by no_pendaftar";
  802.   $data['pendaftar'] = $this->db->query($sql)->row();
  803.   $data['data_tanggal']=$this->db->query("select * from t_daftar_ulang")->result();
  804.   $data['getpemanggil']='10';
  805.   $data['setting']=$this->db->query("select * from t_setting where id_setting='1'")->row();
  806.   $data['file']='Admin/Pendaftar/pendaftar_kelulusan';
  807.   $this->load->view('Admin/Main',$data);
  808.  
  809. }
  810.  
  811. function update_status($getpemanggil=null,$getstatus=null,$getnopendaftar=null){
  812.     if((!empty($getpemanggil))&&(!empty($getstatus))&&(!empty($getnopendaftar))){            
  813.         $this->db->where(array('no_pendaftar'=>$getnopendaftar));
  814.         $hasil=$this->db->update('t_pendaftar',array('status'=>$getstatus));
  815.     }
  816.     switch($getpemanggil){
  817.         case 1;redirect('Admin/Pendaftar/zonasi');break;
  818.         case 2;redirect('Admin/Pendaftar/prestasi');break;
  819.         case 3;redirect('Admin/Pendaftar/afirmasi');break;
  820.         case 4;redirect('Admin/Pendaftar/perpindahan');break;
  821.         case 5;redirect('Admin/Pendaftar/prestasi_akademik');break;
  822.         case 6;redirect('Admin/Pendaftar/abk');break;
  823.         default :redirect('Admin/Pendaftar/zonasi');break;
  824.     }
  825. }
  826.  
  827. function hapus_semua($getpemanggil=null){
  828.     if(!empty($getpemanggil)){
  829.  
  830.         $pendaftar = $this->db->query("select * from t_pendaftar where jalur='$getpemanggil'")->result();
  831.         foreach($pendaftar as $row){
  832.  
  833.             $image_path = 'assets/images/pendaftar/';
  834.                 //hapus foto
  835.             if($row->foto){
  836.                 $filename = $image_path . $row->foto;
  837.                 if (file_exists($filename))
  838.                 {
  839.                     unlink($filename);
  840.                 }
  841.             }
  842.  
  843.  
  844.                 //hapus scan_skhun
  845.             if($row->scan_skhun){
  846.                 $filename = $image_path . $row->scan_skhun;
  847.                 if (file_exists($filename))
  848.                 {
  849.                     unlink($filename);
  850.                 }
  851.             }
  852.  
  853.                 //hapus scan_dta
  854.             if($row->scan_dta){
  855.                 $filename = $image_path . $row->scan_dta;
  856.                 if (file_exists($filename))
  857.                 {
  858.                     unlink($filename);
  859.                 }
  860.             }
  861.  
  862.  
  863.                 //hapus scan_akta
  864.             if($row->scan_akta){
  865.              $filename = $image_path . $row->scan_akta;
  866.              if (file_exists($filename))
  867.              {
  868.                 unlink($filename);
  869.             }
  870.         }
  871.  
  872.  
  873.                 //hapus scan_kk
  874.         if($row->scan_kk){
  875.             $filename = $image_path . $row->scan_kk;
  876.             if (file_exists($filename))
  877.             {
  878.                 unlink($filename);
  879.             }
  880.         }
  881.  
  882.  
  883.                 //hapus scan_nisn
  884.         if( $row->scan_nisn){
  885.           $filename = $image_path . $row->scan_nisn;
  886.           if (file_exists($filename))
  887.           {
  888.             unlink($filename);
  889.         }  
  890.     }
  891.  
  892.  
  893.                 //hapus scan_ketm
  894.     if($row->scan_ketm){
  895.         $filename = $image_path . $row->scan_ketm;
  896.         if (file_exists($filename))
  897.         {
  898.             unlink($filename);
  899.         }
  900.     }
  901.  
  902.  
  903.                 //hapus scan_prestasi
  904.     if($row->scan_prestasi){
  905.       $filename = $image_path . $row->scan_prestasi;
  906.       if (file_exists($filename))
  907.       {
  908.         unlink($filename);
  909.     }  
  910. }
  911.  
  912.  
  913.                 //hapus scan_perpindahan
  914. if($row->scan_perpindahan){
  915.     $filename = $image_path . $row->scan_perpindahan;
  916.     if (file_exists($filename))
  917.     {
  918.         unlink($filename);
  919.     }
  920. }
  921.  
  922.             //end
  923.  
  924. $this->db->where(array('no_pendaftar'=>$row->no_pendaftar));
  925. $hasil=$this->db->delete('t_pendaftar');
  926. }
  927.  
  928.  
  929. switch($getpemanggil){
  930.     case 1;redirect('Admin/Pendaftar/zonasi');break;
  931.     case 2;redirect('Admin/Pendaftar/prestasi');break;
  932.     case 3;redirect('Admin/Pendaftar/afirmasi');break;
  933.     case 4;redirect('Admin/Pendaftar/perpindahan');break;
  934.     case 5;redirect('Admin/Pendaftar/prestasi_akademik');break;
  935.     case 6;redirect('Admin/Pendaftar/abk');break;
  936.     default :redirect('Admin/Pendaftar/zonasi');break;
  937. }
  938. }
  939. }
  940.  
  941. function cetak_verifikasi_berkas($getpemanggil=null,$getnopendaftar=null){
  942.    $data['title'] = 'Bukti Verifikasi Berkas';
  943.    $sql="SELECT p.no_pendaftar,p.nama,j.nama_jalur,p.nisn,p.nik,p.jk,p.tahun_lulus,s.nama_sekolah,p.tempat_lahir,p.tgl_lahir,a.nama_agama,p.no_hp,pr.nama_provinsi,kb.nama_kabupaten,kc.nama_kecamatan,kl.nama_kelurahan,p.rt,p.rw,p.alamat,p.jarak,p.nama_wali,pk.nama_pekerjaan,p.alamat_wali,p.no_hp_wali,ketm.jenis_ketm,p.score_ketm,p.nama_prestasi,p.tingkat_prestasi,p.juara_prestasi,p.score_prestasi,avg(n.rerata)as rerata,p.status,p.foto,p.tgl_penyerahan,p.no_antrian,p.jurusan_1,p.jurusan_2,p.jurusan_3,p.diterima_jurusan  
  944.   FROM t_pendaftar p left join t_jalur j on p.jalur=j.id_jalur left join t_asal_sekolah s on p.asal_sekolah=s.id_sekolah
  945.   left join t_agama a on p.agama=a.id_agama left join t_provinsi pr on p.provinsi=pr.id_provinsi
  946.   left join t_kabupaten kb on p.kabupaten=kb.id_kabupaten left join t_kecamatan kc on p.kecamatan=kc.id_kecamatan
  947.   left join t_kelurahan kl on p.kelurahan=kl.id_kelurahan left join t_ketm ketm on p.jenis_ketm=ketm.id_ketm
  948.   left join t_pekerjaan pk on p.pekerjaan_wali=pk.id_pekerjaan
  949.   left join t_nilai n on p.no_pendaftar=n.no_pendaftar
  950.   where p.no_pendaftar='$getnopendaftar'
  951.   group by no_pendaftar
  952.   order by no_pendaftar";
  953.    $data['pendaftar'] = $this->db->query($sql)->row();
  954.    $data['getpemanggil']=$getpemanggil;
  955.    $data['file']='Admin/Pendaftar/pendaftar_verifikasi';
  956.    $this->load->view('Admin/Main',$data);
  957. }
  958.  
  959. function dokumen_pendaftar($getpemanggil=null,$getnopendaftar=null){
  960.    $data['title'] = 'Dokumen Pendaftar';
  961.    $sql="select * from t_pendaftar where no_pendaftar='$getnopendaftar'";
  962.    $data['pendaftar'] = $this->db->query($sql)->row();
  963.    $data['getpemanggil']=$getpemanggil;
  964.    $data['file']='Admin/Pendaftar/pendaftar_dokumen';
  965.    $this->load->view('Admin/Main',$data);
  966. }
  967.  
  968. function update_verifikasi($getpemanggil=null,$getstatus=null,$getnopendaftar=null){
  969.         //if((!empty($getpemanggil))&&(!empty($getstatus))&&(!empty($getnopendaftar))){            
  970.             $this->db->where(array('no_pendaftar'=>$getnopendaftar));
  971.             $hasil=$this->db->update('t_pendaftar',array('verifikasi'=>$getstatus));
  972.         //}
  973.         switch($getpemanggil){
  974.                     case 1;redirect('Admin/Pendaftar/zonasi');break;
  975.                     case 2;redirect('Admin/Pendaftar/prestasi');break;
  976.                     case 3;redirect('Admin/Pendaftar/afirmasi');break;
  977.                     case 4;redirect('Admin/Pendaftar/perpindahan');break;
  978.                     case 5;redirect('Admin/Pendaftar/prestasi_akademik');break;
  979.                     case 6;redirect('Admin/Pendaftar/abk');break;
  980.                     default :redirect('Admin/Pendaftar/zonasi');break;
  981.                 }
  982.       }
  983.  
  984. }
  985. ?>
RAW Paste Data