<?php
session_start();
require('../lib/dbclass.php');


$data = findQuery("select tbl_user.*,tbl_ward.ward_name,(CASE when tbl_user.user_type=1 THEN 'Admin' else 'Volunteer' END) as Type from tbl_user inner join tbl_ward on tbl_user.ward_id=tbl_ward.id where tbl_user.status=1");


?>

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Language" content="en">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo sitename ?></title>
    <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no" />
    <meta name="description" content="<?php echo sitename ?>">

    <link rel="icon" type="image/x-icon" href="../assets/images/Shade logo.png">
    <link href="..\assets\css\main.css" rel="stylesheet">
    <link rel="stylesheet" href="../assets/css/daterangepicker.css">
</head>

<body>
    <div class="app-container app-theme-white body-tabs-shadow fixed-sidebar fixed-header">
        <div class="app-header header-shadow">
            <div class="app-header__logo">
                <div class="logo-sr">
                    <img width="55px" src="../assets/images/Shade logo.png" alt="">
                </div>
                <div class="header__pane ml-auto">
                    <div>
                        <button type="button" class="hamburger close-sidebar-btn hamburger--elastic"
                            data-class="closed-sidebar">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
            </div>





            <div class="app-header__mobile-menu">
                <div>
                    <button type="button" class="hamburger hamburger--elastic mobile-toggle-nav">
                        <span class="hamburger-box">
                            <span class="hamburger-inner"></span>
                        </span>
                    </button>
                </div>
            </div>
            <div class="app-header__menu">
                <span>
                    <button type="button"
                        class="btn-icon btn-icon-only btn btn-primary btn-sm mobile-toggle-header-nav">
                        <span class="btn-icon-wrapper">
                            <i class="fa fa-ellipsis-v fa-w-6"></i>
                        </span>
                    </button>
                </span>
            </div>
            <div class="app-header__content">

                <div class="app-header-right">
                    <div class="header-btn-lg pr-0">
                        <div class="widget-content p-0">
                            <div class="widget-content-wrapper">

                                <div class="widget-content-left  ml-3 header-user-info">
                                    <!--<div class="widget-heading">
                                        Muhammed murshid
                                    </div>
                                    <div class="widget-subheading">
                                        Admin
                                    </div>-->
                                </div>

                                <div class="d-inline-block dropdown ml-3 p-0">
                                    <button style="width: 40px;" type="button" data-toggle="dropdown"
                                        aria-haspopup="true" aria-expanded="false"
                                        class="btn-shadow dropdown-toggle btn btn-info" fdprocessedid="rwibbh">


                                        <img style="width: 100%;" src="../assets/images/Shade logo.png" alt="">
                                    </button>
                                    <div tabindex="-1" role="menu" aria-hidden="true"
                                        class="dropdown-menu dropdown-menu-right">
                                        <ul class="nav flex-column">
                                            <li class="nav-item">
                                                <a href="logout.php" class="nav-link">
                                                    <i class="nav-link-icon lnr-inbox"></i>
                                                    <span> Logout</span>
                                                </a>
                                            </li>

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

        <div class="app-main">
            <div class="app-sidebar sidebar-shadow">
                <div class="app-header__logo">

                    <div class="header__pane ml-auto">
                        <div>
                            <button type="button" class="hamburger close-sidebar-btn hamburger--elastic "
                                id="toggleButton-header">
                                <span class="hamburger-box">
                                    <span class="hamburger-inner"></span>
                                </span>
                            </button>

                        </div>
                    </div>
                </div>
                <div class="app-header__mobile-menu">
                    <div>
                        <img src="../../assets/images/Shade logo.png" alt="">
                        <button type="button" class="hamburger hamburger--elastic mobile-toggle-nav">
                            <span class="hamburger-box">
                                <span class="hamburger-inner"></span>
                            </span>
                        </button>
                    </div>
                </div>
                <div class="app-header__menu">
                    <span>
                        <button type="button"
                            class="btn-icon btn-icon-only btn btn-primary btn-sm mobile-toggle-header-nav">
                            <span class="btn-icon-wrapper">
                                <i class="fa fa-ellipsis-v fa-w-6"></i>
                            </span>
                        </button>
                    </span>
                </div>
                <div class="scrollbar-sidebar ps ps--active-y">
                    <div class="app-sidebar__inner">
                       
                       
                       <ul class="vertical-nav-menu metismenu">

							
							
							
							<li>
								<a href="../User/user_management.php">

									<i class="fa fa-users" aria-hidden="true"></i>User Management
								</a>
							</li>

                            <li>
                                <a href="../ChallengeReport/challengereport.php">

                                    <i class="fa fa-users" aria-hidden="true"></i>Challenge Report
                                </a>
                            </li>
						</ul>
                    </div>
                    <div class="ps__rail-x" style="left: 0px; bottom: 0px;">
                        <div class="ps__thumb-x" tabindex="0" style="left: 0px; width: 0px;"></div>
                    </div>
                    <div class="ps__rail-y" style="top: 0px; height: 643px; right: 0px;">
                        <div class="ps__thumb-y" tabindex="0" style="top: 0px; height: 610px;"></div>
                    </div>
                </div>
            </div>

            <div class="app-main__outer">
                <div class="app-main__inner">

                    <div class="app-page-title app-page-title-simple">
                        <div class="page-title-wrapper d-flex justify-content-between">
                            <div class="page-title-heading">
                                <div>
                                    <div class="page-title-head center-elem mb-3">
                                        <span class="d-inline-block">
                                            <i class="lnr-apartment opacity-6"></i>
                                        </span>
                                        <span class="d-inline-block">Blocked User</span>
                                        
                                    </div>
                                    
                                    
                                </div>
                            </div>

                            <nav class="" aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a href="user_management.php">User Management</a></li>
                                    <li class="breadcrumb-item"><a href="blocked_user.php">Blocked User</a></li>
                                    
                                </ol>
                            </nav>






                        </div>
                        <div class="row">
                            <div class="col-md-6 col-xl-4">
                                <div class="card mb-3 widget-content">
                                    <div class="widget-content-outer">
                                        <div class="widget-content-wrapper">
                                            <div class="widget-content-left">
                                                <div class="widget-heading">Total Blocked User </div>
                                                <div class="widget-subheading"></div>
                                            </div>
                                            <div class="widget-content-right">
                                                <div class="widget-numbers text-danger"> <?php

                        $blocked = findQuery('select COUNT(*) nos from tbl_user where status=1');
$totalblock                      = $blocked[0]['nos'];
echo $totalblock;
?></div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>

 



                        <div class="row">
                            <div class="col-md-12">
                                <div class="main-card mb-3 card" >
                                    <div class="card-header d-flex justify-content-center">Blocked User
                                        <div class="btn-actions-pane-right">
                                            <div role="group" class="btn-group-sm btn-group">
    
                                                <div class="app-header-left py-1">
                                                    <div class="search-wrapper">
                                                        <div class="input-holder">
                                                           <!-- <input type="text" class="search-input"
                                                                placeholder="Type to search" id="searchInput-header"
                                                                onkeyup="searchTable()">
                                                            <button class="search-icon"><span></span></button>-->
                                                        </div>
                                                       <button id="search-close-new" class="close"></button>
                                                    </div>
    
    
                                                </div>
    
                                               
    
    
                                              
    
    
    
    
    
    
    
    
    
                                            </div>
                                            
                                        </div>
                                        
                                    </div>
                                    <div class="table-responsive">
                                        <table class="align-middle mb-0 table table-borderless table-striped table-hover">
                                            <thead>
                                                <tr>
                                                    <th class="text-center">Si.No</th>
                                                     <th class="text-center">Ward</th>
                                                    <th class="text-center">Name</th>
                                                    <th class="text-center">User Name</th>
                                                    <th class="text-center">Password</th>
                                                    <th class="text-center">Type</th>    
                                                    <th class="text-center">Action</th>
    
    
                                                </tr>
                                            </thead>
                                            <tbody id="tabledata-new">
                                                
                                                
                                             
                                                
												<?php
// Define the number of records per page
$recordsPerPage = 10;

// Calculate the total number of pages
$totalPages = ceil(count($data) / $recordsPerPage);

// Determine the current page number
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
    $currentPage = $_GET['page'];
} else {
    $currentPage = 1;
}

// Calculate the starting record for the current page
$start = ($currentPage - 1) * $recordsPerPage;

// Slice the data array to display only the records for the current page
$paginatedData = array_slice($data, $start, $recordsPerPage);

// Display the paginated data
foreach ($paginatedData as $index => $row) {
    $id = $row['id'];
    ?>
                                                <tr>
                                                    <td class="text-center text-muted"><?php echo $index + $start + 1 ?>.</td>
                                                    	<td class="text-center"><?php echo $row['ward_name'] ?></td>
														<td class="text-center"><?php echo $row['name'] ?></td>
														<td class="text-center"><?php echo $row['username'] ?></td>
														<td class="text-center"><?php echo decrypt($row['password']) ?></td>
														<td class="text-center"><?php echo $row['Type'] ?></td>
                                                    <td class="text-center"> 
                                                        <a class="mb-2 mr-2 badge badge-success" href="unblock.php?blockid=<?php echo $row['id'];?>" title="click for unblock" onclick="return confirm('sure to unblock ?')">Unblock</a>
                                                    </td>
                                                </tr>
                                                <?php } ?>
                                              
                                                
                                        
                                                
                                                
                                            </tbody>
                                        </table>
                                    </div>
    
                                </div><?php
                              if ($totalPages > 0) {
                                  ?>                           
                              <ul class="pagination pagination-sm d-flex justify-content-end">
    <!-- Previous page link -->
    <?php if ($currentPage > 1) { ?>
        <li class="page-item"><a href="?page=<?php echo($currentPage - 1); ?>" class="page-link" aria-label="Previous"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></a></li>
    <?php } else { ?>
        <li class="page-item disabled"><span class="page-link" aria-label="Previous"><span aria-hidden="true">«</span><span class="sr-only">Previous</span></span></li>
    <?php } ?>

    <!-- Page numbers -->
    <li class="page-item <?php echo ($currentPage == 1) ? 'active' : ''; ?>"><a href="?page=1" class="page-link">1</a></li>

    <?php
    // Define the range of neighboring pages to show
    $neighboringPages = 2;

                                  // Show ellipsis if there are more than 5 pages after the current page
                                  if ($totalPages - $currentPage - $neighboringPages > 1) { ?>
        <li class="page-item disabled"></li>
    <?php }







                                  // Loop through the pages
                                  for ($i = max(2, $currentPage - $neighboringPages); $i <= min($currentPage + $neighboringPages, $totalPages); $i++) { ?>
        <?php if ($i != 1 && $i != $totalPages) { ?>
            <li class="page-item <?php echo ($i == $currentPage) ? 'active' : ''; ?>"><a href="?page=<?php echo $i; ?>" class="page-link"><?php echo $i; ?></a></li>
        <?php } ?>
    <?php }


                                  // Show ellipsis if there are more than 5 pages after the current page
                                  if ($totalPages - $currentPage - $neighboringPages > 1) { ?>
        <li class="page-item disabled"><span class="page-link">...</span></li>
    <?php } ?>

    <!-- End of pagination -->
    <?php if ($totalPages != 1) { ?>
        <li class="page-item"><a href="?page=<?php echo $totalPages; ?>" class="page-link"><?php echo $totalPages; ?></a></li>
    <?php } ?>

    <!-- Next page link -->
    <?php if ($currentPage < $totalPages) { ?>
        <li class="page-item"><a href="?page=<?php echo($currentPage + 1); ?>" class="page-link" aria-label="Next"><span aria-hidden="true">»</span><span class="sr-only">Next</span></a></li>
    <?php } else { ?>
        <li class="page-item disabled"><span class="page-link" aria-label="Next"><span aria-hidden="true">»</span><span class="sr-only">Next</span></span></li>
    <?php } ?>
</ul>
<?php
                              }
?>

                            </div>
                        </div>






                    </div>
                    
                </div>
                
                <div class="app-wrapper-footer">
                    <div class="app-footer">
                        <div class="app-footer__inner d-flex justify-content-center">
                            <li style="list-style-type: none;">Developed by <a href="https://workmateinfotech.com/">Workmate Infotech Pvt Ltd</a> </li>
                        </div>
                    </div>
                </div>

            </div>
            </div>
            
          <!-- Bootstrap 4 Modal -->
            
          <div class="success_modal_new">
					<div class="modal fade show" id="statusSuccessModal" tabindex="-1" role="dialog"
						data-bs-backdrop="static" data-bs-keyboard="false">
						<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
							<div class="modal-content">
								<div class="modal-body text-center p-lg-4">
									<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 130.2 130.2">
										<circle class="path circle" fill="none" stroke="#198754" stroke-width="6"
											stroke-miterlimit="10" cx="65.1" cy="65.1" r="62.1" />
										<polyline class="path check" fill="none" stroke="#198754" stroke-width="6"
											stroke-linecap="round" stroke-miterlimit="10"
											points="100.2,40.2 51.5,88.8 29.8,67.5 " />
									</svg>
									<h4 class="text-success mt-3">Oh Yeah!</h4>
									<p class="mt-3"><div id="messagesuccess"></div></p>
									<button type="button" class="btn btn-sm  btn-success"
										data-dismiss="modal">Ok</button>
								</div>
							</div>
						</div>
					</div>
				</div>
                <div class="success_modal_new">
					<div class="modal fade show" id="statusErrorsModal" tabindex="-1" role="dialog"
						data-bs-backdrop="static" data-bs-keyboard="false">
						<div class="modal-dialog modal-dialog-centered modal-sm" role="document">
							<div class="modal-content">
								<div class="modal-body text-center p-lg-4">
									<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 130.2 130.2">
                                        <circle class="path circle" fill="none" stroke="#db3646" stroke-width="6"
                                            stroke-miterlimit="10" cx="65.1" cy="65.1" r="62.1" />
                                        <line class="path line" fill="none" stroke="#db3646" stroke-width="6"
                                            stroke-linecap="round" stroke-miterlimit="10" x1="34.4" y1="37.9" x2="95.8"
                                            y2="92.3" />
                                        <line class="path line" fill="none" stroke="#db3646" stroke-width="6"
                                            stroke-linecap="round" stroke-miterlimit="10" x1="95.8" y1="38" X2="34.4"
                                            y2="92.2" />
                                    </svg>
                                    <h4 class="text-danger mt-3">Oh No!</h4>
                                    <p class="mt-3"><div id="messagefailed"></div></p>
                                    <button type="button" class="btn btn-sm mt-3 btn-danger"
                                        data-dismiss="modal">Ok</button>
								</div>
							</div>
						</div>
					</div>
				</div>

                
            <script src="../assets/scripts/jquery.min.js"></script>
            <script src="../assets/scripts/moment.min.js"></script>
            <script src="../assets/scripts/daterangepicker.min.js"></script>
            <script src="../assets/scripts/custome.js"></script>
            <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.1/js/bootstrap.min.js"></script>
            <script type="text/javascript" src="../assets/scripts/main.js"></script>
            <script src="https://use.fontawesome.com/f9637666d8.js"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.4.2/chosen.jquery.js"></script>
       
           
            <script>
                $(document).ready(function() {
                  // Check if the URL has a parameter indicating invalid login
                  const urlParams = new URLSearchParams(window.location.search);
                  const message = urlParams.get('message');
              
                  if (message == 'Unblocked successfully!') {
                    $('#statusSuccessModal').modal('show');
                    $('#messagesuccess').text(message);
                  }
                  else if (message == 'Something went wrong, please try again.'){
                    $('#statusErrorsModal').modal('show');
                    $('#messagefailed').text(message);
                  }
              
                  // Event listener for modal close event
                  $('#statusSuccessModal').on('hidden.bs.modal', function () {
                    // Remove the message parameter from the URL
                    window.history.replaceState({}, document.title, window.location.pathname);
                  });
                  $('#statusErrorsModal').on('hidden.bs.modal', function () {
                    // Remove the message parameter from the URL
                    window.history.replaceState({}, document.title, window.location.pathname);
                  });
                });
              </script>



</body>

</html>