<?php
	session_start();
	include("library/conn.php");
?>
<!DOCTYPE html>
<html lang="en">
	<head>
        <?php include("library/head.php");?>
        <title>Identification Document Types | <?php echo $_SESSION['systemName']; ?></title>
	</head>
	<body class="app sidebar-mini">

		<!-- Navbar-->
		<?php include("library/header.php");?>
		<!-- Sidebar menu-->
		<div class="app-sidebar__overlay" data-toggle="sidebar"></div>
		<?php include("library/sidebar.php");?>
  
		<main class="app-content">
			<div class="app-title">
				<div>
					<h4 class="text-primary"><i class="fa fa-list-ul fa-lg"></i> IDENTIFICATION DOCUMENT TYPES</h4>
					<p>Identification Document Types Page</p>
				</div>
				<ul class="app-breadcrumb breadcrumb">
					<li class="breadcrumb-item"><i class="fa fa-home"></i></li>
					<li class="breadcrumb-item"><a href="identification-document-types">Identification Document Types</a></li>
				</ul>
			</div>
      
			<?php include("models/admin_config.php");?>
			<?php include("models/system_config.php");?>

			<div class="row">
				
				<div class="col-md-5">
					<div class="tile">
						<div class="tile-body">
							<div class="row">
								<div class="col-md-12">
                                    <h5 class="text-primary"><i class="fa fa-plus-square"></i> Register Identification Document Type</h5>									
                                    <hr />
								</div>
    							<div class="col-md-12">
                                    <form action="#" method="POST" id="addNewIdentificationDocumentTypePageForm">
                    					<div class="row">
                    						<div class="form-group col-md-12">
                    							<label class="control-label">Document Type Name</label>
                    							<input class="form-control" type="text" name="txtDocumentNameAddNewIdentificationDocumentTypePage" id="txtDocumentNameAddNewIdentificationDocumentTypePage" placeholder="Ex: Passport" required>
                    							<input type="hidden" name="txtRegisteredByAddNewIdentificationDocumentTypePage" id="txtRegisteredByAddNewIdentificationDocumentTypePage" value="<?php echo $_SESSION['userIdd']; ?>" required>
                    							<input type="hidden" name="txtRegisterDateAddNewIdentificationDocumentTypePage" id="txtRegisterDateAddNewIdentificationDocumentTypePage" value="<?php echo date("Y-m-d H:i:s");?>" required>
                    						</div>
                        					<div class="form-group col-md-12 text-right">
                        						<button type="submit" class="btn btn-success" name="btnAddNewIdentificationDocumentTypePage" id="btnAddNewIdentificationDocumentTypePage"><i class="fa fa-fw fa-lg fa-save"></i>Register Type</button>
                        					</div>
                        				</div>
					                </form>    							
					            </div>
						    </div>
					    </div>
				    </div>
			    </div>
			
			    <div class="col-md-7">
					<div class="tile">
						<div class="tile-body">
							<div class="row">
								<div class="col-md-12">
									<h5 class="text-primary"><i class="fa fa-list-ul"></i> Identification Document Type List</h5>
									<hr />
								</div>
    							<div class="col-md-12">
    								<table class="table table-bordered table-sm" id="identificationDocumentTypesTable">
    									<thead>
    										<tr class="text-center bg-dark text-white" height="35px">
                                                <th class="align-middle">No</th>
                                                <th class="align-middle">Document Type Name</th>
                                                <th class="align-middle">Action</th>
    										</tr>
    									</thead>
    									<tbody>
    										<?php
    										    $count_id_doc_type = 1;
    											$getIdentificationDocumentTypes = mysqli_query($conn, "SELECT * FROM identification_document_types ORDER BY documentTypeName ASC") or die(mysqli_error($conn));
    											while ($doc_type_rs = mysqli_fetch_array($getIdentificationDocumentTypes)) { ?>
                                                    <tr>
                                                        <td class="align-middle text-center"><?php echo $count_id_doc_type; ?></td>
                                                        <td class="align-middle" width="60%"><?php echo $doc_type_rs[2]; ?></td>
                                                        <td class="align-middle text-center" width="25%">
                                                            <div class="btn-group col-md-12">
                                                                <button type="button" class="btn btn-primary">Action</button>
                                                                <button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
                                                                    <span class="caret"></span>
                                                                </button>
                                                                <div class="dropdown-menu" style="min-width: 8rem;">
                                                                    <a href="#" class="dropdown-item text-primary btnUpdateIdentifictionDocumentType" id="<?php echo "Update". $doc_type_rs[1]; ?>" data-id="<?php echo $doc_type_rs[1]; ?>" data-toggle="modal" data-target="#updateIdentificationDocumentTypeModal"><i class="fa fa-edit"></i> Edit</a>
                                                                    <a href="#" class="dropdown-item text-danger btnDeleteIdentifictionDocumentType" id="<?php echo "Delete". $doc_type_rs[1]; ?>" data-id="<?php echo $doc_type_rs[1]; ?>"><i class="fa fa-trash"></i> Delete</a>
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr><?php
                                                    $count_id_doc_type++;
    											}
    										?>
    									</tbody>
    								</table>
    							</div>
						</div>
					</div>
				</div>


			</div>
			
		</main>
  
		<!-- Essential javascripts for application to work-->
		<?php include("library/footer.php");?>  
		<?php include("library/scripts.php");?>
		
		<script type="text/javascript">
		    $("#identificationDocumentTypesTable").DataTable({"pageLength": 100, "order": []})
		</script>

	</body>
</html>