<?php


$sql = "SELECT id, baslik, baslangic, bitis, renk FROM not_defteri ";
$req = $db->prepare($sql);
$req->execute();
$events = $req->fetchAll();
echo "<!-- partial -->\r\n<div class=\"row\">\r\n\t<div class=\"col-md-12\">\r\n\t\t<div class=\"card\">\r\n\t\t\t<div class=\"card-body\">\r\n\t\t\t\t<h4 class=\"card-title\">";
echo $admindil["txt103"];
echo "</h4>\r\n\t\t\t\t<div id=\"calendar\" class=\"full-calendar\"></div>\r\n\t\t\t</div>\r\n\t\t</div>\r\n\t</div>\r\n</div>\r\n<!-- content-wrapper ends -->\r\n\t\r\n<!-- Modal -->\r\n<div class=\"modal fade\" id=\"ModalAdd\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\">\r\n    <div class=\"modal-dialog\" role=\"document\">\r\n        <div class=\"modal-content\">\r\n            <form class=\"form-horizontal\" method=\"POST\" action=\"../_class/yonetim_islem.php\">\r\n\r\n                <div class=\"modal-header\">\r\n\t\t\t\t\t<h4 class=\"modal-title\" id=\"myModalLabel\">Not Ekle</h4>\r\n                    <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\r\n                    \r\n                </div>\r\n                <div class=\"modal-body\">\r\n\r\n                    <div class=\"form-group\">\r\n                        <label for=\"title\">Başlık</label>\r\n                        <input type=\"text\" name=\"title\" class=\"form-control form-control-sm\" id=\"title\">\r\n                    </div>\r\n                    <div class=\"form-group\">\r\n                        <label for=\"color\">Renk</label>\r\n\t\t\t\t\t\t<select name=\"color\" class=\"form-control\" id=\"color\">\r\n\t\t\t\t\t\t\t<option value=\"\">-Seçiniz-</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#0071c5;\" value=\"#0071c5\">&#9724; Mavi</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#40E0D0;\" value=\"#40E0D0\">&#9724; Turkuaz</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#008000;\" value=\"#008000\">&#9724; Yeşil</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#FFD700;\" value=\"#FFD700\">&#9724; Sarı</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#FF8C00;\" value=\"#FF8C00\">&#9724; Turuncu</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#FF0000;\" value=\"#FF0000\">&#9724; Kırmızı</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#000;\" value=\"#000\">&#9724; Siyah</option>\r\n\t\t\t\t\t\t</select>\r\n                    </div>\r\n                    <div class=\"form-group\">\r\n                        <label for=\"start\">Başlangıç Tarihi</label>\r\n                        <input type=\"text\" name=\"start\" class=\"form-control form-control-sm\" id=\"start\" readonly>\r\n                    </div>\r\n                    <div class=\"form-group\">\r\n                        <label for=\"end\">Bitiş Tarihi</label>\r\n                        <input type=\"text\" name=\"end\" class=\"form-control form-control-sm\" id=\"end\" readonly>\r\n                    </div>\r\n\r\n                </div>\r\n                <div class=\"modal-footer\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"ekleyen\" value=\"";
echo $Bilgilerim["isim"];
echo "\" class=\"form-control\" id=\"ekleyen\">\r\n                    <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Kapat</button>\r\n                    <button type=\"submit\" name=\"not_ekle\" class=\"btn btn-primary\">Kaydet</button>\r\n                </div>\r\n            </form>\r\n        </div>\r\n    </div>\r\n</div>\r\n\r\n\r\n\r\n<!-- Modal -->\r\n<div class=\"modal fade\" id=\"ModalEdit\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\">\r\n    <div class=\"modal-dialog\" role=\"document\">\r\n        <div class=\"modal-content\">\r\n            <form class=\"form-horizontal\" method=\"POST\" action=\"../_class/yonetim_islem.php\">\r\n                <div class=\"modal-header\">\r\n\t\t\t\t\t<h4 class=\"modal-title\" id=\"myModalLabel\">Not Düzenle</h4>\r\n                    <button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">\r\n\t\t\t\t\t\t<span aria-hidden=\"true\">&times;</span>\r\n\t\t\t\t\t</button>\r\n                </div>\r\n\t\t\t\t\r\n                <div class=\"modal-body\">\r\n\t\t\t\t\t<div class=\"form-group\">\r\n\t\t\t\t\t\t<label for=\"title\">Başlık</label>\r\n\t\t\t\t\t\t<input type=\"text\" class=\"form-control form-control-sm\" name=\"title\" id=\"title\" />\r\n\t\t\t\t\t</div>\t\r\n                    <div class=\"form-group\">\r\n                        <label for=\"color\">Renk</label>\r\n\t\t\t\t\t\t<select name=\"color\" class=\"form-control\" id=\"color\">\r\n\t\t\t\t\t\t\t<option value=\"\">-Seçiniz-</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#0071c5;\" value=\"#0071c5\">&#9724; Mavi</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#40E0D0;\" value=\"#40E0D0\">&#9724; Turkuaz</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#008000;\" value=\"#008000\">&#9724; Yeşil</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#FFD700;\" value=\"#FFD700\">&#9724; Sarı</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#FF8C00;\" value=\"#FF8C00\">&#9724; Turuncu</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#FF0000;\" value=\"#FF0000\">&#9724; Kırmızı</option>\r\n\t\t\t\t\t\t\t<option style=\"color:#000;\" value=\"#000\">&#9724; Siyah</option>\r\n\t\t\t\t\t\t</select>\r\n                    </div>\r\n\t\t\t\t\t\r\n                    <div class=\"form-group\">\r\n\t\t\t\t\t\t<div class=\"form-check form-check-danger\">\r\n                            <label class=\"form-check-label\">\r\n                              <input type=\"checkbox\" name=\"delete\" class=\"form-check-input\">\r\n                              Notu Sil\r\n                            <i class=\"input-helper\"></i></label>\r\n                        </div>\r\n                    </div>\r\n                    <input type=\"hidden\" name=\"id\" class=\"form-control\" id=\"id\">\r\n                </div>\r\n                <div class=\"modal-footer\">\r\n                    <button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Kapat</button>\r\n                    <button type=\"submit\" name=\"not_guncelle\" class=\"btn btn-primary\">Güncelle</button>\r\n                </div>\r\n            </form>\r\n        </div>\r\n    </div>\r\n</div>\r\n<script>\r\n\r\n\t\$(document).ready(function() {\r\n\t\t\r\n\t\t\$('#calendar').fullCalendar({\r\n\t\t\tmonthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],\r\n\t\t\tmonthNamesShort: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],\r\n\t\t\tdayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],\r\n\t\t\tdayNamesShort: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],\r\n\t\t\teditable:true,\r\n\t\t\tbuttonText: {\r\n\t\t\t\t\ttoday:    'Bugün',\r\n\t\t\t\t\tmonth:    'Ay',\r\n\t\t\t\t\tweek:     'Hafta',\r\n\t\t\t\t\tday:      'Gün',\r\n\t\t\t\t\tlist:     'Liste',\r\n\t\t\t\t\tlistMonth: 'Aylık Liste',\r\n\t\t\t\t\tlistYear: 'Yıllık Liste',\r\n\t\t\t\t\tlistWeek: 'Haftalık Liste',\r\n\t\t\t\t\tlistDay: 'Günlük Liste'\r\n\t\t\t},\r\n\t\t\theader: {\r\n\t\t\t\tleft: 'prev,next today',\r\n\t\t\t\tcenter: 'title',\r\n\t\t\t\tright: 'month,basicWeek,basicDay'\r\n\t\t\t},\r\n\t\t\tdefaultDate: '";
echo date("Y-m-d");
echo "',\r\n\t\t\teditable: true,\r\n\t\t\teventLimit: true, // allow \"more\" link when too many events\r\n\t\t\tselectable: true,\r\n\t\t\tselectHelper: true,\r\n\t\t\tselect: function(start, end) {\r\n\t\t\t\t\r\n\t\t\t\t\$('#ModalAdd #start').val(moment(start).format('YYYY-MM-DD HH:mm:ss'));\r\n\t\t\t\t\$('#ModalAdd #end').val(moment(end).format('YYYY-MM-DD HH:mm:ss'));\r\n\t\t\t\t\$('#ModalAdd').modal('show');\r\n\t\t\t},\r\n\t\t\teventRender: function(event, element) {\r\n\t\t\t\telement.bind('dblclick', function() {\r\n\t\t\t\t\t\$('#ModalEdit #id').val(event.id);\r\n\t\t\t\t\t\$('#ModalEdit #title').val(event.title);\r\n\t\t\t\t\t\$('#ModalEdit #color').val(event.color);\r\n\t\t\t\t\t\$('#ModalEdit').modal('show');\r\n\t\t\t\t});\r\n\t\t\t},\r\n\t\t\teventDrop: function(event, delta, revertFunc) { // si changement de position\r\n\r\n\t\t\t\tedit(event);\r\n\r\n\t\t\t},\r\n\t\t\teventResize: function(event,dayDelta,minuteDelta,revertFunc) { // si changement de longueur\r\n\r\n\t\t\t\tedit(event);\r\n\r\n\t\t\t},\r\n\t\t\tevents: [\r\n\t\t\t";
foreach ($events as $event) {
    $start = explode(" ", $event["baslangic"]);
    $end = explode(" ", $event["bitis"]);
    if ($start[1] == "00:00:00") {
        $start = $start[0];
    } else {
        $start = $event["baslangic"];
    }
    if ($end[1] == "00:00:00") {
        $end = $end[0];
    } else {
        $end = $event["bitis"];
    }
    echo "\t\t\t\t{\r\n\t\t\t\t\tid: '";
    echo $event["id"];
    echo "',\r\n\t\t\t\t\ttitle: '";
    echo $event["baslik"];
    echo "',\r\n\t\t\t\t\tstart: '";
    echo $start;
    echo "',\r\n\t\t\t\t\tend: '";
    echo $end;
    echo "',\r\n\t\t\t\t\tcolor: '";
    echo $event["renk"];
    echo "',\r\n\t\t\t\t},\r\n\t\t\t";
}
echo "\t\t\t]\r\n\t\t});\r\n\t\t\r\n\t\tfunction edit(event){\r\n\t\t\tstart = event.start.format('YYYY-MM-DD HH:mm:ss');\r\n\t\t\tif(event.end){\r\n\t\t\t\tend = event.end.format('YYYY-MM-DD HH:mm:ss');\r\n\t\t\t}else{\r\n\t\t\t\tend = start;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tid =  event.id;\r\n\t\t\t\r\n\t\t\tEvent = [];\r\n\t\t\tEvent[0] = id;\r\n\t\t\tEvent[1] = start;\r\n\t\t\tEvent[2] = end;\r\n\t\t\t\r\n\t\t\t\$.ajax({\r\n\t\t\t url: '../_class/yonetim_islem.php?notguncelle=ok',\r\n\t\t\t type: \"POST\",\r\n\t\t\t data: {Event:Event},\r\n\t\t\t success: function(rep) {\r\n\t\t\t\t\tif(rep == 'OK'){\r\n\t\t\t\t\t\t\$.toast({\r\n\t\t\t\t\t\t  heading: 'Başarılı!',\r\n\t\t\t\t\t\t  text: 'Başarı ile güncellendi.',\r\n\t\t\t\t\t\t  showHideTransition: 'slide',\r\n\t\t\t\t\t\t  icon: 'success',\r\n\t\t\t\t\t\t  loaderBg: '#fff',\r\n\t\t\t\t\t\t  position: 'top-right'\r\n\t\t\t\t\t\t})\r\n\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\$.toast({\r\n\t\t\t\t\t\t  heading: 'Hata!',\r\n\t\t\t\t\t\t  text: 'Hata oluştu tekrar deneyiniz.!',\r\n\t\t\t\t\t\t  showHideTransition: 'slide',\r\n\t\t\t\t\t\t  icon: 'error',\r\n\t\t\t\t\t\t  loaderBg: '#fff',\r\n\t\t\t\t\t\t  position: 'top-right'\r\n\t\t\t\t\t\t})\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t\t\r\n\t});\r\n\r\n</script>\r\n";
mesaj("not_ekle", 1, "yes", "Başarı ile eklenmiştir.");
mesaj("not_ekle", 2, "no", "Hata oluştu tekrar deneyiniz.!");
mesaj("not_ekle", 3, "bos", "Boş alanlar bıraktınız.");
mesaj("not_guncelle", 1, "sil_yes", "Başarı ile siinmiştir.");
mesaj("not_guncelle", 2, "sil_no", "Hata oluştu tekrar deneyiniz.!");
mesaj("not_guncelle", 1, "guncelle_yes", "Başarı ile güncellenmiştir.");
mesaj("not_guncelle", 2, "guncelle_no", "Hata oluştu tekrar deneyiniz.!");


?>