<?php

if ((int)$admin_info->role !== 1) {
    echo '<script> location.replace("dashboard"); </script>';
    exit();
}

?>

<div class="container-fluid">
    <div class="row">
        <div class="col-lg-12">
            <div class="page-title-box">
                <div class="align-items-center mx-1 mb-5 rounded rounded-5">
                    <div class="card m-b-30 w-100">
                        <div class="card-header">
                            <div id="loading" class="loading">
                                <div class="spinner-grow text-primary" style="margin-top: auto;margin-bottom: auto"
                                     role="status">
                                    <span class="sr-only">بارگذاری...</span>
                                </div>
                                <div class="spinner-grow text-primary" style="margin-top: auto;margin-bottom: auto"
                                     role="status">
                                    <span class="sr-only">بارگذاری...</span>
                                </div>
                                <div class="spinner-grow text-primary" style="margin-top: auto;margin-bottom: auto"
                                     role="status">
                                    <span class="sr-only">بارگذاری...</span>
                                </div>
                            </div>
                            <div class="card-title">
                                <h5>ثبت نرخ تسویه حساب</h5>
                            </div>
                            <hr>
                                <div class="row form-group">
                                    <div class="col-md-3 text-center mb-3">
                                        <br><br>
                                        <span class="mt-3">تسویه اردری</span>
                                        <input onchange="change_settlement_type()" type="checkbox" id="type_settling" name="type_settling"
                                               class="ios8-switch mt-3" <?php echo((isset($_GET['type_settling']) && $_GET['type_settling'] == "on") ? "checked" : ""); ?>>
                                        <label for="type_settling"></label>
                                        <span class="mt-3">&nbsp;&nbsp;تسویه عادی</span>
                                    </div>
                                    <div id="div-normal"  class="col-md-3 text-center mb-3 <?php echo((isset($_GET['type_settling']) && $_GET['type_settling'] == "on") ? "d-none" : ""); ?>">
                                        <label class="fa-pull-right" for="date">زمان تسویه</label>
                                        <select id="date" name="date" class="form-control select2" required>
                                            <option value="0">انتخاب کنید</option>
                                            <?php
                                            $extra_function = new \Functions\Extra();
                                            $dates = $extra_function->calculator_timestamps_web((isset($_GET['type_settling']) && $_GET['type_settling'] == "on"));

                                            foreach ($dates as $date) {
                                                echo '<option value="' . $date["timestamp"] . '">' . $date["fa_date"] . '</option>';
                                            }

                                            ?>
                                        </select>
                                    </div>
                                    <div id="div-order" class="col-md-3 text-center mb-3 <?php echo((isset($_GET['type_settling']) && $_GET['type_settling'] == "on") ? "" : "d-none"); ?>">
                                        <label class="fa-pull-right" for="date2">زمان تسویه</label>
                                        <select name="date2"  id="date2" class="form-control" required>
                                            <option value="0">همه</option>
                                        </select>
                                    </div>
                                    <div class="col-md-3 text-center mb-3">
                                        <label class="fa-pull-right" for="price">مظنه</label>
                                        <input class="form-control" type="number" id="price" name="price" placeholder="1234.56" style="direction: ltr;" required>
                                    </div>
                                    <div class="col-md-3 text-center mb-3">
                                        <label class="fa-pull-right" for="date">&nbsp</label>
                                        <button class="btn btn-primary w-100" id="submit" type="submit">ثبت تسویه</button>
                                    </div>

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