<?php
include 'includ/header.php';
?>
            <div class="container grid px-6 mx-auto ">


                <a style="font-size: 20px"
                   class="text-xs font-semibold tracking-wide text-left text-gray-500 0 dark:text-gray-400 inline-flex items-center w-full text-sm font-semibold transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200"
                >
                    <svg stroke-linejoin="round" fill="gray" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
                         id="Outline" viewBox="0 0 24 24" width="20" height="20">
                        <path d="M19,3H12.472a1.019,1.019,0,0,1-.447-.1L8.869,1.316A3.014,3.014,0,0,0,7.528,1H5A5.006,5.006,0,0,0,0,6V18a5.006,5.006,0,0,0,5,5H19a5.006,5.006,0,0,0,5-5V8A5.006,5.006,0,0,0,19,3ZM5,3H7.528a1.019,1.019,0,0,1,.447.1l3.156,1.579A3.014,3.014,0,0,0,12.472,5H19a3,3,0,0,1,2.779,1.882L2,6.994V6A3,3,0,0,1,5,3ZM19,21H5a3,3,0,0,1-3-3V8.994l20-.113V18A3,3,0,0,1,19,21Z"/>
                    </svg>
                    <span class="ml-4"><?php echo $_LANG['multipleplans']?></span>
                    <span class="ml-4 justify-end inline-flex">
                    <button @click="openModal"
                            class=" text-sm font-medium leading-5 text-white transition-colors duration-150 border border-transparent rounded-lg focus:outline-none ">
                        <img src="icons/add.svg" width="30px">
                    </button>
                    </span>
                    <?php session_notif_wizwiz() ?>
                </a>

                <div style='margin-top:40px' class=" w-full flex justify-center items-center grid gap-6 mb-8 xl:grid-cols-4 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-2 grid-cols-1">
                    <?php
                    plans2($conn);
                    ?>
                    <?php

                    $sql_plans = 'SELECT * FROM server_plans WHERE rahgozar = 0 AND ' . PlanInboundIds::sqlHasInboundsCondition() . ' ORDER BY id DESC';
					
					$stmt = $conn->prepare($sql_plans);
					$stmt->execute();
					$result_plans = $stmt->get_result();
					$stmt->close();
					
                    while ($row_plans = $result_plans->fetch_assoc()) {
                        $id_plans = $row_plans["id"];
                        $server_id_name_plans = $row_plans["server_id"];
                        if (isset($server_id_name_plans)) {

                        } else {
                            echo '';
                        }

                        $sql_server_info_1 = "SELECT * FROM server_info WHERE id=?";
						
						$stmt = $conn->prepare($sql_server_info_1);
						$stmt->bind_param('i', $server_id_name_plans);
						$stmt->execute();
						$result_server_info_1 = $stmt->get_result();
						$stmt->close();

                        $row_server_info = $result_server_info_1->fetch_assoc();
                        echo '
<div class="w-full p-4 m-auto bg-white shadow-sm rounded-2xl dark:bg-gray-800">
    <div class="w-full h-full text-center">
        <div class="flex flex-col justify-between h-full">
            <img src="icons/plans.svg" width="50px" class="mx-auto mt-4" style="color: #5f7d95">
            <p class="mt-4 text-xl font-bold text-gray-800 dark:text-gray-200" style="font-size: 16px">
                ' . $row_plans['title'] . '
            </p>
            <p class="px-6 py-2 text-xs text-gray-600 dark:text-gray-400">
               ' . $_LANG['Days'] . ' ' . $row_plans['days'] . ' - ' . $_LANG['GB'] . ' ' . $row_plans['volume'] . ' - ' . $row_plans['protocol'] . ' ' . $row_plans['type'] . '
            </p>';


                        ?>
                        <?php
                        if (isset($row_server_info['id'])) {
                            $ibIds = PlanInboundIds::parseFromRow($row_plans);
                            $ibLabel = count($ibIds) > 0 ? ' — ' . count($ibIds) . ' inbound' : '';
                            echo '<p style="font-size: 16px" class="px-6 py-2 text-xs text-gray-600 dark:text-gray-400">' . $row_server_info['title'] . $ibLabel . ' </p>';
                        } else {
                            echo '<p style="font-size: 16px" class="px-6 py-2 text-xs text-gray-600 dark:text-gray-400">no server</p>';
                        }

                        echo '<div class="flex items-center justify-center w-full gap-4 mt-3">
                    <a href="multipleplans.php?edit=' . $row_plans['id'] . '">
                    <svg class="m-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="26" fill="#9dbebb"><g id="_01_align_center" data-name="01 align center"><path d="M10.931,2.75a3.728,3.728,0,0,0-7.195,0H0v2H3.736a3.728,3.728,0,0,0,7.195,0H24v-2ZM7.333,5.5a1.75,1.75,0,1,1,1.75-1.75A1.753,1.753,0,0,1,7.333,5.5Z"/><path d="M16.667,8.25A3.745,3.745,0,0,0,13.07,11H0v2H13.07a3.727,3.727,0,0,0,7.194,0H24V11H20.264A3.745,3.745,0,0,0,16.667,8.25Zm0,5.5A1.75,1.75,0,1,1,18.417,12,1.752,1.752,0,0,1,16.667,13.75Z"/><path d="M7.333,16.5a3.745,3.745,0,0,0-3.6,2.75H0v2H3.736a3.728,3.728,0,0,0,7.195,0H24v-2H10.931A3.745,3.745,0,0,0,7.333,16.5Zm0,5.5a1.75,1.75,0,1,1,1.75-1.75A1.753,1.753,0,0,1,7.333,22Z"/></g></svg>
                    </a>
                    <a href="multipleplans.php?delete=' . $row_plans['id'] . '">
                    <svg class="m-2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="26" fill="#ff758f"><g id="_01_align_center" data-name="01 align center"><path d="M18.965,8.464l5.029-5.029L22.565,2.006,17.519,7.051,15.313,4.895a2.011,2.011,0,0,0-2.724-.073A19.71,19.71,0,0,1,6.226,8.687L-.006,10.514v.756A12.892,12.892,0,0,0,13.006,24.006h1.241l.261-.182a14.98,14.98,0,0,0,6.886-12.081,2.013,2.013,0,0,0-.611-1.5ZM13.9,6.34l5.477,5.341a12.652,12.652,0,0,1-.456,3.015L11.941,7.9A24.691,24.691,0,0,0,13.9,6.34Zm-.294,15.645h-.6a11.153,11.153,0,0,1-4.293-.859,11.55,11.55,0,0,0,4.348-3.8l.518-.76L11.91,15.43l-.518.761A9.539,9.539,0,0,1,7.8,19.324l-1.229.618a10.9,10.9,0,0,1-2.585-2.563,11.632,11.632,0,0,0,4.357-2.657L6.932,13.277a9.611,9.611,0,0,1-3.974,2.317,10.4,10.4,0,0,1-.921-3.575l4.755-1.394a15.234,15.234,0,0,0,3.423-1.59l7.911,7.7A14.1,14.1,0,0,1,13.608,21.985Z"/></g></svg>
                    </a>
                    <a href="multipleplans.php?copy=' . $row_plans['id'] . '">
                    <svg class="m-2" id="Layer_1" height="26" viewBox="0 0 24 24" width="26" xmlns="http://www.w3.org/2000/svg" fill="#778da9" data-name="Layer 1"><path d="m15 20h-10a5.006 5.006 0 0 1 -5-5v-10a5.006 5.006 0 0 1 5-5h10a5.006 5.006 0 0 1 5 5v10a5.006 5.006 0 0 1 -5 5zm-10-18a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3v-10a3 3 0 0 0 -3-3zm19 17v-13a1 1 0 0 0 -2 0v13a3 3 0 0 1 -3 3h-13a1 1 0 0 0 0 2h13a5.006 5.006 0 0 0 5-5z"/></svg>                    
                    </a>';
                        if ($row_plans['active'] == '1') {
                            echo '<a href="multipleplans.php?off=' . $row_plans['id'] . '">
                    <svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 24 24" class="m-2" width="27" fill="#219ebc"><path d="M23.821,11.181v0C22.943,9.261,19.5,3,12,3S1.057,9.261.179,11.181a1.969,1.969,0,0,0,0,1.64C1.057,14.739,4.5,21,12,21s10.943-6.261,11.821-8.181A1.968,1.968,0,0,0,23.821,11.181ZM12,18a6,6,0,1,1,6-6A6.006,6.006,0,0,1,12,18Z"/><circle cx="12" cy="12" r="4"/></svg>
                    </a>';
                        } else {
                            echo '<a href="multipleplans.php?on=' . $row_plans['id'] . '">
                    <svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" data-name="Layer 1" viewBox="0 0 24 24" class="m-2" width="27" fill="#bde0fe"><path d="M23.821,11.181v0C22.943,9.261,19.5,3,12,3S1.057,9.261.179,11.181a1.969,1.969,0,0,0,0,1.64C1.057,14.739,4.5,21,12,21s10.943-6.261,11.821-8.181A1.968,1.968,0,0,0,23.821,11.181ZM12,18a6,6,0,1,1,6-6A6.006,6.006,0,0,1,12,18Z"/><circle cx="12" cy="12" r="4"/></svg>
                    </a>';
                        }
                        echo '
</div>
        </div>
    </div>
</div>';
                    }
                    ?>
                </div>


                <?php
                $plan_edit = plan_edit2($conn);
                if (is_array($plan_edit) || is_object($plan_edit)) {
                    foreach ($plan_edit
                             as $value):
                        echo '
<br>
                <div style="width: 100%" class=" mx-auto shadow-xl min-w-0 p-4 bg-white rounded-lg dark:bg-gray-800 text-xs font-semibold tracking-wide text-left text-gray-500 border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800">
        
        
                            <a style="font-size: 20px"
                            class="m-5 text-xs font-semibold tracking-wide text-left text-gray-500 0 dark:text-gray-400 inline-flex items-center w-full text-sm font-semibold transition-colors duration-150 hover:text-gray-800 dark:hover:text-gray-200"
                    >
<svg xmlns="http://www.w3.org/2000/svg"  viewBox="0 0 32 32" width="32px" height="32px" fill="gray"><path d="M 23.90625 3.96875 C 22.859375 3.96875 21.8125 4.375 21 5.1875 L 5.1875 21 L 5.125 21.3125 L 4.03125 26.8125 L 3.71875 28.28125 L 5.1875 27.96875 L 10.6875 26.875 L 11 26.8125 L 26.8125 11 C 28.4375 9.375 28.4375 6.8125 26.8125 5.1875 C 26 4.375 24.953125 3.96875 23.90625 3.96875 Z M 23.90625 5.875 C 24.410156 5.875 24.917969 6.105469 25.40625 6.59375 C 26.378906 7.566406 26.378906 8.621094 25.40625 9.59375 L 24.6875 10.3.125 L 21.71875 7.3125 L 22.40625 6.59375 C 22.894531 6.105469 23.402344 5.875 23.90625 5.875 Z M 20.3125 8.71875 L 23.28125 11.6875 L 11.1875 23.78125 C 10.53125 22.5 9.5 21.46875 8.21875 20.8125 Z M 6.9375 22.4375 C 8.136719 22.921875 9.078125 23.863281 9.5625 25.0625 L 6.28125 25.71875 Z"/></svg>
                        <span class="ml-4"> ' . $_LANG["editplan"] . ' [ ' . $value["title"] . ' ]</span>
                    </a>
        <div>
           
        </div>
        
        
        <br>
        
        
        <div>
<form method="post">
<input type="hidden" name="plan_id" value="' . (int) $value['id'] . '"/>
<input type="hidden" name="plan_edit_page" value="multiple"/>
<div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
        ' . $_LANG['title'] . ' 
    </span>
    <input required name="title_plan" style="font-size: 14px;" value="' . $value["title"] . '" type="text" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder=""/>
    </div>


    <div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
        ' . $_LANG['protocol2'] . '
    </span>
    <input name="protocol_plan" style="font-size: 14px;" value="' . $value["protocol"] . '" type="text" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder="vless"/>
    </div>
    
    
    <div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
        ' . $_LANG['type2'] . '
    </span>
    <input name="type_plan" style="font-size: 14px;" value="' . $value["type"] . '" type="text" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder="tcp"/>
    </div>

   
    

    <br>
    
    
        

<div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
        '.$_LANG['Price3'].'
    </span>
    <input required name="price_plan" style="font-size: 14px;" value="' . $value["price"] . '" type="number" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder=""/>
    </div>


<div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
        '.$_LANG['days'].'
    </span>
    <input required name="days_plan" style="font-size: 14px;" value="' . $value["days"] . '" type="number" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder=""/>
    </div>
    
    
    <div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
        '.$_LANG['volume'].'
    </span>
    <input required name="volume_plan" style="font-size: 14px;" value="' . $value["volume"] . '" type="number" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder=""/>
    </div>
';

                        ?>
                        <br>
                        <label class="block mt-2 text-sm mx-auto" style="width: 99%">
                            <select required name="name_category_wizwiz"
                                    class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">
                                <?php
                                $sql_select_category1 = "SELECT * FROM server_categories where id=?";
								$stmt = $conn->prepare($sql_select_category1);
								$stmt->bind_param('i', $value['catid']);
								$stmt->execute();
								$res_select_category1 = $stmt->get_result();
								$stmt->close();
								
                                $row_select_category1 = $res_select_category1->fetch_assoc();
                                echo '<option value="' . $row_select_category1['id'] . '">' . $row_select_category1['title'] . '</option>';

                                $sql_select_category1 = "SELECT * FROM server_categories";
								$stmt = $conn->prepare($sql_select_category1);
								$stmt->execute();
								$res_select_category1 = $stmt->get_result();
								$stmt->close();
								
                                while ($row_select_category2 = $res_select_category1->fetch_assoc()) {
                                    $row_title_category2 = $row_select_category2['title'];
                                    $row_id_categoryqw2 = $row_select_category2['id'];
                                    if ($row_id_categoryqw2 == $row_select_category1['id']) {

                                    } else {
                                        echo '<option value="' . $row_id_categoryqw2 . '">' . $row_title_category2 . '</option>';
                                    }

                                }
                                ?>

                            </select>
                        </label>

                        <label class="block mt-2 text-sm mx-auto" style="width: 99%">
                            <select required name="name_server_wizwiz"
                                    class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">
                                <?php
                                $sql_server_info1 = "SELECT * FROM server_info where id=?";
								$stmt = $conn->prepare($sql_server_info1);
								$stmt->bind_param('i', $value['server_id']);
								$stmt->execute();
								$res_server_info1 = $stmt->get_result();
								$stmt->close();

                                $row_server_info1 = $res_server_info1->fetch_assoc();
                                echo '<option value="' . $row_server_info1['id'] . '">' . $row_server_info1['title'] . '</option>';

                                $sql_server_info2 = "SELECT * FROM server_info";
								$stmt = $conn->prepare($sql_server_info2);
								$stmt->execute();
								$res_server_info2 = $stmt->get_result();
								$stmt->close();
								
                                while ($row_server_info2 = $res_server_info2->fetch_assoc()) {
                                    $row_title_server_info2 = $row_server_info2['title'];
                                    $row_id_server_info2 = $row_server_info2['id'];
                                    if ($row_id_server_info2 == $row_server_info1['id']) {

                                    } else {
                                        echo '<option value="' . $row_id_server_info2 . '">' . $row_title_server_info2 . '</option>';
                                    }
                                }
                                ?>

                            </select>
                        </label>
                        <br>
                        <?php
                        echo '<div class="flex relative m-2">
    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
       ' . $_LANG["limitip"] . '
    </span>
    <input required name="limitip_plan" style="font-size: 14px;" value="' . $value["limitip"] . '" type="number" id="with-email" class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-blue-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" name="url" placeholder=""/>
    </div>
';
                        echo PlanInboundHelper::renderInboundField($conn, (int) $value['server_id'], PlanInboundIds::parseFromRow($value), 'inbound_ids_plan', false, $value['custom_sni'] ?? null);
                        echo '<br>';
                        ?>
                        <?php
                        if($value["acount"] == 0){

                        }else{
                            echo '
                <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                        ' . $_LANG["count"] . '
                    </span>
                    <input name="acount_plan" style="font-size: 14px;" value="' . $value["acount"] . '" type="number" id="with-email"
                           class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                           placeholder=""/>
                </div>
                    <br>
                    <br>
                    ';
                        }

                        $sql_server_info3 = "SELECT * FROM server_config where id=?";
						$stmt = $conn->prepare($sql_server_info3);
						$stmt->bind_param('i', $value['server_id']);
						$stmt->execute();
						$res_server_info3 = $stmt->get_result();
						$stmt->close();
                        $row_server_info3 = $res_server_info3->fetch_assoc();
                        if ($row_server_info3["reality"] == 'true') {
                            echo '

            <div class="flex relative m-2">
                <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                    ' . $_LANG["dest"] . '
                </span>
                <input name="dest_reality" style="font-size: 14px;" value="' . $value["dest"] . '" type="text" id="with-email"
                       class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                       placeholder="yahoo.com:443" required/>
            </div>       
            <div class="flex relative m-2">
                <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                    ' . $_LANG["spiderX"] . '
                </span>
                <input name="spiderX_reality" style="font-size: 14px;" value="' . $value["spiderX"] . '" type="text" id="with-email"
                       class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                       placeholder="/tc/value" required/>
            </div>
            <div class="flex relative m-2">
                <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                    ' . $_LANG["flow"] . '
                </span>
                <input name="flow_reality" style="font-size: 14px;" value="' . $value["flow"] . '" type="text" id="with-email"
                       class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                       placeholder="/tc/value" required/>
            </div>
                <br>
                    
                <div class="m-1">
                    <label class="text-gray-600 dark:text-gray-400" for="name" style="font-size: 14px">' . $_LANG["serverNames"] . ':
                    <br>
<pre>
[
  "yahoo.com",
  "www.yahoo.com"
]
</pre>
                        <textarea required name="serverNames_reality" style="font-size: 14px" class="mt-2 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray flex-1 w-full px-4 py-2 text-base text-blue-400 placeholder-gray-400 bg-white border border-gray-300 rounded-lg appearance-none focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" id="comment" name="comment" rows="4" cols="30">' . $value["serverNames"] . '</textarea>
                    </label>
                </div>
                            ';
                        } else {

                        }

                        echo '<br>

    <div class="m-1">
        <label class="text-gray-600 dark:text-gray-400" for="name" style="font-size: 14px">' . $_LANG["Description"] . '
            <textarea required name="description_plan" style="font-size: 14px" class="mt-2 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray flex-1 w-full px-4 py-2 text-base text-blue-400 placeholder-gray-400 bg-white border border-gray-300 rounded-lg appearance-none focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent" id="comment" name="comment" rows="2" cols="30">' . $value["descr"] . '</textarea>
        </label>
    </div>


<br>
                  <button name="btn_edit" type="submit" style="background-color: #ccf1db;color:#006e2c !important;"
                  class="justify-end flex px-4 py-2 text-sm font-medium leading-5 text-white transition-colors duration-150 bg-purple-600 border border-transparent rounded-lg active:bg-purple-600 hover:bg-purple-700 focus:outline-none focus:shadow-outline-purple"
                >
                  <span>' . $_LANG["Save2"] . '</span>
                </button>
                </form>

                     </div>
                </div>
                            
                            
                            ';

                    endforeach;
                }
                ?>

                <?php
                /* plan edit POST handled in includ/plan_helpers.php via WizPanelPostHandler */
                ?>


            </div>
        </main>
    </div>
    </div>


    <!-- Modal backdrop. This what you want to place close to the closing body tag -->
    <div
        x-show="isModalOpen"
        x-transition:enter="transition ease-out duration-150"
        x-transition:enter-start="opacity-0"
        x-transition:enter-end="opacity-100"
        x-transition:leave="transition ease-in duration-150"
        x-transition:leave-start="opacity-100"
        x-transition:leave-end="opacity-0"
        class="fixed inset-0 z-30 flex items-end bg-black bg-opacity-30 sm:items-center sm:justify-center"
    >
        <!-- Modal -->
        <div
            x-show="isModalOpen"
            x-transition:enter="transition ease-out duration-150"
            x-transition:enter-start="opacity-0 transform translate-y-1/2"
            x-transition:enter-end="opacity-100"
            x-transition:leave="transition ease-in duration-150"
            x-transition:leave-start="opacity-100"
            x-transition:leave-end="opacity-0  transform translate-y-1/2"
            @click.away="closeModal"
            @keydown.escape="closeModal"
            class="w-full px-6 py-4 overflow-hidden bg-white rounded-t-lg dark:bg-gray-800 sm:rounded-lg sm:m-4 sm:max-w-xl"
            role="dialog"
            id="modal"
        >
            <!-- Remove header if you don't want a close icon. Use modal body to place modal tile. -->

            <?php
            plan_insert2($conn);
            ?>
            <form id="insert_plans2">
                <!-- Modal body -->
                <div style="height: 300px;overflow-y: scroll;">
                    <p class="m-4 dark:text-gray-200 text-gray-700">
                        <b style="color: #2ba84a">tip:</b> Create a multiple plan
                    </p>
                    <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                        <?php echo $_LANG['title'] ?>
                    </span>
                        <input name="title_plan" style="font-size: 14px;" value="" type="text" id="with-email"
                               class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                               placeholder="" required/>
                    </div>
                <label class="block mt-2 text-sm mx-auto" style="width: 97%;line-height: 16px;">
                    <select required name="protocol_plan"
                            class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">
                        <option value="vless">vless</option>
                        <option value="vmess">vmess</option>
                        <option value="trojan">trojan</option>
                    </select>
                </label>

                    <label class="block mt-2 text-sm mx-auto" style="width: 97%;line-height: 16px;">
                        <select required name="type_plan"
                                class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">
                            <option value="ws">ws</option>
                            <option value="tcp">tcp</option>
                            <option value="grpc">grpc</option>
                        </select>
                    </label>

                    <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                        <?php echo $_LANG['days'] ?>
                    </span>
                        <input name="days_plan" style="font-size: 14px;" value="" type="number" id="with-email"
                               class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                               placeholder="" required/>
                    </div>
                    <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                        <?php echo $_LANG['volume'] ?>
                    </span>
                        <input name="volume_plan" style="font-size: 14px;" value="" type="text" id="with-email"
                               class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                               placeholder="" required/>
                    </div>
                    <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                        <?php echo $_LANG['Price3'] ?>
                    </span>
                        <input name="price_plan" style="font-size: 14px;" value="" type="number" id="with-email"
                               class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                               placeholder="" required/>
                    </div>
                    <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                        <?php echo $_LANG['limitip'] ?>
                    </span>
                        <input  name="limitip_plan" style="font-size: 14px;" value="" type="number" id="with-email"
                                class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                                placeholder="" required/>
                    </div>
                    <label class="block mt-2 text-sm mx-auto" style="width: 98%">
                        <select required name="name_servers_wizwiz" id="insert_plans2_server"
                                class="wiz-plan-server-select block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">
                            <?php
                            $sql_category_server_info = "SELECT * FROM server_info";
							$stmt = $conn->prepare($sql_category_server_info);
							$stmt->execute();
							$res_category_server_info = $stmt->get_result();
							$stmt->close();
                            while ($row_category_server_info = $res_category_server_info->fetch_assoc()) {
                                $category_server_info_id_db = $row_category_server_info['id'];
                                $category_server_info_db = $row_category_server_info['title'];

                                echo '<option value="' . $category_server_info_id_db . '">' . $category_server_info_db . '</option>';


                            }
                            ?>
                        </select>
                    </label>
                    <div class="wiz-inbound-picker m-2" data-server-select="#insert_plans2_server" data-input-name="inbound_ids_plan"></div>
                    <div class="flex relative m-2">
                    <span class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-l-md inline-flex  items-center px-3 border-t bg-white border-l border-b  border-gray-300 text-gray-500 shadow-sm text-sm">
                         <?php echo $_LANG['count'] ?>
                    </span>
                        <input name="count_plan" style="font-size: 14px;" value="" type="number" id="with-email"
                               class="dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray rounded-r-lg flex-1 appearance-none border border-gray-300 w-full py-2 px-4 bg-white text-red-400 placeholder-gray-400 shadow-sm text-base focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                               placeholder="" required/>
                    </div>
                    <label class="block mt-2 text-sm mx-auto" style="width: 98%">
                        <select required name="name_category_wizwiz"
                                class="block w-full mt-1 text-sm dark:text-gray-300 dark:border-gray-600 dark:bg-gray-700 form-select focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:focus:shadow-outline-gray">

                            <?php

                            $sql_select_category = "SELECT * FROM server_categories";
							$stmt = $conn->prepare($sql_select_category);
							$stmt->execute();
							$res_select_category = $stmt->get_result();
							$stmt->close();
                            while ($row_select_category = $res_select_category->fetch_assoc()) {
                                $row_title_category = $row_select_category['title'];
                                $row_id_category = $row_select_category['id'];
                                echo '<option value="' . $row_id_category . '">' . $row_title_category . '</option>';

                            }
                            ?>
                        </select>
                    </label>
                    <div class="m-1">
                        <label class="text-gray-600" for="name" style="font-size: 14px">
                        <textarea placeholder="<?php echo $_LANG['Descriptiontitle'] ?>" name="description" style="font-size: 14px"
                                  class="mt-2 dark:border-gray-600 dark:bg-gray-700 focus:border-purple-400 focus:outline-none focus:shadow-outline-purple dark:text-gray-300 dark:focus:shadow-outline-gray flex-1 w-full px-4 py-2 text-base text-blue-400 placeholder-gray-400 bg-white border border-gray-300 rounded-lg appearance-none focus:outline-none focus:ring-2 focus:ring-blue-200 focus:border-transparent"
                                  id="description_field_add" rows="2" cols="30"></textarea>
                        </label>
                    </div>
                </div>
                <footer class="flex flex-col items-center justify-end px-6 py-3 -mx-6 -mb-4 space-y-4 sm:space-y-0 sm:space-x-6 sm:flex-row bg-gray-50 dark:bg-gray-800">
                    <button type="button" style="border: 1px solid #e76d81"
                            class="w-full inline-flex items-center justify-center px-5 py-3 transition-colors duration-150 border border-transparent rounded-lg sm:w-auto sm:px-4 sm:py-2 hover:bg-red-100 "
                            aria-label="close" @click="closeModal">
                        <svg xmlns="http://www.w3.org/2000/svg" fill="#e76d81" id="Outline" viewBox="0 0 24 24" width="21"
                             height="21">
                            <path d="M23.707.293h0a1,1,0,0,0-1.414,0L12,10.586,1.707.293a1,1,0,0,0-1.414,0h0a1,1,0,0,0,0,1.414L10.586,12,.293,22.293a1,1,0,0,0,0,1.414h0a1,1,0,0,0,1.414,0L12,13.414,22.293,23.707a1,1,0,0,0,1.414,0h0a1,1,0,0,0,0-1.414L13.414,12,23.707,1.707A1,1,0,0,0,23.707.293Z"/>
                        </svg>
                    </button>
                    <button style="border: 1px solid #41c76e" name="add_plans_title" type="submit" @click="closeModal"
                            class="inline-flex items-center justify-center w-full px-5 py-3 text-sm font-medium leading-5 text-white transition-colors duration-15 border border-transparent rounded-lg sm:w-auto sm:px-4 sm:py-2 hover:bg-green-100 ">
                        <svg xmlns="http://www.w3.org/2000/svg" id="Outline" fill="#41c76e" viewBox="0 0 24 24" width="22"
                             height="22">
                            <path d="M22.319,4.431,8.5,18.249a1,1,0,0,1-1.417,0L1.739,12.9a1,1,0,0,0-1.417,0h0a1,1,0,0,0,0,1.417l5.346,5.345a3.008,3.008,0,0,0,4.25,0L23.736,5.847a1,1,0,0,0,0-1.416h0A1,1,0,0,0,22.319,4.431Z"/>
                        </svg>
                    </button>
                </footer>
            </form>
<?php
include 'includ/footer.php';
?>
