<?php


include('nav.php');

$getID = $_GET['id'];

// Connect to the database
$mysqli = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);

// output any connection error
if ($mysqli->connect_error) {
	die('Error : ('.$mysqli->connect_errno .') '. $mysqli->connect_error);
}

// the query
$query = "SELECT * FROM store_customers WHERE id = '" . $mysqli->real_escape_string($getID) . "'";

$result = mysqli_query($mysqli, $query);

// mysqli select query
if($result) {
	while ($row = mysqli_fetch_assoc($result)) {

		$customer_name = $row['name']; // customer name
		$customer_email = $row['email']; // customer email
		$customer_address_1 = $row['address_1']; // customer address
		$customer_address_2 = $row['address_2']; // customer address
		$customer_town = $row['town']; // customer town
		$customer_county = $row['county']; // customer county
		$customer_postcode = $row['postcode']; // customer postcode
		$customer_phone = $row['phone']; // customer phone number
		
		//shipping
		$customer_name_ship = $row['name_ship']; // customer name (shipping)
		$customer_address_1_ship = $row['address_1_ship']; // customer address (shipping)
		$customer_address_2_ship = $row['address_2_ship']; // customer address (shipping)
		$customer_town_ship = $row['town_ship']; // customer town (shipping)
		$customer_county_ship = $row['county_ship']; // customer county (shipping)
		$customer_postcode_ship = $row['postcode_ship']; // customer postcode (shipping)
	}
}

/* close connection */
$mysqli->close();

?>

<div style="margin-top: 15px; padding-left: 10px; "  class="hp-main-layout-content">
                <div class="row mb-32 gy-32">
                <div class="col-12">


				
            <div class="col-lg-12">

							<div class="page-header-modern">
            <h2 class="header-modern">Update Customer</h2>

    <div class="user-dropdown dropdown">
        <button class="btn btn-user" type="button" data-toggle="dropdown">
            <i class=""></i>
             <img src="images/icon/invoice360-user.png" height=30px; width=30px;>
            <span class="caret"></span>
        </button>

        <ul class="dropdown-menu user-menu" aria-labelledby="userDropdown">
            <li>
                <a class="dropdown-item" href="">
                    <i class="fa fa-user me-2"></i> <?php echo strtok($_SESSION['user_name'], ' ');?> (<?php echo $_SESSION['role']; ?>)
                </a>
            </li>

            <li>
                <a class="dropdown-item" href="Admin/payment-details.php">
                    <i class="fa fa-credit-card"></i> Billing history
                </a>
            </li>

            <li>
                <a class="dropdown-item" href="Admin/company-profile.php">
                    <i class="fa fa-cog me-2"></i> Settings
                </a>
            </li>

            <li><hr class="dropdown-divider"></li>

            <li>
                <a class="dropdown-item text-danger" href="logout.php">
                    <i class="fa fa-sign-out me-2"></i> Sign Out
                </a>
            </li>
        </ul>
        </div>
    </div>
					
                </div>
                <div class="card">
                    
                            
                        <div class="card-body">
		<!-- <hr> -->

		<div id="response" class="alert alert-success" style="display:none;">
			<a href="#" class="close" data-dismiss="alert">&times;</a>
			<div class="message"></div>
		</div>
        <form method="post" id="update_customer">
	<input type="hidden" name="action" value="update_customer">
	<input type="hidden" name="id" value="<?php echo $getID; ?>">
			
			
			<div class="row">

    <!-- LEFT: CUSTOMER INFORMATION -->
    <div style="margin-top: 25px;" class="col-xl-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <h4>
                    <i class="fa fa-user text-primary"></i> 
                    Select Customer Information

					
                </h4>

				
                
				
            </div>

            <div class="panel-body form-group">
                <div class="row">

                    <div class="col-xs-6">
                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom copy-input required" name="customer_name" id="customer_name" placeholder="Customer Name" tabindex="1" value="<?php echo $customer_name; ?>">
                        </div>

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom copy-input required" name="customer_address_1" id="customer_address_1" placeholder="Address Line 1" tabindex="3" value="<?php echo $customer_address_1; ?>">
                        </div>

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom copy-input required" name="customer_town" id="customer_town" placeholder="Town / City" tabindex="5" value="<?php echo $customer_town; ?>">
                        </div>

                        <div class="form-group no-margin-bottom">
                            <input type="text" class="form-control copy-input" name="customer_postcode" id="customer_postcode" placeholder="Postcode" tabindex="7" value="<?php echo $customer_postcode; ?>">
                        </div>
                    </div>

                    <div class="col-xs-6">

                        <div class="form-group">
                            <div class="input-group margin-bottom">
                                <span class="input-group-addon"><i class="fa fa-envelope"></i></span>
                                <input type="email" class="form-control copy-input" name="customer_email" id="customer_email" placeholder="Email Address" tabindex="2" value="<?php echo $customer_email; ?>">
                            </div>
                        </div>

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom copy-input" name="customer_address_2" id="customer_address_2" placeholder="Address Line 2" tabindex="4" value="<?php echo $customer_address_2; ?>">
                        </div>

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom copy-input" name="customer_county" id="customer_county" placeholder="Country" tabindex="6" value="<?php echo $customer_county; ?>">
                        </div>

                        <div class="form-group no-margin-bottom">
                            <input type="text" class="form-control" name="customer_phone" id="customer_phone" placeholder="Phone Number" tabindex="8" value="<?php echo $customer_phone; ?>">
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>

    <!-- RIGHT: SHIPPING INFORMATION -->
    <div style="margin-top: 25px;"  class="col-xl-6">
        <div class="panel panel-default">
            <div class="panel-body">
                <h4>
                    <i class="fa fa-truck text-primary"></i> 
                    Shipping Information
                </h4>
            </div>

            <div class="panel-body form-group">
                <div class="row">

                    <div class="col-xs-6">

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom required" name="customer_name_ship" id="customer_name_ship" placeholder="Recipient Name" tabindex="9" value="<?php echo $customer_name_ship; ?>">
                        </div>

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom" name="customer_address_2_ship" id="customer_address_2_ship" placeholder="Address Line 2" tabindex="11" value="<?php echo $customer_address_2_ship; ?>">
                        </div>

                        <div class="form-group no-margin-bottom">
                            <input type="text" class="form-control" name="customer_county_ship" id="customer_county_ship" placeholder="Country" tabindex="13" value="<?php echo $customer_county_ship; ?>">
                        </div>

                    </div>

                    <div class="col-xs-6">

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom required" name="customer_address_1_ship" id="customer_address_1_ship" placeholder="Address Line 1" tabindex="10" value="<?php echo $customer_address_1_ship; ?>">
                        </div>

                        <div class="form-group">
                            <input type="text" class="form-control margin-bottom" name="customer_town_ship" id="customer_town_ship" placeholder="Town / City" tabindex="12" value="<?php echo $customer_town_ship; ?>">
                        </div>

                        <div class="form-group no-margin-bottom">
                            <input type="text" class="form-control" name="customer_postcode_ship" id="customer_postcode_ship" placeholder="Postcode" tabindex="14" value="<?php echo $customer_postcode_ship; ?>">
                        </div>

                    </div>

                </div>
            </div>

        </div>
    </div>

</div>

	<div class="row">
		<div class="col-xs-12 margin-top btn-group">
			<input type="submit" id="action_update_customer" class="btn btn-primary float-right" value="Update Customer" data-loading-text="Updating...">
		</div>
							
						</div>




                                    
                                   
                                </div>



								<div>
				<br>
				<br>
				<br>
				<br>
				<br>
				<br>
                <br>
				<br>
				<br>
                <br>
				<br>
                <br>
				<br>
				<br>

			</div>		

</div>
</div>
</div>
</div>
</div>
</div>
</div>


                
							
					

					

			
		</form>
        <br>
				<br>
				<br>
                <br>
				<br>
				<br>






             

 <!-- Plugin -->

    <script src="app-assets/js/plugin/bootstrap.bundle.min.js"></script>
    <script src="app-assets/js/plugin/swiper-bundle.min.js"></script>
    <script src="app-assets/js/plugin/jquery.mask.min.js"></script>
    <script src="app-assets/js/plugin/autocomplete.min.js"></script>
    <script src="app-assets/js/plugin/moment.min.js"></script>

    <!-- Layouts -->
    <script src="app-assets/js/layouts/header-search.js"></script>
    <script src="app-assets/js/layouts/sider.js"></script>
    <script src="app-assets/js/components/input-number.js"></script>

    <!-- Base -->
    <script src="app-assets/js/base/index.js"></script>
    <!-- Customizer -->
    <script src="app-assets/js/customizer.js"></script>

    <!-- Charts -->
    <script src="app-assets/js/plugin/apexcharts.min.js"></script>
    <script src="app-assets/js/charts/apex-chart.js"></script>

    <!-- Cards -->
    <script src="app-assets/js/cards/card-advance.js"></script>
    <script src="app-assets/js/cards/card-analytic.js"></script>
    <script src="app-assets/js/cards/card-statistic.js"></script>

    <!-- Pages -->
    <script src="app-assets/js/pages/dashboard-ecommerce.js"></script>

    <!-- Custom -->
    <script src="assets/js/main.js"></script>   
</body>


</html>