<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php

if($menu['kirim']=='0'){{$kirim="Tidak";}}elseif($menu['kirim']=='1'){{$kirim="Kirm";}}
if($menu['soal']=='0'){{$soal="2 Jenis Soal - CBT";}}elseif($menu['soal']=='1'){{$soal="6 Jenis Soal - AKM";}}
if($menu['opsi']=='0'){{$opsi="Sesuai Jenjang";}}elseif($menu['opsi']=='1'){{$opsi="Bebas Opsi";}}
if($menu['sinkron']=='0'){{$sinkron="Tarik Data dari Server";}}elseif($menu['sinkron']=='1'){{$sinkron="Kirim Data ke Server";}}
if($menu['ujian']=='0'){{$ujian="Non Aktif";}}elseif($menu['ujian']=='1'){{$ujian="Aktif";}}
?>
<?php if ($ac == '') { ?>
  <div class="row">
     <div class="col-md-12">
		<div class="card">
             <div class="card-header">									
                  <h5 class="card-title">Pengaturan Ujian</h5>
					</div>
                      <div class="card-body">
                             
                               <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
                                      <li class="nav-item" role="presentation">
                                        <button class="nav-link active" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="true">Setting Ujian</button>
                                            </li>
                                          <li class="nav-item" role="presentation">
                                               <button class="nav-link" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Hapus Data</button>
                                                 </li>
                                                    
                                                </ul>
                                                <div class="tab-content" id="pills-tabContent">
                                            <div class="tab-pane fade active show" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
                                            <div class="card" >
                                                                     
                                            <div class="row">
											
											 <div class="col-md-7">
											 <div class="box-body">
											<div class="example-container">
                                            <div class="example-content">
											<div class="alert alert-custom" role="alert">
                                                    <div class="custom-alert-icon icon-dark"><i class="fa fa-check fa-2x"></i></div>
                                                    <div class="alert-content">
                                                        <span class="alert-text" style="text-align:justify"> Pastikan Pilihan Model Soal, Jika merubah model soal saat Bank Soal dan Soal sudah terisi maka akan terhapus otomatis. Menganti model soal Pastikan belum ada data Bank Soal dan Soal</span>
                                                    </div>
                                                </div>
                                               <form id="formujian">
                                                   <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Jenis Soal</label>
													<div class="col-md-5">
                                                       <select class="form-select" name="jenissoal" required="true">
														<option value="<?= $menu['soal'] ?>"><?= $soal ?></option>
														<option value="">--Pilih Jenis Soal--</option>
														<option value="0">2 Jenis Soal - CBT</option>
														<option value="1">6 Jenis Soal - AKM</option>
													</select>
                                                    </div>
													 </div>
                                                    <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Opsi Jawaban</label>
													<div class="col-md-5">
                                                       <select class="form-select" name="jenisopsi" required="true">
														<option value="<?= $menu['opsi'] ?>"><?= $opsi ?></option>
														<option value="">--Pilih Opsi--</option>
														<option value="0">Sesuai Jenjang</option>
														<option value="1">Bebas Opsi</option>
													</select>
                                                    </div> 
													</div>
                                                    <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Kirim Nilai Otomatis</label>
													<div class="col-md-8">
                                                        <select class="form-select" name="kirim" required="true">
														<option value="<?= $menu['kirim'] ?>"><?= $kirim ?></option>
														<option value="">--Pilih Kirim Nilai--</option>
														<option value="0">Tidak</option>
														<option value="1">Kirim</option>
													</select>
                                                    </div>
                                                    </div>
													 
													<p>
													<div class="right">
													
                                                   <button type="submit" class="btn btn-outline-primary"><i class="fa fa-check-circle"></i>Simpan</button>
													
                                                    </div>
													<br><br>
                                            </div>
                                          </form >
                                        </div>
                                         </div>
										    </div>
											  <script>
										$('#formujian').submit(function(e){
										e.preventDefault();
										var data = new FormData(this);
										$.ajax(
										{
											type: 'POST',
											url: 'sandik_ujian/crud.php?pg=edit_ujian',
											enctype: 'multipart/form-data',
											data: data,
											cache: false,
											contentType: false,
											processData: false,
											success: function(data){   		
												iziToast.info(
												{
													title: 'Sukses!',
													message: 'Data berhasil disimpan',
													titleColor: '#FFFF00',
													messageColor: '#fff',
													backgroundColor: 'rgba(0, 0, 0, 0.5)',
													 progressBarColor: '#FFFF00',
													  position: 'topRight'
												});
												setTimeout(function()
												{
													window.location.reload();
												}, 2000);
											  
											}
										});
										return false;
									});
									</script>	
													 <div class="col-md-5">
											 <div class="box-body">
											<div class="example-container">
                                            <div class="example-content">
											<div class="alert alert-custom" role="alert">
                                                    <div class="custom-alert-icon icon-dark"><i class="fa fa-check fa-2x"></i></div>
                                                    <div class="alert-content">
                                                      
                                                        <span class="alert-text" style="text-align:justify"> Penggantian Model Sinkron bisa diubah setiap saat sesuai kebutuhan. Antara Tarik Data dari Server dan Kirim Data ke Server</span>
                                                    </div>
                                                </div>
                                               <form id="formserver">
											    <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Menu di Guru</label>
													<div class="col-md-8">
                                                        <select class="form-select" name="ujian" required="true">
														<option value="<?= $menu['ujian'] ?>"><?= $ujian ?></option>
														<option value="">Pilih Menu</option>
														<option value="0">Non Aktif</option>
														<option value="1">Aktif</option>
													</select>
                                                    </div>
                                                    </div>
													 <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Sinkron Server</label>
													<div class="col-md-8">
                                                        <select class="form-select" name="sinkron" required="true">
														<option value="<?= $menu['sinkron'] ?>"><?= $sinkron ?></option>
														<option value="">Pilih Sinkron</option>
														<option value="0">Tarik Data dari Server</option>
														<option value="1">Kirim Data ke Server</option>
													</select>
                                                    </div>
                                                    </div>
													<p>
													<div class="right">
													
                                                   <button type="submit" class="btn btn-outline-primary"><i class="fa fa-check-circle"></i>Simpan</button>
													
                                                    </div>
													<br><br>
												</div>
                                          </form >
                                        </div>
                                         </div>
										    </div>
                                                  </div>
                                         </div>
										    </div>	
												 <script>
										$('#formserver').submit(function(e){
										e.preventDefault();
										var data = new FormData(this);
										$.ajax(
										{
											type: 'POST',
											url: 'sandik_ujian/crud.php?pg=edit_sinkron',
											enctype: 'multipart/form-data',
											data: data,
											cache: false,
											contentType: false,
											processData: false,
											success: function(data){   		
												iziToast.info(
												{
													title: 'Sukses!',
													message: 'Data berhasil disimpan',
													titleColor: '#FFFF00',
													messageColor: '#fff',
													backgroundColor: 'rgba(0, 0, 0, 0.5)',
													 progressBarColor: '#FFFF00',
													  position: 'topRight'
												});
												setTimeout(function()
												{
													window.location.reload();
												}, 2000);
											  
											}
										});
										return false;
									});
									</script>		
											
                                   <div class="tab-pane fade" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
                                                      
						 <div class="box-body">
											<div class="example-container">
                                            <div class="example-content">
									<form id='formhapusdata' action='' method='post'>
										<div class='card-body'>
											<?= $info4 ?>

											<div class='form-group'>
                                       
                                        <div class='row'>
                                            <div class='col-md-5'>
                                                <div class='checkbox'>
                                                    
                                                    <b>Data Master</b><br />
                                                    
                                                    <label><input type='checkbox' name='data[]' value='banksoal' /> Bank Soal</label><br />
													 <label><input type='checkbox' name='data[]' value='soal' /> Soal Ujian</label><br />
                                                    <label><input type='checkbox' name='data[]' value='jawaban' /> Jawaban</label><br />
													 <label><input type='checkbox' name='data[]' value='jawaban_dup' /> Duplikat Jawaban</label><br />
													<label><input type='checkbox' name='data[]' value='jodoh' /> Menjodohkan</label><br />
                                                    <label><input type='checkbox' name='data[]' value='nilai' /> Nilai Ujian</label><br />
                                                    <label><input type='checkbox' name='data[]' value='ujian' /> Jadwal Ujian</label><br />
                                                    <label><input type='checkbox' name='data[]' value='siswa' /> Data Siswa</label><br />
													<label><input type='checkbox' name='data[]' value='kelas' /> Data Kelas</label><br />
													<label><input type='checkbox' name='data[]' value='pk' /> Data Jurusan</label><br />
													<label><input type='checkbox' name='data[]' value='mata_pelajaran' /> Mata Pelajaran</label><br />
													<label><input type='checkbox' name='data[]' value='file_pendukung' /> Data File</label><br />
                                                </div>
                                            </div>
                                            <div class='col-md-7'>
                                               <br>
                                                <div class='form-group'>
                                                    <label>Password Admin</label>
													<div class="input-group">
															<input type='password' name='password' class='form-control form-control-sm' required='true' />
														<span class="input-group-btn">
														 <button type='submit' name='submit3' class='btn btn-danger'><i class='fa fa-trash'></i> Reset</button>
																
														</span>
															</div>
														   </div>
                                               
															</div>
														</div>
													</div>
												</div>
											</form>
										</div>
											</div>
                                                    
                                                </div>
                                            </div>
										
									<script>
 
								$('#formhapusdata').submit(function(e) {
									e.preventDefault();
									$.ajax({
										type: 'POST',
										url: 'pengaturan/crud_setting.php?pg=setting_clear',
										data: $(this).serialize(),
										success: function(data) {
											console.log(data);
											if (data == "ok") {
												iziToast.success({
													title: 'Sukses!',
													message: 'data berhasil dikosongkan',
													titleColor: '#FFFF00',
													messageColor: '#fff',
													backgroundColor: 'rgba(0, 0, 0, 0.5)',
													 progressBarColor: '#FFFF00',
													  position: 'topRight'
														});
													 setTimeout(function() {
															window.location.reload();
														}, 2000);
													} else {
														iziToast.error({
															title: 'Gagal!',
															message: 'Belum ada yang dipilih',
															position: 'topRight'
														});
														setTimeout(function() {
															window.location.reload();
														}, 2000);
													}

												}
											});
											return false;
										});
									   
									</script>
									<?php } ?>