<?php
include_once "./header.php";
require 'app/config.php';
require 'function.php';




?>

<body>
 

    <input type="hidden" placeholder="default" id="pdpDefault" pdp-id="pdp-6317423" class="pdp-el">
        <div class="fluid-container data-form register-form" style="display: none;">
        <div class="row justify-content-center" id="register-form-container ">
            <div class="col-md-6">
                <span id="close-form" onclick="close_form()">
                    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7ElEQVR4nO2Z3UrDMBTH81Amft01012oCOKt+BAqKA4miCJ44Y0PIIj4id6IdzrfwyFDbzargjYbrZVFWtexuXY2TZN0kD+cu5X9fzkn56QNAFpaWlqZVh2jWWKge8tAhGBEZYTl/ZcBS3VjaIbLvIXRjizTJAoGw63kK6/YPGkHnGYG8MomQwB37AAYWhkC+EwAoNo06goNQKJWJz9GSW54QDOQH6ffN9fUPT1ihrALK36oA2iZp+a7HywQ9voSpVWT0tortTfW1AC4Z8dt80F8HR78C9E2HzxXiweROkBjYY42H8o9EP0y0WPebAEUV9XsARYIHvNEZBuNA8FrnoieA/0g7MIyt3kiY5BFQdCXN27zRNYkjoTgNE9kHiV8iMpTaCbsYryeT1QC+Bu29qfmgz1xwj6xiUyA0G6TEgQQDRDVKpuV51QggEiAfn0+ssUyQgBRAHGGVBoQQAQAy4TlhQBpAyQ5HjQW52mz/Bh+isWSAdyri24jVTPWC0pYJpz9PQUlNDFC3cvzRBO2E8KJYV7cJp4c9TPB8mrYWU7O7nbs34sBkBhAA+CBywDMzqdFA36wAxiwpNw4DgLeMgN4lwvqjaPfyKEpkETe5YJq85aBNgGPvMsF7/u83D0BLa9sEq+8lpaWFpClH85QF54vuUIVAAAAAElFTkSuQmCC" alt="close-window">
                </span>
                <h1 class="text-center mt-3">ثبت نام</h1>

                <form method="post" class="m-4" id="register-form" action="">
                    <div class="form-group">
                        <label for="phone">شماره تلفن</label>
                        <input type="text" class="form-control" id="phone" name="phone" value="09140790345">
                        <label for="first_name"> نام شما</label>
                        <input type="text" class="form-control" id="first_name" name="first_name" >
                        <div class="telegram-field ">
                        <small><a href="https://t.me/MYTReminderbot">ابتدا ربات زیر رااستارت کنید</a></small></br>
                        <label for="telegram_usern">آیدی تلگرام (بدون @ وارد کنید):</label>

                        <input placeholder="MREBR79" type="text" class="form-control" id="telegram_usern" name="telegram_usern">


                    </div>
                 
                    <button type="submit" class="btn btn-primary ">تنظیم</button>
                        
                    </div>
                 
                    
                
                </form>
            </div>
        </div>
    </div>
    <div class="fluid-container data-form" style="display: none;">
        <div class="row justify-content-center" id="main-form-container">
            <div class="col-md-6">
                <span id="close-form" onclick="close_form()">
                    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7ElEQVR4nO2Z3UrDMBTH81Amft01012oCOKt+BAqKA4miCJ44Y0PIIj4id6IdzrfwyFDbzargjYbrZVFWtexuXY2TZN0kD+cu5X9fzkn56QNAFpaWlqZVh2jWWKge8tAhGBEZYTl/ZcBS3VjaIbLvIXRjizTJAoGw63kK6/YPGkHnGYG8MomQwB37AAYWhkC+EwAoNo06goNQKJWJz9GSW54QDOQH6ffN9fUPT1ihrALK36oA2iZp+a7HywQ9voSpVWT0tortTfW1AC4Z8dt80F8HR78C9E2HzxXiweROkBjYY42H8o9EP0y0WPebAEUV9XsARYIHvNEZBuNA8FrnoieA/0g7MIyt3kiY5BFQdCXN27zRNYkjoTgNE9kHiV8iMpTaCbsYryeT1QC+Bu29qfmgz1xwj6xiUyA0G6TEgQQDRDVKpuV51QggEiAfn0+ssUyQgBRAHGGVBoQQAQAy4TlhQBpAyQ5HjQW52mz/Bh+isWSAdyri24jVTPWC0pYJpz9PQUlNDFC3cvzRBO2E8KJYV7cJp4c9TPB8mrYWU7O7nbs34sBkBhAA+CBywDMzqdFA36wAxiwpNw4DgLeMgN4lwvqjaPfyKEpkETe5YJq85aBNgGPvMsF7/u83D0BLa9sEq+8lpaWFpClH85QF54vuUIVAAAAAElFTkSuQmCC" alt="close-window">
                </span>
                <h1 class="text-center mt-3">یادآور</h1>

                <form method="post" class="m-4" id="main-form" action="">
                     <div class="form-group">
                        <label for="send_time">تاریخ</label>
                        <input type="text" class="form-control" id="send_time" name="send_time">
                        <input type="hidden" class="form-control" id="gsend_time" name="gsend_time">
                        <input type="time" id="time" class="time-picker" name="time" data-coreui-toggle="time-picker">
                    </div>
                    
                 
                   
                
                </form>

            </div>
        </div>
    </div>
    </div>
    </div>
    <div class=" fluid-container row justify-content-center" id="recent-reminders" style="display:none;">
        <span id="close-recent-reminders" onclick="close_recent_reminders()"> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7ElEQVR4nO2Z3UrDMBTH81Amft01012oCOKt+BAqKA4miCJ44Y0PIIj4id6IdzrfwyFDbzargjYbrZVFWtexuXY2TZN0kD+cu5X9fzkn56QNAFpaWlqZVh2jWWKge8tAhGBEZYTl/ZcBS3VjaIbLvIXRjizTJAoGw63kK6/YPGkHnGYG8MomQwB37AAYWhkC+EwAoNo06goNQKJWJz9GSW54QDOQH6ffN9fUPT1ihrALK36oA2iZp+a7HywQ9voSpVWT0tortTfW1AC4Z8dt80F8HR78C9E2HzxXiweROkBjYY42H8o9EP0y0WPebAEUV9XsARYIHvNEZBuNA8FrnoieA/0g7MIyt3kiY5BFQdCXN27zRNYkjoTgNE9kHiV8iMpTaCbsYryeT1QC+Bu29qfmgz1xwj6xiUyA0G6TEgQQDRDVKpuV51QggEiAfn0+ssUyQgBRAHGGVBoQQAQAy4TlhQBpAyQ5HjQW52mz/Bh+isWSAdyri24jVTPWC0pYJpz9PQUlNDFC3cvzRBO2E8KJYV7cJp4c9TPB8mrYWU7O7nbs34sBkBhAA+CBywDMzqdFA36wAxiwpNw4DgLeMgN4lwvqjaPfyKEpkETe5YJq85aBNgGPvMsF7/u83D0BLa9sEq+8lpaWFpClH85QF54vuUIVAAAAAElFTkSuQmCC" alt="close-window">
                </span>
        <div class="col-md-11">

            <div class="card">
                <div class="card-body">
                    <div class="card-header">
                        <h2>یادآور های در انتظار</h2>
                        <table id="pending-reminder-table" class="table table-responsive">
                            <thead>
                                <tr>
                                    <th>شماره موبایل</th>
                                    <th>تاریخ</th>
                                    <th>پیام</th>
                                    <th>وضعیت</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody id="pending-reminder-tablebody">
                            </tbody>
                        </table>
                    </div>
                </div>


                
                    <div class="card-body">
                        <div class="card-header">
                            <h4>یادآور های تکمیل شده</h4>
                            <table id="complete-reminder-table" class="table table-responsive">
                                <thead>
                                    <tr>
                                        <th>شماره موبایل</th>
                                        <th>تاریخ</th>
                                        <th>پیام</th>
                                        <th>وضعیت</th>
                                    </tr>
                                </thead>

                                <tbody id="complete-reminder-tablebody">
                                </tbody>
                            </table>

                        </div>
                    </div>

                
            </div>
        </div>

       
    </div>
     <span id="set-user-random" class=" fixed-top  border border-info ">تنظیم رندوم کاربران </span>
    <span id="all-reminder" class=" fixed-bottom  border border-info ">کل یادآورها</span>
    <span id="register-reminder" class=" fixed-bottom border border-info "> ثبت نام</span>
    <script src="js/jquery-1.10.1.min.js"></script>
    <script src="js/persianDatepicker.js"></script>
    <script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
    <script src="js/main.js"></script>
    <script>
        $(function() {
            //usage
            $("#send_time").persianDatepicker({
                theme: "latoja",
                cellWidth: 14,
                cellHeight: 2,
                fontSize: 12,
                formatDate: "YYYY/MM/DD hh:mm:ss"

            });

            //themes
            $("#pdpDefault").persianDatepicker({
                alwaysShow: true,
                formatDate: "YYYY/MM/DD hh:mm:ss"
            });








        });
    </script>
    <?php
    $stmt_complete = $db->prepare("SELECT * FROM phone  WHERE status = ?");
    $stmt_complete->execute(["completed"]);

    $row = $stmt_complete->fetch();

    while ($row = $stmt_complete->fetch()) {


    ?>
        <div class="completed-remider" data-complete=<?php echo explode(" ", $row["send_time"])[0]; ?> style="display:none;"></div>
    <?php

    }
    $stmt_pending = $db->prepare("SELECT * FROM phone  WHERE status = ?");
    $stmt_pending->execute(["pending"]);

    $row = $stmt_pending->fetch();

    while ($row = $stmt_pending->fetch()) {


    ?>
        <div class="pending-remider" data-complete=<?php echo explode(" ", $row["send_time"])[0]; ?> style="display:none;"></div>
    <?php

    }
    ?>
    <script>
        function date_status() {
            setTimeout(function() {
                let completed_date = $(".completed-remider");
                let completed_day_el;

                completed_date.each(function() {
                    completed_day_el = $(this).attr("data-complete").split("-")
                    completed_day_el[1] = completed_day_el[1].charAt(0).replace("0", "").concat(completed_day_el[1].charAt(1));
                    completed_day_el[2] = completed_day_el[2].charAt(0).replace("0", "").concat(completed_day_el[2].charAt(1));
                    completed_day_el = completed_day_el.toString();
                    completed_day_el = completed_day_el.replaceAll(",", "/");


                    $(".day.cell[data-gdate='" + completed_day_el + "']").addClass("bg-success");





                });
            }, 1000);
            setTimeout(function() {
                let pending_date = $(".pending-remider");
                let pending_day_el;

                pending_date.each(function() {
                    pending_day_el = $(this).attr("data-complete").split("-")
                    pending_day_el[1] = pending_day_el[1].charAt(0).replace("0", "").concat(pending_day_el[1].charAt(1));
                    pending_day_el[2] = pending_day_el[2].charAt(0).replace("0", "").concat(pending_day_el[2].charAt(1));
                    pending_day_el = pending_day_el.toString();
                    pending_day_el = pending_day_el.replaceAll(",", "/");

                    if ($(".day.cell[data-gdate='" + pending_day_el + "']").hasClass("bg-success")) {

                    } else {
                        $(".day.cell[data-gdate='" + pending_day_el + "']").addClass("bg-warning");
                    }






                });
            }, 1000);
        }
    </script>
</body>

</html>