View difference between Paste ID: C1ET5q94 and V2kw9zFL
SHOW: | | - or go back to the newest paste.
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>");
28+
            //kls.append("<option value=" +n.nama_kelas+ ">"+n.nama_kelas+"</option>");
29
			kls.append($("<option>").val(n.nama_kelas).text(n.nama_kelas));
30
          });
31
        }
32
      });
33
    });
34
35
    $("#setkelas").change(function(){
36
      var kls = $("#setkelas option:selected").val();
37
      $("#setmpl option:selected").hide();
38
      $("#setmpl option").hide();
39
40
      $.ajax({
41
        method  : "POST",
42
        url     : "proses.php?q=mpl",
43
        cache   : false,
44
        data    : {
45
          kelas : kls
46
        },
47
        success : function(x){
48
          //console.log(x);
49
          var obj = JSON.parse(x);
50
          var mpl = $("#setmpl");
51
          //a = key, b = val
52
          $.each(obj, function(a, b){
53
            mpl.append("<option value="+b.id+">"+b.nama_mapel+"</option>");
54
          });
55
        }
56
      });
57
58
    });
59
60
    $("#setkelas").click(function(){
61
      var jur = $("#setjur option:selected").val();
62
      if (jur == '') {
63
        sweetAlert('Oops', 'Maaf Anda belum memilih paket keahlian!', 'error');
64
      }
65
    });
66
  });
67
</script>
68
<div class="col-md-12">
69
  <h4>Persiapan sebelum entry nilai</h4>
70
  <hr>
71
  <div class="row">
72
    <div class="col-md-8">
73
      <?php
74
        echo open_form('', 'post', "class='form-group'");
75
76
        echo label('jurusan', 'Paket Keahlian');
77
        echo select_open('jurusan', "class='form-control' id='setjur'");
78
        echo option('','', '-- Pilih Jurusan --');
79
        while ($j = mysqli_fetch_object($jur)) :
80
          echo option($j->paket, '', $j->paket);
81
        endwhile;
82
        echo select_close()."<br>";
83
84
        echo label('kelas', 'Kelas');
85
        echo select_open('kelas', "class='form-control' id='setkelas'");
86
        echo option('','', '-- Pilih Kelas --');
87
        echo select_close()."<br>";
88
89
        echo label('mapel', 'Mata Pelajaran');
90
        echo select_open('mapel', "class='form-control' id='setmpl'");
91
        echo option('','', '-- Pilih Mata Pelajaran --');
92
        echo select_close()."<br>";
93
94
        echo input('submit', 'submit', "class='btn btn-primary' value='Entry Sekarang!'");
95
      ?>
96
    </div>
97
    <div class="col-md-4">
98
      <div class="panel panel-primary">
99
        <div class="panel-heading">
100
          Petunjuk
101
        </div>
102
        <div class="panel-body">
103
          <ul class="list-group">
104
            <li class="list-group-item"><strong>1.</strong> Pilih <strong>Paket Keahlian</strong> terlebih dahulu</li>
105
            <li class="list-group-item"><strong>2.</strong> Setelah itu pilih <strong>Kelas</strong> mana yang akan diisi nilainya</li>
106
            <li class="list-group-item"><strong>3.</strong> Kemudian pilih mata pelajarannya</li>
107
            <li class="list-group-item"><strong>4.</strong> Klik tombol <strong>Entry Sekarang</strong></li>
108
            <li class="list-group-item"><strong>5.</strong> Mulailah mengisi nilai </li>
109
          </ul>
110
        </div>
111
      </div>
112
    </div> <!-- end of class col-md-4 -->
113
  </div> <!-- end of class row -->
114
</div> <!-- end of class col-md-12 -->
115
116
<?php
117
if (isset($_POST['submit'])) {
118
  $mapel  = addslashes($_POST['mapel']);
119
  $kelas  = anti_inject($_POST['kelas']);
120
121
  if (empty(trim($mapel)) || empty(trim($kelas))) {
122
    echo "<script>sweetAlert('Oops!', 'Form harus diisi semua!', 'error')</script>";
123
    echo location('opsi-entry');
124
  } else {
125
126
    //Membuat session kelas, dan mapel
127
    $_SESSION['nama_kelas']   = $kelas;
128
    $_SESSION['mapel_id']   = $mapel;
129
    redirect('entry-nilai-rapot');
130
  }
131
}
132
133
134
?>