<?php 
	ini_set("display_errors",0);
    session_start();
    include "../modules/Class/autoload.php"; 
    $url = '217.11.177.108:9907/Fines/api/rbdaapi/index.php';
    $secret = 'shohinnewkey';
    $inputdate = date('ymdHis');                        
    $data = [
        "action"=>"getlogins",
        "inputdate"=>$inputdate,
        "sign"=>md5('getlogins'.$plate.$inputdate.$secret)
    ];
    $jsondata = json_encode($data);
    $sendcurl = sendcurl($jsondata,$url);
    $loginarray = customjsondecode($sendcurl); 
?>
<!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">

                    <!-- 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 ;">
                                <form method="post" action="#">
									<div class="row">
										<div class="col-4">
										   <div class="form-group">
											<label for="my-input">Дата от</label>
											
											<input value = "<?=$_REQUEST['from']?>" id="my-input" class="form-control" type="date" name="from">
										   </div>
										</div>
										<div class="col-4">
											<div class="form-group">
												<label for="my-input">Дата до</label>
												<input value = "<?=$_REQUEST['to']?>" id="my-input" class="form-control" type="date" name="to">
											   </div>
										</div>
										<div class="col-4">
											<div class="form-group">
												<label for="my-select">Инспектор</label>
												<select id="my-select" class="form-control" name="login">
													<?php if (isset($_REQUEST['fio'])){ ?>
														<option value="<?=$_REQUEST['login']?>"><?=$_REQUEST['fio'].' ('.$_REQUEST['login'].')'?></option>
													<?php }?>
													<option value="*">Выберите логин</option>
                                                    <?php foreach ($loginarray as $item){ ?>
                                                        <option value="<?=$item['login']?>"><?=$item['fio'].' ('.$item['login'].')'?></option>
                                                    <?php }?>
												</select>
											</div>																			    <input type="hidden" name="page" value="1">		   
										</div>
										
										
										<div class="col-4">
											<div class="form-group">
											   <button name = "sbt" class="btn btn-success" type="submit">Поиск</button>
											</div>
										</div>
									</div>
									
								</form>
                                </div>
                                    
                                                                             
                            </div>
                        <!--end card body-->
                    </div> <!-- end card-->
                </div>
				<!--Тело -->
				<?php
					if(isset($_REQUEST['sbt'])){
						
						$from = $_REQUEST['from'];
						$to = $_REQUEST['to'];
						$login = $_REQUEST['login'];
                        $page = $_REQUEST['page'];
                        if ($page==""){$page=1;}
                        if($page=="1"){$previous = $page;}else{$previous = $page-1;}
						$nextpage = $page+1;
                        //print_r($_REQUEST);
						
					
				?>
				<div class="card">
                        <div class="card-body">
                            <div class="p-lg-3">
                                <?php 
								if($from =='' or $to=='' ){
									echo '<div class="alert alert-warning" role="alert">
												Введите данные даты от и до !!
										  </div>';
									return;
								}
									$url = '217.11.177.108:9907/Fines/api/rbdaapi/index.php';
									$secret = 'shohinnewkey';
									$inputdate = date('ymdHis');
									$data = [
									"action"=>"sporpagination",
									"from"=>$from,
									"to"=>$to,
									"page"=>$page,
									"status"=>'10',
									"inputdate"=>$inputdate,
                                    "login"=>$login,
									"sign"=>md5('sporpagination'.$inputdate.$secret)
									];
									$jsondata = json_encode($data);
									$sendcurl = sendcurl($jsondata,$url);			
									$arraydata = customjsondecode($sendcurl);	
                                    //return;                           
                                    //return;							
								?>
								
								<div class="col" style="overflow-x:auto ;">
                                <table border="1" class="table table-light table-bordered table-striped">
                                        <thead class="thead-light ">
                                            <tr  style="text-align: center;">
                                                <th>№</th>
                                                <th>Ордер штрафа</th>
                                                <th>Номер автомобиля</th>
                                                <th>Дата спора</th>
                                                <th>Дата подтверждения</th>
                                                <th>Штраф</th>
                                                <th>Сумма</th>                                              
                                                <th>Списал штраф</th>
                                                <th>Подробнее</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php 
                                                if($page==1){$limit=1;}else{$limit = (($page-1)*10)+1;}
                                                $i=$limit; 
                                             
                                             
                                                foreach($arraydata as $item){ 
												$counter = $item['counter'];
											?>
                                                <tr style="text-align: center;">
                                                    <td><?=$i?></td>
                                                    <td><?=$item['orderID']?></td>
                                                    <td><?=$item['account']?></td>
                                                    <td><?=$item['inputdate']?></td>
                                                    <td><?=SanaTime($item['approved_date'])?></td>
                                                    <td><?=$item['Name']?></td>
                                                    <td><?=$item['summa']?></td>
                                                    <td><?=$item['fio']?></td>
                                                    <td> <a target="_blank" href="auditproceed.php?order=<?=$item['orderID']?>">
                                                            <i class="mdi mdi-book-search-outline" style="font-size: 21px;color: blue;"></i>
                                                        </a>
                                                    </td>
                                                </tr>
                                            <?php $i++; } ?>
                                        </tbody>  
										<div class="col" >
										<nav aria-label="Page navigation">
											<ul class="pagination">
												<li class="page-item active" aria-current="page">
													<a class="page-link" href="auditdisputacceptnew.php?sbt&from=<?=$from?>&to=<?=$to?>&login=<?=$login?>&page=<?=$previous?>">Предыдущая<span class="sr-only">(current)</span></a>
												</li>
												<li class="page-item disabled">
													<a class="page-link" href="#" tabindex="-1" aria-disabled="true"><?=$page?></a>
												</li>
												<li class="page-item">
													<a class="page-link" href="auditdisputacceptnew.php?sbt&from=<?=$from?>&to=<?=$to?>&login=<?=$login?>&page=<?=$nextpage?>">Следующая</a>
												</li>
											</ul>
										</nav>
										</div>										
                                    </table>
                                </div>
                                                                             
                            </div>
                        <!--end card body-->
                    </div> <!-- end card-->
					
                </div>
				<?php }?>
				<!-- 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>