<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>
<?php

if(!empty($_POST)){

 $id = $_GET["id"]; 
 $title = $_POST['title'];
 $description = $_POST['description'];  

 

  $update = $dbh->prepare("UPDATE allergy SET title = '".$title."', description = '".$description."' WHERE id = '".$id."'");
  $update->execute(); 
  foreach ($_POST["en"] as $key => $value) {
   dilguncelle("en","allergy",$id,$key,$value);
 }
}
?>

<?php
$sorgu = $dbh->prepare("SELECT * FROM allergy Where id=:id");
$sorgu->execute(['id' => (int)$_GET["id"]]);
$sonuc = $sorgu->fetch(); 
$sonucen = cevir("allergy",$sonuc,"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">Alerji Düzenle - <?=$sonuc['title'];?></h4>
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li>
                  <li class="breadcrumb-item"><a href="alerji-liste.php">Alerji Listesi</a></li>
                  <li class="breadcrumb-item active">Alerji Düzenle</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">Alerji Düzenle</h4>
              <p class="text-muted mb-0">Değerli kullanıcı, bu alandan alerji düzenleyebilirsiniz. Zorunlu olarak doldurmanız gereken alanlar * olarak belirtilmiştir.</p> 
            </div><!--end card-header-->
            <div class="card-body">

                <div class="row">

                    <div class="col-xl-6"> 
                  <div class="form-group">
                    <label for="exampleInputEmail1">Alerji Adı * </label>
                    <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Lütfen bir alerji adı giriniz" name="title" value="<?=$sonuc['title'];?>" required=""> 
                  </div>
                </div>

                  <div class="col-xl-6"> 
                  <div class="form-group">
                    <label for="exampleInputEmail1">Alerji Açıklaması </label>
                    <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Lütfen bir alerji açıklaması giriniz" name="description" value="<?=$sonuc['description'];?>"> 
                  </div>
                </div> 
                 
              </div>



 

              <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">Alerji Adı * </label>
                        <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Lütfen bir alerji adı giriniz" name="en[title]" value="<?=$sonucen['title'];?>">
                        </div>

                        <div class="form-group">
                          <label for="exampleInputEmail1">Alerji Açıklaması </label>
                        <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Lütfen bir alerji açıklaması giriniz" name="en[description]" value="<?=$sonucen['description'];?>">
                        </div>

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

        <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';?>

