<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<?php
if($menu['absen_siswa']=='0'){{$absis="MANUAL";}}elseif($menu['absen_siswa']=='1'){{$absis="RFID";}}
if($menu['absen_guru']=='0'){{$abgur="MANUAL";}}elseif($menu['absen_guru']=='1'){{$abgur="RFID";}}
elseif($menu['absen_guru']=='2'){{$abgur="G P S";}}elseif($menu['absen_guru']=='1'){{$abgur="FACE ID";}}
if($setting['kirimabsen']=='0'){{$kirim="Non Aktif";}}elseif($setting['kirimabsen']=='1'){{$kirim="Aktifkan";}}
if($menu['ptm']=='0'){{$ptm="Non Aktif";}}elseif($menu['ptm']=='1'){{$ptm="Aktifkan";}}

?>
<div class='row'>
        <div class='col-md-6'>
            <div class="card">
             <div class="card-header">	
                  <h5 class='card-title'><i class="fas fa-tools"></i> Pengaturan Absen</h5></div>    
			 
			 
                      <div class="card-body">
                    <form id='menu'   class="form-horizontal" >
					<div class="row mb-1">
							<label class="col-md-4 col-form-label bold">Menu di Guru</label>
							<div class="col-sm-5">
						   <select name="ptm"  class="form-select" style="width: 100%;" require="true">
                               <option value="<?= $menu['ptm']  ?>"><?= $ptm  ?></option>
							      <option value="">--Pilih Menu--</option>
								  <option value="0">Non Aktif</option>
			                      <option value="1">Aktifkan</option>
                                  </select>
							</div>
		                    </div>
							<div class="row mb-1">
							<label class="col-md-4 col-form-label bold">Kirim Pesan Absensi</label>
							<div class="col-sm-5">
						   <select name="pesan"  class="form-select" style="width: 100%;" require="true">
                               <option value="<?= $setting['kirimabsen']  ?>"><?= $kirim  ?></option>
							      <option value="">--Pilih Pesan--</option>
								  <option value="0">Non Aktif</option>
			                      <option value="1">Aktifkan</option>
                                  </select>
							</div>
		                    </div>
							<div class="row mb-1">
							<label class="col-md-4 col-form-label bold">Model Absen Siswa</label>
							
							<div class="col-sm-5">
						   <select name="absis"  class="form-select" style="width: 100%;" require="true">
                               <option value="<?= $menu['absen_siswa']  ?>"><?= $absis  ?></option>
							      <option value="">--Pilih Model Absen--</option>
								  <option value="0">Manual</option>
			                      <option value="1">RFID</option>
                                  </select>
							</div>
		                    </div>
							<div class="row mb-1">
							<label class="col-md-4 col-form-label bold">Model Absen Pegawai</label>
							<div class="col-sm-8">
						   <select name="abgur"  class="form-select" style="width: 100%;" required>
                             <option value="<?= $menu['absen_guru']  ?>"><?= $abgur  ?></option>
							      <option value="">--Pilih Model Absen--</option>
								  <option value="0">MANUAL</option>
			                      <option value="1">RFID</option>
								  
                                  </select>
								 </div>  
							</div>
							<div class="right">
						   <button type='submit' name='submit' class='btn btn-outline-success'><i class='fa fa-check-circle' ></i>Simpan</button>
					 </div>
					 </form>
                        </div>
					 </div>
                   </div>
			   
              
						  <script>
				  $('#menu').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'sandik_ptm/crud_setting.php?pg=settingptm',
            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-6'>
						   <div class="card">
							 <div class="card-header">	
								  <h5 class='card-title'>
								  <i class="fas fa-trash"></i> Reset Data PTM</h5></div>   
                                       <div class="card-body">         
												<div class='checkbox'>
												 <form id='formhapusdata' action='' method='post'>
                                                      <b>Pilih Data</b><br />
                                                    <label><input type='checkbox' name='data[]' value='absensi' /> Absen Pegawai - Kelas</label><br />
													<label><input type='checkbox' name='data[]' value='absen_mapel' /> Absen Mapel</label><br />
													<label><input type='checkbox' name='data[]' value='jadwal_mapel' /> Jadwal Mapel</label><br />
													<label><input type='checkbox' name='data[]' value='agenda' /> Agenda - Jurnal</label><br />
													<label><input type='checkbox' name='data[]' value='nilai_harian' /> Data Nilai Harian</label><br />
													<label><input type='checkbox' name='data[]' value='datarfid' /> Data RFID</label><br />
													<label><input type='checkbox' name='data[]' value='tujuan' /> Tujuan Pembelajaran</label><br />
													<label><input type='checkbox' name='data[]' value='lingkup' /> Lingkup Materi</label><br />
													<label><input type='checkbox' name='data[]' value='bel' /> Bell Otomatis</label><br />
													
                                                </div>
                                            </div>
											<div class="card-body">  
                                            <div class="row mb-1">
													<label  class="col-md-4 col-form-label bold">Password Admin</label>
													<div class="col-sm-8">
													<div class="input-group">
                                                    <input type='password' name='password' class='form-control' required='true' />
                                                <span class="input-group-btn">
												 <button type='submit' name='submit3' class='btn btn-outline-danger'><i class='fa fa-trash'></i> Reset</button>
												</span>
												</div>
                                               </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                        
                    </div>
                </div>
            </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.info(
            {
                title: 'Sukses!',
                message: 'Data berhasil dihapus',
				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: 'Maaf!',
                        message: data,
                        position: 'topRight'
                    });
                }

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