<?php 
    if(!isset($_GET["id"]) || empty($_GET["id"])){
        header("Location: /admin/webinar/list");
        exit();
    }
    $webinar_details       = $zoomApi->getWebinarFromDb($_GET['id']);
    if(empty($webinar_details)) {
        header("Location: /admin/webinar/list");
        exit();
    }

    $inboxApi  	          = new InboxApi($db, $utils);
    $senders              = $inboxApi->getSenders();
    $contactLists         = $inboxApi->getContactLists();

    $data = array();
    $data['title'] = "Web Semineri 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/webinar.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' => "Web Seminerleri",
        'href' => "/admin/webinar/list",
        'index' => 2
    );
    $data['breadcrumbs'][] = array(
        'text' => "Web Semineri Düzenle",
        'href' => "#",
        'index' => 3
    );

    if($_SERVER['REQUEST_METHOD'] == 'POST'){
        if(isset($_POST['action']) && !empty($_POST['action'])) {
            switch($_POST['action']) {
                case 'update_webinar':
                    $request = array(
                        'topic' => $_POST['topic'],
                        'agenda' => $_POST['agenda'],
                        'duration' => $_POST['duration'],
                        'start_time' => gmdate('Y-m-d\TH:i:s\Z', strtotime($_POST['start_time'])),
                        'password' => $_POST['password'],
                        'timezone' => $_POST['timezone'],
                        'settings' => array(
                            'contact_email' => $_POST['contact_email'],
                            'approval_type' => isset($_POST['approval_type']) ? 0 : 2,
                            'host_video' => isset($_POST['host_video']) ? true : false,
                            'panelists_video' => isset($_POST['panelists_video']) ? true : false,
                            'question_and_answer' => isset($_POST['question_and_answer']) ? array('enable'=>true, 'answer_questions'=>'all', 'attendees_can_comment'=> true, 'attendees_can_upvote'=> true) : array('enable'=>false),
                            'practice_session' => isset($_POST['practice_session']) ? true : false,
                            'auto_recording' => isset($_POST['auto_recording']) ? 'cloud' : 'none',
                            'email_language' => $_POST['email_language'],
                            'global_dial_in_countries' => array($_POST['global_dial_in_countries']),
                            'post_webinar_survey' => isset($_POST['survey_url']) && !empty($_POST['survey_url']) ? true : false,
                            'survey_url' => $_POST['survey_url']
                        )
                    );

                    $result = $zoomApi->updateWebinar($_GET["id"], $request);

                    if(!$result){
                        $session->data['messageType'] = "error"; 
                        $session->data['messageTitle'] = "Hata!"; 
                        $session->data['message'] = "Bir hata oluştu ve webinar güncellenemedi."; 
                        header("Refresh: 0;");
                        exit();
                    }else{
                        $session->data['messageType'] = "success"; 
                        $session->data['messageTitle'] = "Başarılı!"; 
                        $session->data['message'] = "Webinar başarıyla güncellendi."; 
                        header("Refresh: 0;");
                        exit();
                    }
                break;

                case 'send_email':
                    $subject                       = $_POST['subject'];
                    $language                      = $_POST['language'];
                    $htmlContent                   = $_POST['message'];
                    $sender                        = $_POST['sender'];
                    $lists                         = $_POST['lists'];
                    //$plannedTime                   = $_POST['plannedTime'];

                    $_email_header = '<html><body><center style="height: 100%"> <table align="center" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" style="background-color: #ffffff"> <tbody> <tr> <td align="center" style="padding: 10px" valign="top"> <!--[if gte mso 9]> <table align="center" border="0" cellspacing="0" cellpadding="0" style="width:800px;" width="800"> <tr> <td align="center" valign="top"> <![endif]--> <table align="center" border="0" cellpadding="0" cellspacing="0" style="max-width: 800px" width="100%"> <tbody> <tr> <td align="center" valign="top"> <table align="center" border="0" cellpadding="0" cellspacing="0" style="border-radius: 5px 5px 0 0;background-color: #ffffff" width="100%"> <tbody> <tr> <td align="center" style="padding-right: 20px;padding-left: 20px" valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td align="center" valign="top" style="padding-top: 25px;padding-bottom: 25px; text-align: center"> <a href="https://www.mustelaprofesyonel.com/" target="_blank" style="text-decoration: none" tabindex="-1" rel="external" class="external"> <img alt="Mustela Profesyonel" width="120" style="border: 0;color: #004d9d;font-family: \'Helvetica Neue\', Helvetica, Arial, Verdana, sans-serif;font-size: 24px;font-weight: bold;height: auto;letter-spacing: -2px;line-height: 100%;text-align: center;outline: none;text-decoration: none" src="https://www.mustelaprofesyonel.com/assets/img/email/logo.png"> </a> </td> </tr> <tr> <td style="padding-bottom: 20px" valign="top"> <p style="color: #004d9d;font-family: \'Helvetica Neue\', Helvetica, Arial, Verdana, sans-serif;font-size: 16px;font-weight: 400;line-height: 24px;padding-top: 0;margin-top: 0;text-align: left">';
                    $_email_footer = '</p> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td align="center" valign="top" style="color: #004d9d;background: #ffffff;font-family: \'Helvetica Neue\', Helvetica, Arial, Verdana, sans-serif;font-size: 12px;font-weight: 400;line-height: 24px;padding-top: 25px;padding-bottom: 25px;text-align: center;border-radius: 0 0 5px 5px;"> <p style="color: #004d9d;font-family: \'Helvetica Neue\', Helvetica, Arial, Verdana, sans-serif;font-size: 12px;font-weight: 400;line-height: 24px;padding-top: 0;margin: 0;text-align: center"> © 2022 Expanscience Laboratuvarları, Tüm Hakları Saklıdır.<br>Barbaros Mah. Halk Cad. Kardelen Sok. No:2 Kat:18/ 62-67 Ataşehir İstanbul</p> <a href="https://www.mustelaprofesyonel.com/iletisim" target="_blank" style="color: #004d9d;font-weight: 500;text-decoration: none" tabindex="-1" rel="external" class="external">İletişim</a> <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span> <a href="https://www.mustelaprofesyonel.com/kvkk-aydinlatma-metni" target="_blank" style="color: #004d9d;font-weight: 500;text-decoration: none" tabindex="-1" rel="external" class="external">KVKK Aydınlatma Metni</a> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <!--[if gte mso 9]> </td> </tr> </table> <![endif]--> </td> </tr> </tbody> </table> </center></body></html>';
                    $htmlContent = $_email_header.$_POST['message'].$_email_footer;

                    $list_str = implode('", "', $lists);
                    $request    = '{
                        "senderAccountId":"'.$sender.'",
                        "subject":"'.$subject.'",
                        "htmlContent":"'.str_replace('"', '\"', $htmlContent).'",
                        "language":"'.$language.'",
                        "listType": 2,
                        "lists": ["'.$list_str.'"]
                        }';
                    $createCampaign = $inboxApi->createCustomCampaign($request);

                    if(!$createCampaign['status']) {
                        $session->data['messageType'] = "error"; 
                        $session->data['messageTitle'] = "Hata!";
                        $session->data['message'] = $createCampaign['message'];
                    }else{
                        $session->data['messageType'] = "success"; 
                        $session->data['messageTitle'] = "Başarılı!"; 
                        $session->data['message'] = "Email başarıyla kaydedildi."; 
                        header("Refresh: 0;");
                        exit();
                    }
                break;
            }
        }
	}
    

    $webinar_qa                = $zoomApi->getChat($_GET['id']);
    //$zoomApi->saveChatHistory($_GET['id']);
    $webinar_logs              = $zoomApi->getWebinarLogs($_GET['id']);
    $webinar_chat              = $zoomApi->getChatHistory($_GET['id']);
    $webinar_participant_logs  = $zoomApi->getParticipantLogs($_GET['id']);
    $webinar_registrants       = $zoomApi->getRegistrants($_GET['id'], array('page_size'=>100, 'status'=>'approved'));
    //$webinar_registrants       = $zoomApi->getRegistrants($_GET['id'], array('page_size'=>100, 'status'=>'pending'));
    //$webinar_registrants       = $zoomApi->getRegistrants($_GET['id'], array('page_size'=>100, 'status'=>'denied'));
    $surveys = $survey->getSurveys();
?>
<?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">
                        <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="#generalTab" aria-selected="true">Genel Bilgiler</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#qaTab" aria-selected="false">Q&A</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#chatTab" aria-selected="false">Chat</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#logsTab" aria-selected="false">Webinar Log Kayıtları</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#participantLogsTab" aria-selected="false">Katılımcı Log Kayıtları</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#registrantsTab" aria-selected="false">Katılımcılar</a>
                                <a class="list-group-item list-group-item-action" data-bs-toggle="tab" href="#emailTab" aria-selected="false">Bildirim Gönder</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="generalTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Genel Bilgiler</h5>
                                    </div>
                                    <div class="card-body">
                                        <form action="" method="post">
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="topic" class="form-label font-weight-bold">Başlık</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <input type="text" class="form-control" name="topic" id="topic" placeholder="Topic" value="<?php echo htmlspecialchars($webinar_details["topic"], ENT_QUOTES, "UTF-8"); ?>">
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="agenda" class="form-label font-weight-bold">Açıklama</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <textarea class="form-control" name="agenda" id="agenda" rows="6"><?php echo htmlspecialchars($webinar_details["agenda"], ENT_QUOTES, "UTF-8"); ?></textarea>
                                                </div>
                                            </div>
                                            <hr>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="webinar_id" class="form-label font-weight-bold">Webinar ID</label>
                                                </div>
                                                <div class="col-md-4">
                                                    <span><?php echo $webinar_details["webinar_id"]; ?></span><span class="copy-to-clipboard" data-text="<?php echo $webinar_details["webinar_id"]; ?>" title="Kopyala"><i class="bi bi-clipboard ms-2"></i></span>
                                                    <input type="hidden" class="form-control" name="webinar_id" id="webinar_id"value="<?php echo $webinar_details["webinar_id"]; ?>">
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="duration" class="form-label font-weight-bold">Süre</label>
                                                </div>
                                                <div class="col-md-6 col-xl-4">
                                                    <div class="input-group">
                                                        <input type="number" class="form-control" name="duration" id="duration" placeholder="Süre" aria-describedby="duration-type" value="<?php echo $webinar_details["duration"]; ?>">
                                                        <span class="input-group-text" id="duration-type">Dakika</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="start_time" class="form-label font-weight-bold">Başlangıç Tarihi</label>
                                                </div>
                                                <div class="col-md-6 col-xl-4">
                                                    <input type="datetime-local" class="form-control" name="start_time" id="start_time" value="<?php echo date('Y-m-d\TH:i', strtotime($webinar_details["start_time"])); ?>">
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="password" class="form-label font-weight-bold">Parola</label>
                                                </div>
                                                <div class="col-md-6 col-xl-4">
                                                    <input type="text" class="form-control" name="password" id="password" placeholder="Webinar Passcode" value="<?php echo $webinar_details["password"]; ?>">
                                                </div>
                                            </div>
                                            <hr>
                                            
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="contact_email" class="form-label font-weight-bold">İletişim Epostası</label>
                                                </div>
                                                <div class="col-md-4">
                                                    <input type="text" class="form-control" name="contact_email" id="contact_email" placeholder="" value="<?php echo htmlspecialchars($webinar_details["contact_email"], ENT_QUOTES, "UTF-8"); ?>">
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="survey_url" class="form-label font-weight-bold">Anket Adresi</label>
                                                </div>
                                                <div class="col-md-6">
                                                    <div class="input-group mb-3">
                                                        <input type="url" class="form-control" name="survey_url" id="survey_url" value="<?php echo htmlspecialchars($webinar_details["survey_url"], ENT_QUOTES, "UTF-8"); ?>">
                                                        <button class="btn btn-outline-secondary" type="button" data-bs-toggle="modal" data-bs-target="#survey-modal">Seç</button>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label class="form-label font-weight-bold">Kimlik Doğrulama</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <div class="form-check">
                                                        <input type="checkbox" class="form-check-input" name="approval_type" id="approval_type" <?php echo $webinar_details["approval_type"] == 0 ? 'checked' : ''; ?>> <label for="approval_type" class="form-check-label">Panelistlerin katılmak için kimlik doğrulamasını gerektir</label>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label class="form-label font-weight-bold">Video</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <div class="form-check">
                                                        <input type="checkbox" class="form-check-input" name="host_video" id="host_video" <?php echo $webinar_details["host_video"] == true ? 'checked' : ''; ?>> <label for="host_video" class="form-check-label">Host</label>
                                                    </div>
                                                    <div class="form-check">
                                                        <input type="checkbox" class="form-check-input" name="panelists_video" id="panelists_video" <?php echo $webinar_details["panelists_video"] == true ? 'checked' : ''; ?>> <label for="panelists_video" class="form-check-label">Panelistler</label>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label class="form-label font-weight-bold">Webinar Ayarları</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <div class="form-check">
                                                        <input type="checkbox" class="form-check-input" name="question_and_answer" id="question_and_answer" <?php echo $webinar_details["question_and_answer"] == true ? 'checked' : ''; ?>> <label for="question_and_answer" class="form-check-label">Soru Cevap</label>
                                                    </div>
                                                    <div class="form-check">
                                                        <input type="checkbox" class="form-check-input" name="practice_session" id="practice_session" <?php echo $webinar_details["practice_session"] == true ? 'checked' : ''; ?>> <label for="practice_session" class="form-check-label">Alıştırma Oturumunu Etkinleştir</label>
                                                    </div>
                                                    <div class="form-check">
                                                        <input type="checkbox" class="form-check-input" name="auto_recording" id="auto_recording" <?php echo $webinar_details["auto_recording"] == 'cloud' ? 'checked' : ''; ?>> <label for="auto_recording" class="form-check-label">Bulut Kaydı</label>
                                                    </div>
                                                </div>
                                            </div>
                                            <hr>
                                            <div class="row mb-3">
                                                <div class="col-md-3">
                                                    <label for="registration_url" class="form-label font-weight-bold">registration_url</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <a href="<?php echo $webinar_details["registration_url"]; ?>" target="_blank" rel="noopener noreferrer"><?php echo $webinar_details["registration_url"]; ?></a><span class="copy-to-clipboard" data-text="<?php echo $webinar_details["registration_url"]; ?>" 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="join_url" class="form-label font-weight-bold">join_url</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <a href="<?php echo $webinar_details["join_url"]; ?>" target="_blank" rel="noopener noreferrer"><?php echo $webinar_details["join_url"]; ?></a><span class="copy-to-clipboard" data-text="<?php echo $webinar_details["join_url"]; ?>" 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="start_url" class="form-label font-weight-bold">start_url</label>
                                                </div>
                                                <div class="col-md-9">
                                                    <a href="<?php echo $webinar_details["start_url"]; ?>" target="_blank" rel="noopener noreferrer"><?php echo $webinar_details["start_url"]; ?></a><span class="copy-to-clipboard" data-text="<?php echo $webinar_details["start_url"]; ?>" title="Kopyala"><i class="bi bi-clipboard ms-2"></i></span>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-12 text-end">
                                                    <a href="/admin/webinar/list" class="btn btn-secondary me-2">Geri</a>
                                                    <input type="submit" name="update" class="btn btn-primary" value="Güncelle">
                                                </div>
                                            </div>
                                            <input type="hidden" name="timezone" value="Europe/Istanbul">
                                            <input type="hidden" name="email_language" value="tr-TR">
                                            <input type="hidden" name="global_dial_in_countries" value="TR">
                                            <input type="hidden" name="action" value="update_webinar">
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="qaTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Q&A</h5>
                                    </div>
                                    <div class="card-body">
                                        <?php if(!empty($webinar_qa)): ?>
                                            <?php foreach($webinar_qa as $webinar_qa_questions): ?>
                                                <div class="card mb-3">
                                                    <div class="card-header bg-light">
                                                        <span><i class="bi bi-person-fill me-1"></i> <?php echo $webinar_qa_questions["name"]; ?></span>
                                                    </div>
                                                    <div class="card-body">
                                                        <?php foreach($webinar_qa_questions['question_details'] as $webinar_qa_details): ?>
                                                            <div class="row mb-3">
                                                                <div class="col-12">
                                                                    <span class="fw-bold me-2">Soru: </span><span><?php echo $webinar_qa_details["question"]; ?></span>
                                                                </div>
                                                                <div class="col-12">
                                                                    <span class="fw-bold me-2">Cevap: </span><span><?php echo $webinar_qa_details["answer"]; ?></span>
                                                                </div>
                                                            </div>
                                                        <?php endforeach; ?>
                                                    </div>
                                                </div>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="chatTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Chat Geçmişi</h5>
                                        <button type="button" class="btn btn-success btn-sm me-2" data-action="/admin/webinar/excel" data-report="chat-history" 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="chat-table">
                                                <thead>
                                                    <tr>
                                                        <th>Kullanıcı</th>
                                                        <th>Mesaj</th>
                                                        <th>Zaman</th>
                                                    </tr>
                                                </thead>
                                                <?php if(!empty($webinar_chat)): ?>
                                                    <tbody>
                                                    <?php foreach($webinar_chat as $row): ?>
                                                        <tr>
                                                            <td><?php echo $row['user_name']; ?></td>
                                                            <td><?php echo $row['message']; ?></td>
                                                            <td><?php echo $row['time']; ?></td>
                                                        </tr>
                                                    <?php endforeach; ?>
                                                    </tbody>
                                                <?php endif; ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="participantLogsTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Katılımcı Log Kayıtları</h5>
                                        <button type="button" class="btn btn-success btn-sm me-2" data-action="/admin/webinar/excel" data-report="participant-logs" 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="participant-logs-table">
                                                <thead>
                                                    <tr>
                                                        <th>Kullanıcı Adı</th>
                                                        <th>Email</th>
                                                        <th>Katılma Tarihi</th>
                                                        <th>Ayrılma Tarihi</th>
                                                        <th>Ayrılma Nedeni</th>
                                                    </tr>
                                                </thead>
                                                <?php if(!empty($webinar_participant_logs)): ?>
                                                    <tbody>
                                                    <?php foreach($webinar_participant_logs as $row): ?>
                                                        <tr>
                                                            <td><?php echo $row['user_name']; ?></td>
                                                            <td><?php echo $row['email']; ?></td>
                                                            <td><?php echo $row['join_time']; ?></td>
                                                            <td><?php echo $row['leave_time']; ?></td>
                                                            <td><?php echo $row['leave_reason']; ?></td>
                                                        </tr>
                                                    <?php endforeach; ?>
                                                    </tbody>
                                                <?php endif; ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="logsTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Webinar Log Kayıtları</h5>
                                        <button type="button" class="btn btn-success btn-sm me-2" data-action="/admin/webinar/excel" data-report="webinar-logs" 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="webinar-logs-table">
                                                <thead>
                                                    <tr>
                                                        <th>Tür</th>
                                                        <th>Mesaj</th>
                                                        <th>Tarih</th>
                                                    </tr>
                                                </thead>
                                                <?php if(!empty($webinar_logs)): ?>
                                                    <tbody>
                                                    <?php foreach($webinar_logs as $row): ?>
                                                        <tr>
                                                            <td><?php echo $row['type']; ?></td>
                                                            <td><?php echo $row['message']; ?></td>
                                                            <td><?php echo $row['date']; ?></td>
                                                        </tr>
                                                    <?php endforeach; ?>
                                                    </tbody>
                                                <?php endif; ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="registrantsTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Katılımcılar</h5>
                                    </div>
                                    <div class="card-body p-0">
                                        <div class="table-responsive">
                                            <table class="table table-striped table-hover table-bordered table-sortable mb-0" id="registrants-table">
                                                <thead>
                                                    <tr>
                                                        <th>Durum</th>
                                                        <th>Adı</th>
                                                        <th>Email</th>
                                                        <th>Katılma Tarihi</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <?php if(!empty($webinar_registrants)): ?>
                                                        <?php foreach($webinar_registrants as $registrant): ?>
                                                            <tr>
                                                                <td><?php echo $registrant["status"]; ?></td>
                                                                <td><?php echo $registrant["name"]; ?></td>
                                                                <td><?php echo $registrant["email"]; ?></td>
                                                                <td><?php echo $registrant["create_time"]; ?></td>
                                                            </tr>
                                                        <?php endforeach; ?>
                                                    <?php endif; ?>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="tab-pane fade" id="emailTab" role="tabpanel">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title">Bildirim Gönder</h5>
                                    </div>
                                    <div class="card-body">
                                        <form action="" method="post">
                                            <div class="row mb-3">
                                                <div class="col-12">
                                                    <label for="subject" class="form-label font-weight-bold">Konu</label>
                                                </div>
                                                <div class="col-md-6">
                                                    <input type="text" class="form-control" name="subject" id="subject" placeholder="Konu" value="<?php echo htmlspecialchars($webinar_details["topic"], ENT_QUOTES, "UTF-8"); ?>">
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-12">
                                                    <label for="sender" class="form-label font-weight-bold">Gönderim Hesabı</label>
                                                </div>
                                                <div class="col-md-6">
                                                    <select name="sender" id="sender" class="form-control form-select" required>
                                                        <?php foreach($senders as $sender): ?>
                                                            <option value="<?php echo $sender['id']; ?>"><?php echo $sender['fullName']; ?></option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-12">
                                                    <label for="language" class="form-label font-weight-bold">Dil</label>
                                                </div>
                                                <div class="col-md-6">
                                                    <select name="language" id="language" class="form-control form-select" required>
                                                        <option value="tr-TR">Türkçe</option>
                                                        <option value="en-US">İngilizce</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-12">
                                                    <label for="lists" class="form-label font-weight-bold">Kişi Listeleri</label>
                                                </div>
                                                <div class="col-12">
                                                    <select name="lists[]" id="lists" class="form-control form-select js-choice" multiple required>
                                                        <?php foreach($contactLists as $list): ?>
                                                            <option value="<?php echo $list['id']; ?>"><?php echo $list['listName']; ?></option>
                                                        <?php endforeach; ?>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row mb-3 d-none">
                                                <div class="col-12">
                                                    <label for="plannedTime" class="form-label font-weight-bold">Gönderim Tarihi</label>
                                                </div>
                                                <div class="col-12">
                                                    <input type="datetime-local" name="plannedTime" id="plannedTime" class="form-control" value="<?php echo date('Y-m-d\TH:i:sP'); ?>">
                                                </div>
                                            </div>
                                            <div class="row mb-3">
                                                <div class="col-12">
                                                    <label for="message" class="form-label font-weight-bold">Mesaj</label>
                                                </div>
                                                <div class="col-12">
                                                    <textarea class="form-control editor" name="message" id="message" rows="6">
                                                        <p><b>Konu:</b> <?php echo htmlspecialchars($webinar_details["topic"], ENT_QUOTES, "UTF-8"); ?></p>
                                                        <p><b>Süre:</b> <?php echo $webinar_details["duration"]; ?></p>
                                                        <p><b>Tarih:</b> <?php echo date('d M Y G:i', strtotime($webinar_details["start_time"])); ?></p>
                                                        <p><b>Webinar ID:</b> <?php echo $webinar_details["webinar_id"]; ?></p>
                                                        <p><b>Parola:</b> <?php echo $webinar_details["password"]; ?></p>
                                                        <p><b>Kayıt Linki:</b> <a href="<?php echo $webinar_details["registration_url"]; ?>"><?php echo $webinar_details["registration_url"]; ?></a></p>
                                                        <p><b>Katılım Linki:</b> <a href="<?php echo $webinar_details["join_url"]; ?>"><?php echo $webinar_details["join_url"]; ?></a></p>
                                                    </textarea>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-12 text-end">
                                                    <input type="submit" name="update" class="btn btn-primary" value="Gönder">
                                                </div>
                                            </div>
                                            <input type="hidden" name="action" value="send_email">
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <div class="modal" tabindex="-1" id="survey-modal">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title fw-bold">Anketler</h5>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body p-0">
                        <table class="table table-striped table-hover table-sortable mb-0" id="survey-table">
                            <thead>
                                <tr>
                                    <th>Başlık</th>
                                    <th></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php if(count($surveys)>0): ?>
                                    <?php foreach($surveys as $row): ?>
                                        <tr>
                                            <td><?php echo $row['title']; ?></td>
                                            <td class="text-center"><button class="btn btn-primary btn-sm survey-select" data-url="<?php echo $App->url; ?>/anket/<?php echo $row['guid']; ?>">Seç</button></td>
                                        </tr>
                                    <?php endforeach; ?>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Vazgeç</button>
                    </div>
                </div>
            </div>
        </div>
<?php include DIR_VIEWS."parts/footer.php"; ?>
<script>
    new JSTable("#participant-logs-table", {
        serverSide : false,
        perPage : 15,
        labels: {
            placeholder: "Ara...",
            perPage: "sayfa başına kayıt",
            noRows: "Hiçbir kayıt bulunamadı!",
            info: "{rows} kayıttan {start} - {end} arası görüntüleniyor",
            loading: "Yükleniyor...",
            infoFiltered: "{rows} kayıttan {start} - {end} arası görüntüleniyor ({rowsTotal} kayıt arasından filtrelendi)"
        },
        layout: {
            top: "{search}",
            bottom: "{info}{pager}"
        }
    });
    new JSTable("#webinar-logs-table", {
        serverSide : false,
        perPage : 15,
        labels: {
            placeholder: "Ara...",
            perPage: "sayfa başına kayıt",
            noRows: "Hiçbir kayıt bulunamadı!",
            info: "{rows} kayıttan {start} - {end} arası görüntüleniyor",
            loading: "Yükleniyor...",
            infoFiltered: "{rows} kayıttan {start} - {end} arası görüntüleniyor ({rowsTotal} kayıt arasından filtrelendi)"
        },
        layout: {
            top: "{search}",
            bottom: "{info}{pager}"
        }
    });
    new JSTable("#chat-table", {
        serverSide : false,
        perPage : 15,
        labels: {
            placeholder: "Ara...",
            perPage: "sayfa başına kayıt",
            noRows: "Hiçbir kayıt bulunamadı!",
            info: "{rows} kayıttan {start} - {end} arası görüntüleniyor",
            loading: "Yükleniyor...",
            infoFiltered: "{rows} kayıttan {start} - {end} arası görüntüleniyor ({rowsTotal} kayıt arasından filtrelendi)"
        },
        layout: {
            top: "{search}",
            bottom: "{info}{pager}"
        }
    });
    new JSTable("#registrants-table", {
        serverSide : false,
        perPage : 15,
        labels: {
            placeholder: "Ara...",
            perPage: "sayfa başına kayıt",
            noRows: "Hiçbir kayıt bulunamadı!",
            info: "{rows} kayıttan {start} - {end} arası görüntüleniyor",
            loading: "Yükleniyor...",
            infoFiltered: "{rows} kayıttan {start} - {end} arası görüntüleniyor ({rowsTotal} kayıt arasından filtrelendi)"
        },
        layout: {
            top: "{search}",
            bottom: "{info}{pager}"
        }
    });
</script>