<?php include("../elemetns_web/header.php") ?>
<?php include("../../assets/script/login/login_check.php");
include("../../assets/script/manipulationpost_function/manipulationpost.php");
?>

<div class="container_addpost">
    <form class="addpost" method="post" enctype="multipart/form-data">

        <?php include("../../assets/script/file/script.php") ?>
        <article class="post">

            <input type="hidden" name="id" value="<?php echo $id ?>">

            <div class="content">

                <div class="img_container">
                    <img src="../../assets/img<?php echo $img ?>" alt="wybierz zdjecie" class="img_post">
                    <button id="select_images_add" type="button">Wybierz zdjecie</button>
                </div>

                <div class="content_data">
                    <input class="post_title" type="text" name="tytul" placeholder="tytuł" required minlength="10" maxlength="70" value="<?php echo $tytulpost ?>"></input>
                    <textarea class="post_content" name="tresc" placeholder="tresc" required minlength="100" maxlength="3000"><?php echo $trescpost ?></textarea>
                </div>

            </div>

        </article>

        <div class="file_and_com <?php echo $erro ?>">

            <div id="menager_file">

                <div id="select_img" class="menager_file_views">

                    <div class="fold">

                        <?php foreach ($fold_list as $fold) { ?>
                            <button type="button" class="fold_select"><?php echo $fold['name_fold'] ?></button>

                        <?php } ?>

                    </div>

                    <div id="fold_in_views">

                        <?php foreach ($fold_list as $fold_data) { ?>

                            <section id="<?php echo $fold_data["name_fold"] ?>" class="folder_in_view">

                                <?php foreach ($fold_data["list_file"] as $file_data) { ?>
                                    <?php if (isset($imgpost) && $file_data["dir_img"] == $imgpost) { ?>
                                        <div class="img_select">

                                            <img src=" <?php echo $file_data["dir_img_pre"] ?>">
                                            <label for="file">
                                                <p><?php echo $file_data["name_img"] ?></p>
                                            </label>
                                            <input value="<?php echo $file_data["dir_img"] ?>" name="filedir" type="radio" checked />

                                        </div>
                                    <?php } else { ?>
                                        <div class="img_select">

                                            <img src=" <?php echo $file_data["dir_img_pre"] ?>">
                                            <label for="file">
                                                <p><?php echo $file_data["name_img"] ?></p>
                                            </label>
                                            <input value="<?php echo $file_data["dir_img"] ?>" name="filedir" type="radio" />

                                        </div>
                                    <?php } ?>

                                <?php } ?>

                            </section>

                        <?php } ?>

                        <div class="nav_folder">

                            <p class="select_file"></p>
                            <button id="x" type="button">wybierz zdjecie</button>

                        </div>

                    </div>

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


        <button type="submit" name=<?php echo $names_sub ?>><?php echo $text_button ?></button>
    </form>
</div>
<script src="../../assets/js/validation.js"></script>
<script src="../../assets/js/fold_select.js"></script>

<?php include("../elemetns_web/footer.php") ?>