File "branch_create.php"
Full path: /home/fsibplc/public_html/fsib/remittance/branch_create.php
File
size: 3.2 B (3.2 KB bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
include 'all_sql.php';
include 'sidebar.php';
$success = false;
if (isset($_POST['branch_create'])) {
$zone_id = $_POST['zone_id'];
$new_br_name = $_POST['new_br_name'];
$new_br_code = $_POST['new_br_code'];
$zone_name_sql = "SELECT DISTINCT(zone_id),`branch_div_details`.`zone` FROM `branch` INNER JOIN `branch_div_details` ON branch.branch_id = branch_div_details.branch_code WHERE zone_id = '$zone_id'";
$zone_name_sql_execute = $conn->query($zone_name_sql);
$total_zone = $zone_name_sql_execute->num_rows;
$all_zone_name = $zone_name_sql_execute->fetch_assoc();
$zone_name = $all_zone_name['zone'];
$insert_branch_tbl = "INSERT INTO `branch`(`zone_id`, `branch_id`, `branch_name`) VALUES ('$zone_id','$new_br_code','$new_br_name')";
$insert_branch_tbl_execute = $conn->query($insert_branch_tbl);
$affected_rows = $insert_branch_tbl_execute->num_rows;
$insert_branch_div_details_tbl = "INSERT INTO `branch_div_details`(`branch_name`, `branch_code`, `zone`) VALUES ('$new_br_name','$new_br_code','$zone_name')";
$insert_branch_div_details_tbl_execute = $conn->query($insert_branch_div_details_tbl);
$affected_rows1 = $insert_branch_div_details_tbl_execute->num_rows;
if (($insert_branch_tbl_execute) && ($insert_branch_div_details_tbl_execute)) {
$success = true;
}
}
?>
<div class="show-content">
<div class="card" style="width: 600px;margin:30px auto">
<h3 class="text-info mt-3 text-center">New Branch Create</h3>
<script>
<?php if ($success) { ?>
alert('New branch created successfully!\nZone: <?php echo $zone_name; ?>\nBranch Code: <?php echo $new_br_code; ?>\nBranch Name: <?php echo $new_br_name; ?>');
<?php } ?>
</script>
<form action="" method="post" class="p-5">
<div class="form-group row">
<label for="zone" class="form-label">Select Zone</label>
<select name="zone_id" id="zone_id" class="form-control">
<option value="">Select a Zone</option>
<?php
while ($all_zone = $zone_sql_execute->fetch_assoc()) {
?>
<option value="<?php echo $all_zone['zone_id']; ?>"><?php echo $all_zone['zone']; ?></option>
<<?php
}
?>
</select>
</div>
<div class="form-group row">
<label for="br_code" class="form-label">Branch Code</label>
<input type="text" name="new_br_code" id="new_br_code" class="form-control" required>
</div>
<div class="form-group row">
<label for="br_name" class="form-label">Branch Name</label>
<input type="text" name="new_br_name" class="form-control" required>
</div>
<div class="form-group row">
<input type="submit" value="Submit" name="branch_create" class="btn btn-success">
</div>
</form>
</div>
</div>
<script>
</script>
<?php include 'footer.php'; ?>