<?php
$iFileName =	ADMIN_URL . '?module=' . $_GET['module'] . '&section=' . $_GET['section'];
$validate = new Validation();
$iPageTitle = 'Manage Teachers';
if ($_SESSION['SUPER_ADMIN']['usertype'] == '2') {
	redirect('panel_login.php');
	exit;
}
if ($_SESSION['success'] != "") {
	$stat['success'] = $_SESSION['success'];
	unset($_SESSION['success']);
}
if (isset($_POST['addnewrecord'])) {
	$validate->addRule($_POST['fullname'], '', 'Name', true);
	$validate->addRule($_POST['email'], '', 'Email', true);
	$validate->addRule($_POST['phoneno'], '', 'Mobile', true);
	$validate->addRule($_POST['dob'], '', 'Date Of Birth', true);
	$validate->addRule($_POST['fathersname'], '', 'Fathers name', true);
	$validate->addRule($_POST['gender'], '', 'Gender', true);
	$validate->addRule($_POST['password'], '', 'Password', true);
	if ($validate->validate() && count($stat) == 0) {
		$iEmail = $db->getRow("select id from  admin_login where emailid='" . $_POST['email'] . "' limit 1");
		$iEmailStudent = $db->getRow("select id from  student_registration where email='" . $_POST['email'] . "' limit 1");
		if ($iEmail['id'] != '' || $iEmailStudent['id'] != '') {
			$stat['error'] = 'This email id is already exit.';
		} else {
			if (isset($_FILES["thumbnail"]["name"]) && !empty($_FILES["thumbnail"]["name"])) {
				$filename_thumbnail = basename($_FILES['thumbnail']['name']);
				$ext_thumbnail = strtolower(substr($filename_thumbnail, strrpos($filename_thumbnail, '.') + 1));
				if (in_array($ext_thumbnail, array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG', 'gif', 'webp', 'pdf', 'PDF'))) {
					$newfile_thumbnail =	md5(time()) . '-' . rand(10000, 99999) . '.' . $ext_thumbnail;
					move_uploaded_file($_FILES['thumbnail']['tmp_name'], "../uploads/" . $newfile_thumbnail);
				}
			}
			$aryData = array(
				'token'    			=>	token($iPreFix . 'admin_login'),
				'firstname'   		    =>	$_POST['fullname'],
				'emailid'   		  =>	$_POST['email'],
				'mobileno'   		=>	$_POST['phoneno'],
				'dob'   		    =>	$_POST['dob'],
				'fathersname'   =>	$_POST['fathersname'],
				'gender'   			=>	$_POST['gender'],
				'password'   		=>	md5($_POST['password']),
				'location'   		=>	$_POST['location'],
				'status'   		=>	$_POST['status'],
				'usertype'   		    =>	$_POST['usertype'],
				'create_by' =>  $_SESSION['SUPER_ADMIN']['id'],
				'updated_by' =>  $_SESSION['SUPER_ADMIN']['id'],
				'create_at'   => date("Y-m-d h:i:s"),
			);
			$flgIn = $db->insertAry($iPreFix . "admin_login", $aryData);
			// echo $flgIn = $db->getLastQuery(); exit;
			$_SESSION['success'] = "Submited Successfully";
			redirect($iFileName);
			unset($_POST);
		}
	} else {
		$stat['error'] = $validate->errors();
	}
} elseif (isset($_POST['updaterecord'])) {
	$validate->addRule($_POST['fullname'], '', 'Name', true);
	$validate->addRule($_POST['email'], '', 'Email', true);
	$validate->addRule($_POST['phoneno'], '', 'Mobile', true);
	$validate->addRule($_POST['dob'], '', 'Date Of Birth', true);
	$validate->addRule($_POST['fathersname'], '', 'Fathers name', true);
	$validate->addRule($_POST['gender'], '', 'Gender', true);
	if ($validate->validate() && count($stat) == 0) {
		$iEmail = $db->getRow("select id from  admin_login where emailid='" . $_POST['email'] . "' and token!='" . $_GET['token'] . "' limit 1");
		$iEmailStudent = $db->getRow("select id from  student_registration where email='" . $_POST['email'] . "'  and token!='" . $_GET['token'] . "'  limit 1");
		if ($iEmail['id'] != '' || $iEmailStudent['id'] != '') {
			$stat['error'] = 'This email id is already exit.';
		} else {
			if (isset($_FILES["thumbnail"]["name"]) && !empty($_FILES["thumbnail"]["name"])) {
				$filename_thumbnail = basename($_FILES['thumbnail']['name']);
				$ext_thumbnail = strtolower(substr($filename_thumbnail, strrpos($filename_thumbnail, '.') + 1));
				if (in_array($ext_thumbnail, array('jpg', 'jpeg', 'png', 'JPG', 'JPEG', 'PNG', 'gif', 'webp', 'pdf', 'PDF'))) {
					$newfile_thumbnail =	md5(time()) . '-' . rand(10000, 99999) . '.' . $ext_thumbnail;
					move_uploaded_file($_FILES['thumbnail']['tmp_name'], "../uploads/" . $newfile_thumbnail);
				}
			} else {
				$newfile_thumbnail = $_POST['thumbnail_old'];
			}
			$aryData = array(
				'firstname'   		    =>	$_POST['fullname'],
				'emailid'   		  =>	$_POST['email'],
				'mobileno'   		=>	$_POST['phoneno'],
				'dob'   		    =>	$_POST['dob'],
				'fathersname'   =>	$_POST['fathersname'],
				'gender'   			=>	$_POST['gender'],
				'location'   			=>	$_POST['location'],
				'status'   		=>	$_POST['status'],
				'usertype'   		    =>	$_POST['usertype'],
				'updated_by' =>  $_SESSION['SUPER_ADMIN']['id'],
			);
			$flgIn = $db->updateAry("admin_login", $aryData, "where token='" . $_GET['token'] . "'");
			// echo $flgIn = $db->getLastQuery(); exit;
			$_SESSION['success'] = "Update Successfully";
			redirect($iFileName);
			unset($_POST);
		}
	} else {
		$stat['error'] = $validate->errors();
	}
} elseif (isset($_POST['changepasswordrecord'])) {
	$validate->addRule($_POST['password'], '', 'Password', true);
	if ($validate->validate() && count($stat) == 0) {
		$aryData = array(
			'password'   		    =>	md5($_POST['password']),
		);
		$flgIn = $db->updateAry("admin_login", $aryData, "where token='" . $_GET['token'] . "'");
		//	 echo $flgIn = $db->getLastQuery(); exit;
		$_SESSION['success'] = "Update Successfully";
		redirect($iFileName);
		unset($_POST);
	} else {
		$stat['error'] = $validate->errors();
	}
} elseif (($_REQUEST['action'] == 'delete')) {
	$flgIn = $db->delete($iPreFix . "admin_login", "where token='" . $_GET['token'] . "'");
	$_SESSION['success'] = 'Deleted Successfully';
	redirect($iFileName);
}
?>
<!DOCTYPE html>
<html lang="en">

<head>
	<style>
		.statcls3 {
			background: #ffb339;
		}

		.statcls3::before {
			font-size: 14px;
			content: 'Pending';
			background: #ffb339;
		}

		.btn-list {
			margin-bottom: 8px;
		}
	</style>
	<?php include('inc.meta.php'); ?>
</head>

<body>
	<?php include('inc.header.php'); ?>
	<?php include('inc.sidemenu.php'); ?>
	<div class="main-panel">
		<div class="container-fluid">
			<div class="row">
				<div class="col-12">
					<h1 class="page-title"><?php echo $iPageTitle; ?></h1>
				</div>
			</div>
			<div class="card">
				<div class="row">
					<div class="col-lg-8"><?php echo msg($stat); ?></div>
					<div class="col-lg-3"><a href="<?php echo $iFileName; ?>&action=add" title="Add record" class="btn-add"><i class="ti-plus"></i> Add New Record</a> </div>
				</div>
			</div>
			<?php if ($_GET['action'] == 'add') { ?>
				<div class="row my-4">
					<div class="col-12">
						<div class="card">
							<div class="card-body">
								<form action="" method="POST" enctype="multipart/form-data">
									<div class="row">
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">
													Name </label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control" name="fullname"
															value="<?php echo $_POST['fullname']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">
													Email Id </label>
												<div class="row">
													<div class="col-12">
														<input type="text" required class="form-control" name="email" value="<?php echo $_POST['email']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Phone No. </label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control" name="phoneno" value="<?php echo $_POST['phoneno']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label"> Date Of Birth </label>
												<div class="row">
													<div class="col-12">

														<input type="calender" class="form-control datepicker" onkeypress="return false" name="dob"
															value="<?php echo $_POST['dob']; ?>">


													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label"> Fathers Name </label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control" name="fathersname" value="<?php echo $_POST['fathersname']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Gender </label>
												<div class="row">
													<div class="col-12" style="padding-top:7px;display:flex;gap:6px;">
														<span>Male</span>
														<input type="radio" name="gender" value="0" <?php if ($_POST['gender'] == 0) {
																										echo 'checked';
																									} ?>>
														<span>Female</span>
														<input type="radio" name="gender" value="1" <?php if ($_POST['gender'] == 1) {
																										echo 'checked';
																									} ?>>
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Password </label>
												<div class="row">
													<div class="col-12">
														<input type="password" class="form-control" name="password" value="<?php echo $_POST['password']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Training Center Location</label>
												<div class="row">
													<div class="col-12">
														<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
															<select class="form-select" name="location">
																<?php $i = 0;
																$iMultiRecord = $db->getRows("select * from training_center");
																foreach ($iMultiRecord as $iList) {
																?>
																	<option value="<?php echo $iList['id']; ?>"
																		<?php if ($iList['id'] == $iSingleRecord['location']) {
																			echo 'selected';
																		} ?>>
																		<?php echo $iList['location']; ?>
																	</option>
																<?php } ?>
															</select>
														<?php } else {
															$iAdminLocation = $db->getRow("select location from admin_login where id='" . $_SESSION['SUPER_ADMIN']['id'] . "'");
															$iMultiRe = $db->getRow("select location from training_center where id='" . $iAdminLocation['location'] . "'");
														?>
															<input type="hidden" class="form-control" value="<?php echo $iAdminLocation['location']; ?>"
																name="location">
															<?php echo $iMultiRe['location']; ?>
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
													<label class="form-label">User Type</label>
												<?php } ?>
												<div class="row">
													<div class="col-12">
														<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
															<select class="form-select" name="usertype">
																<option value="1" <?php if ($iSingleRecord['usertype'] == '1') {
																						echo 'selected';
																					} ?>>Higher Authority</option>
																<option value="2" <?php if ($iSingleRecord['usertype'] == '2') {
																						echo 'selected';
																					} ?>>Teacher</option>
															</select>
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
													<label class="form-label">Status</label>
												<?php } ?>
												<div class="row">
													<div class="col-12">
														<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
															<select class="form-select" name="status">
																<option value="3" <?php if ($iSingleRecord['status'] == '3') {
																						echo 'selected';
																					} ?>>Pending</option>
																<option value="1" <?php if ($iSingleRecord['status'] == '1') {
																						echo 'selected';
																					} ?>>Active</option>
																<option value="0" <?php if ($iSingleRecord['status'] == '0') {
																						echo 'selected';
																					} ?>>Inactive</option>
															</select>
														<?php } else { ?>
															<input type="hidden" value="3" name="status">
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="row footsect">
										<div class="col-12">
											<button type="submit" name="addnewrecord" class="btn-submit"><i class="fa fa-paper-plane-o"></i> Submit</button>
											<a href="<?php echo $iFileName; ?>" class="btn-back"><i class="ti-back-left"></i> Back</a>
										</div>
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			<?php } elseif ($_GET['action'] == 'edit') {
				$iSingleRecord = $db->getRow("select * from  " . $iPreFix . "admin_login where token='" . $_GET['token'] . "' limit 1");
				//if($iSingleRecord['id']=='')	{	redirect($iFileName); exit; }
				$it = $db->getRow("select * from  admin_login where id='" . $iSingleRecord['id'] . "'");
				$location = $db->getRow("select * from training_center where id='" . $it['location'] . "' ");
			?>
				<div class="row my-4">
					<div class="col-12">
						<div class="card">
							<div class="card-body">
								<form action="" method="POST" enctype="multipart/form-data">
									<div class="row">
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Teachers Name</label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control" name="fullname" value="<?php echo $iSingleRecord['firstname']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Email Id</label>
												<div class="row">
													<div class="col-12">
														<input type="text" required class="form-control" name="email" value="<?php echo $iSingleRecord['emailid']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Phone No. </label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control" name="phoneno" value="<?php echo $iSingleRecord['mobileno']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Date Of Birth </label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control datepicker" name="dob" value="<?php echo $iSingleRecord['dob']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Fathers Name </label>
												<div class="row">
													<div class="col-12">
														<input type="text" class="form-control" name="fathersname" value="<?php echo $iSingleRecord['fathersname']; ?>">
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Gender </label>
												<div class="row">
													<div class="col-12" style="padding-top:7px;display:flex;gap:6px;">
														<span>Male</span>
														<input type="radio" name="gender" value="0" <?php if ($iSingleRecord['gender'] == 0) {
																										echo 'checked';
																									} ?>>
														<span>Female</span>
														<input type="radio" name="gender" value="1" <?php if ($iSingleRecord['gender'] == 1) {
																										echo 'checked';
																									} ?>>
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Location</label>
												<div class="row">
													<div class="col-12">
														<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
															<select class="form-select" name="location">
																<?php $i = 0;
																$iMultiRecord = $db->getRows("select * from training_center");
																foreach ($iMultiRecord as $iList) {
																?>
																	<option value="<?php echo $iList['id']; ?>" <?php if ($iList['id'] == $iSingleRecord['location']) {
																													echo 'selected';
																												} ?>>
																		<?php echo $iList['location']; ?>
																	</option>
																<?php } ?>
															</select>
														<?php } else { ?>
															<input type="hidden" class="form-control" value="<?php echo $location['id']; ?>" name="location">
														<?php echo $location['location'];
														} ?>
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
													<label class="form-label">User Type</label>
												<?php } ?>
												<div class="row">
													<div class="col-12">
														<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
															<select class="form-select" name="usertype">
																<option value="1" <?php if ($iSingleRecord['usertype'] == '1') {
																						echo 'selected';
																					} ?>>Higher Authority</option>
																<option value="2" <?php if ($iSingleRecord['usertype'] == '2') {
																						echo 'selected';
																					} ?>>Teacher</option>
															</select>
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
													<label class="form-label">Status </label>
												<?php } ?>
												<div class="row">
													<div class="col-12">
														<?php if ($_SESSION['SUPER_ADMIN']['usertype'] == 0) { ?>
															<select class="form-select" name="status">
																<option value="1" <?php if ($iSingleRecord['status'] == '1') {
																						echo 'selected';
																					} ?>>Active</option>
																<option value="0" <?php if ($iSingleRecord['status'] == '0') {
																						echo 'selected';
																					} ?>>Inactive</option>
																<option value="3" <?php if ($iSingleRecord['status'] == '3') {
																						echo 'selected';
																					} ?>>Pending</option>
															</select>
														<?php } else { ?>
															<input type="hidden" value="<?php echo $iSingleRecord['status']; ?>" name="status">
														<?php } ?>
													</div>
												</div>
											</div>
										</div>
										<div class="row footsect">
											<div class="col-12">
												<button type="submit" name="updaterecord" class="btn-submit"><i class="fa fa-paper-plane-o"></i> Submit</button>
												<a href="<?php echo $iFileName; ?>" class="btn-back"><i class="ti-back-left"></i> Back</a>
											</div>
										</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			<?php } elseif ($_GET['action'] == 'view') {
				$iSingleRecord = $db->getRow("select * from  " . $iPreFix . "admin_login where token='" . $_GET['token'] . "' limit 1");
			?>
				<div class="row my-4">
					<div class="col-12">
						<div class="card">
							<div class="card-body">
								<form action="" method="POST">
									<div class="row">
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label col-12">Teachers Name</label>
												<?php echo $iSingleRecord['firstname']; ?>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label col-12">Email Id</label>
												<?php echo $iSingleRecord['emailid']; ?>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label col-12">Phone No.</label>
												<?php echo $iSingleRecord['mobileno']; ?>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label datepicker col-12">Date Of Birth</label>
												<?php echo $iSingleRecord['dob']; ?>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label col-12">Fathers Name</label>
												<?php echo $iSingleRecord['fathersname']; ?>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label col-12">Gender</label>
												<?php if ($iSingleRecord['gender'] == 0) {
													echo "Male";
												} else {
													echo "Female";
												} ?>
											</div>
										</div>
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label col-12">location</label>
												<?php
												$ilocation = $db->getRow("select location from  training_center where id='" . $iSingleRecord['location'] . "' limit 1");
												?>
												<?php echo 	$ilocation['location']; ?>
											</div>
											<div class="col-lg-6">
												<div class="form-group">
													<label class="form-label col-12">Status</label>
													<?php if ($iSingleRecord['status'] == '1') {
														echo 'Active';
													} elseif ($iSingleRecord['status'] == '0') {
														echo 'Inactive';
													} elseif ($iSingleRecord['status'] == '3') {
														echo 'Pending';
													} ?>
												</div>
											</div>
										</div>
										<div class="row footsect">
											<div class="col-12"> <a href="<?php echo $iFileName; ?>" class="btn-back"><i class="ti-back-left"></i> Back</a> </div>
										</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			<?php } elseif ($_GET['action'] == 'changepassword') {
				$iSingleRecord = $db->getRow("select * from  " . $iPreFix . "admin_login where token='" . $_GET['token'] . "' limit 1");  ?>
				<div class="row my-4">
					<div class="col-12">
						<div class="card">
							<div class="card-body">
								<form action="" method="POST" enctype="multipart/form-data">
									<div class="row">
										<div class="col-lg-6">
											<div class="form-group">
												<label class="form-label">Change Password </label>
												<div class="row">
													<div class="col-12">
														<input type="text" placeholder="Please Enter New Passowrd " class="form-control" name="password">
													</div>
												</div>
											</div>
										</div>
										<div class="row footsect">
											<div class="col-12">
												<button type="submit" name="changepasswordrecord" class="btn-submit"><i class="fa fa-paper-plane-o"></i> Submit</button>
												<a href="<?php echo $iFileName; ?>" class="btn-back"><i class="ti-back-left"></i> Back</a>
											</div>
										</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			<?php } else { ?>
				<div class="row my-4">
					<div class="col-12">
						<div class="card">
							<div class="card-body">
								<div class="table-responsive">
									<table class="datatable table table-striped table-bordered" style="width:100%">
										<thead>
											<tr>
												<th>#</th>
												<th>Teacher Name</th>
												<th>Email Id</th>
												<th>Phone No.</th>
												<th>Date Of Birth</th>
												<th>Fathers Name</th>
												<th>Gender</th>
												<th>Location</th>
												<th>User Type</th>
												<th>Created By</th>
												<th>Last Updated By</th>
												<th>Status</th>
												<th>Action</th>
											</tr>
										</thead>
										<tbody>
											<?php $i = 0;
											$iTeacherDetail = $db->getRow("select  location from admin_login where id='" . $_SESSION['SUPER_ADMIN']['id'] . "'");
											if ($_SESSION['SUPER_ADMIN']['usertype'] != 0) {
												$iMultiRecord = $db->getRows("select * from " . $iPreFix . "admin_login where id!=1 and id!='" . $_SESSION['SUPER_ADMIN']['id'] . "' and location='" . $iTeacherDetail['location'] . "'");
											} else {
												$iMultiRecord = $db->getRows("select * from " . $iPreFix . "admin_login where id!=1");
											}
											foreach ($iMultiRecord as $iList) {
												$i = $i + 1;

												$iCreatedBy = $db->getRow("select * from admin_login where id='" . $iList['create_by'] . "'  ");
												$iUpdateBy = $db->getRow("select * from admin_login where id='" . $iList['updated_by'] . "'  ");
											?>
												<tr>
													<td><?php echo $i;  ?></td>
													<td> <?php echo $iList['firstname']; ?></td>
													<td> <?php echo $iList['emailid']; ?></td>
													<td> <?php echo $iList['mobileno']; ?></td>
													<td> <?php echo $iList['dob']; ?></td>
													<td> <?php echo $iList['fathersname']; ?></td>
													<td> <?php if ($iList['gender'] == 0) {
																echo "Male";
															} else {
																echo "Female";
															} ?></td>
													<td> <?php $ilocation = $db->getRow("select location from  training_center where id='" . $iList['location'] . "' limit 1"); ?>
														<?php echo 	$ilocation['location']; ?></td>
													<td> <?php if ($iList['usertype'] == 1) {
																echo "Higher Authority";
															} else if ($iList['usertype'] == 2) {
																echo "Teacher";
															} ?></td>
													<td><?php echo $iCreatedBy['firstname']; ?></td>
													<td><?php echo $iUpdateBy['firstname']; ?></td>
													<td><span class="statcls statcls<?php echo $iList['status']; ?>"><?php echo $iList['status']; ?></span></td>
													<td>
														<a href="<?php echo $iFileName; ?>&action=view&token=<?php echo $iList['token']; ?>" class="btn-list" title="View record"><i class="ti-search"></i>View </a>
														<a href="<?php echo $iFileName; ?>&action=edit&token=<?php echo $iList['token']; ?>" class="btn-list" title="Update record"><i class="ti-pencil-alt"></i>Edit</a>
														<a href="<?php echo $iFileName; ?>&action=changepassword&token=<?php echo $iList['token']; ?>" class="btn-list" title="Update record"><i class="ti-pencil-alt"></i>Change Password</a>
														<a href="javascript:del('<?php echo $iFileName; ?>&action=delete&token=<?php echo $iList['token']; ?>')" class="btn-list" title="Delete record"><i class="ti-trash"></i>Delete</a>
													</td>
												</tr>
											<?php } ?>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
		<?php include('inc.footer.php'); ?>
	</div>
	<?php include('inc.js.php'); ?>
	<script>
		function formatDate() {
			const dateInput = document.getElementById('birthdate').value;
			if (dateInput) {
				const date = new Date(dateInput);
				const year = date.getFullYear().toString().slice(-2); // Get last 2 digits of the year
				const month = (date.getMonth() + 1).toString().padStart(2, '0'); // Month is zero-based
				const day = date.getDate().toString().padStart(2, '0');
				const formattedDate = `${year}-${month}-${day}`;

				document.getElementById('formattedDate').textContent = `Formatted Date: ${formattedDate}`;
			} else {
				document.getElementById('formattedDate').textContent = 'No date selected';
			}
		}
	</script>
</body>

</html>