<?php
ob_start();
session_start();

require_once 'includes.php';

require_once("conn.php");

require_once("config.php");

require_once 'dbconfig4.php';

if(isset($_SESSION['admin_user_id'])){

	$user_qury=mysqli_query($conn,"SELECT * FROM ormsusers WHERE user_id='$_SESSION[admin_user_id]'");

	$user_resalt=mysqli_fetch_array($user_qury);

	$customer = $user_resalt['user_id'];
	
	$adminbalance = number_format((float)$user_resalt['balance'],2);

	if($user_resalt['image']==""){

		$image_path="images/empty.jpg";

	}

	else{

		$image_path="../dashboard/images/admin/".$user_resalt['image'];

	}

}


if(isset($_GET['remove'])){
	$remove=mysqli_real_escape_string($conn,$_GET['remove']);
	mysqli_query($conn,"DELETE FROM ormsvideoclass WHERE classid='$remove'");
	echo "<script>window.location='videoclass.php';</script>";
}
?>

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

<head>
	
	<meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>District | Mobile Recharge and Billing System | ORMS | Dashbaord</title>
    <?php
	require_once 'headercss.php';
	?>

</head>

<body>

        <!--**********************************
        Main wrapper start
    ***********************************-->
    <div id="main-wrapper">
	
<?php
require_once 'header.php';
?>

        <!--**********************************
            Sidebar start
        ***********************************-->
        <div class="deznav">
            <div class="deznav-scroll">
<?php

require_once 'sidebarmenu.php';

?>
            </div>
        </div>
        <!--**********************************
            Sidebar end
        ***********************************-->
		
        <!--**********************************
            Content body start
        ***********************************-->
        <div class="content-body">
            <!-- row -->
            <div class="container-fluid">
				<div class="row">
				<div class="col-xl-12 col-xxl-12 col-sm-12">
				<div class="alert alert-danger bg-danger text-white" role="alert">
				<strong>Alert!</strong> ඔබගේ ගිනුම තහවුරු කිරීම අසම්පුර්නයි.<a href="identity_verify.php" class="btn btn-success float-right" style="padding: 0px 3px;">සම්පුර්න කරන්න</a>
				</div>
				</div>
				</div>    
                <div class="row page-titles mx-0">
                    <div class="col-sm-6 p-md-0">
                        <div class="welcome-text">
                            <h4>All District</h4>
                        </div>
                    </div>
                    <div class="col-sm-6 p-md-0 justify-content-sm-end mt-2 mt-sm-0 d-flex">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="home.php">Home</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">District</a></li>
                            <li class="breadcrumb-item active"><a href="javascript:void(0);">All District</a></li>
                        </ol>
                    </div>
                </div>
				
				<div class="row">
					<div class="col-lg-12">
						<div class="row tab-content">
							<div id="list-view" class="tab-pane fade active show col-lg-12">
								<div class="card">
									<div class="card-header">
										<h4 class="card-title">All District </h4>
										<a href="add_district.php" class="btn btn-square btn-secondary">+ Add District</a>
									</div>
									<div class="card-body">
										<div class="table-responsive">
											<table id="example3" class="table table-bordered">
												<thead>
													<tr>
														<th>#</th>
														<th>Action</th>
														<th>Status</th>
														<th>Province</th>
														<th>District Name</th>
														<th>Add Date/Time</th>
													</tr>
												</thead>
												<tbody>
<?php
$count=0;
$list_qury=mysqli_query($conn,"SELECT * FROM ormsdistrict where userid='".$_SESSION['admin_user_id']."' ORDER BY did DESC");

while($list_resalt=mysqli_fetch_array($list_qury)){
$count++;

?>
<tr>
<td><?php echo number_format($count,0); ?></td>
<td align="center">
<a href="edit_district.php?did=<?php echo $list_resalt['did']; ?>" class="btn btn-sm btn-primary"><i class="fa fa-lg fa-edit"></i></a>
<a href="district.php?remove=<?php echo $list_resalt['did']; ?>" onClick="JavaScript:return confirm('Are your sure delete district?');" class="btn btn-sm btn-danger"><i class="fa fa-lg fa-trash"></i></a>
</td>
<td><?php 
						
							if($list_resalt['status'] == "Dective"){

								echo '<button class="btn btn-danger btn-sm" on>Dective</button>';

							}else if($list_resalt['status'] == "Active"){

								echo '<button class="btn btn-success btn-sm">Active</button>';

							}
						?></td>
<td><?php

						$id = $list_resalt['province'];

						$query = $DB_con->prepare('SELECT pname FROM ormsprovince WHERE poid='.$id);

						$query->execute();

						$result = $query->fetch();

						echo $result['pname'];

					  ?></td>
<td><h5 class="badge badge-primary"><?php echo $list_resalt['dname']; ?></h5></td>									
<td><?php echo date_format(date_create($list_resalt['add_date']),"M d, Y - h:i:s A"); ?></td>
													
												</tr>
								<?php 
								}
								?>
												</tbody>
											</table>
										</div>
									</div>
                                </div>
                            </div>
						</div>
					</div>
				</div>
				
            </div>
        </div>
        <!--**********************************
            Content body end
        ***********************************-->


        <?php
		require_once 'footer.php';
		?>

		<!--**********************************
           Support ticket button start
        ***********************************-->

        <!--**********************************
           Support ticket button end
        ***********************************-->


    </div>
    <!--**********************************
        Main wrapper end
    ***********************************-->

    <?php
	require_once 'footerjs.php';
	?>
    
	
</body>
</html>