<?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 products WHERE product_id = '" . $mysqli->real_escape_string($getID) . "'";
$query2 = "SELECT * FROM company";

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

// mysqli select query
if($result) {
	while ($row = mysqli_fetch_assoc($result)) {
		$product_name = $row['product_name']; // product name
		$product_desc = $row['product_desc']; // product description
		$product_price = $row['product_price']; // product price
	}
}
if($result2) {
	while ($row = mysqli_fetch_assoc($result2)) {		
		$currency = $row['currency']; // customer address (shipping)
		$vat_rate = $row['vat_rate']; // customer town (shipping)


		
	}
}

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


<div style="margin-top: 30px;"  class="hp-main-layout-content">
                <div class="row mb-32 gy-32">
                <div class="col-12">
                    <div style="padding-left: 10px;"  class="page-header-modern">
            <h2 class="header-modern">Edit Product</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="content-body">
    <div class="container-fluid">      
    
       
        <!-- row -->
		<div id="response" class="alert alert-success" style="display:none;">
	<a href="#" class="close" data-dismiss="alert">&times;</a>
	<div class="message"></div>
</div>


                    <div class="row">
            <div class="col-lg-12">
                <div class="card">
                            
                    <div class="card-body">
                        <div class="row">
	<div class="col-xs-12">
		<div class="panel panel-default">
			
			<div class="panel-body form-group form-group-sm">
				<form method="post" id="update_product">
					<input type="hidden" name="action" value="update_product">
					<input type="hidden" name="id" value="<?php echo $getID; ?>">
					<div class="row">
                                    <div class="col-xl-6">
                                    
                                        <div class="mb-24 row">
                                            <label class="col-lg-4 col-form-label" for="validationCustom01">Product Name
                                                <span class="text-danger"></span>
                                            </label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control required" name="product_name" placeholder="Enter product name" value="<?php echo $product_name; ?>">
                                                <div class="invalid-feedback">
                                                    Please enter a Product Name.
                                                </div>
                                            </div>
                                        </div>
                                        <div class="mb-24 row">
                                            <label class="col-lg-4 col-form-label" for="validationCustom02">Product Description <span
                                                    class="text-danger"></span>
                                            </label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control required" name="product_desc" placeholder="Enter product description" value="<?php echo $product_desc; ?>">
                                                <div class="invalid-feedback">
                                                    Please enter Product Description
                                                </div>
                                            </div>
                                        </div>
                                       
                                    



                                      
                                        
                                    </div>
                                    <div class="col-xl-6">
                                    
                                    <div class="mb-24 row">
                                            <label class="col-lg-4 col-form-label" for="validationCustom01">Product Price
                                                <span class="text-danger"></span>
                                            </label>
                                            <div class="col-lg-6">
                                            <div class="input-group">
                                            <span class="input-group-addon"><?php echo $currency ?></span>
                                                <input type="text" class="form-control required" name="product_price" class="form-control required" placeholder="0.00" aria-describedby="sizing-addon1" value="<?php echo $product_price; ?>">
                                                </div>
                                                <div class="invalid-feedback">
                                                    Please enter price
                                                </div>
                                            </div>
                                        </div>


					<div class="row">
						<div class="col-xs-12 margin-top btn-group">
							<input type="submit" id="action_update_product" class="btn btn-primary float-right" value="Update product" data-loading-text="Updating...">
                            <a href="product-list.php" style="margin-right:7px" class="btn btn-danger float-right">Close</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
<div>
                    </div>
                    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div>

</div>
</div>

</div>
<div style="height: 500px"></div>

                        
                    
                


<!-- 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>