<?php
session_start();
include "../modules/Class/autoload.php"; 
$url = '217.11.177.108:9907/Fines/api/rbdaapi/index.php';
$secret = 'shohinnewkey';
$inputdate = date('ymdHis');
$plate = filterdb($_REQUEST['plate']);
$data = [
    "action"=>"getrank",
    "inputdate"=>$inputdate,
    "sign"=>md5('getrank'.$inputdate.$secret)
];
$jsondata = json_encode($data);
$sendcurl = sendcurl($jsondata,$url);
$arraydata = customjsondecode($sendcurl);     
$dataproceed = $arraydata[0];   
?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>РБДА</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="РБДА" name="description" />
    <meta content="Themesdesign" name="author" />
    <!-- App favicon -->
    <link rel="shortcut icon" href="../assets/images/nerufavicon.png">
    <!-- Bootstrap Css -->
    <link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- Icons Css -->
    <link href="../assets/css/icons.min.css" rel="stylesheet" type="text/css" />
    <!-- App Css-->
    <link href="../assets/css/app.min.css" rel="stylesheet" type="text/css" />

</head>

<body data-sidebar="dark">

    <!-- Begin page -->
    <div id="layout-wrapper">

        
        <?php include "header.php";?>
        <!-- ========== Left Sidebar Start ========== -->
        <?php include "menu.php"?>
        <!-- Left Sidebar End -->

        <!-- ============================================================== -->
        <!-- Start right Content here -->
        <!-- ============================================================== -->
        <div class="main-content">

            <div class="page-content">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-6">
                            <?php if($_SESSION['error'] =="addrank" and $_SESSION['exists'] =="1"  ){ ?>
                            <div class="alert alert-danger alert-dismissible fade show" role="alert">
                            Звание <?=$_SESSION['login']?> уже существует, создайте другое!
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <?php $_SESSION['error']=''; } ?>
                            <?php if($_SESSION['error'] =="addrank" and $_SESSION['exists'] =="0"  ){ ?>
                            <div class="alert alert-success alert-dismissible fade show" role="alert">
                                Звание <?=$_SESSION['fio']?> успешно создано!
                                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>   
                            <?php $_SESSION['error']=''; } ?>                        
                        </div>
                                        

                        <!-- Если обновление -->
                        <?php if($_SESSION['error'] =="userupdate" and $_SESSION['exists'] =="1"  ){ ?>
                        <div class="alert alert-danger alert-dismissible fade show" role="alert">
                        Произошла ошибка при обновлении данных, обратитесь к разработчику.
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <?php $_SESSION['error']=''; } ?>
                        <?php if($_SESSION['error'] =="userupdate" and $_SESSION['exists'] =="0"  ){ ?>
                        <div class="alert alert-success alert-dismissible fade show" role="alert">
                            Пользователь <?=$_SESSION['fio']?> успешно отредактирован!
                            <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>       
                        <?php $_SESSION['error']=''; } ?>                    
                    </div>
                    <!-- start page title -->
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box d-flex align-items-center justify-content-between">
                                <h4 class="mb-0 font-size-18">Список звании</h4>
                            </div>
                        </div>
                    </div>
                    <!-- end page title -->
                <div class="card">
                        <div class="card-body">
                            <div class="p-lg-3">
                                <div class="col" style="overflow-x:auto ;">
                                    <a href="rankadd.php"> <button class="btn btn-primary" type="button">Добавить название</button></a>
                                    <br>
                                    <br>
                                <table class="table table-light">
                                        <thead class="thead-light table-bordered table-striped">
                                            <tr style="text-align: center;">
                                                <th>№</th>
                                                <th>Название</th>
                                                <th>Дата добавления/изменения</th>
                                                <th>Действие</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            
                                        <?php $i=1;foreach ($arraydata as $value) {
                                            if($value['Status']=='1'){$stat = '<span class="badge badge-success">Активный</span>'; }else{$stat = '<span class="badge badge-danger">Не активен</span>';}    
                                        ?>
                                            <tr style="text-align: center;">
                                                <td><?=$i?></td>
                                                <td><?=$value['Name']?></td>
                                                <td><?=$stat?></td>
                                                <td><?=SanaTime($value['Inputdate'])?></td>
                                                <td style="text-align: center;">
                                                    <a href="rankupd.php?login=<?=$value['ID']?>"> <i title="Редактировать" style="text-align: center; font-size: 23px;color:blue;" class="mdi mdi-account-edit-outline"></i></a>
                                                </td>
                                            </tr>
                                        <?php $i++; } ?>
                                        </tbody>
                                       
                                    </table>
                                </div>
                                    
                                                                             
                            </div>
                        <!--end card body-->
                    </div> <!-- end card-->
                </div> <!-- container-fluid -->
            </div>
            <!-- End Page-content -->
        </div>
        <!-- end main content-->

    </div>
    <!-- END layout-wrapper -->

    <!-- JAVASCRIPT -->
    <script src="../assets/libs/jquery/jquery.min.js"></script>
    <script src="../assets/libs/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="../assets/libs/metismenu/metisMenu.min.js"></script>
    <script src="../assets/libs/simplebar/simplebar.min.js"></script>
    <script src="../assets/libs/node-waves/waves.min.js"></script>

    <script src="../assets/js/app.js"></script>
    <script src="../assets/js/myjs.js"></script>

</body>

</html>