<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>
<?php
if(!empty($_POST)){

  $about_title = $_POST['about_title']; 
  $about_description = $_POST['about_description']; 
  $business_phone = $_POST['business_phone'];  

  if ($_FILES['foto']['tmp_name'] != "") {
    $boyut = $_FILES['foto']['size'];
    $tip = mime_content_type($_FILES['foto']['tmp_name']);
    if($tip!="image/jpeg" && $tip!="image/jpg" && $tip!="image/png" && $tip!="application/pdf"){
      echo 'Dosya Jpeg veya Png yada Gif , PDF formatında olmalı';
    }elseif ($boyut > (1024 * 1024 * 30)) {
     echo 'Dosya 10MB den büyük olamaz.';
   } else {
    $tip = $_FILES['foto']['type'];
    $isim = $_FILES['foto']['name'];
    $uzanti = explode('.', $isim);
    $uzanti = $uzanti[count($uzanti) - 1];
    $random = rand();
    $dosya = $_FILES['foto']['tmp_name'];
    $foto_url = $random . "." . $uzanti;

    copy($dosya, '../img/' . $foto_url);
    echo " <script>
    const Toast = Swal.mixin({
      toast: true,
      position: 'top-end',
      showConfirmButton: false,
      timer: 6000,
      timerProgressBar: true,
      didOpen: (toast) => {
        toast.addEventListener('mouseenter', Swal.stopTimer)
        toast.addEventListener('mouseleave', Swal.resumeTimer)
      }
      })

      Toast.fire({
        icon: 'success',
        title: 'Başarı ile güncellendi.'
        })
        </script> ";

        $settings = $dbh->prepare("UPDATE about_us SET foto = '".$foto_url."' WHERE id=1 ");
        $settings->execute();
      }
    } 

     

          /* katalog bitiş */

          $update = $dbh->prepare("UPDATE about_us SET about_title = '".$about_title."', about_description = '".$about_description."' WHERE id = 1 " );
          $update->execute();
          $id=1;

          foreach ($_POST["en"] as $key => $value) {
         dilguncelle("en","about_us",$id,$key,$value);
      }
        }
        ?>

        <?php
        $ayar = $dbh->query("SELECT * FROM about_us WHERE id = 1 ", PDO::FETCH_ASSOC);
        if ($ayar->rowCount()) {
          foreach ($ayar as $ayar) {
          }
        }
        $sonucen = cevir("about_us",$ayar,"en");
        ?>  
        <!-- Page Content-->
        <div class="page-content">
          <div class="container-fluid">
            <!-- Page-Title -->

            <form method="post" action="" enctype="multipart/form-data">

              <div class="row">
                <div class="col-sm-12">
                  <div class="page-title-box">
                    <div class="row">
                      <div class="col">
                        <h4 class="page-title">Hakkımızda Sayfası</h4>
                        <ol class="breadcrumb">
                          <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li> 
                          <li class="breadcrumb-item active">Hakkımızda Sayfası</li>
                        </ol>
                      </div><!--end col-->
                      <div class="col-auto align-self-center">
                        <button class="btn btn-primary" type="submit">
                          <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                          GÜNCELLE
                        </button> 
                      </div><!--end col-->  
                    </div><!--end row-->                                                              
                  </div><!--end page-title-box-->
                </div><!--end col-->
              </div><!--end row-->
              <!-- end page title end breadcrumb -->


              <div class="row">
                <div class="col-lg-12">
                  <div class="card">
                    <div class="card-header">
                      <h4 class="card-title">Hakkımızda Sayfası</h4>
                      <p class="text-muted mb-0">Değerli kullanıcı, bu alan sayesinde hakkımızda sayfasının içeriğini güncelleyebilirsiniz.</p> 
                    </div><!--end card-header-->
                    <div class="card-body">
                      <div class="row">

                        <div class="col-xl-12"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">Hakkımızda Başlığı </label>
                            <input type="text" class="form-control" maxlength="999" id="thresholdconfig" aria-describedby="emailHelp" name="about_title" value="<?=$ayar['about_title'];?>" required=""> 
                          </div>
                        </div>

                        <div class="col-xl-12"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">Hakkımızda Açıklaması </label>
                        <textarea name="about_description" id="icerik" class="ckeditor"><?=$ayar['about_description'];?></textarea>
                      </div>
                    </div>

                      </div>
                      
                      <div class="row"> 

                        <div class="col-xl-12">   
                          <div class="card-body">
                            <input type="file" id="input-file-now-custom-3" name="foto" accept="image/x-png,image/gif,image/png,image/jpeg,application/pdf" class="dropify" data-default-file="../img/<?=$ayar['foto'];?>" />    
                          </div><!--end col--> 
                        </div>
                         
                      </div>
                      
                      <!-- dil başlangıçı -->

                      <div class="row"> 
                        <div class="col-lg-12 col-xl-12">  
                          <div class="accordion" id="accordionExample">
                             
                      <div class="card mb-1 border shadow-none">
                        <div class="card-header  rounded-0" id="headingTwo">
                          <a href="" class="collapsed text-dark" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                            <i data-feather="sliders"></i> İngilizce Dil Ayarları
                          </a>
                        </div>
                        <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
                          <div class="card-body">

                            <div class="form-group">
                              <label for="exampleInputEmail1">Hakkımızda Başlığı * </label>
                              <input type="text" class="form-control" maxlength="999" id="thresholdconfig" aria-describedby="emailHelp" placeholder="Lütfen bir başlık giriniz" name="en[about_title]" value="<?=$sonucen['about_title'];?>"> 
                            </div>

                            <div class="form-group">
                              <label for="exampleInputEmail1">Hakkımızda Açıklaması</label>
                              <textarea name="en[about_description]" id="metining" class="ckeditor" cols="30" rows="10"><?=$sonucen['about_description'];?></textarea>
                            </div>

                          </div>
                        </div>
                      </div> 
                    </div>      
                  </div><!--end col-->
                </div><!--end row-->

                <!-- dil bitişi --> 

                <br>    
                <button class="btn btn-primary btn-block" type="submit">
                  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                  GÜNCELLE
                </button>
              </form>                                           
            </div><!--end card-body-->
          </div><!--end card-->
        </div><!--end col-->


      </div><!--end row-->



    </div><!-- container -->

    <?php include 'inc/footer.php';?>

