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

?>           
	
                   <div class="row">
                          <div class="col-md-8">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">JURNAL GURU</h5>
										
                                    </div>
                                    <div class="card-body">
									
									<div class="card-box table-responsive">
                                        <table id="datatable1" class="table table-bordered table-hover" style="width:100%;font-size:12px">
                                            <thead>
                                                <tr>
                                                    <th width="5%">NO</th> 
													<th>ROMBEL</th>													                           
                                                    <th>MAPEL</th>
													 <th>PENCAPAIAN</th>
													  <th>JURNAL</th>
													
                                                </tr>
                                            </thead>
                                            <tbody>
											<?php
											$no=0;
											if($user['level']=='admin'):
											$query = mysqli_query($koneksi, "SELECT * FROM agenda WHERE pencapaian='Tidak tercapai'"); 
											else:
											$query = mysqli_query($koneksi, "SELECT * FROM agenda WHERE idguru='$user[id_user]' and pencapaian='Tidak tercapai'"); 	
											endif;
											  while ($data = mysqli_fetch_array($query)) :
											 $peg = fetch($koneksi,'users',['id_user'=>$data['idguru']]);
											$no++;
											   ?>
                                                <tr>
                                                    <td><?= $no; ?></td>
                                                     <td><?= $data['kelas'] ?> - <?= $peg['nama'] ?></td>
                                                      <td><h5><?= $data['mapel'] ?> <span class="badge badge-primary"><?= $data['kuri'] ?></span></h5></td>										   
													  <td><?= $data['pencapaian'] ?></td>
													   <td>
													  <a href="?pg=jurnal&id=<?= $data['id'] ?>" class="btn btn-sm btn-success"><i class="material-icons">edit</i></a>
													   </td>
													  
                                                </tr>
												<?php endwhile; ?>
                                                </table>
												 </div>
											</div>
										</div>
										
									</div>
									<?php if ($ac == '') : ?>
									<?php $jurnal = fetch($koneksi,'agenda',['id'=>$_GET['id']]); ?>
					             <div class="col-md-4">                    
                                <div class="card widget widget-payment-request">
                                    <div class="card-header">
                                  
                                    </div>
                                    <div class="card-body">
                                        <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"><?= strtoupper($user['nama']) ?></span>
                                                    <span class="widget-payment-request-author-about"><?= $setting['sekolah'] ?></span>
                                               
											   </div>
                                            </div>
											
									<div class="widget-payment-request-info m-t-md">
									 <div class="d-grid gap-2">
									<button class="btn btn-dark" type="button" disabled>
										<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
										 JURNAL HARIAN GURU
									</button>
											</div>
										
									<form id='formlingkup' class="row g-1"> 
									<input type="hidden" name="id" value="<?= $jurnal['id'] ?>" class="form-control" >
									 <div class="col-md-12">
								<label class="form-label bold">Tanggal</label>
								<input type="text" name="tanggal" value="<?= $jurnal['tanggal'] ?>" class="form-control"  autocomplete="off" readonly>
							     </div>	
								 
								 <div class="row">
                               <div class="col-md-6">
									<label class="bold">Rombel</label>
										<input type="text" value="<?= $jurnal['kelas'] ?>"  class="form-control" readonly >
											</div>	
								
							    <div class='col-md-6'>
                                    <label class="bold">Mapel</label>
                                       <input type="text" value="<?= $jurnal['mapel'] ?>"  class="form-control" readonly >
                                            </div> 
								         </div>   
										 <div class="col-md-12">
								<label class="form-label bold">Hambatan</label>
								<textarea class="form-control" name="hambatan" rows="3" autocomplete="off" required="true"><?= $jurnal['hambatan'] ?></textarea>
							     </div>	
								  <div class="col-md-12">
								<label class="form-label bold">Pemecahan</label>
								<textarea class="form-control" name="pemecahan" rows="3" autocomplete="off" required="true"><?= $jurnal['pemecahan'] ?></textarea>
							     </div>	
								 <p>
									  
								           <div class="d-grid gap-2">
                                       		<?php if($jurnal !=''): ?>							 
                                         <button type="submit" class="btn btn-primary flex-grow-1 m-l-xxs" id="blockui-2">Simpan</button>
                                          <?php else : ?>
										   <button  class="btn btn-light flex-grow-1 m-l-xxs" disabled>Simpan</button>
										  <?php endif; ?>
                                            </div>
										</form>
										
										</div>
									 </div>
					            </div>
								</div>
							</div>
						</div>
					</div>
				</div>
						
							<script>
						$('#formlingkup').submit(function(e) {
								e.preventDefault();
								var data = new FormData(this);
								$.ajax({
									type: 'POST',
									 url: 'cbtserver_ptm/tjadwal.php?pg=jurnal',
									enctype: 'multipart/form-data',
									data: data,
									cache: false,
									contentType: false,
									processData: false,
									beforeSend: function() {},
									success: function(data) {
									   
										setTimeout(function() {
											window.location.reload();
										}, 1500);
									}
								})
								return false;
							});
							</script>
							
							
           
					  <?php endif ?>
					  
					  
					  
					  	  
					  
					  
					