<?php 
include("../connection.php");
include("../user.php");

$user_id = $_REQUEST['id'];
$edituser = mysqli_fetch_array(mysqli_query($con, "SELECT * FROM branch_master WHERE id='$user_id'"));
?>
<!doctype html>
<html class="no-js" lang=""> 
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php  ?></title>
    <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="apple-touch-icon" href="../images/bluebase.png">
    <link rel="shortcut icon" href="../images/bluebase.png">
    <style>
        input, textarea {
            text-transform: uppercase;
        }
    </style> 
</head>
<body>
    <div class="col-lg-8">
        <div class="card">
            <div class="card-header">
                <strong>Edit DIVISION</strong>
                <a href="branch_master_view.php">
                    <button class="btn btn-primary" style="width:50px;margin-left:450px;"><i class="fa fa-backward"></i></button>
                </a>			
            </div>
            <div class="card-body card-block">
                <form method="post" enctype="multipart/form-data" class="form-horizontal" action="branch_update.php">
                    <div class="row form-group">
                        <div class="col col-md-3"><label for="text-input" class="form-control-label">Branch Name</label></div>
                        <div class="col-12 col-md-9">
                            <input type="text" id="branch_name" name="branch_name" value="<?php echo $edituser['branch_name']; ?>" placeholder="Enter Branch Name" class="form-control" autocomplete="off" onchange="branchval(this.value)" >
                        </div>
                    </div>
                    <div class="row form-group">
                        <div class="col col-md-3"><label for="text-input" class="form-control-label">Division</label></div>
                    <div class="col-12 col-md-9"><input type="text" id="division" name="division" placeholder="Enter Division" class="form-control" autocomplete="off" value="<?php echo $edituser['division']; ?>" ></div>
            		</div>
                    <div class="row form-group">
                        <div class="col col-md-3"><label for="text-input" class=" form-control-label">Tower</label></div>
            		    <div class="col-12 col-md-9">
            		        <select id="tower" name="tower" placeholder="SELECT TOWER" class="form-control select-search" autocomplete="off" >
            					<option value="" selected disabled>SELECT TOWER</option>
            					<?php
            					$brn = mysqli_query($con, "SELECT id,location FROM location_master where  status='0' order by location asc");
            					while ($brc = mysqli_fetch_array($brn)) {
            					?>
            						<option value="<?php echo $brc['id']; ?>" <?php if($edituser['tower'] == $brc['id']){ echo "selected";} ?>><?php echo strtoupper($brc['location']); ?></option>
            					<?php
            					}
            					?>
            				</select>
            			</div>
            		</div>
                    <input type="hidden" name="branch_id" value="<?php echo $user_id; ?>">
                    <div>
                        <button type="submit" name="submit" class="btn btn-success"><i class="fa fa-dot-circle-o"></i> Submit</button>
                    </div>
                </form>
            </div>
        </div>
        <div class="clearfix"></div>
        <footer class="site-footer"></footer>
    </div><!-- /#right-panel -->
    <script>
        // Initialize Select2
        $(document).ready(function() {
            $('.select-search').select2({
                placeholder: "-- SELECT --",  // Optional placeholder text
                allowClear: true                // Optional: allows clearing the selection
            });
        });
    </script>
</body>
</html>  
