Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.22 KB | None | 0 0
  1. <?php
  2. $id = @$_SESSION['guru']['id'];
  3.  
  4. $jur = select('DISTINCT(paket)', 'tbl_kelas');
  5. ?>
  6. <script type="text/javascript">
  7.   $(document).ready(function(){
  8.     $("#setjur").change(function(){
  9.       var jur = $("#setjur option:selected").val();
  10.       $("#setkelas option:selected").hide();
  11.       $("#setkelas option").hide();
  12.  
  13.       $.ajax({
  14.         method  : "POST",
  15.         url     : "proses.php?q=kls",
  16.         cache   : false,
  17.         data    : {
  18.           paket : jur
  19.         },
  20.         success : function(data){          
  21.           var jur = JSON.parse(data);
  22.           var kls = $("#setkelas");
  23.           //i = key, n = val
  24.           $.each(jur, function(i,n){
  25.             //kls.html("<option>-- Pilih Kelas --</option>")
  26.             //var nmkls = n.nama_kelas;
  27.            
  28.             kls.append("<option value=" +n.nama_kelas+ ">"+n.nama_kelas+"</option>");
  29.           });
  30.         }
  31.       });
  32.     });
  33.  
  34.     $("#setkelas").change(function(){
  35.       var kls = $("#setkelas option:selected").val();
  36.       $("#setmpl option:selected").hide();
  37.       $("#setmpl option").hide();
  38.  
  39.       $.ajax({
  40.         method  : "POST",
  41.         url     : "proses.php?q=mpl",
  42.         cache   : false,
  43.         data    : {
  44.           kelas : kls
  45.         },
  46.         success : function(x){
  47.           //console.log(x);
  48.           var obj = JSON.parse(x);
  49.           var mpl = $("#setmpl");
  50.           //a = key, b = val
  51.           $.each(obj, function(a, b){
  52.             mpl.append("<option value="+b.id+">"+b.nama_mapel+"</option>");
  53.           });
  54.         }
  55.       });
  56.  
  57.     });
  58.  
  59.     $("#setkelas").click(function(){
  60.       var jur = $("#setjur option:selected").val();
  61.       if (jur == '') {
  62.         sweetAlert('Oops', 'Maaf Anda belum memilih paket keahlian!', 'error');
  63.       }
  64.     });
  65.   });
  66. </script>
  67. <div class="col-md-12">
  68.   <h4>Persiapan sebelum entry nilai</h4>
  69.   <hr>
  70.   <div class="row">
  71.     <div class="col-md-8">
  72.       <?php
  73.         echo open_form('', 'post', "class='form-group'");
  74.  
  75.         echo label('jurusan', 'Paket Keahlian');
  76.         echo select_open('jurusan', "class='form-control' id='setjur'");
  77.         echo option('','', '-- Pilih Jurusan --');
  78.         while ($j = mysqli_fetch_object($jur)) :
  79.           echo option($j->paket, '', $j->paket);
  80.         endwhile;
  81.         echo select_close()."<br>";
  82.  
  83.         echo label('kelas', 'Kelas');
  84.         echo select_open('kelas', "class='form-control' id='setkelas'");
  85.         echo option('','', '-- Pilih Kelas --');
  86.         echo select_close()."<br>";
  87.  
  88.         echo label('mapel', 'Mata Pelajaran');
  89.         echo select_open('mapel', "class='form-control' id='setmpl'");
  90.         echo option('','', '-- Pilih Mata Pelajaran --');
  91.         echo select_close()."<br>";
  92.  
  93.         echo input('submit', 'submit', "class='btn btn-primary' value='Entry Sekarang!'");
  94.       ?>
  95.     </div>
  96.     <div class="col-md-4">
  97.       <div class="panel panel-primary">
  98.         <div class="panel-heading">
  99.           Petunjuk
  100.         </div>
  101.         <div class="panel-body">
  102.           <ul class="list-group">
  103.             <li class="list-group-item"><strong>1.</strong> Pilih <strong>Paket Keahlian</strong> terlebih dahulu</li>
  104.             <li class="list-group-item"><strong>2.</strong> Setelah itu pilih <strong>Kelas</strong> mana yang akan diisi nilainya</li>
  105.             <li class="list-group-item"><strong>3.</strong> Kemudian pilih mata pelajarannya</li>
  106.             <li class="list-group-item"><strong>4.</strong> Klik tombol <strong>Entry Sekarang</strong></li>
  107.             <li class="list-group-item"><strong>5.</strong> Mulailah mengisi nilai </li>
  108.           </ul>
  109.         </div>
  110.       </div>
  111.     </div> <!-- end of class col-md-4 -->
  112.   </div> <!-- end of class row -->
  113. </div> <!-- end of class col-md-12 -->
  114.  
  115. <?php
  116. if (isset($_POST['submit'])) {
  117.   $mapel  = addslashes($_POST['mapel']);
  118.   $kelas  = anti_inject($_POST['kelas']);
  119.  
  120.   if (empty(trim($mapel)) || empty(trim($kelas))) {
  121.     echo "<script>sweetAlert('Oops!', 'Form harus diisi semua!', 'error')</script>";
  122.     echo location('opsi-entry');
  123.   } else {
  124.  
  125.     //Membuat session kelas, dan mapel
  126.     $_SESSION['nama_kelas']   = $kelas;
  127.     $_SESSION['mapel_id']   = $mapel;
  128.     redirect('entry-nilai-rapot');
  129.   }
  130. }
  131.  
  132.  
  133. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement