<?php 
    if(!isset($_GET["id"]) || empty($_GET["id"])){
        header("Location: /admin/survey/list");
        exit();
    }
    $survey_details       = $survey->getSurvey($_GET['id']);
    $survey_questions     = $survey->getSurveyQuestions($_GET['id']);
    $survey_applications  = $survey->getSurveyApplications($_GET['id']);
    if(empty($survey_details)) {
        header("Location: /admin/survey/list");
        exit();
    }

    $data = array();
    $data['title'] = "Anket Düzenle | ".$App->title;
    $data['links'] = [];
    $data['styles'] = ['/admin/public/assets/css/jstable.css'];
    $data['header']['scripts'] = [];
    $data['version'] = $App->version;
    $data['csrf_token'] = $csrf_generator->create();
    $data['sidebar_menu'] = $menu->get(array('position'=>'sidebar'));
    $data['sidebar_active_menu'] = $menu->getActiveMenuItemId(trim($_SERVER['REQUEST_URI']));
    $data['footer']['scripts'] = ['/admin/public/assets/js/jstable.min.js', '/admin/public/assets/js/pages/survey/edit.js'];
    $menu_items = $menu->get(array('position'=>'footer'));
    foreach($menu_items as $item){
        if($item['col'] == "1"){
            $data['menu']['footer']["1"][] = $item;
        }
        if($item['col'] == "2"){
            $data['menu']['footer']["2"][] = $item;
        }
        if($item['col'] == "3"){
            $data['menu']['footer']["3"][] = $item;
        }
        if($item['col'] == "4"){
            $data['menu']['footer']["4"][] = $item;
        }
    }

    $data['breadcrumbs'] = array();
    $data['breadcrumbs'][] = array(
        'text' => "Pano",
        'href' => "/admin",
        'index' => 1
    );
    $data['breadcrumbs'][] = array(
        'text' => "Anketler",
        'href' => "/admin/survey/list",
        'index' => 2
    );
    $data['breadcrumbs'][] = array(
        'text' => "Anket Düzenle",
        'href' => "#",
        'index' => 3
    );

    if($_SERVER['REQUEST_METHOD'] == 'POST'){
        if(isset($_POST['action']) && !empty($_POST['action'])) {
            switch($_POST['action']) {
                case 'survey-details':
                    $guid                          = $_GET['id'];
                    $title                         = $_POST['title'];
                    $status                        = $_POST['status'];
                    $login_required                = $_POST['login_required'];
                    $completion_confirmation       = $_POST['completion_confirmation'];
                    $description                   = $_POST['description'];

                    $stmt = $db->query("UPDATE {$db->prefix}survey SET `title`=:title, `login_required`=:login_required, `completion_confirmation`=:completion_confirmation, `description`=:description, `status`=:status WHERE `guid`=:guid", array(':title'=>$title, ':login_required'=>$login_required, ':completion_confirmation'=>$completion_confirmation, ':description'=>$description, ':status'=>$status, ':guid'=>$guid));
                    if($stmt->error){
                        $utils->errorLog("error", "Cannot update survey. Error: ".$stmt->error_info['message'], $session->data['user_id'], $_SERVER['REQUEST_URI']);
                        $session->data['messageType'] = "error"; 
                        $session->data['messageTitle'] = "Hata!"; 
                        $session->data['message'] = "Bir hata oluştu ve anket güncellenemedi."; 
                        header("Refresh: 0;");
                        exit();
                    }else{
                        $utils->updateUrl("survey", $survey_details["id"], $title, strip_tags($description));
                        $session->data['messageType'] = "success"; 
                        $session->data['messageTitle'] = "Başarılı!"; 
                        $session->data['message'] = "Anket başarıyla güncellendi."; 
                        header("Refresh: 0;");
                        exit();
                    }
                break;
                case 'new-question':
                    $survey_id                     = $survey_details['id'];
                    $title                         = $_POST['title'];
                    $description                   = $_POST['description'];
                    $type                          = $_POST['type'];
                    $options                       = $_POST['options'];
                    $inline                        = isset($_POST['inline']) ? 1 : 0;
                    $required                      = isset($_POST['required']) ? 1 : 0;

                    $stmt = $db->query("INSERT INTO {$db->prefix}survey_questions (`survey_id`, `title`, `description`, `type`, `required`, `inline`, `options`) VALUES (:survey_id, :title, :description, :type, :required, :inline, :options)", array(':title'=>$title, ':description'=>$description, ':survey_id'=>$survey_id, ':type'=>$type, ':required'=>$required, ':options'=>$options, ':inline'=>$inline));
                    if($stmt->error){
                        $utils->errorLog("error", "Cannot update survey. Error: ".$stmt->error_info['message'], $session->data['user_id'], $_SERVER['REQUEST_URI']);
                        $session->data['messageType'] = "error"; 
                        $session->data['messageTitle'] = "Hata!"; 
                        $session->data['message'] = "Bir hata oluştu ve anket sorusu kaydedilemedi."; 
                        header("Refresh: 0;");
                        exit();
                    }else{
                        $session->data['messageType'] = "success"; 
                        $session->data['messageTitle'] = "Başarılı!"; 
                        $session->data['message'] = "Anket sorusu başarıyla kaydedildi."; 
                        header("Refresh: 0;");
                        exit();
                    }
                break;
                case 'update-question':
                    $question_id                   = $_POST['question-id'];
                    $title                         = $_POST['title'];
                    $description                   = $_POST['description'];
                    $type                          = $_POST['type'];
                    $options                       = $_POST['options'];
                    $inline                        = isset($_POST['inline']) ? 1 : 0;
                    $required                      = isset($_POST['required']) ? 1 : 0;

                    $stmt = $db->query("UPDATE {$db->prefix}survey_questions SET `title`=:title, `description`=:description, `type`=:type, `required`=:required, `inline`=:inline, `options`=:options WHERE id=:id", array(':title'=>$title, ':description'=>$description, ':type'=>$type, ':required'=>$required, ':options'=>$options, ':inline'=>$inline, ':id'=>$question_id));
                    if($stmt->error){
                        $utils->errorLog("error", "Cannot update survey question. Error: ".$stmt->error_info['message'], $session->data['user_id'], $_SERVER['REQUEST_URI']);
                        $session->data['messageType'] = "error"; 
                        $session->data['messageTitle'] = "Hata!"; 
                        $session->data['message'] = "Bir hata oluştu ve anket sorusu güncellenemedi."; 
                        header("Refresh: 0;");
                        exit();
                    }else{
                        $session->data['messageType'] = "success"; 
                        $session->data['messageTitle'] = "Başarılı!"; 
                        $session->data['message'] = "Anket sorusu başarıyla güncellendi."; 
                        header("Refresh: 0;");
                        exit();
                    }
                break;
            }
        }
	}
?>
<?php include DIR_VIEWS."parts/header.php"; ?>
        <main class="content">
        <div class="container-fluid">
                <div class="row">
                    <div class="col-md-4 col-xl-3 sticky-top">
                        <div class="card">
                            <div class="list-group list-group-flush" id="profile-settings" role="tablist">
                                <a class="list-group-item list-group-item-action active" data-bs-toggle="tab" href="#infoTab" aria-selected="true">Anket Detayları</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#questionsTab" aria-selected="false">Sorular</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#answersTab" aria-selected="false">Yanıtlar</a>
                            </div>
                        </div>
                    </div>

                    <div class="col-md-8 col-xl-9">
                        <div class="tab-content" id="tab-content">
                            <div class="tab-pane fade active show" id="infoTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Anket Bilgileri</h5>
                                    </div>
                                    <div class="card-body">
                                        <form action="" method="post">
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="title" class="form-label font-weight-bold">Link</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <a href="<?php echo $App->url; ?>/anket/<?php echo $survey_details["guid"]; ?>" target="_blank" rel="noopener noreferrer"><?php echo $App->url; ?>/anket/<?php echo $survey_details["guid"]; ?></a><span class="copy-to-clipboard" data-text="<?php echo $App->url; ?>/anket/<?php echo $survey_details["guid"]; ?>" title="Kopyala"><i class="bi bi-clipboard ms-2"></i></span>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="title" class="form-label font-weight-bold">Başlık</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <input type="text" class="form-control" name="title" id="title" placeholder="Başlık" value="<?php echo $survey_details["title"]; ?>" required>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="status" class="form-label font-weight-bold">Durum</label>
                                                </div>
                                                <div class="col-md-6">
                                                    <select name="status" id="status" class="form-control form-select">
                                                        <option value="1" <?php echo $survey_details["status"] == "1" ? 'selected' : ''; ?>>Aktif</option>
                                                        <option value="0" <?php echo $survey_details["status"] == "0" ? 'selected' : ''; ?>>Pasif</option>
                                                        <option value="2" <?php echo $survey_details["status"] == "2" ? 'selected' : ''; ?>>Taslak</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="login_required" class="form-label font-weight-bold">Üye Girişi Zorunlu</label>
                                                </div>
                                                <div class="col-md-6">
                                                    <select name="login_required" id="login_required" class="form-control form-select">
                                                        <option value="0" <?php echo $survey_details["login_required"] == "1" ? 'selected' : ''; ?>>Hayır</option>
                                                        <option value="1" <?php echo $survey_details["login_required"] == "1" ? 'selected' : ''; ?>>Evet</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-12">
                                                    <label for="description" class="form-label font-weight-bold">Açıklama</label>
                                                </div>
                                                <div class="col-md-12">
                                                    <textarea class="form-control editor" name="description" id="description" rows="10"><?php echo $survey_details["description"]; ?></textarea>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-12">
                                                    <label for="completion_confirmation" class="form-label font-weight-bold">Onay Mesajı</label>
                                                </div>
                                                <div class="col-md-12">
                                                    <textarea class="form-control editor" name="completion_confirmation" id="completion_confirmation" rows="10"><?php echo $survey_details["completion_confirmation"]; ?></textarea>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-12 text-end">
                                                    <input type="submit" name="update" class="btn btn-primary" value="Güncelle">
                                                </div>
                                            </div>
                                            <input type="hidden" name="action" value="survey-details">
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="questionsTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Sorular</h5>
                                    </div>
                                    <div class="card-body">
                                        <?php if(count($survey_questions) > 0): ?>
                                            <?php foreach($survey_questions as $row): ?>
                                                <div class="card card-body mb-3">
                                                    <div class="row">
                                                        <div class="col-12">
                                                            <?php if($row['type'] == 'text' || $row['type'] == 'email' || $row['type'] == 'tel' || $row['type'] == 'url' || $row['type'] == 'number' || $row['type'] == 'file' || $row['type'] == 'date' || $row['type'] == 'datetime-local' || $row['type'] == 'time'): ?>
                                                                <label for="var-<?php echo $row['id']; ?>" class="col-form-label fw-bold"><?php echo $row['title']; ?> <?php echo $row['required'] == 1 ? '<span class="text-danger">*</span>' : ''; ?></label>
                                                                <?php if($row['description'] != ''): ?><p class="mb-3"><em><?php echo $row['description']; ?></em></p><?php endif; ?>
                                                                <input type="<?php echo $row['type']; ?>" class="form-control" name="<?php echo $row['id']; ?>" id="var-<?php echo $row['id']; ?>" value="" <?php echo $row['required'] == 1 ? 'required' : ''; ?>>
                                                            <?php elseif($row['type'] == 'textarea'): ?>
                                                                <label for="var-<?php echo $row['id']; ?>" class="col-form-label fw-bold"><?php echo $row['title']; ?> <?php echo $row['required'] == 1 ? '<span class="text-danger">*</span>' : ''; ?></label>
                                                                <?php if($row['description'] != ''): ?><p class="mb-3"><em><?php echo $row['description']; ?></em></p><?php endif; ?>
                                                                <textarea class="form-control" name="<?php echo $row['id']; ?>" id="var-<?php echo $row['id']; ?>" <?php echo $row['required'] == 1 ? 'required' : ''; ?>></textarea>
                                                            <?php elseif($row['type'] == 'select'): ?>
                                                                <label for="var-<?php echo $row['id']; ?>" class="col-form-label fw-bold"><?php echo $row['title']; ?> <?php echo $row['required'] == 1 ? '<span class="text-danger">*</span>' : ''; ?></label>
                                                                <?php if($row['description'] != ''): ?><p class="mb-3"><em><?php echo $row['description']; ?></em></p><?php endif; ?>
                                                                <select id="var-<?php echo $row['id']; ?>" name="<?php echo $row['id']; ?>" class="form-select" <?php echo $row['required'] == 1 ? 'required' : ''; ?>>
                                                                    <?php if(count(preg_split("/\r\n|\n|\r/", $row['options'])) > 0): ?>
                                                                        <?php foreach(preg_split("/\r\n|\n|\r/", $row['options']) as $option): ?>
                                                                            <option value="<?php echo $option; ?>"><?php echo $option; ?></option>
                                                                        <?php endforeach; ?>
                                                                    <?php endif; ?>
                                                                </select>
                                                            <?php elseif($row['type'] == 'radio'): ?>
                                                                <label class="col-form-label fw-bold"><?php echo $row['title']; ?> <?php echo $row['required'] == 1 ? '<span class="text-danger">*</span>' : ''; ?></label>
                                                                <?php if($row['description'] != ''): ?><p class="mb-3"><em><?php echo $row['description']; ?></em></p><?php endif; ?>
                                                                <?php if(count(preg_split("/\r\n|\n|\r/", $row['options'])) > 0): ?>
                                                                    <?php if($row['inline'] == 1): ?>
                                                                        <?php $i = 1; ?>
                                                                        <?php foreach(preg_split("/\r\n|\n|\r/", $row['options']) as $option): ?>
                                                                            <div class="form-check form-check-inline mb-2">
                                                                                <input class="form-check-input" type="radio" name="<?php echo $row['id']; ?>" id="radio-<?php echo $i; ?>" value="<?php echo $option; ?>">
                                                                                <label class="form-check-label" for="radio-<?php echo $i; ?>">
                                                                                    <?php echo $option; ?>
                                                                                </label>
                                                                            </div>
                                                                            <?php $i++; ?>
                                                                        <?php endforeach; ?>
                                                                    <?php else: ?>
                                                                        <?php $i = 1; ?>
                                                                        <?php foreach(preg_split("/\r\n|\n|\r/", $row['options']) as $option): ?>
                                                                            <div class="form-check mb-2">
                                                                                <input class="form-check-input" type="radio" name="<?php echo $row['id']; ?>" id="radio-<?php echo $i; ?>" value="<?php echo $option; ?>">
                                                                                <label class="form-check-label" for="radio-<?php echo $i; ?>">
                                                                                    <?php echo $option; ?>
                                                                                </label>
                                                                            </div>
                                                                            <?php $i++; ?>
                                                                        <?php endforeach; ?>
                                                                    <?php endif; ?>
                                                                <?php endif; ?>
                                                            <?php elseif($row['type'] == 'checkbox'): ?>
                                                                <label for="<?php echo $row['id']; ?>" class="col-form-label fw-bold"><?php echo $row['title']; ?> <?php echo $row['required'] == 1 ? '<span class="text-danger">*</span>' : ''; ?></label>
                                                                <?php if($row['description'] != ''): ?><p class="mb-3"><em><?php echo $row['description']; ?></em></p><?php endif; ?>
                                                                <?php if(count(preg_split("/\r\n|\n|\r/", $row['options'])) > 0): ?>
                                                                    <?php if($row['inline'] == 1): ?>
                                                                        <?php $i = 1; ?>
                                                                        <?php foreach(preg_split("/\r\n|\n|\r/", $row['options']) as $option): ?>
                                                                            <div class="form-check form-check-inline mb-2">
                                                                                <input class="form-check-input" type="checkbox" name="<?php echo $row['id']; ?>[]" id="checkbox-<?php echo $i; ?>" value="<?php echo $option; ?>">
                                                                                <label class="form-check-label" for="checkbox-<?php echo $i; ?>">
                                                                                    <?php echo $option; ?>
                                                                                </label>
                                                                            </div>
                                                                            <?php $i++; ?>
                                                                        <?php endforeach; ?>
                                                                    <?php else: ?>
                                                                        <?php $i = 1; ?>
                                                                        <?php foreach(preg_split("/\r\n|\n|\r/", $row['options']) as $option): ?>
                                                                            <div class="form-check mb-2">
                                                                                <input class="form-check-input" type="checkbox" name="<?php echo $row['id']; ?>[]" id="checkbox-<?php echo $i; ?>" value="<?php echo $option; ?>">
                                                                                <label class="form-check-label" for="checkbox-<?php echo $i; ?>">
                                                                                    <?php echo $option; ?>
                                                                                </label>
                                                                            </div>
                                                                            <?php $i++; ?>
                                                                        <?php endforeach; ?>
                                                                    <?php endif; ?>
                                                                <?php endif; ?>
                                                            <?php endif; ?>
                                                        </div>
                                                        <hr class="my-3">
                                                        <div class="col-12 text-center">
                                                            <button  type="button" class="btn btn btn-primary btn-sm me-2" data-bs-toggle="modal" data-bs-target="#update-question-modal" data-id="<?php echo $row['id']; ?>"><i class="bi bi-pencil-square"></i> Güncelle</button>
                                                            <button  type="button" class="btn btn btn-danger btn-sm" data-delete data-href="/admin/survey/delete-question?id=<?php echo $row['id']; ?>"><i class="bi bi-trash"></i></button>
                                                        </div>
                                                    </div>
                                                </div>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                        <hr>
                                        <div class="row mt-3">
                                            <div class="col-12 text-center">
                                                <button type="button" class="btn btn btn-primary btn-sm me-2" data-bs-toggle="modal" data-bs-target="#new-question-modal"><i class="bi bi-plus-circle-dotted"></i> Yeni Soru</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="answersTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Yanıtlar</h5>
                                        <button type="button" class="btn btn-success btn-sm me-2" data-action="/admin/survey/excel" data-report="answers" data-id="<?php echo $survey_details["guid"]; ?>" data-guid="<?php echo $survey_details["guid"]; ?>" data-export><i class="bi bi-file-earmark-excel"></i> Excel</button>
                                    </div>
                                    <div class="card-body p-0">
                                        <div class="table-responsive">
                                            <table class="table table-condensed table-striped table-hover" id="applications-table">
                                                <thead>
                                                    <tr>
                                                        <th>Kullanıcı</th>
                                                        <th>Eposta</th>
                                                        <th>Tarih</th>
                                                        <th></th>
                                                    </tr>
                                                </thead>
                                                <?php if(!empty($survey_applications)): ?>
                                                    <tbody>
                                                    <?php foreach($survey_applications as $row): ?>
                                                        <tr>
                                                            <td><?php echo $row['user_name']; ?></td>
                                                            <td><?php echo $row['user_email']; ?></td>
                                                            <td><?php echo $row['date_added']; ?></td>
                                                            <td><button type="button" class="btn btn btn-primary btn-sm me-2" data-bs-toggle="modal" data-bs-target="#view-answer-modal" data-id="<?php echo $row['id']; ?>"><i class="bi bi-eye"></i> Görüntüle</button></td>
                                                        </tr>
                                                    <?php endforeach; ?>
                                                    </tbody>
                                                <?php endif; ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <form action="" method="post" id="add-question-form">
            <div class="modal" tabindex="-1" id="new-question-modal">
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title fw-bold">Yeni Soru</h5>
                        </div>
                        <div class="modal-body">
                            <div class="row mb-3">
                                <div class="col-12">
                                    <label for="new-question-type" class="col-form-label">Tür *</label>
                                    <select name="type" id="new-question-type" class="form-select">
                                        <option value="text" data-inline="false" data-options="false">Metin</option>
                                        <option value="textarea" data-inline="false" data-options="false">Uzun Metin</option>
                                        <option value="email" data-inline="false" data-options="false">Email</option>
                                        <option value="tel" data-inline="false" data-options="false">Telefon</option>
                                        <option value="url" data-inline="false" data-options="false">Link</option>
                                        <option value="number" data-inline="false" data-options="false">Sayı</option>
                                        <option value="file" data-inline="false" data-options="false">Dosya</option>
                                        <option value="date" data-inline="false" data-options="false">Tarih</option>
                                        <option value="time" data-inline="false" data-options="false">Saat</option>
                                        <option value="datetime-local" data-inline="false" data-options="false">Tam Tarih</option>
                                        <option value="checkbox" data-inline="true" data-options="true">Çoklu Seçim (checkbox)</option>
                                        <option value="radio" data-inline="true" data-options="true">Tekli Seçim (radio)</option>
                                        <option value="select" data-inline="false" data-options="true">Açılır Liste (dropdown)</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-12">
                                    <label for="new-question-title" class="col-form-label">Başlık *</label>
                                    <input type="text" class="form-control" name="title" id="new-question-title" value="" required>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-12">
                                    <label for="new-question-description" class="col-form-label">Açıklama</label>
                                    <textarea class="form-control" name="description" id="new-question-description" rows="3"></textarea>
                                </div>
                            </div>
                            <div class="row mb-3 d-none" id="is-options">
                                <div class="col-12">
                                    <label class="col-form-label" for="new-question-options">Seçenekler <i>(Alt alta yazınız)</i></label>
                                    <textarea class="form-control" name="options" id="new-question-options" rows="3"></textarea>
                                </div>
                            </div>
                            <div class="row mb-3 d-none" id="is-inline">
                                <div class="col-12">
                                    <div class="form-check">
                                        <label class="form-check-label" for="new-question-inline">
                                            Tek Sıra
                                        </label>
                                        <input class="form-check-input" type="checkbox" value="" name="inline" id="new-question-inline">
                                    </div>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-12">
                                    <div class="form-check">
                                        <label class="form-check-label" for="new-question-required">
                                        Zorunlu alan
                                        </label>
                                        <input class="form-check-input" type="checkbox" value="" name="required" id="new-question-required">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" name="action" value="new-question">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Vazgeç</button>
                            <button type="submit" class="btn btn-primary">Kaydet</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <form action="" method="post" id="update-question-form">
            <div class="modal" tabindex="-1" id="update-question-modal">
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title fw-bold">Soru Güncelle</h5>
                        </div>
                        <div class="modal-body">
                            <div class="row mb-3">
                                <div class="col-12">
                                    <label for="update-question-type" class="col-form-label">Tür *</label>
                                    <select name="type" id="update-question-type" class="form-select">
                                        <option value="text" data-inline="false" data-options="false">Metin</option>
                                        <option value="textarea" data-inline="false" data-options="false">Uzun Metin</option>
                                        <option value="email" data-inline="false" data-options="false">Email</option>
                                        <option value="tel" data-inline="false" data-options="false">Telefon</option>
                                        <option value="url" data-inline="false" data-options="false">Link</option>
                                        <option value="number" data-inline="false" data-options="false">Sayı</option>
                                        <option value="file" data-inline="false" data-options="false">Dosya</option>
                                        <option value="date" data-inline="false" data-options="false">Tarih</option>
                                        <option value="time" data-inline="false" data-options="false">Saat</option>
                                        <option value="datetime-local" data-inline="false" data-options="false">Tam Tarih</option>
                                        <option value="checkbox" data-inline="true" data-options="true">Çoklu Seçim (checkbox)</option>
                                        <option value="radio" data-inline="true" data-options="true">Tekli Seçim (radio)</option>
                                        <option value="select" data-inline="false" data-options="true">Açılır Liste (dropdown)</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-12">
                                    <label for="update-question-title" class="col-form-label">Başlık *</label>
                                    <input type="text" class="form-control" name="title" id="update-question-title" value="" required>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-12">
                                    <label for="update-question-description" class="col-form-label">Açıklama</label>
                                    <textarea class="form-control" name="description" id="update-question-description" rows="3"></textarea>
                                </div>
                            </div>
                            <div class="row mb-3 d-none" id="update-is-options">
                                <div class="col-12">
                                    <label class="col-form-label" for="update-question-options">Seçenekler <i>(Alt alta yazınız)</i></label>
                                    <textarea class="form-control" name="options" id="update-question-options" rows="3"></textarea>
                                </div>
                            </div>
                            <div class="row mb-3 d-none" id="update-is-inline">
                                <div class="col-12">
                                    <div class="form-check">
                                        <label class="form-check-label" for="update-question-inline">
                                            Tek Sıra
                                        </label>
                                        <input class="form-check-input" type="checkbox" value="" name="inline" id="update-question-inline">
                                    </div>
                                </div>
                            </div>
                            <div class="row mb-3">
                                <div class="col-12">
                                    <div class="form-check">
                                        <label class="form-check-label" for="update-question-required">
                                        Zorunlu alan
                                        </label>
                                        <input class="form-check-input" type="checkbox" value="" name="required" id="update-question-required">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <input type="hidden" name="question-id" id="update-question-id" value="">
                            <input type="hidden" name="action" value="update-question">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Vazgeç</button>
                            <button type="submit" class="btn btn-primary">Güncelle</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <div class="modal" tabindex="-1" id="view-answer-modal">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title fw-bold">Anket Cevapları</h5>
                    </div>
                    <div class="modal-body">
                        
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" data-bs-dismiss="modal">Tamam</button>
                    </div>
                </div>
            </div>
        </div>
<?php include DIR_VIEWS."parts/footer.php"; ?>