<?php if(!defined("Hacking")){die("404 Not Found"); } ?>

<?php
$kullanici = $db->select('admin')
    ->where('admin_id',session("id"))
    ->run(true);
if($kullanici['yetki']==1)
{ ?>

  <?php if(!defined("Hacking")){die("404 Not Found"); } ?>

  <div id="tour-11" class="header-content">
    <h2><i class="fa fa-lock"></i>Süper Admin Kontrol Paneli <a href="index.php?do=profil&ekle" style="float: right;margin-right:35px;color:white;" class="btn btn-success"><i class="glyphicon glyphicon-plus"></i> Yeni</a></h2>
  </div>
  <div class="body-content animated fadeIn">
    <div class="row">
      <div class="col-md-12">
        <div class="panel">
          <div class="panel-body no-padding">
            <div class="table-responsive">
              <table class="table table-bordered table-middle">
                <thead>
                  <tr>
                    <th>Kullanıcı Adı</th>
                    <th>Ad Soyad</th>
                    <th>E-Posta</th>
                    <th class="text-center">Yetki</th>
                    <th class="text-center" style="width: 11%;">İşlem</th>
                  </tr>
                </thead>
                <tbody>
                  <?php
                              $Yoneticiler = $Admin->yonetici_listele();
                              foreach ($Yoneticiler as $key => $value){ ?>
                  <?php if($value['yetki']==1){ echo '<tr class="border-success">'; }
                        else { echo '<tr class="border-warning">'; } ?>
                    <td><b> <?php echo $value['username']; ?> </b></td>
                    <td>    <?php echo $value['adsoyad'];  ?>     </td>
                    <td>    <?php echo $value['email'];  ?>     </td>
                    <td class="text-center">    <?php if($value['yetki']==1){echo "<span style='color:green'>Süper";} else{ echo "<span style='color:#F6BB43'>Normal";}  ?></span>     </td>
                    <td class="text-center">
                      <a href="index.php?do=profil&duzenle=<?=$value['admin_id']; ?>" class="btn btn-success btn-s"> <i class="fa fa-edit"></i></a>

                      <a href="#" onclick="itemsil(<?=$value['admin_id']?>,'','<?=$value['username']?>','admin');" class="btn btn-danger btn-s"> <i class="fa fa-trash-o"></i></a></td>
                  </tr>
                  <?php } ?>
                </tbody>
              </table>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>


<?php
}
else {  ?>

<div id="tour-11" class="header-content">
  <h2><i class="fa fa-user"></i>Profil Ayarları</h2>
</div>
<div class="body-content animated fadeIn">
<div class="row">
  <div class="col-md-12">
    <div class="panel rounded shadow">
      <div class="panel-body no-padding">
        <?php
                    if($_POST){
                        $username   = @post('username');
                        $adsoyad    = @post('adsoyad');
                        $email      = @post('email');
                        $id         = @session('id');
                        // Değiş
                        $profil = $db->update('admin')
                            ->where('admin_id',$id)
                            ->set(array(
                                'username' => $username,
                                'adsoyad'  => $adsoyad,
                                'email'    => $email
                            ));
                        if($profil){
                            echo '<div class="alert alert-success">
                                <strong>Tebrikler!</strong> Profil Bilgileriniz Değiştirildi. Lütfen Tekrar Giriş Yapınız.
                            </div>';
                            git('index.php?do=cikis',2);
                        }else{
                            echo '<div class="alert alert-danger">
                                <strong>Hata!</strong> Lütfen daha Sonra Tekrar Deneyiniz.Yönlendiriliyorsunuz.
                            </div>';
                        }
                    }
                    ?>
        <form action="" method="post">
          <div class="form-body">
            <div class="form-group">
              <label class="control-label">
              <li class="fa fa-user-circle"></li>
              &nbsp;&nbsp;Adınız ve Soyadınız
              </label>
              <input class="form-control" name="adsoyad" value="<?php echo session('adsoyad'); ?>" type="text">
            </div>
            <div class="form-group">
              <label class="control-label">
              <li class="fa fa-user-circle-o"></li>
              &nbsp;&nbsp;Kullanıcı Adı (Panel girişinde kullanılır)
              </label>
              <input class="form-control" name="username" value="<?php echo session('username'); ?>" type="text">
            </div>
            <div class="form-group">
              <label class="control-label">
              <li class="fa fa-envelope"></li>
              &nbsp;&nbsp;E-Posta
              </label>
              <input class="form-control" name="email" value="<?php echo session('email'); ?>" type="text">
            </div>
          </div>
          <div class="form-footer">
            <div class="pull-left">
              <button class="btn btn-primary mr-5" type="submit">
              <li class="fa fa-floppy-o"></li>
              &nbsp;&nbsp;Bilgilerimi Güncelle</button>
            </div>
            <div class="clearfix"></div>
          </div>
        </form>
      </div>
    </div>
  </div>
</div>

<?php } ?>
