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

<?php if ($ac == '') { ?>
<?php
$skkb=fetch($koneksi,'skkb',['id'=>1]);
?>
    <div class='row'>
        <div class='col-md-12'>
           <div class="card">
             <div class="card-header">	
                    <h5 class='card-title'><i class="fas fa-envelope"></i> Managemen Surat</h5>
					</div>    
			 
                <div class='card-body'>
                   <form method="post" action="" enctype="multipart/form-data">
				   <div class='right'>
                        <button type='submit' name='submit' class='btn btn-sm btn-primary'><i class='fa fa-check'></i> Simpan</button>
                    </div>
                   <p>
                            <div class="col-md-12">
                                    <label class="bold">Header</label>
										<textarea id='editor2' name='header' class='form-control' rows='1' cols='80' style='width:100%;'><?= $skkb['header'] ?></textarea>
							
                            </div><p>
							<div class="col-md-12">
                               
                                    <label class="bold">Isi</label>
                                    
										<textarea id='editor2' name='isi' class='editor1' rows='5' cols='80' style='width:100%;'><?= $skkb['isi'] ?></textarea>
						
                            </div><p>
                            
								 <div class="col-md-12">
								 <label class="bold">Foter</label>
                                
										<textarea id='editor2' name='foter' class='editor1' rows='5' cols='80' style='width:100%;'><?= $skkb['foter'] ?></textarea>
									
                                    </div>
								 
                    </div>
                    
                </form>
            </div>
        </div>
    </div>
	</div>
	<?php
            
            if (isset($_POST['submit'])) {
		$header=$_POST['header'];
		$isi=$_POST['isi'];
	    $foter=$_POST['foter'];
		
	  $exec = mysqli_query($koneksi, "UPDATE skkb SET header='$header',isi='$isi',foter='$foter' WHERE id='1' ");		   
	if($exec){
	echo "
	  <script type='text/javascript'>
		setTimeout(function () { 	
			swal({
				title: 'Sukses !!!',
				text:  'Tamplete Berhasil diubah',
				type: 'success',
				timer: 1000,
				showConfirmButton: true
			});		
		},10);	
		window.setTimeout(function(){ 
			window.location.replace('?pg=skkb');
		} ,1000);	
	  </script>";
	
	}
			}
            ?>
   
	<?php } ?>

			
		
	<script>
	tinymce.init({
		selector: '.editor1',
		
		plugins: [
			'advlist autolink lists link image charmap print preview hr anchor pagebreak',
			'searchreplace wordcount visualblocks visualchars code fullscreen',
			'insertdatetime media nonbreaking save table contextmenu directionality',
			'emoticons template paste textcolor colorpicker textpattern imagetools uploadimage paste formula'
		],

		toolbar: 'bold italic fontselect fontsizeselect | alignleft aligncenter alignright bullist numlist  backcolor forecolor | formula code | imagetools link image paste ',
		fontsize_formats: '8pt 10pt 12pt 14pt 18pt 24pt 36pt',
		paste_data_images: true,

		images_upload_handler: function(blobInfo, success, failure) {
			success('data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64());
		},
		image_class_list: [{
			title: 'Responsive',
			value: 'img-responsive'
		}],
	});
</script>