<?php

if (isset($_GET["islem"]) == "duzenle") {
    $sayfaid = $_GET["id"];
    $durum = "duzenle";
    $Sorgu = $db->prepare("SELECT * FROM footer_menu WHERE id = ? AND dil = ?");
    $Sorgu->execute([$sayfaid, $_SESSION["admin_dil"]]);
    if ($Sorgu->rowCount()) {
        $Sonuc = $Sorgu->fetch(PDO::FETCH_ASSOC);
    }
}
echo "<link href=\"assets/plugins/nestable/jquery.nestable.css\" rel=\"stylesheet\" />\r\n<link href=\"assets/plugins/select2/select2.css\" rel=\"stylesheet\" type=\"text/css\" />\r\n<div class=\"content\">\r\n    <div class=\"container-fluid\">\r\n\r\n        <!-- Page-Title -->\r\n        <div class=\"row\">\r\n            <div class=\"col-sm-12\">\r\n\t\t\t\t<div class=\"btn-group pull-right m-t-15\">\r\n\t\t\t\t\t<button type=\"button\" class=\"btn btn-default dropdown-toggle waves-effect waves-light\" data-toggle=\"dropdown\" aria-expanded=\"false\">Düzenleme Dili <strong>";
echo $mevcutDil["adi"];
echo "</strong></button>\r\n\t\t\t\t\t<div class=\"dropdown-menu dropdown-menu-right\" aria-labelledby=\"btnGroupDrop1\">\r\n\t\t\t\t\t\t";
$DILSorgu = $db->prepare("SELECT * FROM diller ORDER BY sira ASC");
$DILSorgu->execute();
$DILislem = $DILSorgu->fetchALL(PDO::FETCH_ASSOC);
echo "\t\t\t\t\t\t\t";
foreach ($DILislem as $DILSonuc) {
    echo "\t\t\t\t\t\t\t<a class=\"dropdown-item\" href=\"footer-menu-ayar.html?dil=";
    echo $DILSonuc["id"];
    echo "\">";
    echo $DILSonuc["adi"];
    echo "</a>\r\n\t\t\t\t\t\t\t";
}
echo "\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n                <h4 class=\"page-title\">";
echo $admindil["txt64"];
echo "</h4>\r\n                <ol class=\"breadcrumb\">\r\n                    <li class=\"breadcrumb-item\"><a href=\"index.html\">";
echo $admindil["txt1"];
echo "</a></li>\r\n                    <li class=\"breadcrumb-item\"><a href=\"menu-ayar.html\">";
echo $admindil["txt48"];
echo "</a></li>\r\n                    <li class=\"breadcrumb-item active\">";
echo $admindil["txt64"];
echo "</li>\r\n                </ol>\r\n\r\n            </div>\r\n        </div>\r\n\r\n        <div class=\"row\">\r\n            <div class=\"col-sm-12\">\r\n                <div class=\"card-box\">\r\n                    <div class=\"row\">\r\n                        <div class=\"col-md-6\">\r\n                            <h4 class=\"m-t-0 header-title\"><b>FOOTER MENÜ EKLE / DÜZENLE</b></h4></br>\r\n\t\t\t\r\n\t\t\t\t\t\t\t<form method=\"post\" action=\"../system/panel_islemler.php\" enctype=\"multipart/form-data\">\r\n\t\t\t\t\t\t\t\t<input id=\"id\" name=\"id\" type=\"hidden\" value=\"";
echo $Sonuc["id"];
echo "\">\r\n\t\t\t\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t\t\t\t<label for=\"menu_ust\">Üst Menü Seç</label>\r\n\t\t\t\t\t\t\t\t\t<select name=\"menu_ust\" id=\"menu_ust\" class=\"form-control select2\">\r\n\t\t\t\t\t\t\t\t\t\t<option value=\"0\">Üst Menü</option>\r\n\t\t\t\t\t\t\t\t\t\t";
$MENUSorgu = $db->prepare("SELECT * FROM footer_menu WHERE menu_ust = ? AND dil = ? ORDER BY menu_sira ASC");
$MENUSorgu->execute(["0", $_SESSION["admin_dil"]]);
$MENUislem = $MENUSorgu->fetchALL(PDO::FETCH_ASSOC);
echo "\t\t\t\t\t\t\t\t\t\t";
foreach ($MENUislem as $MENUSonuc) {
    echo "\t\t\t\t\t\t\t\t\t\t<option value=\"";
    echo $MENUSonuc["id"];
    echo "\" ";
    echo $Sonuc["menu_ust"] == $MENUSonuc["id"] ? "selected" : "";
    echo ">";
    echo $MENUSonuc["menu_isim"];
    echo "</option>\r\n\t\t\t\t\t\t\t\t\t\t";
}
echo "\t\t\t\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t\t\t\t<label for=\"menu_sira\">Menü Sıra</label>\r\n\t\t\t\t\t\t\t\t\t<input type=\"number\" class=\"form-control\" name=\"menu_sira\" id=\"menu_sira\" value=\"";
echo isset($_GET["islem"]) == "duzenle" ? $Sonuc["menu_sira"] : "";
echo "\" />\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t\t\t\t<label for=\"menu_isim\">Menü Adı</label>\r\n\t\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form-control\" name=\"menu_isim\" required id=\"menu_isim\" value=\"";
echo isset($_GET["islem"]) == "duzenle" ? $Sonuc["menu_isim"] : "";
echo "\" />\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t\t\t\t<label for=\"menu_url\">Bağlantı Sayfası</label>\r\n\t\t\t\t\t\t\t\t\t<select name=\"menu_url\" id=\"menu_url\" class=\"form-control select2\">\r\n\t\t\t\t\t\t\t\t\t\t<option value=\"0\">Diğer (Manuel Link Ekle)</option>\r\n\t\t\t\t\t\t\t\t\t\t<optgroup label=\"";
echo $admindil["txt3"];
echo "\">\r\n\t\t\t\t\t\t\t\t\t\t";
$SAYFASorgu = $db->prepare("SELECT * FROM sayfalar WHERE durum = ? AND dil = ? ORDER BY id ASC");
$SAYFASorgu->execute(["1", $_SESSION["admin_dil"]]);
$SAYFAislem = $SAYFASorgu->fetchALL(PDO::FETCH_ASSOC);
echo "\t\t\t\t\t\t\t\t\t\t\t";
foreach ($SAYFAislem as $SAYFASonuc) {
    echo "\t\t\t\t\t\t\t\t\t\t\t<option value=\"sayfa/";
    echo $SAYFASonuc["seo"];
    echo ".html\" ";
    echo $Sonuc["menu_url"] == "sayfa/" . $SAYFASonuc["seo"] . ".html" ? "selected" : "";
    echo ">";
    echo $SAYFASonuc["adi"];
    echo "</option>\r\n\t\t\t\t\t\t\t\t\t\t\t";
}
echo "\t\t\t\t\t\t\t\t\t\t</optgroup>\r\n\t\t\t\t\t\t\t\t\t\t<optgroup label=\"Kategoriler\">\r\n\t\t\t\t\t\t\t\t\t\t";
$KATSorgu = $db->prepare("SELECT * FROM kategori WHERE dil = ? ORDER BY sira ASC");
$KATSorgu->execute([$_SESSION["admin_dil"]]);
$KATislem = $KATSorgu->fetchALL(PDO::FETCH_ASSOC);
echo "\t\t\t\t\t\t\t\t\t\t\t";
foreach ($KATislem as $KATSonuc) {
    echo "\t\t\t\t\t\t\t\t\t\t\t<option value=\"kategori/";
    echo $KATSonuc["seo"];
    echo ".html\" ";
    echo $Sonuc["menu_url"] == "kategori/" . $KATSonuc["seo"] . ".html" ? "selected" : "";
    echo ">";
    echo $KATSonuc["adi"];
    echo "</option>\r\n\t\t\t\t\t\t\t\t\t\t\t";
}
echo "\t\t\t\t\t\t\t\t\t\t</optgroup>\r\n\t\t\t\t\t\t\t\t\t\t<optgroup label=\"Sabit Sayfalar\">\r\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"arac-listesi.html\" ";
echo $Sonuc["menu_url"] == "arac-listesi.html" ? "selected" : "";
echo ">Araç Listesi</option>\r\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"transfer.html\" ";
echo $Sonuc["menu_url"] == "transfer.html" ? "selected" : "";
echo ">Transfer</option>\r\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"kampanyalar.html\" ";
echo $Sonuc["menu_url"] == "kampanyalar.html" ? "selected" : "";
echo ">Kampanyalar</option>\r\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"haberler.html\" ";
echo $Sonuc["menu_url"] == "haberler.html" ? "selected" : "";
echo ">Haberler</option>\r\n\t\t\t\t\t\t\t\t\t\t\t<option value=\"iletisim.html\" ";
echo $Sonuc["menu_url"] == "iletisim.html" ? "selected" : "";
echo ">İletisim</option>\r\n\t\t\t\t\t\t\t\t\t\t</optgroup>\r\n\t\t\t\t\t\t\t\t\t</select>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t<div class=\"form-group link\">\r\n\t\t\t\t\t\t\t\t\t<label for=\"link\">Bağlantı Adresi (Manuel Link Ekle)</label>\r\n\t\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form-control\" name=\"link\" id=\"link\" value=\"";
echo isset($_GET["islem"]) == "duzenle" ? $Sonuc["link"] : "";
echo "\" />\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t<div class=\"checkbox checkbox-custom\">\r\n\t\t\t\t\t\t\t\t\t<input id=\"checkbox11\" name=\"sekme\" ";
if ($Sonuc["sekme"] == "1") {
    echo " checked ";
}
echo " type=\"checkbox\">\r\n\t\t\t\t\t\t\t\t\t<label for=\"checkbox11\">\r\n\t\t\t\t\t\t\t\t\t\tTıklandığında yeni sekmeye gitsin mi ?\r\n\t\t\t\t\t\t\t\t\t</label>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t";
if (isset($_GET["islem"]) == "duzenle") {
    echo "\t\t\t\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t\t\t\t<label class=\"control-label\">Durumu</label> <span class=\"clearfix\"></span>\r\n\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"menu_durum\" ";
    if ($Sonuc["menu_durum"] == "1") {
        echo " checked ";
    }
    echo " value=\"1\" data-plugin=\"switchery\" data-switchery=\"true\" data-color=\"#1AB394\" data-secondary-color=\"#ED5565\" />\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t";
} else {
    echo "\t\t\t\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t\t\t\t<label class=\"control-label\">Durumu</label> <span class=\"clearfix\"></span>\r\n\t\t\t\t\t\t\t\t\t<input type=\"checkbox\" name=\"menu_durum\" value=\"1\" checked data-plugin=\"switchery\" data-switchery=\"true\" data-color=\"#1AB394\" data-secondary-color=\"#ED5565\" />\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t";
}
echo "\t\t\t\t\t\t\t\t\t<span class=\"clearfix\"></span>\r\n\t\t\t\t\t\t\t\t";
if (isset($_GET["islem"]) == "duzenle") {
    echo "\t\t\t\t\t\t\t\t<button type=\"submit\" name=\"FooterMenuGuncelle\" class=\"btn btn-primary waves-effect waves-light\">\r\n\t\t\t\t\t\t\t\t\t   <span class=\"btn-label\"><i class=\"fa fa-check\"></i></span>Güncelle\r\n\t\t\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t\t\t<a href=\"footer-menu-ayar.html\" class=\"btn btn-success waves-effect waves-light\">\r\n\t\t\t\t\t\t\t\t\t<span class=\"btn-label\"><i class=\"fa fa-plus\"></i></span>Yeni Ekle\r\n\t\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t\t\t";
} else {
    echo "\t\t\t\t\t\t\t\t<button type=\"submit\" name=\"FooterMenuKaydet\" class=\"btn btn-success waves-effect waves-light autohidebut\">\r\n\t\t\t\t\t\t\t\t\t   <span class=\"btn-label\"><i class=\"fa fa-check\"></i></span>Kaydet\r\n\t\t\t\t\t\t\t\t</button>\r\n\t\t\t\t\t\t\t\t";
}
echo "\t\t\t\t\t\t\t</form>\r\n                        </div>\r\n                        <!-- end col -->\r\n\r\n                        <div class=\"col-md-6\">\r\n                            <h4 class=\"m-t-0 header-title\"><b>AKTİF MENÜLER</b></h4></br>\r\n\r\n                            <div class=\"custom-dd dd\" id=\"nestable_list_2\">\r\n                                <ol class=\"dd-list\">\r\n\t\t\t\t\t\t\t\t";
$USTMENUSorgu = $db->prepare("SELECT * FROM footer_menu WHERE menu_ust = ? AND dil = ? ORDER BY menu_sira ASC");
$USTMENUSorgu->execute(["0", $_SESSION["admin_dil"]]);
$USTMENUislem = $USTMENUSorgu->fetchALL(PDO::FETCH_ASSOC);
echo "\t\t\t\t\t\t\t\t\t";
foreach ($USTMENUislem as $USTMENUSonuc) {
    echo "\t\t\t\t\t\t\t\t\t\t<li class=\"dd-item\">\r\n                                        <div class=\"dd-handle\">\r\n                                            ";
    echo $USTMENUSonuc["menu_isim"];
    echo " <div class=\"menubuton\"><a href=\"footermenu/duzenle/";
    echo $USTMENUSonuc["id"];
    echo ".html\">Düzenle</a> - <a href=\"javascript:;\" id=\"\" onclick=\"\$.Notification.confirm('success','top right', 'Silmek istediğinize emin misiniz ?','../system/panel_islemler.php?footermenusil=ok&id=";
    echo $USTMENUSonuc["id"];
    echo "')\">Sil</a></div>\r\n                                        </div>\r\n\t\t\t\t\t\t\t\t\t\t";
    $ALTMENUSorgu = $db->prepare("SELECT * FROM footer_menu WHERE menu_ust = ? AND dil = ? ORDER BY menu_sira ASC");
    $ALTMENUSorgu->execute([$USTMENUSonuc["id"], $_SESSION["admin_dil"]]);
    $ALTMENUislem = $ALTMENUSorgu->fetchALL(PDO::FETCH_ASSOC);
    echo "\t\t\t\t\t\t\t\t\t\t";
    foreach ($ALTMENUislem as $ALTMENUSonuc) {
        echo "\t\t\t\t\t\t\t\t\t\t<ol class=\"dd-list\">\r\n                                            <li class=\"dd-item\">\r\n                                                <div class=\"dd-handle\">\r\n                                                    ";
        echo $ALTMENUSonuc["menu_isim"];
        echo " <div class=\"menubuton\"><a href=\"footermenu/duzenle/";
        echo $ALTMENUSonuc["id"];
        echo ".html\">Düzenle</a> - <a href=\"javascript:;\" id=\"\" onclick=\"\$.Notification.confirm('success','top right', 'Silmek istediğinize emin misiniz ?','../system/panel_islemler.php?footermenusil=ok&id=";
        echo $ALTMENUSonuc["id"];
        echo "')\">Sil</a></div>\r\n                                                </div>\r\n                                            </li>\r\n                                        </ol>\r\n\t\t\t\t\t\t\t\t\t\t";
    }
    echo "                                    </li>\r\n\t\t\t\t\t\t\t\t\t";
}
echo "                                </ol>\r\n                            </div>\r\n                        </div>\r\n                        <!-- end col -->\r\n                    </div>\r\n                    <!-- end row -->\r\n                </div>\r\n                <!-- end card-box -->\r\n            </div>\r\n            <!-- end col -->\r\n        </div>\r\n        <!-- end Row -->\r\n\r\n    </div>\r\n    <!-- container -->\r\n\r\n</div>\r\n<script> \r\n\$(document).ready(function(e) {\r\n\t\$('#menu_url').bind('change', linkGetir);\r\n});\r\nfunction linkGetir(){\r\n\tvar value = \$(this).val();\r\n\tif(value=='0'){\r\n\t\t \$('.link').removeClass('hidden');\r\n\t\t \$('.link input').attr('required','required');\r\n\t}else{\r\n\t\t \$('.link').addClass('hidden');\r\n\t\t \$('.link input').removeAttr('required');\r\n\t}\r\n}\r\n\$('#menu_url').ready(function(){\r\n\tvar value = \$(\"#menu_url\").val();\r\n\tif(value=='0'){\r\n\t\t \$('.link').removeClass('hidden');\r\n\t\t \$('.link input').attr('required','required');\r\n\t}else{\r\n\t\t \$('.link').addClass('hidden');\r\n\t\t \$('.link input').removeAttr('required');\r\n\t}\r\n});\t\r\n</script>\r\n";
if ($_SESSION["FooterMenuKaydet"] == "yes") {
    echo "\r\n\t<script>\r\n\t\$(document).ready(function () {\r\n\t\t\$.Notification.autoHideNotify('success', 'top right', 'Başarılı!','Başarı ile eklenmiştir.')\r\n\t});\r\n\t</script>";
    unset($_SESSION["FooterMenuKaydet"]);
}
if ($_SESSION["FooterMenuKaydet"] == "no") {
    echo "\r\n\t<script>\r\n\t\$(document).ready(function () {\r\n\t\t\$.Notification.autoHideNotify('error', 'top right', 'Hata!','Hata oluştu tekrar deneyiniz.!')\r\n\t});\r\n\t</script>";
    unset($_SESSION["FooterMenuKaydet"]);
}
echo "\r\n";
if ($_SESSION["FooterMenuGuncelle"] == "yes") {
    echo "\r\n\t<script>\r\n\t\$(document).ready(function () {\r\n\t\t\$.Notification.autoHideNotify('success', 'top right', 'Başarılı!','Başarı ile guncellenmiştir.')\r\n\t});\r\n\t</script>";
    unset($_SESSION["FooterMenuGuncelle"]);
}
if ($_SESSION["FooterMenuGuncelle"] == "no") {
    echo "\r\n\t<script>\r\n\t\$(document).ready(function () {\r\n\t\t\$.Notification.autoHideNotify('error', 'top right', 'Hata!','Hata oluştu tekrar deneyiniz.!')\r\n\t});\r\n\t</script>";
    unset($_SESSION["FooterMenuGuncelle"]);
}
echo "\r\n";
if ($_SESSION["footermenusil"] == "yes") {
    echo "\r\n\t<script>\r\n\t\$(document).ready(function () {\r\n\t\t\$.Notification.autoHideNotify('success', 'top right', 'Başarılı!','Başarı ile silinmiştir.')\r\n\t});\r\n\t</script>";
    unset($_SESSION["footermenusil"]);
}
if ($_SESSION["footermenusil"] == "no") {
    echo "\r\n\t<script>\r\n\t\$(document).ready(function () {\r\n\t\t\$.Notification.autoHideNotify('error', 'top right', 'Hata!','Hata oluştu tekrar deneyiniz.!')\r\n\t});\r\n\t</script>";
    unset($_SESSION["footermenusil"]);
}

?>