<?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="bold">MAPEL EKSTRAKURIKULER</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>NAMA EKSTRAKURIKULER</th>
													  <th></th>
                                                </tr>
                                            </thead>
                                            <tbody>
											<?php
											$no=0;
											
											$query = mysqli_query($koneksi, "SELECT * FROM m_eskul"); 	
											  while ($data = mysqli_fetch_array($query)) :
											
											$no++;
											   ?>
                                                <tr>
                                                    <td><?= $no; ?></td>
                                                     <td><?= $data['ekstra'] ?></td>
                                                     
													   <td>
													   	<button data-id="<?= $data['id'] ?>"  class="hapus btn btn-sm btn-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="Hapus"><i class="material-icons">delete</i> </button>
                                                
													   </td>
                                                </tr>
												<?php endwhile; ?>
												</tbody>
                                                </table>
												 </div>
											</div>
										</div>
										
									</div>
								
					               <div class="col-md-4">  
                               <form id="formeskul">								   
                                <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-primary" type="button" disabled>
										<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
										 EKSTRAKURIKULER
									</button>
											</div>
										
								
                               <div class="col-md-12">
								<label class="form-label bold">Nama Ekstrakurikuler</label>
								<input type="text" name="eskul" class="form-control" required="true">
							     </div>	
							       
							      <p>
									  
								         <div class="d-grid gap-2">
                                       
                                         <button type="submit" class="btn btn-primary flex-grow-1 m-l-xxs" id="blockui-3">SIMPAN</button>
                                           
                                            </div>
										
										</div>
									 </div>
					            </div>
								</div>
							</div>
						</div>
						</form>
					</div>
				
							
		                                  <script>
											   $('#formeskul').submit(function(e) {
												e.preventDefault();
												var data = new FormData(this);
												$.ajax({
													type: 'POST',
													 url: 'cbtserver_rapor/catatan/tcatat.php?pg=eskul',
													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>
							   
					
					  
					  
					  	  <script>
									$('#datatable1').on('click', '.hapus', function() {
									var id = $(this).data('id');
									console.log(id);
									swal({
											  title: 'Yakin hapus data?',
											  text: "You won't be able to revert this!",
											  type: 'warning',
											  showCancelButton: true,
											  confirmButtonColor: '#3085d6',
											  cancelButtonColor: '#d33',
											  confirmButtonText: 'Ya, Hapus!',
											  cancelButtonText: "Batal"				  
									}).then((result) => {
										if (result.value) {
											$.ajax({
											   url: 'cbtserver_rapor/catatan/tcatat.php?pg=hapus',
												method: "POST",
												data: 'id=' + id,
												success: function(data) {
													  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);
												}
											});
										}
										return false;
									})

								});

							</script>    
					  
					  
					