<?php
$url = isset($_GET['url']) ? $_GET['url'] : '';
$segments = explode('/', $url);
$id = get_id($segments[3]);
$menu = post($id);
if ($menu['content'] != '') {
    $menuitems = json_decode($menu['content'], true);
    $menuitems = $menuitems[0];
    foreach ($menuitems as &$menuitem) {
        $menuitem['title'] = $db->table('menuitems')->where('id', '=', $menuitem['id'])->get_var('title');
        $menuitem['type'] = $db->table('menuitems')->where('id', '=', $menuitem['id'])->get_var('type');
        $menuitem['slug'] = $db->table('menuitems')->where('id', '=', $menuitem['id'])->get_var('slug');
        $menuitem['target'] = $db->table('menuitems')->where('id', '=', $menuitem['id'])->get_var('target');

        if (!empty($menuitem['children'][0])) {
            foreach ($menuitem['children'][0] as &$child) {
                $child['title'] = $db->table('menuitems')->where('id', '=', $child['id'])->get_var('title');
                $child['type'] = $db->table('menuitems')->where('id', '=', $child['id'])->get_var('type');
                $child['slug'] = $db->table('menuitems')->where('id', '=', $child['id'])->get_var('slug');
                $child['target'] = $db->table('menuitems')->where('id', '=', $child['id'])->get_var('target');
                if (!empty($child['children'][0])) {
                    foreach ($child['children'][0] as &$child1) {
                        $child1['title'] = $db->table('menuitems')->where('id', '=', $child1['id'])->get_var('title');
                        $child1['type'] = $db->table('menuitems')->where('id', '=', $child1['id'])->get_var('type');
                        $child1['slug'] = $db->table('menuitems')->where('id', '=', $child1['id'])->get_var('slug');
                        $child1['target'] = $db->table('menuitems')->where('id', '=', $child1['id'])->get_var('target');
                        if (!empty($child1['children'][0])) {
                            foreach ($child1['children'][0] as &$child2) {
                                $child2['title'] = $db->table('menuitems')->where('id', '=', $child2['id'])->get_var('title');
                                $child2['type'] = $db->table('menuitems')->where('id', '=', $child2['id'])->get_var('type');
                                $child2['slug'] = $db->table('menuitems')->where('id', '=', $child2['id'])->get_var('slug');
                                $child2['target'] = $db->table('menuitems')->where('id', '=', $child2['id'])->get_var('target');
                            }
                        }
                    }
                }
            }
        }
    }
} else {
    $menuitems = menu_Items('data', $menu['id']);
}


if ($_POST) {
    $csrf_token = csrf_token($_POST['csrf_token']);
    if ($csrf_token[0]) {
        $title = m_u_p('title');
        $status = m_u_p('status');
		$content = isset($_POST['content']) ? m_clean_input($_POST['content'], 'string') : '';
        if (empty($title)) {
			$_SESSION['formSuccess'] = false;
			$_SESSION['error_message'] = lang('form_vali_title');
			m_redirect($_SERVER["HTTP_REFERER"]);
			exit;
		}
		if ($content !== '' && json_decode($content, true) === null) {
			$_SESSION['formSuccess'] = false;
			$_SESSION['error_message'] = lang('form_error_message');
            m_redirect($_SERVER["HTTP_REFERER"]);
            exit;
        }
        $data = [
            'title' => $title,
            'status' => $status,
            'content' => $content,
        ];
        $query = $db->table('posts')->where('id', '=', $id)->update($data);
        if ($query) {
            $_SESSION['formSuccess'] = true;
			$_SESSION['success_message'] = lang('form_success_message');
            if (isset($_POST['save'])) {
                m_redirect(ADMIN_URL . '/menu/lists');
            } else {
                m_redirect(ADMIN_URL . '/menu/edit/' . $id);
            }
        } else {
            $_SESSION['formSuccess'] = false;
			$_SESSION['error_message'] = lang('form_error_message');
            m_redirect($_SERVER["HTTP_REFERER"]);
            exit;
        }

    } else {
		$_SESSION['formSuccess'] = $csrf_token[0];
		$_SESSION['error_message'] = $csrf_token[1];
        m_redirect($_SERVER["HTTP_REFERER"]);
    }
}
?>
<div class="row">
    <div class="col-xxl-12">
        <div class="alert alert-primary alert-border-left alert-dismissible fade show lang_alert" role="alert">
            <i class="ri-error-warning-line me-3 align-middle fs-16"></i>
			<?= lang('form_editing_lang') ?> <?= lang_name($menu['lang']) ?>
        </div>
    </div>
</div>
<form class="needs-validation" novalidate method="POST">
    <input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token']['value']; ?>">
    <input type="hidden" name="id" value="<?= $id ?>">
    <input type="hidden" name="lang_ref_id" value="<?= $menu['lang_ref_id'] ?>">
    <input type="hidden" name="lang" value="<?= $menu['lang'] ?>">
    <div class="row">
      
        <div class="col-xxl-10">
            <div class="card">
                <div class="card-header align-items-center d-flex">
					<h4 class="card-title mb-0 flex-grow-1 text-muted"><?= lang('form_detail') ?></h4>
                </div><!-- end card header -->
                <div class="card-body">
                    <div class="live-preview">
                        <div class="row">


                            <div class="col-md-12">
                                <div class="mb-3 input-group-v ">
									<label for="title" class="form-label"><?= lang('form_input_title') ?></label>
                                    <input type="text" name="title" class="form-control input-group-flat"
                                           value="<?= $menu['title'] ?>"
										   placeholder="<?= lang('form_input_title_placeholder') ?>" id="title" required>
                                    <div class="invalid-feedback">
										<?= lang('form_vali_title') ?>
                                    </div>
                                </div>
                            </div>
                            <!--end col-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="core-menu-structure">
                <div class="row row-cards">
                    <div class="col-md-4">
                        <div class="card mb-3">
                            <div class="card-header">
                                <a class="d-flex justify-content-between w-100 align-items-center text-decoration-none"
                                   data-bs-toggle="collapse" data-parent="#accordion" href="#pages"
                                   aria-expanded="true">
                                    <h4 class="card-title">
										<?= lang('menu.module.pages', [], 'Sayfalar') ?>
                                    </h4>
                                    <button type="button" class="btn-action">
                                        <span class="icon-tabler-wrapper icon-sm">
                                            <svg xmlns="http://www.w3.org/2000/svg"
												 class="icon icon-tabler icon-tabler-chevron-down" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                 fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                <path d="M6 9l6 6l6 -6"></path>
                                                </svg>
                                        </span>
                                    </button>
                                </a>
                            </div>
                            <div id="pages" class="box-links-for-menu panel-collapse collapse show">
                                <div class="card-body overflow-auto" style="max-height: 20rem;">
                                    <div class="the-box">
                                        <ul class="list-unstyled list-item" id="pages-list">
                                            <?php
                                            foreach (posts('data', 'pages', $menu['lang']) as $post) {
                                                ?>
                                                <li>
                                                    <label class="form-check" style="font-size: 14px">
                                                        <input type="checkbox" name="select-pages[]"
                                                               class="form-check-input" value="<?= $post['id'] ?>">
                                                        <span class="form-check-label"><?= $post['title'] ?></span>
                                                    </label>
                                                </li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </div>

                                <div class="card-footer d-flex align-items-center justify-content-between">

                                    <label class="mb-0">
                                        <input type="checkbox" class="form-check-input me-1" id="select-all-pages">
										<?= lang('menu.all_select', [], 'Tümünü seç') ?>
                                    </label>
                                    <div>
                                        <button class="btn btn-add-to-menu" type="button" id="add-pages"
                                                data-id="<?= $menu['id'] ?>" data-type="pages">
                                            <span class="icon-tabler-wrapper icon-left">
                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                     class="icon icon-tabler icon-tabler-plus" width="24" height="24"
                                                     viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                     fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                    <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                    <path d="M12 5l0 14"></path>
                                                    <path d="M5 12l14 0"></path>
                                                </svg>
                                            </span>
											<?= lang('menu.select', [], 'Seç') ?>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php
                        if (posts('total_count', 'services', $menu['lang']) != 0){
                            ?>
                        <div class="card mb-3">
                            <div class="card-header">
                                <a class="d-flex justify-content-between w-100 align-items-center text-decoration-none"
                                   data-bs-toggle="collapse" data-parent="#accordion" href="#services"
                                   aria-expanded="true">
                                    <h4 class="card-title">
										<?= lang('menu.module.services', [], 'Hizmetler') ?>
                                    </h4>
                                    <button type="button" class="btn-action">
                                        <span class="icon-tabler-wrapper icon-sm">
                                            <svg xmlns="http://www.w3.org/2000/svg"
												 class="icon icon-tabler icon-tabler-chevron-down" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                 fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                <path d="M6 9l6 6l6 -6"></path>
                                                </svg>
                                        </span>
                                    </button>
                                </a>
                            </div>

                            <div id="services" class="box-links-for-menu panel-collapse collapse ">
                                <div class="card-body overflow-auto" style="max-height: 20rem;">
                                    <div class="the-box">
                                        <ul class="list-unstyled list-item" id="services-list">
                                            <?php
                                                foreach (posts('data', 'services', $menu['lang']) as $post) {
                                            ?>
                                                    <li>
                                                        <label class="form-check" style="font-size: 14px">
                                                            <input type="checkbox" name="select-services[]"
                                                                   class="form-check-input" value="<?= $post['id'] ?>">
                                                            <span class="form-check-label"><?= $post['title'] ?></span>
                                                        </label>
                                                    </li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </div>

                                <div class="card-footer d-flex align-items-center justify-content-between">

                                    <label class="mb-0">
                                        <input type="checkbox" class="form-check-input me-1" id="select-all-services">
										<?= lang('menu.all_select', [], 'Tümünü seç') ?>
                                    </label>
                                    <div>
                                        <button class="btn btn-add-to-menu" type="button" id="add-services"
                                                data-id="<?= $menu['id'] ?>" data-type="services">
                                            <span class="icon-tabler-wrapper icon-left">
                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                     class="icon icon-tabler icon-tabler-plus" width="24" height="24"
                                                     viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                     fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                    <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                    <path d="M12 5l0 14"></path>
                                                    <path d="M5 12l14 0"></path>
                                                </svg>
                                            </span>
											<?= lang('menu.select', [], 'Seç') ?>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php } ?>
                        <?php
                        if (posts('total_count', 'projects', $menu['lang']) != 0){
                        ?>
                        <div class="card mb-3">
                            <div class="card-header">
                                <a class="d-flex justify-content-between w-100 align-items-center text-decoration-none"
                                   data-bs-toggle="collapse" data-parent="#accordion" href="#projects"
                                   aria-expanded="true">
                                    <h4 class="card-title">
										<?= lang('menu.module.projects', [], 'Projeler') ?>
                                    </h4>
                                    <button type="button" class="btn-action">
                                        <span class="icon-tabler-wrapper icon-sm">
                                            <svg xmlns="http://www.w3.org/2000/svg"
												 class="icon icon-tabler icon-tabler-chevron-down" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                 fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                <path d="M6 9l6 6l6 -6"></path>
                                                </svg>
                                        </span>
                                    </button>
                                </a>
                            </div>
                            <div id="projects" class="box-links-for-menu panel-collapse collapse ">
                                <div class="card-body overflow-auto" style="max-height: 20rem;">
                                    <div class="the-box">
                                        <ul class="list-unstyled list-item" id="projects-list">
                                            <?php
                                            foreach (posts('data', 'projects', $menu['lang']) as $post) {
                                                ?>
                                                <li>
                                                    <label class="form-check" style="font-size: 14px">
                                                        <input type="checkbox" name="select-projects[]"
                                                               class="form-check-input" value="<?= $post['id'] ?>">
                                                        <span class="form-check-label"><?= $post['title'] ?></span>
                                                    </label>
                                                </li>
                                            <?php } ?>
                                        </ul>
                                    </div>
                                </div>

                                <div class="card-footer d-flex align-items-center justify-content-between">

                                    <label class="mb-0">
                                        <input type="checkbox" class="form-check-input me-1" id="select-all-projects">
										<?= lang('menu.all_select', [], 'Tümünü seç') ?>
                                    </label>
                                    <div>
                                        <button class="btn btn-add-to-menu" type="button" id="add-projects"
                                                data-id="<?= $menu['id'] ?>" data-type="projects">
                                            <span class="icon-tabler-wrapper icon-left">
                                                <svg xmlns="http://www.w3.org/2000/svg"
                                                     class="icon icon-tabler icon-tabler-plus" width="24" height="24"
                                                     viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"
                                                     fill="none" stroke-linecap="round" stroke-linejoin="round">
                                                    <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                    <path d="M12 5l0 14"></path>
                                                    <path d="M5 12l14 0"></path>
                                                </svg>
                                            </span>
											<?= lang('menu.select', [], 'Seç') ?>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <?php } ?>
                        <div class="card">
                            <div class="card-header">
                                <a class="d-flex justify-content-between w-100 align-items-center text-decoration-none"
                                   data-bs-toggle="collapse" data-parent="#accordion" href="#collapseCustomLink">
                                    <h4 class="card-title">
										<?= lang('menu.module.custom_link', [], 'Özel bağlantı') ?>
                                    </h4>
                                    <button type="button" class="btn-action">
                                <span class="icon-tabler-wrapper icon-sm">
                                    <svg xmlns="http://www.w3.org/2000/svg"
                                         class="icon icon-tabler icon-tabler-chevron-down" width="24" height="24"
                                         viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
                                         stroke-linecap="round" stroke-linejoin="round">
                                      <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                      <path d="M6 9l6 6l6 -6"></path>
                                    </svg>
                                </span>
                                    </button>
                                </a>
                            </div>
                            <div id="collapseCustomLink" class="box-links-for-menu collapse">
                                <div class="card-body">
                                    <div id="external_link" class="the-box">
                                        <div class="node-content" id="menu-node-create-form">
                                            <div class="mb-3 position-relative">
                                                <label class="form-label" for="linktext">
													<?= lang('form_input_title') ?>
                                                </label>
                                                <input class="form-control" id="linktext" name="menu_item_title"
                                                       type="text">
                                            </div>
                                            <div class="mb-3 position-relative">
                                                <label class="form-label" for="url">
                                                    URL
                                                </label>
                                                <input class="form-control" id="url"
                                                       name="url" type="text" value="/">
                                            </div>
                                            <div class="mb-3 position-relative">
                                                <label class="form-label" for="menu-node-target-new"
                                                       data-update="target">
													<?= lang('form_input_target', [], 'Hedef') ?>
                                                </label>
                                                <select class="form-control form-select" id="menu-node-target-new"
                                                        name="target">
													<option value="_self"><?= lang('form_input_target_self', [], 'Aynı sekme') ?></option>
													<option value="_blank"><?= lang('form_input_target_blank', [], 'Yeni sekme') ?></option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="card-footer text-end">
                                    <button class="btn  btn-add-to-menu" id="add-custom-link" type="button"
                                            data-id="<?= $menu['id'] ?>" data-type="custom">
                                        <span class="icon-tabler-wrapper icon-left">
                                            <svg xmlns="http://www.w3.org/2000/svg"
                                                 class="icon icon-tabler icon-tabler-plus" width="24" height="24"
                                                 viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
                                                 stroke-linecap="round" stroke-linejoin="round">
                                              <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                              <path d="M12 5l0 14"></path>
                                              <path d="M5 12l14 0"></path>
                                            </svg>
                                        </span>
										<?= lang('menu.select', [], 'Seç') ?>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-8">
                        <div class="card mb-3">
                            <div class="card-header">
                                <h4 class="card-title">
									<?= lang('menu.structure', [], 'Menü yapısı') ?>
                                </h4>
                            </div>
                            <div class="card-body">
                                <div class="dd nestable-menu" id="nestable" data-depth="0">
                                    <?php
                                    if (menu_Items('total_count', $menu['id'])) {
                                        ?>
                                        <ul class="menu ui-sortable dd-list" id="menuitems"
                                            data-id="<?= $menu['id'] ?>">
                                            <?php
                                            foreach ($menuitems as $key => $item) {
                                                ?>
                                                <li data-id="<?= $item['id'] ?>" class="dd-item dd3-item">
                                                    <div class="dd3-content d-flex justify-content-between">
                                                        <div data-update="title"
                                                             class="fw-medium"><?= $item['title'] ?></div>
                                                        <div class="text-end me-5"><?= menu_type($item['type']) ?></div>
                                                        <a class="show-item-details" href="#">
                                                    <span class="icon-tabler-wrapper">
                                                        <svg xmlns="http://www.w3.org/2000/svg"
                                                             class="icon icon-tabler icon-tabler-chevron-down"
                                                             width="24" height="24" viewBox="0 0 24 24" stroke-width="2"
                                                             stroke="currentColor" fill="none" stroke-linecap="round"
                                                             stroke-linejoin="round">
                                                          <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                          <path d="M6 9l6 6l6 -6"></path>
                                                        </svg>
                                                    </span>
                                                        </a>
                                                    </div>

                                                    <div class="item-details">
                                                        <div class="mb-3 position-relative">
                                                            <label class="form-label" for="menu-node-title-1">
																<?= lang('form_input_title') ?>
                                                            </label>
                                                            <input class="form-control" id="menu-node-title-1"
                                                                   name="menu_item_title" type="text"
                                                            value="<?= $item['title'] ?>">
                                                        </div>
                                                        <div class="mb-3 position-relative">
                                                            <label class="form-label" for="menu-node-url-1">
                                                                URL
                                                            </label>
                                                            <input class="form-control" data-old="/"
                                                                   id="menu-node-url-1"
                                                                   name="menu_item_url" type="text"
                                                                   value="<?= $item['slug'] ?>">
                                                        </div>
                                                        <div class="mb-3 position-relative">
                                                            <label class="form-label" for="menu-node-target-1">
																<?= lang('form_input_target', [], 'Hedef') ?>
                                                            </label>
                                                            <select class="form-control form-select" data-old="_self"
                                                                    id="menu-node-target-1" name="menu_item_target">
                                                                <option value="_self" <?php if ($item['target'] == '_self') {
                                                                    echo 'selected="selected"';
																} ?>><?= lang('form_input_target_self', [], 'Aynı sekme') ?> </option>
                                                                <option value="_blank" <?php if ($item['target'] == '_blank') {
                                                                    echo 'selected="selected"';
																} ?>><?= lang('form_input_target_blank', [], 'Yeni sekme') ?></option>
                                                            </select>
                                                        </div>
                                                        <div class="text-end mt-2">
															<a class="btn btn-primary btn-uptade btn-sm"><?= lang('menu.button.update', [], 'Güncelle') ?></a>
                                                            <a class="btn btn-danger btn-remove btn-sm"
                                                               data-id="<?= $item['id'] ?>" data-key="<?= $key ?>"
															   data-menuid="<?= $menu['id'] ?>"><?= lang('menu.button.remove', [], 'Kaldır') ?></a>
															<a class="btn btn-light btn-cancel btn-sm"><?= lang('menu.button.cancel', [], 'İptal') ?></a>
                                                        </div>
                                                    </div>
                                                    <div class="clearfix"></div>
                                                    <ul>
                                                        <?php
                                                        if ($item['children'][0]) {
                                                            foreach ($item['children'][0] as $childkey => $childmenu) {
                                                                ?>
                                                                <li data-id="<?= $childmenu['id'] ?>"
                                                                    class="dd-item dd3-item">
                                                                    <div class="dd3-content d-flex justify-content-between">
                                                                        <div class="fw-medium"><?= $childmenu['title'] ?></div>
                                                                        <div class="text-end me-5"><?= menu_type($childmenu['type']) ?></div>
                                                                        <a class="show-item-details" href="#">
                                                        <span class="icon-tabler-wrapper">
                                                            <svg xmlns="http://www.w3.org/2000/svg"
                                                                 class="icon icon-tabler icon-tabler-chevron-down"
																		 width="24" height="24" viewBox="0 0 24 24" stroke-width="2"
																		 stroke="currentColor" fill="none" stroke-linecap="round"
                                                                 stroke-linejoin="round">
                                                              <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                              <path d="M6 9l6 6l6 -6"></path>
                                                            </svg>
                                                        </span>
                                                                        </a>
                                                                    </div>

                                                                    <div class="item-details">
                                                                        <input class="menu_id" name="menu_id"
                                                                               type="hidden" value="1">
                                                                        <div class="mb-3 position-relative">
                                                                            <label class="form-label"
                                                                                   for="menu-node-title-1">
																		<?= lang('form_input_title') ?>
                                                                            </label>
                                                                            <input class="form-control"
                                                                                   id="menu-node-title-1"
                                                                                   name="menu_item_title" type="text"
                                                                                   value="<?= $childmenu['title'] ?>">
                                                                        </div>
                                                                        <div class="mb-3 position-relative">
                                                                            <label class="form-label"
                                                                                   for="menu-node-url-1">
                                                                                URL
                                                                            </label>
                                                                            <input class="form-control" data-old="/"
                                                                                   id="menu-node-url-1"
                                                                                   name="url" type="text"
                                                                                   value="<?= $childmenu['slug'] ?>">
                                                                        </div>
                                                                        <div class="mb-3 position-relative">
                                                                            <label class="form-label"
                                                                                   for="menu-node-target-1">
																		<?= lang('form_input_target', [], 'Hedef') ?>
                                                                            </label>
                                                                            <select class="form-control form-select"
                                                                                    data-old="_self"
                                                                                    id="menu-node-target-1"
                                                                                    name="target">
                                                                                <option value="_self" <?php if ($childmenu['target'] == '_self') {
                                                                                    echo 'selected="selected"';
																		} ?>><?= lang('form_input_target_self', [], 'Aynı sekme') ?> </option>
                                                                                <option value="_blank" <?php if ($childmenu['target'] == '_blank') {
                                                                                    echo 'selected="selected"';
																		} ?>><?= lang('form_input_target_blank', [], 'Yeni sekme') ?></option>
                                                                            </select>
                                                                        </div>
                                                                        <div class="text-end mt-2">
																	<a class="btn btn-primary btn-uptade btn-sm"><?= lang('menu.button.update', [], 'Güncelle') ?></a>
                                                                            <a class="btn btn-danger btn-remove btn-sm"
                                                                               data-id="<?= $childmenu['id'] ?>"
                                                                               data-key="<?= $key ?>"
                                                                               data-in="<?= $childkey ?>"
                                                                               data-menuid="<?= $menu['id'] ?>"
																	   href="#"><?= lang('menu.button.remove', [], 'Kaldır') ?></a>
                                                                            <a class="btn btn-primary btn-cancel btn-sm"
																	   href="#"><?= lang('menu.button.cancel', [], 'İptal') ?></a>
                                                                        </div>
                                                                    </div>
                                                                    <div class="clearfix"></div>

                                                                    <ul>
                                                                        <?php
                                                                        if ($childmenu['children'][0]) {
                                                                            foreach ($childmenu['children'][0] as $childkey1 => $childmenu1) {
                                                                                ?>
                                                                                <li data-id="<?= $childmenu1['id'] ?>"
                                                                                    class="dd-item dd3-item">
                                                                                    <div class="dd3-content d-flex justify-content-between">
                                                                                        <div class="fw-medium"><?= $childmenu1['title'] ?></div>
                                                                                        <div class="text-end me-5"><?= menu_type($childmenu1['type']) ?></div>
                                                                                        <a class="show-item-details"
                                                                                           href="#">
                                                                                <span class="icon-tabler-wrapper">
                                                                                    <svg xmlns="http://www.w3.org/2000/svg"
                                                                                         class="icon icon-tabler icon-tabler-chevron-down"
																			 width="24" height="24" viewBox="0 0 24 24"
                                                                                         stroke-width="2"
																			 stroke="currentColor" fill="none"
                                                                                         stroke-linecap="round"
                                                                                         stroke-linejoin="round">
																		  <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                                                                                      <path d="M6 9l6 6l6 -6"></path>
                                                                                    </svg>
                                                                                </span>
                                                                                        </a>
                                                                                    </div>

                                                                                    <div class="item-details">
                                                                                        <input class="menu_id"
                                                                                               name="menu_id"
																		   type="hidden"
																		   value="1">
                                                                                        <div class="mb-3 position-relative">
                                                                                            <label class="form-label"
                                                                                                   for="menu-node-title-1">
																		<?= lang('form_input_title') ?>
                                                                                            </label>
                                                                                            <input class="form-control"
                                                                                                   id="menu-node-title-1"
                                                                                                   name="menu_item_title"
                                                                                                   type="text"
                                                                                                   value="<?= $childmenu1['title'] ?>">
                                                                                        </div>
                                                                                        <div class="mb-3 position-relative">
                                                                                            <label class="form-label"
                                                                                                   for="menu-node-url-1">
                                                                                                URL
                                                                                            </label>
                                                                                            <input class="form-control"
                                                                                                   data-old="/"
                                                                                                   id="menu-node-url-1"
                                                                                                   name="url"
                                                                                                   type="text"
                                                                                                   value="/">
                                                                                        </div>
                                                                                        <div class="mb-3 position-relative">
                                                                                            <label class="form-label"
                                                                                                   for="menu-node-target-1">
																			<?= lang('form_input_target', [], 'Hedef') ?>
                                                                                            </label>
                                                                                            <select class="form-control form-select"
                                                                                                    data-old="_self"
                                                                                                    id="menu-node-target-1"
                                                                                                    name="target">
                                                                                                <option value="_self" <?php if ($childmenu1['target'] == '_self') {
                                                                                                    echo 'selected="selected"';
																			} ?>><?= lang('form_input_target_self', [], 'Aynı sekme') ?> </option>
                                                                                                <option value="_blank" <?php if ($childmenu1['target'] == '_blank') {
                                                                                                    echo 'selected="selected"';
																			} ?>><?= lang('form_input_target_blank', [], 'Yeni sekme') ?></option>
                                                                                            </select>
                                                                                        </div>
                                                                                        <div class="text-end mt-2">
																		<a class="btn btn-primary btn-uptade btn-sm"><?= lang('menu.button.update', [], 'Güncelle') ?></a>
                                                                                            <a class="btn btn-danger btn-remove btn-sm"
                                                                                               data-id="<?= $childmenu1['id'] ?>"
                                                                                               data-key="<?= $key ?>"
                                                                                               data-in="<?= $childkey1 ?>"
                                                                                               data-menuid="<?= $menu['id'] ?>"
																		   href="#"><?= lang('menu.button.remove', [], 'Kaldır') ?></a>
                                                                                            <a class="btn btn-primary btn-cancel btn-sm"
																		   href="#"><?= lang('menu.button.cancel', [], 'İptal') ?></a>
                                                                                                        </div>
                                                                                                    </div>
                                                                                                    <div class="clearfix"></div>
                                                                                                </li>
                                                                                                <?php
                                                                                            }
                                                                                        }
                                                                                        ?>
                                                                                    </ul>

                                                                                </li>
                                                                                <?php
                                                                            }
                                                                        }
                                                                        ?>
                                        </ul>
                                        <?php } // end foreach ($menuitems)
                                        } // end if menu_Items('total_count', $menu['id'])
                                        ?>
                                        <?php if (!menu_Items('total_count', $menu['id'])) {
										echo '<p>' . lang('menu.item.none', [], 'Menü öğesi bulunamadı') . '</p>';
                                        } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id="serialize_output"></div>
            <input type="hidden" name="content" id="serialize_input" value='<?= htmlspecialchars($menu['content'], ENT_QUOTES, 'UTF-8') ?>'>
        </div> <!-- end col -->

        <div class="col-xxl-2">
            <div class="card card-body">
						<h4 class="card-title  flex-grow-1 text-muted"><?= lang('published') ?></h4>
                <hr>
                <div class="saved">
                    <button class="btn btn-primary" type="submit" value="save_and_edit" name="save_and_edit">
                <span class="icon-tabler-wrapper icon-left">
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-device-floppy"
                         width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
                         stroke-linecap="round" stroke-linejoin="round">
                      <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                      <path d="M6 4h10l4 4v10a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2"></path>
							  <path d="M12 14m-2 0a 2 2 0 1 0 4 0a 2 2 0 1 0 -4 0"></path>
                      <path d="M14 4l0 4l-6 0l0 -4"></path>
                    </svg>
                </span>
							<?= lang('save_and_edit') ?>
                    </button>
                    <button class="btn btn-light" type="submit" name="save" value="save">
                <span class="icon-tabler-wrapper icon-left">
							<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-transfer-in" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
                      <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
                      <path d="M4 18v3h16v-14l-8 -4l-8 4v3"></path>
                      <path d="M4 14h9"></path>
                      <path d="M10 11l3 3l-3 3"></path>
                    </svg>
                </span>
							<?= lang('save') ?>
                    </button>
                </div>
            </div>
            <div class="card card-body">
						<h4 class="card-title  flex-grow-1 text-muted"><?= lang('page_title_languages') ?></h4>
                <hr>
                <div class="list-others-language">
                    <?php foreach (posts_langs($menu['lang_ref_id'], lang_is_default('lang_code')) as $menus_lang) {
                        if ($menus_lang['lang'] != $menu['lang']) {
                            ?>
                            <a class="gap-2 d-flex align-items-center text-decoration-none"
                               href="<?= $menus_lang['id'] ?>" target="_blank">
                                <img src="<?= ADMIN_FOLDER ?>/model/languages/flags/<?= $menus_lang['lang'] ?>.svg"
                                     title="<?= lang_name($menus_lang['lang']) ?>" class="flag" style="height: 16px"
                                     alt="<?= lang_name($menus_lang['lang']) ?> Bayrak">
                                <span><?= lang_name($menus_lang['lang']) ?> <span class="icon-tabler-wrapper"><i
                                                class="bx bx-edit"></i></span></span>
                            </a>
                        <?php }
                    } ?>
                </div>
            </div>

            <div class="card card-body">
						<h4 class="card-title  flex-grow-1 text-muted"><?= lang('status') ?></h4>
                <hr>
                <select class="form-select mb-3" name="status">
                    <option <?php echo ($menu['status'] == 1) ? 'selected="selected"' : ''; ?>
									value="1"><?= lang('status_option_published') ?> </option>
                    <option <?php echo ($menu['status'] == 2) ? 'selected="selected"' : ''; ?>
									value="2"><?= lang('status_option_draft') ?> </option>
                    <option <?php echo ($menu['status'] == 0) ? 'selected="selected"' : ''; ?>
									value="0"><?= lang('status_option_unpublished') ?> </option>
                </select>
            </div>
        </div> <!-- end col -->
      
    </div>


</form>
