<?php 
$slide = mysqli_fetch_array(mysqli_query($koneksi, "SELECT * FROM menu  WHERE id='1'"));
if($menu['vote']=='0'){{$vote="Non Aktif";}}elseif($menu['vote']=='1'){{$vote="Aktif";}}
if($menu['realtime']=='0'){{$real="Tidak";}}elseif($menu['realtime']=='1'){{$real="Ya";}}
 ?>
<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 E Vote</h5></div>    
			  
						<div class="card-body">
                    <form id='menu'  method='post' class="form-horizontal">
						<div class="row mb-1">
							<label  class="col-md-4 col-form-label bold">Tampil di Siswa</label>
							    <div class="col-sm-8">
						    <select name="vote" id="vote" class="form-select" style="width: 100%;">
                             <option value="<?= $menu['vote']  ?>"><?= $vote  ?></option>
								<option value="1">Aktif</option>
								<option value="0">Non Aktif</option>
                                  </select>
							</div>
		                    </div>
							<div class="row mb-1">
							<label  class="col-md-4 col-form-label bold">Tampil Real Time</label>
							<div class="col-sm-8">
						    <select name="real" id="real" class="form-select" style="width: 100%;">
                             <option value="<?= $menu['realtime']  ?>"><?= $real  ?></option>
								
								<option value="1"> Ya</option>
                                  </select>
							</div>
		                    </div>	
							<p>
					 <button type='submit' name='submit' class='btn right btn-outline-primary'><i class='fa fa-check-circle' ></i><span> Simpan</span></button>
					 <br><br><br>
					
					  </form>
                        </div>
					 </div>
                       </div>
						  <script>
		$('#menu').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'sandik_vote/crud_vote.php?pg=seting',
            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> Hapus Data E Vote</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='kandidat' /> Data Kandidat</label><br />
													<label><input type='checkbox' name='data[]' value='datapemilihan' /> Data Pemilihan</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>