<?php 

session_name('super_admin_session');

if (!is_dir(dirname(__DIR__) . '/session_data/super')) { mkdir(dirname(__DIR__) . '/session_data/super', 0700, true); } session_save_path(dirname(__DIR__) . '/session_data/super');

session_set_cookie_params(['path' => '/', 'httponly' => true, 'samesite' => 'Strict']);

session_start();

error_reporting(0);

include('includes/dbconnection.php');
require_once 'includes/session_term_helper.php';
$stResult = resolveCurrentSessionTerm($con);
$currentSessionName = $stResult['session_name'];
$currentTermName    = $stResult['term_name'];

include('includes/flash.php');

 

if(isset($_GET['delid']))

{

  $rid=intval($_GET['delid']);

  $sql="update tblusers set status='0' where id=:rid";

  $query=$dbh->prepare($sql);

  $query->bindParam(':rid',$rid,PDO::PARAM_STR);

  $query->execute();

  flash_alert(' blocked successfuly'); 

  header('Location: blockuser.php'); exit;

}

?>

<?php @include("includes/head.php"); ?>

<style>



    /* Cards Styling */

    .small-box {

        border-radius: 12px;

        transition: 0.3s ease-in-out;

        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);

        overflow: hidden;

        background: white;

    }



    .small-box:hover {

        transform: translateY(-4px);

        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);

    }



    .small-box .inner {

        padding: 20px;

    }



    .small-box p {

        font-size: 1rem;

        font-weight: bold;

        color: whitesmoke;

    }



    .small-box span {

        font-size: 1rem;

        color: #666;

        font-weight: bold;

    }



    .small-box .icon {

        position: absolute;

        right: 20px;

        top: 20px;

        font-size: 3rem;

        color: rgba(255, 255, 255, 0.8);

    }



    .small-box-footer {

        display: block;

        padding: 12px;

        font-weight: 600;

        font-size: 1rem;

        text-align: center;

        background: rgba(0, 0, 0, 0.1);

        border-top: 1px solid rgba(255, 255, 255, 0.2);

    }



    .small-box-footer:hover {

        background: rgba(0, 0, 0, 0.15);

    }



   

    .dashboard-header {

        font-size: 1.3rem;

        font-weight: 400;

        color: #333;

        text-align: center;

        margin-bottom: 10px;

    }



    

    .breadcrumb {

        background: none;

        padding: 0;

    }

</style>

<body class="hold-transition sidebar-mini layout-fixed">

  <div class="wrapper">

    <!-- Navbar -->

    <?php @include("includes/header.php"); ?>

    <!-- /.navbar -->

    <!-- Main Sidebar Container -->

    <?php @include("includes/sidebar.php"); ?>

    <!-- Content Wrapper. Contains page content -->

    <div class="content-wrapper">

      <!-- Content Header (Page header) -->

<section class="content-header premium-header">

    <div class="container-fluid">

        <div class="header-glass-card">

            <div class="row align-items-center">

                <div class="col-md-8">

                    <div class="title-section">

                        <div class="icon-box bg-primary-gradient shadow-sm">

                            <i class="fas fa-users"></i>

                        </div>

                        <div>

                            <h1 class="premium-title text-primary">

                                System User Management

                                <span class="premium-subtitle text-secondary">Block User</span>

                            </h1>
                            <div class="mt-1">
                              <?php if ($currentSessionName): ?>
                                <span class="badge badge-primary mr-1">
                                  <i class="fas fa-calendar-alt"></i>
                                  <?= htmlspecialchars($currentSessionName) ?>
                                </span>
                              <?php endif; ?>
                              <?php if ($currentTermName): ?>
                                <span class="badge badge-success">
                                  <i class="fas fa-bookmark"></i>
                                  <?= htmlspecialchars($currentTermName) ?>
                                </span>
                              <?php else: ?>
                                <span class="badge badge-warning">
                                  <i class="fas fa-exclamation-triangle"></i> No active term
                                </span>
                              <?php endif; ?>
                            </div>

                        </div>

                    </div>

                </div>

                <div class="col-md-4">

                    <nav aria-label="breadcrumb">

                        <ol class="breadcrumb premium-breadcrumb">

                            <li class="breadcrumb-item"><a href="dashboard.php" class="text-primary">Home</a></li>

                            <li class="breadcrumb-item active" aria-current="page">Block User</li>

                        </ol>

                    </nav>

                </div>

            </div>

        </div>

    </div>

</section>  



      <section class="content-header">

        <div class="container-fluid">

          <div class="row">

                        <?php

                        $dashboard_items = [

                            ["query" => "SELECT * FROM tblusers", "label" => "TOTAL USERS", "icon" => "fas fa-users", "bg" => "bg-info", "link" => "#"],

                            ["query" => "SELECT * FROM tblusers WHERE sex ='Male'", "label" => "TOTAL MALE", "icon" => "fas fa-male", "bg" => "bg-success", "link" => "#"],

                            ["query" => "SELECT * FROM tblusers WHERE sex = 'Female'", "label" => "TOTAL FEMALE", "icon" => "fas fa-female", "bg" => "bg-warning", "link" => "#"],

                            ["query" => "SELECT * FROM tblusers WHERE status=1", "label" => "ACTIVE USERS", "icon" => "fas fa-users", "bg" => "bg-danger", "link" => "#"],

                           ];



                        foreach ($dashboard_items as $item) {

                            $query = mysqli_query($con, $item["query"]);

                            $count = mysqli_num_rows($query);

                            echo "

                            <div class='col-sm-3 col-3'>

                                <div class='small-box {$item['bg']}'>

                                    <div class='inner'>

                                        <h3>{$count}</h3>

                                        <p><b>{$item['label']}</b></p>

                                    </div>

                                    <div class='icon'>

                                        <i class='fa {$item['icon']}'></i>

                                    </div>

                                    <a href='{$item['link']}' class='small-box-footer'>More info <i class='fas fa-arrow-circle-right'></i></a>

                                </div>

                            </div>";

                        }

                        ?>

                    </div>



          <!-- /.row -->

        </div><!-- /.container-fluid -->

      </section><!-- /.section -->

      <!-- /.content-wrapper -->

      <!-- Main content -->

      <section class="content">

        <div class="container-fluid">

          <div class="">



          </div>

          <div class="row">

            <div class="col-12">

              <div class="card card-primary">

                <div class="card-header">

                  <h5 class="card-title font-weight-bold"><i class="fas fa-user-plus"></i> Register New user</h5>

                  <div class="card-tools">

                   <button type="button" class="user" data-toggle="modal" data-target="#edit_data" style= "background-color: #007BFF; color: white; border:none;" ><i class="fas fa-ban" ></i> See blocked users

                   </button>

                   <button type="button" class="user" data-toggle="modal" data-target="#edit_data1" style= "background-color: #007BFF; color: white; border: none;" ><i class="fas fa-plus" ></i> Register New User

                   </button>

                 </div>

               </div>

               <!-- /.card-header -->

               <div class="modal fade" id="edit_data1">

                <div class="modal-dialog modal-xl">

                  <div class="modal-content">

                    <div class="modal-header">

                      <h4 class="modal-title"><i class="fas fa-user-plus"></i> Register New User</h4>

                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                        <span aria-hidden="true">&times;</span>

                      </button>

                    </div>

                    <div class="modal-body">

                      <!-- <p>One fine body&hellip;</p> -->
<!-- loaded via AJAX -->
</div>

                      <!-- <div class="modal-footer ">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

                        <button type="button" class="btn btn-primary">Save changes</button>

                      </div> -->

                    </div>

                    <!-- /.modal-content -->

                  </div>

                  <!-- /.modal-dialog -->

                </div>

                <!-- /.modal -->



                <div class="modal fade" id="edit_data">

                  <div class="modal-dialog modal-xl">

                    <div class="modal-content">

                      <div class="modal-header">

                        <h4 class="modal-title"><i class="fas fa-ban"></i> Blocked User</h4>

                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                          <span aria-hidden="true">&times;</span>

                        </button>

                      </div>

                      <div class="modal-body">

                        <!-- <p>One fine body&hellip;</p> -->
<!-- loaded via AJAX -->
</div>

                      <div class="modal-footer ">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

                        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->

                      </div>

                    </div>

                    <!-- /.modal-content -->

                  </div>

                  <!-- /.modal-dialog -->

                </div>

                <!-- /.modal -->



                <div id="editData" class="modal fade">

                  <div class="modal-dialog ">

                    <div class="modal-content">

                      <div class="modal-header">

                        <h5 class="modal-title"><i class="fas fa-user-edit"></i> Edit User's Details</h5>

                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                          <span aria-hidden="true">&times;</span>

                        </button>

                      </div>

                      <div class="modal-body" id="info_update">

                        <!-- <p>One fine body&hellip;</p> -->
<!-- loaded via AJAX -->
</div>

                      <div class="modal-footer ">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

                        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->

                      </div>

                      <!-- /.modal-content -->

                    </div>

                    <!-- /.modal-dialog -->

                  </div>

                  <!-- /.modal -->

                </div>



                <div class="card-body">

                  <table id="example1" class="table table-bordered table-striped">

                    <thead>

                      <tr>

                        <th class="text-center">Name</th>

                        <th class="text-center">Mobile</th>

                        <th class="text-center">Email</th>

                        <th class="text-center">Permission</th>

                        <th class="text-center">Action</th>

                      </tr>

                    </thead>

                    <tbody>

                     <?php

                     $aid=$_SESSION['cpmsaid'];

                     $usertype = $_SESSION['usertype'];

                     $property = $_SESSION['property'];

                     $sql="SELECT * from tblusers where status='1' OR status = '2'";

                     $query = $dbh -> prepare($sql);

                     $query->execute();

                     $results=$query->fetchAll(PDO::FETCH_OBJ);



                     $cnt=1;

                     if($query->rowCount() > 0)

                     {

                      foreach($results as $row)

                        {               ?>

                         <tr>

                          <td class="text-left"><?php  echo htmlentities($row->name);?> <?php  echo htmlentities($row->lastname);?></td>

                          <td class="text-left"><?php  echo htmlentities($row->mobile);?></td>

                          <td class="text-left" ><?php  echo htmlentities($row->email);?></td>

                          <td class="text-left"><?php  echo htmlentities($row->permission);?></td>

                          <td class="text-left">

                           <button class="edit_data btn btn-xs btn-primary" id="<?php echo  ($row->id); ?>" title="click for edit"><i class="fas fa-edit"></i> Edit</button>

                           <a class="btn btn-xs btn-danger" href="userregister.php?delid=<?php echo ($row->id);?>" title="click for block" onclick="return confirm('sure to block ?')" ><i class="fas fa-ban"></i> Ban</a>

                         </td>

                       </tr>



                       <?php 

                     }

                   } ?>

                 </tbody>



               </table>

             </div>

             <!-- /.card-body -->

           </div>

           <!-- /.card -->

         </div>

         <!-- /.col -->

       </div>

       <!-- /.row -->

     </div>

     <!-- /.container-fluid -->

   </section>

   <!-- /.content -->

 </div>

 <!-- /.content-wrapper -->

 <?php @include("includes/footer.php"); ?>



 <!-- Control Sidebar -->

 <aside class="control-sidebar control-sidebar-dark">

  <!-- Control sidebar content goes here -->

</aside>

<!-- /.control-sidebar -->

</div>

<!-- ./wrapper -->

<?php @include("includes/foot.php"); ?>

<!-- page script -->

<script type="text/javascript">

  $(document).ready(function(){

    $(document).on('click','.edit_data',function(){

      var edit_id=$(this).attr('id');

      $.ajax({

        url:"edituser-form.php",

        type:"post",

        data:{edit_id:edit_id},

        success:function(data){

          $("#info_update").html(data);

          $("#editData").data('ajax-src', 'edituser-form.php').modal('show');
            $("#editData").find('form:not([action])').attr('data-ajax-action', 'edituser-form.php');

        }

      });

    });

  });

</script>

</body>

</html>



