<?php include('session.php'); ?>
<!DOCTYPE html>
<html lang="en">
  <head>
	<title>ECIMS ADMIN | ADD BUILDING</title>
    <?php include('includes/head.php'); ?>
  </head>
  <body>
    <div class="container-scroller">
      <div class="horizontal-menu">
        <?php include('includes/header.php'); ?>
      </div>
      <div class="container-fluid page-body-wrapper">
        <div class="main-panel">
          <div class="content-wrapper">
            <div class="page-header">
              <h3 class="page-title"> Add Building </h3>
            </div>
            <div class="row">
              <div class="col-12 grid-margin stretch-card">
                <div class="card">
                  <div class="card-body">
                      <?php $err = $msg = '';
							if(isset($_POST['submit'])) {
								$bNo = mysqli_real_escape_string($conn, $_POST['bNo']);
								$bName = mysqli_real_escape_string($conn, $_POST['bName']);
								$landmark = mysqli_real_escape_string($conn, $_POST['landmark']);
							$insert = $conn->query("INSERT INTO building_list (bNo,bName,landmark,isDeleted) VALUES('".$bNo."','".$bName."','".$landmark."','0')");
							if($insert){
								$msg = 'Data Added Successfully.';
							} else {
								$err = $conn->error;
							}
						}
						if(!empty($err)){
						  echo "
							<div class='alert alert-danger alert-dismissible'>
							  <h4><i class='fa fa-warning'></i> Error!</h4>
							  ".$err."
							</div>
						  ";
						}
						if(!empty($msg)){
						  echo "
							<div class='alert alert-success alert-dismissible'>
							  <h4><i class='fa fa-check'></i> Success!</h4>
							  ".$msg."
							</div>
						  ";
						}
						?>
                    <form class="forms-sample" method="POST">
                      <div class="form-group">
                        <label for="bNo">Building No</label>
                        <input type="text" class="form-control" required name="bNo" id="bNo" placeholder="Building No">
                      </div>
                      <div class="form-group">
                        <label for="bName">Building Name</label>
                        <input type="text" class="form-control" required name="bName" id="bName" placeholder="Building Name">
                      </div>
                      <div class="form-group">
                        <label for="landmark">Landmark</label>
                        <input type="text" class="form-control" required name="landmark" id="landmark" placeholder="Landmark">
                      </div>
                      <button type="submit" name="submit" class="btn btn-primary me-2">Submit</button>
                    </form>
                  </div>
                </div>
              </div>
            </div>
          </div>
		  <?php include('includes/footer.php'); ?>
        </div>
      </div>
    </div>
    <?php include('includes/foot.php'); ?>
  </body>
</html>