 <?php 
 defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
$jumguru = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM users WHERE nowa<>'' AND level='guru'"));
$jumstaff = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM users WHERE nowa<>'' AND level='staff'"));
$jumsiswa = mysqli_num_rows(mysqli_query($koneksi, "SELECT * FROM siswa WHERE nowa<>''"));


?>


                       <div class="row">
                            <div class="col-xl-4">
                                <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            <div class="widget-stats-icon widget-stats-icon-primary">
                                                <i class="material-icons-outlined">schedule</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">JAM MASUK</span>
                                                <span class="widget-stats-amount"><?= $setting['jam_masuk'] ?></span><p>
                                                <span class="widget-stats-info"><?= $setting['sekolah'] ?></span>
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-positive align-self-start">
                                                <i class="material-icons">keyboard_arrow_up</i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
							
                            <div class="col-xl-4">
                                 <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            <div class="widget-stats-icon widget-stats-icon-success">
                                                <i class="material-icons-outlined">schedule</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">JAM PULANG</span>
                                                <span class="widget-stats-amount"><?= $setting['jam_pulang'] ?></span><p>
                                                <span class="widget-stats-info"><?= $setting['sekolah'] ?></span>
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-positive align-self-start">
                                                <i class="material-icons">keyboard_arrow_up</i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                          
                            <div class="col-xl-4">
                                <div class="card widget widget-stats">
                                    <div class="card-body">
                                        <div class="widget-stats-container d-flex">
                                            <div class="widget-stats-icon widget-stats-icon-danger">
                                                <i class="material-icons-outlined">school</i>
                                            </div>
                                            <div class="widget-stats-content flex-fill">
                                                <span class="widget-stats-title">JAM DETEK ALPHA</span>
                                                <span class="widget-stats-amount"><?= $setting['detek_alpha'] ?></span><p>
                                                <span class="widget-stats-info"><?= $setting['sekolah'] ?></span>
                                            </div>
                                            <div class="widget-stats-indicator widget-stats-indicator-negative align-self-start">
                                                <i class="material-icons">keyboard_arrow_up</i>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                           <div class="col-xl-8">
                                <div class="card widget widget-payment-request">
                                    <div class="card-header">
                                        <h5 class="card-title">
										<span id='waktu' style="font-size:18px;color:red"><?= $waktu ?></span>
										
										<button class="btn btn-secondary kanan" type="button" disabled>
                                      <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> 
									<?= buat_tanggal('D, d M Y') ?> </button>
										</h5>
                                    </div>
                                    <div class="card-body">
                                        
                                            
                                           
                                        </div>
                                    </div>
                                </div>
                         
                             <div class="col-xl-4">
                                <div class="card widget widget-payment-request">
                                    <div class="card-header">
                                        <h5 class="card-title">SETTING PRESENSI</h5>
                                    </div>
                                    <div class="card-body">
									 <form id="formsiswa">
                                        <div class="widget-payment-request-container">
                                            <div class="widget-payment-request-author">
                                                <div class="avatar m-r-sm">
                                                    <img src="../images/user.png" alt="">
                                                </div>
                                                <div class="widget-payment-request-author-info">
                                                    <span class="widget-payment-request-author-name"><?= $setting['sekolah'] ?></span>
                                                    <span class="widget-payment-request-author-about"><?= date('d M Y') ?></span>
                                                </div>
                                            </div>
                                            
                                            <div class="widget-payment-request-info m-t-md">
                                                <div class="widget-payment-request-info-item">
                                                    <span class="widget-payment-request-info-title d-block">
													<label>JAM MASUK</label>
                                                  <input type='text' name='masuk'  class='timer form-control' value="<?= $setting['jam_masuk'] ?>" required="true" autocomplete="off" />
                                                 
												 <label>JAM PULANG</label>
                                                  <input type='text' name='pulang'  class='jam1 form-control' value="<?= $setting['jam_pulang'] ?>" required="true" autocomplete="off" />													  
                                                    <label>JAM DETEK ALPHA SISWA</label>
                                                  <input type='text' name='alpha'  class='jam2 form-control' value="<?= $setting['detek_alpha'] ?>" required="true" autocomplete="off" />	
													</span>                                                  
                                                </div>                                               
                                            </div>
											<p>
                                           <div class="d-grid gap-2">
                                             
                                                <button type="submit" id="blockui-3" class="btn btn-primary flex-grow-1 m-l-xxs">UPDATE</button>
                                            </div>
                                        </div>
										</form>
										<p>
                                    </div>
                                </div>
                            </div>
                        </div>
                             	
					</div>
                     	<script>
					$('#formsiswa').submit(function(e){
						e.preventDefault();
						var data = new FormData(this);
						$.ajax(
						{
							type: 'POST',
							 url: 'cbtserver_absen/tsetting.php?pg=ubah',
							data: data,
							cache: false,
							contentType: false,
							processData: false,
							success: function(data){   		
							setTimeout(function()
								{
								window.location.reload();
										}, 2000);
													  
										}
									});
								return false;
							});
						</script>