<?php
defined('APK') or exit('Anda tidak dizinkan mengakses langsung script ini!');
?>
<div class='row'>

       <div class='col-md-12'>
           <div class="card">
              <div class="card-header">	
				       <h5 class="card-title">Pengaturan Sekolah</h5>
					</div>
                       	
                         <div class='card-body'>
						 <div class="example-container">
                          <div class="example-content">
						 	<form id="formpengaturan" action='' method='post' enctype='multipart/form-data'>
                      <div class="row mb-1">
        <label  class="col-md-2 col-form-label bold">Nama Aplikasi</label>
        <div class="col-md-3">
            <input type='text' name='aplikasi' value="<?= $setting['aplikasi'] ?>" class='form-control' readonly />
        </div>
    
        <label  class="col-md-2 col-form-label bold">Nama Sekolah</label>
        <div class="col-md-5">
            <input type='text' name='sekolah' value="<?= $setting['sekolah'] ?>" class='form-control' required='true' />
        </div>
    </div>
	 <div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Jenis Satuan Pend</label>
        <div class="col-sm-3">
           <select name='jenis' id="jenis" class='form-select'  required='true'>
            <option value="<?= $setting['jenis'] ?>"><?= $setting['jenis'] ?></option>
                <option value='REGULER'>REGULER</option>
                   <option value='PKBM'>PKBM</option>
              </select>
        </div>
        <label  class="col-sm-2 col-form-label bold">Jenjang</label>
        <div class="col-sm-5">
         <select name='jenjang' id="jenjang" class='form-select'  required='true'>
           <option value="<?= $setting['jenjang'] ?>"><?= $setting['jenjang'] ?></option>
                               
             </select>
        </div>
    </div>
	<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">N P S N</label>
        <div class="col-sm-3">
		<input type='text' name='npsn' value="<?= $setting['npsn'] ?>" class='form-control' required='true' />
          </div>
        <label  class="col-sm-2 col-form-label bold">Kode Sekolah</label>
        <div class="col-sm-5">    
		  <input type='text' name='kode' value="<?= $setting['kode_sekolah'] ?>" class='form-control' required='true'  />
              </div>
			</div>
			<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Semester</label>
        <div class="col-sm-3">	
	 <select name='semester' class='form-select' required='true'>
        <option value="<?= $setting['semester'] ?>"><?= $setting['semester'] ?></option>
             <option value='1'>1</option>
                   <option value='2'>2</option>
             </select>
       </div>
          <label  class="col-sm-2 col-form-label bold">Tahun Pelajaran</label>
        <div class="col-sm-5">	                                    										 
			<input type='text' name='tp' value="<?= $setting['tp'] ?>" class='form-control' autocomplete="off" required='true'  />
                   </div>
					</div>
		<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">ID Server</label>
        <div class="col-sm-3">	
		<input type='text' name='id_server' value="<?= $setting['id_server'] ?>" class='form-control' required='true' />
          </div>
		 <label  class="col-sm-2 col-form-label bold">Telphone</label>
        <div class="col-sm-5">	 				                	 
		<input type='text' name='telp' value="<?= $setting['telp'] ?>" class='form-control' />
               </div>	
	     </div>
			<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Faximily</label>
        <div class="col-sm-10">
			<input type='text' name='fax' value="<?= $setting['fax'] ?>" class='form-control' required='true' />
                </div>
					</div>
			<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Alamat</label>
        <div class="col-sm-4">
			<input type="text" name='alamat' class='form-control' value="<?= $setting['alamat'] ?>"  required='true' >
                                            </div>
		  <label  class="col-sm-1 col-form-label bold">Desa</label>
        <div class="col-sm-5">
	<input type="text" name='desa' class='form-control' value="<?= $setting['desa'] ?>"  required='true' >
            </div>
			  </div>
		<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Kecamatan</label>
        <div class="col-sm-4">
			<input type='text' name='kecamatan' value="<?= $setting['kecamatan'] ?>" class='form-control'  required='true' />
                  </div>
				<label  class="col-sm-1 col-form-label bold">Kab/Kota</label>
        <div class="col-sm-5">
			<input type='text' name='kabupaten' value="<?= $setting['kabupaten'] ?>" class='form-control'  required='true' />
                                            </div>
						               </div>
			<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Propinsi</label>
        <div class="col-sm-4">
		 <input type="text" name='propinsi' class='form-control' value="<?= $setting['propinsi'] ?>"  required='true' >
             </div>
				<label  class="col-sm-1 col-form-label bold">Email</label>
        <div class="col-sm-5">
			<input type='text' name='email' value="<?= $setting['email'] ?>" class='form-control' />
                                            </div>
						                </div>		
									
		<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Website</label>
        <div class="col-sm-10">
			<input type='text' name='web' value="<?= $setting['web'] ?>" class='form-control' />
                                            </div>
										  </div>
		<div class="row mb-1">
        <label  class="col-sm-2 col-form-label bold">Kepala Sekolah</label>
        <div class="col-sm-4">
			<input type='text' name='kepsek' value="<?= $setting['kepsek'] ?>" class='form-control'  />
                                       </div>
		<label  class="col-sm-1 col-form-label bold">NIP Kasek</label>
        <div class="col-sm-5">
			 <input type='text' name='nip' value="<?= $setting['nip'] ?>" class='form-control'  />
                                       </div>
						            </div>
								
								<div class="row">									  
							<div class="col-sm-12">	
							 <div class="form-group">
							<label class="bold" class="col-sm-3 control-label">Token Sinkron</label>
							<input type="text" name='token_api' class="form-control" id='tokenapi' value="<?= $setting['token_api'] ?>"  readonly>
                                    </div>                 
                                       </div>
						            </div>	
									<p>
									<div class="row">									  
							<div class="col-sm-5">	
							 <div class="form-group">
							<label class="bold">Waktu Server</label>
							  <select name='waktu' class='form-select' required='true' >
                                                    <option value="<?= $setting['waktu'] ?>"><?= $setting['waktu'] ?></option>
                                                    <option value='Asia/Jakarta'>Asia/Jakarta</option>
                                                    <option value='Asia/Makassar'>Asia/Makassar</option>
                                                    <option value='Asia/Jayapura'>Asia/Jayapura</option>
                                                </select>           
                                       </div>
						            </div>	
									<div class="col-sm-7">
									<div class="form-group">
							<label class="bold">URL Sinkron Server</label>
							  <input type='text' name='url' value="<?= $setting['url_host'] ?>" class='form-control' />
                                           </div>              
                                       </div>
						            </div>	
									
							<div class="row">									  
							<div class="col-sm-5">	
							 <div class="form-group">
							<label class="bold">Logo</label>
							   <input type='file' name='logo' class='form-control' />
                                            </div>
										</div>
                                     <div class="col-sm-2">	
                                      <div class="form-group">									 
                                                <img src="<?= $homeurl ?>/<?= $setting['logo'] ?>" height='50px' />
                                            </div>
						                </div>				
									 </div><p>
								<div class="row">									  
							<div class="col-sm-5">	
							 <div class="form-group">
							<label class="bold">Tanda Tangan</label>
							   <input type='file' name='ttd' class='form-control' />
                                            </div>
										</div>
											  <div class="col-sm-2">
                                              <div class="form-group">											  
                                                <img src="<?php echo $homeurl . '/dist/img/ttd.png' . '?date=' . time(); ?> " height='50px' />
                                            </div>
						                </div>	
										 </div><p>
						       <div class="row">									  
							<div class="col-sm-5">	
							 <div class="form-group">
							<label class="bold">Stempel</label>
							   <input type='file' name="stempel" id="stempel" class='form-control' />
                                            </div>
											 </div>
											  <div class="col-sm-2">	
                                               	 <div class="form-group">											  
                                                <img src="<?= $homeurl ?>/<?= $setting['stempel'] ?>" height='50px' />
                                            </div>
						                </div>
                                    </div>	
                                      <p>
						       <div class="row">									  
							<div class="col-sm-5">	
							 <div class="form-group">
							<label class="bold">Background Login</label>
							   <input type='file' name="bk" id="bk" class='form-control' />
                                            </div>
											 </div>
											  <div class="col-sm-2">	
                                               	 <div class="form-group">											  
                                                <img src="<?= $homeurl ?>/<?= $setting['background'] ?>" height='50px' />
                                            </div>
						                </div>
                                    </div>											
                                    <div class="row">									  
							<div class="col-sm-5">	
							 <div class="form-group">
							<label class="bold"></label>							  
                                            </div>
										</div>
										
									<div class="row">									  
							<div class="col-sm-12">	
							 <div class="form-group">
							<label class="bold">Header Laporan</label>
							<textarea name="laporan" class="form-control" rowspan="3" ><?= $setting['header'] ?></textarea>
                                            </div>
										</div>	
										<p>
                                     <div class="right">	
                                      								 
                                                <button type='submit' name='submit1' class='btn btn-outline-primary right' ><i class="fas fa-check-circle"></i>Simpan</button>
														
                                            </div>
						               
									           </form>
								            
											</div>
										</div>
									</div>
								</div> 
                          
									 
<script>
   $('#formpengaturan').submit(function(e) {
        e.preventDefault();
        var data = new FormData(this);
      
        $.ajax({
            type: 'POST',
            url: 'pengaturan/crud_setting.php?pg=setting_app',
            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>
<script>	
	$("#jenis").change(function() {
		var jenis = $(this).val();
			console.log(jenis);
			$.ajax({
			type: "POST",
			url: "pengaturan/crud_setting.php?pg=ambil_jenjang", 
			data: "jenis=" + jenis, 
			success: function(response) { 
			$("#jenjang").html(response);
				}
				});
					});
				</script>