Skip to content

Commit

Permalink
added new fields for employee and also adding the employee to employe…
Browse files Browse the repository at this point in the history
…e table
  • Loading branch information
kamranzafar4343 committed Oct 25, 2024
1 parent 6e894dd commit ec7584b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
39 changes: 35 additions & 4 deletions create.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
$registration = mysqli_real_escape_string($conn, $_POST['registration']);
$expiry = mysqli_real_escape_string($conn, $_POST['expiry']);
$foc = mysqli_real_escape_string($conn, $_POST['foc']); //foc means focal person = contact person
$role = mysqli_real_escape_string($conn, $_POST['role']); //foc means focal person = contact person
$auth = mysqli_real_escape_string($conn, $_POST['authority']); //foc means focal person = contact person
$foc_phone = mysqli_real_escape_string($conn, $_POST['foc_phone']);
$comp_email = mysqli_real_escape_string($conn, $_POST['comp_email']);
$address = mysqli_real_escape_string($conn, $_POST['address']);
Expand All @@ -62,8 +64,9 @@
}

// Insert the record into the database
$sql = "INSERT INTO `compani` (`comp_name`, `acc_desc`, `registration`, `expiry`, `foc`, `foc_phone`, `email`, `add_1`)
VALUES ('$comp_name', '$registration', '$desc', '$expiry', '$foc', '$foc_phone', '$comp_email', '$address')";
$sql = "INSERT INTO `compani` (`comp_name`, `acc_desc`, `registration`, `expiry`, `foc`, `role`, `auth` , `foc_phone`, `email`, `add_1`)
VALUES ('$comp_name', '$registration', '$desc', '$expiry', '$foc', '$role', '$auth', '$foc_phone', '$comp_email', '$address')";


//added code to insert data into branch table and redirect to branches table of specific company
if (mysqli_query($conn, $sql)) {
Expand All @@ -72,10 +75,17 @@
$newCompanyId = mysqli_insert_id($conn);

$insertBranchSql = "INSERT INTO `branches` (`comp_id_fk`, `branch_name`, `account_desc`, `registration_date` , `expiry_date`, `contact_person`, `contact_phone`, `address`) VALUES ('$newCompanyId', '$comp_name Head Office', '$desc', '$registration', '$expiry', '$foc', '$foc_phone', '$address')";


if (mysqli_query($conn, $insertBranchSql)) {

//get id of newly inserted branch
$newBranchId = mysqli_insert_id($conn);

$addStaff = "INSERT INTO `employee` (`branch_id_fk`, `name`, `email`, `phone`, `role`, `Authority`) VALUES ('$newBranchId', '$foc', '$comp_email', '$foc_phone', '$role', '$auth') ";
}
}

if (mysqli_query($conn, $insertBranchSql)) {
if (mysqli_query($conn, $addStaff)) {
header("Location: Branches.php?id=" . $newCompanyId);
exit; // Stop further script execution
} else {
Expand Down Expand Up @@ -494,6 +504,27 @@
<label for="" class="form-label">Contact Person</label>
<input type="text" class="form-control" id="" name="foc" required pattern="[A-Za-z\s\.]+" required minlength="3" maxlength="38" title="only letters allowed; at least 3" required>
</div>
<div class="col-md-6">
<label for="" class="form-label">Role</label>
<select name="role" id="" class="form-select">
<option value="">Select Role of the Employee</option>
<option value="Branch Manager">Branch Manager</option>
<option value="Department Manager">Department Manager</option>
<option value="Junior Employee">Junior Employee</option>
<option value="Head of Operations">Head of Operations</option>
</select>
</div>

<div class="col-md-6">
<label for="phone" class="form-label">Access/Authority</label>
<select name="authority" id="" class="form-select">
<option value="">Select level of access</option>
<option value="can get information about branch boxes">can get information about branch boxes</option>
<option value="only retrieve department boxes">only retrieve department boxes</option>
<option value="all departments of their branch">all departments of their branch</option>
<option value="all departments and all branches of company">all departments and all branches of company</option>
</select>
</div>
<div class="col-md-6">
<label for="phone" class="form-label">Phone</label>
<input type="text" class="form-control" id="" name="foc_phone" required>
Expand Down
4 changes: 2 additions & 2 deletions updateStaff.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@

<head>
<meta charset="UTF-8">
<title>Update Company</title>
<title>Update Staff</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">


Expand Down Expand Up @@ -696,7 +696,7 @@
<!-- Start Header form -->
<div class="headerimg text-center">
<img src="image/update.png.png" alt="network-logo" width="50" height="50" />
<h2>Update</h2>
<h2>Update Staff Info</h2>
</div>
<!-- End Header form -->

Expand Down

0 comments on commit ec7584b

Please sign in to comment.