<?php



include("asl.php");

error_reporting(E_ALL);
ini_set('display_errors', '0');

?>



<!DOCTYPE HTML>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html ; charset=utf-8" />
    <meta http-equiv="content-type" content="text/html" />
    <meta name="author" content="persian" />

    <title>طراحی ربات ahp</title>


    <link rel="Stylesheet" type="text/css" href="style.css" />


    <style>
        @font-face {
            font-family: 'amir';
            src: url('font/BKoodakBold.ttf')format('truetype'),
                url('font/BKoodakBold.eot')format('eot'),
                url('font/BKoodakBold.woff')format('woff');

        }

        .date-picker-container {
    padding: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.date-field {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-field label {
    min-width: 80px;
    color: #333;
    font-weight: 500;
}

.date-input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    width: 100%;
    max-width: 200px;
    background-color: #fff;
    transition: border-color 0.3s ease;
}

.date-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 5px rgba(0,123,255,0.3);
}

.submit-btn {
    width: 100%;
    padding: 10px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.submit-btn:hover {
    background-color: #218838;
}

    </style>


</head>

<body dir="rtl" align="center">
    <div align="center">
        <?php

        //   import_request_variables("p" , "a_");


        //old import
        function checkarray($summerarray, $mainkey, $mainarray)
        {
            if (in_array($mainkey, $summerarray)) {
                unset($mainarray["$mainkey"]);
                return $mainarray;
            } else {
                return "ok";
            }
        }

        $summerarray = array();
        $artest = $_POST;
        foreach ($artest as $postinfo) {

            $ar_mainkey = array_search($postinfo, $artest);
            if (checkarray($summerarray, $ar_mainkey, $artest) != "ok") {
                $artest = checkarray($summerarray, $ar_mainkey, $artest);
                $ar_mainkey = array_search($postinfo, $artest);
            }
            ${'a_' . $ar_mainkey} = $postinfo;
            $summerarray[] = $ar_mainkey;
        }
        //old import


        try {
            $conn = new PDO("mysql:host=$servername;dbname=$mydb", $username, $password,  array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
            // set the PDO error mode to exception

            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (PDOException $e) {
            echo "Connection failed: " . $e->getMessage();
        }




        $sql = "select * from admin";
        $stmt =   $conn->prepare($sql);
        $stmt->execute();

        $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
        $show = $stmt->fetch();

        $user = $show["user"];
        $pass = $show["pass"];


        $getpass = hash_hmac('md5', $a_pass, 'salt');





        if ($user == $a_user && $pass == $getpass) {







            if ($a_noa == "insertnewplace") {




                if ($a_ispic == "on" || $a_isvideo == "on") {


                    //uploading


                    if (!$_FILES['myfile']['name'] == "" && $_FILES["myfile"]["error"] == 0) {



                        $ext = end(explode('.', $_FILES['myfile']['name']));

                        $formats = array('jpg', 'JPG', 'gif', 'GIF', 'png', 'PNG', 'RAR', 'rar', 'ZIP', 'zip', 'mp4', '3gp', 'mov');
                        if (!in_array($ext, $formats)) {

                            print "<p style='color:green' >پسوند معتبر برای آپلود نیست</p>";
                        } elseif (file_exists('upload/' . $_FILES["myfile"]["name"])) {
                            print "<p style='color:green' >متاسفیم این فایل قبلا اپلود شده لطفا نام ان را تغییر دهید</p>";
                        } elseif (536870912 < $_FILES["myfile"]["size"]) {


                            print "<p style='color:green' >سایز فایل باید کمتر از نیم گیگ باشد</p>";
                        } else {
                            $path = "upload/" . $_FILES["myfile"]["name"];
                            move_uploaded_file($_FILES["myfile"]["tmp_name"], $path);
                            print "
        <span class='green' >
        اپلود با موفقیت انجام 
        شد
        </span>
        ";
                        }
                        $namemyfile = $_FILES["myfile"]["name"];
                    }


                    //uploading
                    $sql = "insert into place (name,info,address,ispic,isvideo,type,sellorhire,city) values (\"$a_name\" , \"$a_info\",\"$namemyfile\", \"$a_ispic\",\"$a_isvideo\",\"$a_type\",\"$a_sellorhire\",\"$a_city\" )";
                    $conn->exec($sql);
                    echo "<p style='color:green' >محصول ذخیره شد</p>";
                } else {
                    $sql = "insert into place (name,info,address,ispic,isvideo,type,sellorhire,city) values (\"$a_name\" , \"$a_info\",\"$namemyfile\", \"$a_ispic\",\"$a_isvideo\",\"$a_type\",\"$a_sellorhire\",\"$a_city\" )";
                    $conn->exec($sql);



                    echo "<p style='color:green' >محصول ذخیره شد بدون عکس و کلیپ</p>";
                }
            }





            if ($a_newuser == "") {
            } else {

                $newpass = hash_hmac('md5', $a_newpass, 'salt');
                $sql = "update admin set user = \"$a_newuser\"  , pass=\"$newpass\"  ";
                $conn->exec($sql);
                echo "<p style='color:green' >يوزرنيم و پسورد با موفقيت به روز رساني شد لطفا از پنل خارج شده مجددا وارد شويد</p>";



                function redirect($url)
                {
                    if (!headers_sent()) {
                        header('Location: ' . $url);
                        exit;
                    } else {
                        echo '<script type="text/javascript">';
                        echo 'window.location.href="' . $url . '";';
                        echo '</script>';
                        echo '<noscript>';
                        echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
                        echo '</noscript>';
                        exit;
                    }
                }
                redirect("enter.php");
            }
        } else {
            echo "<p style='color:red' >يوزرنيم و يا پسورد اشتباه وارد شده </p><br />
                      <a href='enter.php' target='_blank' >بازگشت به صفحه ی ورود</a>
              
                      ";



            function redirect($url)
            {
                if (!headers_sent()) {
                    header('Location: ' . $url);
                    exit;
                } else {
                    echo '<script type="text/javascript">';
                    echo 'window.location.href="' . $url . '";';
                    echo '</script>';
                    echo '<noscript>';
                    echo '<meta http-equiv="refresh" content="0;url=' . $url . '" />';
                    echo '</noscript>';
                    exit;
                }
            }




            redirect("enter.php");
        }














        function sendmessage($text, $chatid, $keys)
        {

            $send = "https://api.telegram.org/bot5763525832:AAGC0TGrBxfDQAvAi3u3dFMf1JYeBNdb2fY/sendmessage?chat_id=$chatid&text=$text&parse_mode=Html&reply_markup=$keys";
            $sended = file_get_contents($send);
        }



        function sendphoto($address, $chatid, $key, $caption)
        {

            $bot_url    = "https://api.telegram.org/bot5763525832:AAGC0TGrBxfDQAvAi3u3dFMf1JYeBNdb2fY/";
            $url = $bot_url . "sendPhoto?caption=$caption&reply_markup=$key&chat_id=" . $chatid;
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                "Content-Type:multipart/form-data"
            ));
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, array(
                "photo"     => "@" . "upload/" . $address,
            ));
            curl_setopt($ch, CURLOPT_INFILESIZE, filesize("upload/" . $address));
            $output = curl_exec($ch);
            return $output;
        }



        if ($a_noa == "sending") {


            if (!$_FILES['myfile']['name'] == "" && $_FILES["myfile"]["error"] == 0) {



                $ext = end(explode('.', $_FILES['myfile']['name']));

                $formats = array('jpg', 'JPG', 'gif', 'GIF', 'png', 'PNG', 'RAR', 'rar', 'ZIP', 'zip', 'mp4', '3gp', 'mov', 'mp3', 'ogg', 'MP4', '3GP', 'MOV', 'MP3', 'OGG');
                if ($ext == "jpg" || $ext == "JPG" || $ext == "png" || $ext == "PNG") {
                    $filetype = "pic";
                } elseif ($ext == "gif" || $ext == "GIF" || $ext == "mp4" || $ext == "MP4" || $ext == "3gp" || $ext == "3GP" || $ext == "mov" || $ext == "MOV") {
                    $filetype = "video";
                } elseif ($ext == "mp3" || $ext == "MP3" || $ext == "ogg") {
                    $filetype = "voice";
                }


                if (!in_array($ext, $formats)) {

                    print "<p style='color:green' >پسوند معتبر برای آپلود نیست</p>";
                } elseif (file_exists('upload/' . $_FILES["myfile"]["name"])) {
                    print "<p style='color:green' >متاسفیم این فایل قبلا اپلود شده لطفا نام ان را تغییر دهید</p>";
                } elseif (536870912 < $_FILES["myfile"]["size"]) {


                    print "<p style='color:green' >سایز فایل باید کمتر از نیم گیگ باشد</p>";
                } else {
                    $path = "upload/" . $_FILES["myfile"]["name"];
                    move_uploaded_file($_FILES["myfile"]["tmp_name"], $path);
                }
                $namemyfile = $_FILES["myfile"]["name"];
            }


            $stmt = $conn->prepare("SELECT * FROM users LIMIT $a_ifrom, $a_ito");
            $stmt->execute();

            // set the resulting array to associative
            $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);

            $l = $stmt->fetchAll();

            $forwork =  ($a_ito - $a_ifrom) + 2;

            for ($i = 0; $i < $forwork; $i++) {

                // print"in $i  \\\ ".$l[$i]["chatid"]."<br />";

                if ($namemyfile == "" || $namemyfile == " ") {
                    sendmessage(urlencode("$a_info"), $l[$i]["chatid"], "");
                } else {
                    sendphoto($namemyfile, $l[$i]["chatid"], "", urlencode("$a_info"));
                }
                //sendmessage($text,'80433998',$key);
            }
        }



        if(isset($_POST['users_list'])){
            
            $sql = "update admin set users_list = '".$_POST['users_list']."'  ";
            $conn->exec($sql);
            print("اپدیت انجام شد");
        }


        elseif(isset($_POST['a_subgroup'])){
            
            $sql = "update admin set a_subgroup = '".$_POST['a_subgroup']."'  ";
            
            $conn->exec($sql);
            print("اپدیت انجام شد");
        }


        elseif(isset($_POST['b_subgroup'])){
            
            $sql = "update admin set b_subgroup = '".$_POST['b_subgroup']."'  ";
            $conn->exec($sql);
            print("اپدیت انجام شد");
        }

        
        
                $sql = "select * from admin";
                $stmt = $conn->prepare($sql);
                $stmt->execute();
        
                $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
                $show = $stmt->fetch();
        
                $user = $show["user"];
                $pass = $show["pass"];
                $users_list=$show["users_list"];
                $a_subgroup=$show["a_subgroup"];
                $b_subgroup=$show["b_subgroup"];
                





// if(isset($_POST['export'])){
//     ob_clean();
//     flush();

//     header('Content-Type: text/csv');
//     header('Content-Disposition: attachment; filename="groupA.csv"');

//     $output = fopen('php://output', 'w');

//     // تعریف ترتیب ستون‌ها، با قرار دادن "C - Problem Value" بعد از "Usage"
//     $columns = ["Gmail", "Password", "Subject", "User", "Problem", "First charge", "Last charge", "Usage", "Date", "Hour"];
    
//     fputcsv($output, $columns);

//     // تابع برای تمیز کردن داده‌ها
//     function cleanData($data) {
//         $data = preg_replace('/[\x00-\x1F\x7F]/', '', $data);
//         $data = trim($data);
//         $data = str_replace(["\n", "\r"], ' ', $data);
//         $data = preg_replace('/\s+/', ' ', $data);
//         return $data;
//     }

//     $stmt = $conn->query("SELECT a, b, `subject`, `name`, problem, c, problem_value, `date`, `hour` FROM a_problems_history");

//     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
//         // اضافه کردن مقدار ترکیب شده بعد از "Usage"
//         $newRow = [
//             cleanData($row["a"]), // Gmail
//             cleanData($row["b"]), // Password
//             cleanData($row["subject"]), // Subject
//             cleanData($row["name"]), // User
//             cleanData($row["problem"]), // Problem
//             cleanData($row["c"]), // First charge
//             cleanData($row["problem_value"]), // Last charge
//             cleanData(floatval($row["c"])-floatval($row["problem_value"])), // C - Problem Value
//             cleanData($row["date"]), // Date
//             cleanData($row["hour"]) // Hour
//         ];

//         fputcsv($output, $newRow);
//     }

//     fclose($output);
//     exit();
// }


if(isset($_POST['export'])){
    ob_clean();
    flush();

    header('Content-Type: text/csv');
    header('Content-Disposition: attachment; filename="groupA.csv"');

    $output = fopen('php://output', 'w');

    // Define column order
    $columns = ["Gmail", "Password", "Subject", "User", "Problem", "First charge", "Last charge", "Usage", "Date", "Hour"];
    
    fputcsv($output, $columns);

    // Function to clean data
    function cleanData($data) {
        $data = preg_replace('/[\x00-\x1F\x7F]/', '', $data);
        $data = trim($data);
        $data = str_replace(["\n", "\r"], ' ', $data);
        $data = preg_replace('/\s+/', ' ', $data);
        return $data;
    }

    // Get the full dates from the form
    $fromDate = isset($_POST['fromDate']) ? $_POST['fromDate'] : null;
    $toDate = isset($_POST['toDate']) ? $_POST['toDate'] : null;

    // Base SQL query
    $sql = "SELECT a, b, `subject`, `name`, problem, c, problem_value, `date`, `hour` 
            FROM a_problems_history";

    // Add WHERE clause if dates are provided
    if ($fromDate && $toDate) {
        // Sanitize inputs using $conn->quote()
        $fromDate = $conn->quote($fromDate); // e.g., '2025-03-01'
        $toDate = $conn->quote($toDate);     // e.g., '2025-03-11'
        $sql .= " WHERE `date` BETWEEN $fromDate AND $toDate";
    }

    $stmt = $conn->query($sql);

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $newRow = [
            cleanData($row["a"]), // Gmail
            cleanData($row["b"]), // Password
            cleanData($row["subject"]), // Subject
            cleanData($row["name"]), // User
            cleanData($row["problem"]), // Problem
            cleanData($row["c"]), // First charge
            cleanData($row["problem_value"]), // Last charge
            cleanData(floatval($row["c"]) - floatval($row["problem_value"])), // Usage
            cleanData($row["date"]), // Date
            cleanData($row["hour"]) // Hour
        ];

        fputcsv($output, $newRow);
    }

    fclose($output);
    exit();
}

if(isset($_POST['exportB'])){
    ob_clean();
    flush();

    header('Content-Type: text/csv');
    header('Content-Disposition: attachment; filename="groupB.csv"');

    $output = fopen('php://output', 'w');

    // Define column order
    $columns = ["Gmail", "Password","Subject", "User", "Problem", "First charge", "Last charge", "Usage", "Date", "Hour"];
    
    fputcsv($output, $columns);

    // Function to clean data
    function cleanData($data) {
        $data = preg_replace('/[\x00-\x1F\x7F]/', '', $data);
        $data = trim($data);
        $data = str_replace(["\n", "\r"], ' ', $data);
        $data = preg_replace('/\s+/', ' ', $data);
        return $data;
    }

    // Get the full dates from the form
    $fromDate = isset($_POST['fromDate']) ? $_POST['fromDate'] : null;
    $toDate = isset($_POST['toDate']) ? $_POST['toDate'] : null;

    // Base SQL query
    $sql = "SELECT a,  b,`subject`, `name`, problem, c, problem_value, `date`, `hour` 
            FROM a_problems_history";

    // Add WHERE clause if dates are provided
    if ($fromDate && $toDate) {
        // Sanitize inputs using $conn->quote()
        $fromDate = $conn->quote($fromDate); // e.g., '2025-03-01'
        $toDate = $conn->quote($toDate);     // e.g., '2025-03-11'
        $sql .= " WHERE `date` BETWEEN $fromDate AND $toDate";
    }

    $stmt = $conn->query($sql);

    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $newRow = [
            cleanData($row["a"]), // Gmail
            cleanData($row["b"]), // Password
            cleanData($row["subject"]), // Subject
            cleanData($row["name"]), // User
            cleanData($row["problem"]), // Problem
            cleanData($row["c"]), // First charge
            cleanData($row["problem_value"]), // Last charge
            cleanData(floatval($row["c"]) - floatval($row["problem_value"])), // Usage
            cleanData($row["date"]), // Date
            cleanData($row["hour"]) // Hour
        ];

        fputcsv($output, $newRow);
    }

    fclose($output);
    exit();
}





        ?>

        <h1 class="white">پنل ربات </h1>
        <br></br>
        <h4 class="white">پنل مدیریتی ربات</h4>
        <div id="content" align="right">
            <div id="content-content">
                <table>
                    <tr>
                        <td><img class="radius" src="images/user.png" /></td>
                        <td class="gray" valign="bottom">خوش آمدید <?php print $userse; ?></td>

                        <td>
                            <form target="_blank" method='post' action='users.php'>


                                <input type='submit' style='width:100%' class='font' value='نمایش کاربران' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>

                  

                        <td>
                            <form target="_blank" method='post' action='group_a.php'>


                                <input type='submit' style='width:100%' class='font' value='گروه A' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>

                        <td>
                            <form target="_blank" method='post' action='group_b.php'>


                                <input type='submit' style='width:100%' class='font' value='گروه B' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>


                        <td>
                            <form target="_blank" method='post' action='a_problems.php'>


                                <input type='submit' style='width:100%' class='font' value='اکانت های مشکل دار A' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>
                        
                   
                        <td>
                            <form target="_blank" method='post' action='b_problems.php'>


                                <input type='submit' style='width:100%' class='font' value='اکانت های مشکل دار B' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>

                        <td>
                            <form target="_blank" method='post' action='a_search.php'>


                                <input type='submit' style='width:100%' class='font' value='تاریخچه A' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>
                        

                        <td>
                            <form target="_blank" method='post' action='b_search.php'>


                                <input type='submit' style='width:100%' class='font' value='تاریخچه B' />
                                <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" class='font' />
                            </form>
                        </td>

                        
                    </tr>
                   

                    

                </table>



                <br />
                <br />
                <a href="https://telegram.me/" target="_blank">
                    <input class='button-blue' style="width:725px;" type="button" value="رفتن به داخل ربات" />
                </a>

                <br />
                <div id="fish">










                <h3 class='gray'>◄ خانه</h3>




                    <h5 class='gray'>◄ ارسال خبر جدید</h5>

                    <form method='post' enctype='multipart/form-data' action='index.php'>
                        <table>
                            <tr>

                                <th class='th'>از </th>
                                <th class='th'>تا </th>
                                <th class='th'>متن برای ارسال</th>





                            </tr>
                            <tr>
                                <td align='center' class='td'><input placeholder="از " type='text' name='ifrom' class='font' /> </td>
                                <td align='center' class='td'><input placeholder="تا " type='text' name='ito' class='font' /> </td>
                                <td align='center' class='td'><textarea name="info" style='height:200px'></textarea> </td>


                            </tr>


                            <tr>

                                <td>
                                    <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                    <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" />
                                    <!--
        <input type="file"  id="file" name="myfile"/>
        -->
                                    <input type='hidden' name='noa' value='sending' /><input type='submit' class='font' value='ارسال' />
                                </td>

                            </tr>

                        </table>
                    </form>














                    <hr />
                    <hr />
                    <hr />

                    <br />
                    <br />
                    <br />
                    <br />

<!-- 
                    <h3>شماره کاربران مجاز</h3>

                    <form method='post' action='index.php'>
                        <table>
                            <tr>
                                <th class='th'>لیست</th>



                            </tr>
                            <tr>
                                <td align='center' class='td'>
                                    
                                
                                <textarea  style='width:750px' type='text' name='admin_list' class='font' ><?php print$users_list; ?></textarea> 
                            
                            </td>
                    




                            </tr>


                            <tr>

                                <td> 
                                    
                                <input type='hidden' name='user' value="<?php echo $a_user ?>" />
                                    <input type='hidden' name='pass' value="<?php echo $a_pass ?>" />

                                <input type='submit' class='font' value='تغيير' /> </td>

                            </tr>

                        </table>
                    </form>


                    <hr />
                    <hr />
                    <hr />

                    <br />
                    <br />
                    <br />
                    <br /> -->

                    <?php
                        if(isset($_POST['1_month'])){
                            // var_dump($_POST);

                            $sql = "update packages set 1_month = '" . $_POST['1_month'] . "'  , 6_month='" . $_POST['6_month'] . "', 12_month='" . $_POST['12_month'] . "'  ";
                            $conn->exec($sql);
                        }


                        if(isset($_POST['groups'])){
                            $a = $_POST['a_group'];
                            $b = $_POST['b_group'];
                            $c = $_POST['c_group'];
                            $d = $_POST['d_group'];
                            $e = $_POST['e_group'];
                            $f = $_POST['f_group'];
                            $g = $_POST['g_group'];
                            
                            $sql = "update admin set a_group='$a', b_group='$b', c_group='$c', d_group='$d', e_group='$e', f_group='$f', g_group='$g'";
                            $conn->exec($sql);
                        }


                        $sql = "select * from packages";
                        $stmt = $conn->prepare($sql);
                        $stmt->execute();
                        $stmt->setFetchMode(PDO::FETCH_ASSOC);
                        $getter = $stmt->fetch();
                        $numrowfusers = $stmt->rowCount();

                        $one_month = $getter['1_month'];
                        $six_month = $getter['6_month'];
                        $twelve_month = $getter['12_month'];


                        $sql = "select * from admin  ";
                        $stmt = $conn->prepare($sql);
                        $stmt->execute();
                        $stmt->setFetchMode(PDO::FETCH_ASSOC);
                        $getterAdmin = $stmt->fetch();
                    
                    ?>

<!-- 
                    <form method='post' action='index.php'>
                        <table>
                            <tr>
                                <th class='th' >قیمت پکیج یکماهه</th>
                                <th class='th' >قیمت پکیج شش ماهه</th>
                                <th class='th' >قیمت پکیج یکساله</th>


                            </tr>
                            <tr>
                                <td align='center' class='td'><input placeholder="قیمت یکماهه" value="<?php echo $one_month ?>" type='text' name='1_month' class='font' /> </td>
                                <td align='center' class='td'><input placeholder="قیمت شش ماهه" value="<?php echo $six_month ?>" type='text' name='6_month' class='font' /> </td>
                                <td align='center' class='td'>
                                    <input placeholder="قیمت یکساله" type="text" value="<?php echo $twelve_month ?>" name="12_month" class="font" />
                                    <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                    <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" />
                                </td>

                            </tr>

                            <tr>

                                <td> <input type='submit' class='font' value='تغيير' /> </td>

                            </tr>

                        </table>
                    </form>


                    <hr />
                    <hr />
                    <hr />

                    <br />
                    <br />
                    <br />
                    <br /> -->

                    <h5 class='gray'>◄ زمان بندی ها</h5>


                    <form method='post' action='index.php'>
                        <table>
                            <tr>
                                <th class='th'>دسته بندی A </th>
                                <th class='th'>دسته بندی B </th>
                                <!-- <th class='th'>دسته بندی C</th> -->


                            </tr>
                            <tr>
                            <td align='center' class='td'><input type='text' name='a_group' class='font' value="<?php echo $getterAdmin['a_group'] ?>" /> </td>
                            <td align='center' class='td'><input type='text' name='b_group' class='font' value="<?php echo $getterAdmin['b_group'] ?>" /> </td>
                            <!-- <td align='center' class='td'><input  type='text' name='c_group' class='font' value="<?php echo $getterAdmin['c_group'] ?>" /> </td> -->
                                </td>

                            </tr>

                            <!-- <tr>
                                <th class='th'>دسته بندی D </th>
                                <th class='th'>دسته بندی E </th>
                                <th class='th'>دسته بندی F</th>


                            </tr>
                            <tr>
                                <td align='center' class='td'><input  name='d_group' type='text'  class='font' value="<?php echo $getterAdmin['d_group'] ?>"/> </td>
                                <td align='center' class='td'><input  name="e_group"   type='text' class="font" value="<?php echo $getterAdmin['e_group'] ?>"/>
                                <td align='center' class='td'><input  name="f_group"  type='text' class="font" value="<?php echo $getterAdmin['f_group'] ?>"/>
                                </td>

                            </tr> -->


                            <!-- <tr>
                                <th class='th'>دسته بندی G </th>

                            </tr> -->
                            <tr>
                                <!-- <td align='center' class='td'><input  name='g_group' type='text' class='font' value="<?php echo $getterAdmin['g_group'] ?>"/> </td>
                                    <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                    <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" />
                                </td> -->


                                <td> <input type='submit' class='font' name='groups' value='تغيير' /> </td>

                            </tr>

                        </table>
                    </form>

                    <hr>
                    <hr>
                    <hr>

                    <br>
                    <br>
                    <br>


<h4 class='gray' >خروجی اکسل A</h4>
<td>
    <form target="_blank" method='post' action='index.php'>
        <div class="date-picker-container">
            <!-- Date range input fields -->
            <div class="date-field">
                <label for="fromDate">From Date:</label>
                <input type="date" name="fromDate" id="fromDate" class="date-input" required />
            </div>

            <div class="date-field">
                <label for="toDate">To Date:</label>
                <input type="date" name="toDate" id="toDate" class="date-input" required />
            </div>

            <!-- Hidden fields and submit button -->
            <input type='submit' class='submit-btn' value='خروجی اکسل A' />
            <input type='hidden' name='user' value="<?php echo $a_user; ?>" />
            <input type='hidden' name='pass' value="<?php echo $a_pass; ?>" />
            <input type='hidden' name='export'/>
        </div>
    </form>
</td>


<h4 class='gray' >خروجی اکسل B</h4>
<td>
    <form target="_blank" method='post' action='index.php'>
        <div class="date-picker-container">
            <!-- Date range input fields -->
            <div class="date-field">
                <label for="fromDate">From Date:</label>
                <input type="date" name="fromDate" id="fromDate" class="date-input" required />
            </div>

            <div class="date-field">
                <label for="toDate">To Date:</label>
                <input type="date" name="toDate" id="toDate" class="date-input" required />
            </div>

            <!-- Hidden fields and submit button -->
            <input type='submit' class='submit-btn' value='خروجی اکسل B' />
            <input type='hidden' name='user' value="<?php echo $a_user; ?>" />
            <input type='hidden' name='pass' value="<?php echo $a_pass; ?>" />
            <input type='hidden' name='exportB'/>
        </div>
    </form>
</td>


<h4 class='gray' >لیست کاربران مجاز به استفاده</h4>

<form method='post' action='index.php'>
    <table>
        <tr>
            <th class='th'>لیست</th>



        </tr>
        <tr>
            <td align='center' class='td'>
                
            
            <textarea  style='width:750px' type='text' name='users_list' class='font' ><?php print$users_list; ?></textarea> 
        
        </td>





        </tr>


        <tr>

            <td> 
                
            <input type='hidden' name='user' value="<?php echo $a_user ?>" />
                <input type='hidden' name='pass' value="<?php echo $a_pass ?>" />

            <input type='submit' class='font' value='تغيير' /> </td>

        </tr>

    </table>
</form>


                    <hr>
                    <hr>
                    <hr>

                    <br>
                    <br>
                    <br>






<h4 class='gray' >زیرگروه های A</h4>

<form method='post' action='index.php'>
    <table>
        <tr>
            <th class='th'>زیرگروه ها</th>



        </tr>
        <tr>
            <td align='center' class='td'>
                
            
            <textarea  style='width:750px' type='text' name='a_subgroup' class='font' ><?php print$a_subgroup; ?></textarea> 
        
        </td>





        </tr>


        <tr>

            <td> 
                
            <input type='hidden' name='user' value="<?php echo $a_user ?>" />
                <input type='hidden' name='pass' value="<?php echo $a_pass ?>" />

            <input type='submit' class='font' value='تغيير' /> </td>

        </tr>

    </table>
</form>


                    <hr>
                    <hr>
                    <hr>

                    <br>
                    <br>
                    <br>


<h4 class='gray' >زیرگروه های B</h4>

<form method='post' action='index.php'>
    <table>
        <tr>
            <th class='th'>زیرگروه ها</th>



        </tr>
        <tr>
            <td align='center' class='td'>
                
            
            <textarea  style='width:750px' type='text' name='b_subgroup' class='font' ><?php print$b_subgroup; ?></textarea> 
        
        </td>





        </tr>


        <tr>

            <td> 
                
            <input type='hidden' name='user' value="<?php echo $a_user ?>" />
                <input type='hidden' name='pass' value="<?php echo $a_pass ?>" />

            <input type='submit' class='font' value='تغيير' /> </td>

        </tr>

    </table>
</form>


                    <hr>
                    <hr>
                    <hr>

                    <br>
                    <br>
                    <br>



                    <form method='post' action='index.php'>
                        <table>
                            <tr>
                                <th class='th'>يوزرنيم جديد </th>
                                <th class='th' colspan="2">پسورد جديد</th>


                            </tr>
                            <tr>
                                <td align='center' class='td'><input placeholder="يوزرنيم" type='text' name='newuser' class='font' /> </td>
                                <td align='center' class='td'><input placeholder="پسورد" name="newpass" type="password" class="font" />
                                    <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                    <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" />
                                </td>




                            </tr>


                            <tr>

                                <td> <input type='submit' class='font' value='تغيير' /> </td>

                            </tr>

                        </table>
                    </form>



                    <?php

                    if (isset($_POST['code'])) {
                        $sql = "update discount_code set code = '" . $_POST['code'] . "'  , precentage='" . $_POST['precentage'] . "'  ";
                        $conn->exec($sql);
                        print('انجام شد');
                    }



                    $sql = "select * from discount_code  ";
                    $stmt = $conn->prepare($sql);
                    $stmt->execute();
                    $stmt->setFetchMode(PDO::FETCH_ASSOC);
                    $getter = $stmt->fetchAll();
                    $numrowfusers = $stmt->rowCount();



                   

                    $code = $getter[0]["code"];
                    $precentage = $getter[0]["precentage"];


                  
                    ?>



<!-- 
                    <form method='post' action='index.php'>
                        <table>
                            <tr>
                                <th class='th'>کد تخفیف</th>
                                <th class='th' colspan="2">درصد</th>


                            </tr>
                            <tr>
                                <td align='center' class='td'><input placeholder="کد تخفیف" type='text' name='code' class='font' value='<?php print $code; ?>' /> </td>
                                <td align='center' class='td'><input placeholder="درصد" name="precentage" type="text" class="font" value='<?php print $precentage; ?>' />
                                    <input type='hidden' name='user' value="<?php echo $a_user  ?>" />
                                    <input type='hidden' name='pass' value="<?php echo $a_pass  ?>" />
                                </td>




                            </tr>


                            <tr>

                                <td> <input type='submit' class='font' value='تغيير' /> </td>

                            </tr>

                        </table>
                    </form> -->



                </div>












                <div id="shower">



























                    <hr />
                    <hr />
                    <hr />

                    <br />
                    <br />
                    <br />
                    <br />






                </div>
























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




        <!-- <a style="text-decoration:none ;" href="http://beminfo.io" target="_blank" class="gray">bem token</a> -->
    </div>

    <?php
    $conn = null;
    ?>
</body>

</html>