<?php
defined("BASEPATH") or exit("No direct access allowed");
if (isset($_POST['ubah'])){
    
    $namafolder="images/"; 
    If (empty($_FILES["filegbr"]["tmp_name"])){
            echo '
            <script>
            	swal("Good Job","Anda belum memilih logo","error");
            </script>
    		';
    		
    } else {    
        
        $jenis_gambar=$_FILES['filegbr']['type'];
        if($jenis_gambar=="image/jpeg" || $jenis_gambar=="image/jpg" || $jenis_gambar=="image/gif" || $jenis_gambar=="image/png"){
            
            $logo = $namafolder . basename($_FILES['filegbr']['name']);
            
            if (move_uploaded_file($_FILES['filegbr']['tmp_name'], $logo)) {
            
                //simpan
                mysqli_query($con,"update akunn set logo='$logo'  where id=1");
                echo '
                <script>
                	swal("Good Job","Anda sukses menyimpan logo","success");
                </script>
        		';
            } else {
                echo '
                <script>
                	swal("Good Error","Logo gagal diupload","error");
                </script>
        		';
            }
        }else {
            echo '
            <script>
            	swal("Good Error","Jenis gambar logo yang anda diupload salah. Harus .jpg .png","error");
            </script>
    	  	';
        }
     
    }

        echo '
		<!-- <div class="alert alert-success alert-dismissable" style="margin-top:20px">
            <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h4><i class="icon glyphicon glyphicon-remove"></i> Anda sukses menyimpan setting.</div> -->
		';
        
   
}

$data=mysqli_fetch_row(mysqli_query($con,"select * from akunn where id=1"));

?>
    <style>
        #image-holder {
            margin-top: 8px;
        }
        
        #image-holder img {
            border: 8px solid #DDD;
            max-width:100%;
        }
    </style>
    
   <div class="card-header">
          
          <nav aria-label="breadcrumb">
                      <ol class="breadcrumb bg-warning text-white-all">
                        <li class="breadcrumb-item"><a href="#"><i class="fas fa-tachometer-alt"></i> Home</a></li>
                        <li class="breadcrumb-item"><a href="#"><i class="far fa-file"></i> Akun</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><i class="fas fa-list"></i> Logo</li>
                      </ol>
                    </nav>
                    
            <div class="card-body">
            <div class="alert alert-primary alert-has-icon p-4">
            <div class="alert-icon"><i class="far fa-lightbulb"></i></div>
            <div class="alert-body">
            <div class="alert-title">Petunjuk:</div>
            1. Logo ini tampil di <a href="index.php?page=newlink">QRCode Link Tracking</a><br>
            2. Logo ini juga tampil di Link Validasi QRCode Diskont.
            </div>
            </div>
        </div>         
					
          </div>
          
          

               <div class="card-body">
                <form action="" method="POST" enctype="multipart/form-data"> 

                        <div class="form-group">
                            <label for="tiga" class="col-sm-2 control-label">Logo</label>
                            <div class="col-sm-10">
                                <img class="img-rounded" src="<?php echo $data[18]; ?>"> <br>
                                <input type='file' name='filegbr' id='Filegambar'>
                            </div>
                        </div>
                    
                        <div class="form-group">
                          <div class  ="col-sm-4">
                            <button type="submit" class="btn btn-primary" name="ubah"><span class="glyphicon glyphicon-pencil"></span> Upload</button>
                          </div>
                        </div>

                </form>
            </div>
        
      
    