<!--
Author: W3layouts
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>nehrdelivery.com</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
 <!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel='stylesheet' type='text/css' />
<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />
<link href="css/font-awesome.css" rel="stylesheet"> 
<!-- jQuery -->
<script src="js/jquery.min.js"></script>
<!----webfonts--->
<link href='http://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'>
<!---//webfonts--->  
<script>
    $(document).ready(function(){
        
      $("#btn_submit").click(function(){
        setOnBoardResponse("","");
      });
      
      $("#onboard_form").submit(function(event) {

        /* stop form from submitting normally */
          event.preventDefault();
        
          /* get the action attribute from the <form action=""> element */
          var formValues = $(this).serialize();
          var url = 'common/logic_customer_on_board.php';
         $.post("common/logic_staff_edit.php", formValues, function(data){
            if(data == 'Success'){
                $('#onboard_form').trigger("reset");
                setOnBoardResponse("Onboarding success!","");
                var delay = 500; 
                var url = 'staff_onboard.php'
                setTimeout(function(){ window.location = url; }, delay);
            }else{
                console.log(data);
                setOnBoardResponse("","Onboarding failed!");
            }  
        });
         
    });
    });
    
    function setOnBoardResponse(success, failure){
        $("#onboard_result_success").text(success);
        $("#onboard_result_fail").text(failure);
    }
</script>
</head>
<body>
    <div id="wrapper">
     <!-- Navigation -->
        <?php include 'common/nav.php';?>
        <?php include 'common/connection.php';?>
        <div id="page-wrapper">
        <div class="graphs">
	   <div class="md">
		 <h3>Staff Management</h3>
		<div class="form-group">
		  <div class="row">
			
			<div id="onbording">
			<div class="col-md-12">
			    <div class="well1 white">
			        <center><span id="onboard_result_success" style="color: green;"></span></center>
			        <center><span id="onboard_result_fail" style="color: red;"></span></center>
			        <h3><u>Staff edit</u></h3>
			        <div class="row">
			            <?php
			            $sid = $_POST["sid"];
					    $servername = "localhost";
                        $username = "finstech_sales";
                        $password = "SalesApp@123";
                        $dbname = "finstech_salesapp";
                        
                        $arr = [];
                        try {
                            $pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
                            $stmt = $pdo->prepare("select * from master_staff where staff_id = ?");
                            $stmt->execute([$sid]); 
                            $user = $stmt->fetch();
                        }catch(PDOException $e) {
                            echo $sql . "<br>" . $e->getMessage();
                        }
                        $stmt = null;
                        $pdo = null;
					?>
                <form id="onboard_form" class="form-floating" method="post">
                    <div class="col-md-6">
                        <input type="hidden" name="sid" value="<?php echo $user['staff_id']; ?>"
                  <fieldset>
                    <div class="form-group">
                      <label class="control-label">Name</label>
                      <input type="text" name="staff_name" id="staff_name" value="<?php echo $user['name']; ?>" class="form-control1" required="required">
                    </div>
                    <!--<div class="form-group">
                      <label class="control-label">Email</label>
                      <input type="email" class="form-control1 ng-invalid ng-valid-email ng-invalid-required ng-touched" ng-model="model.email" required="">
                    </div>-->
                    <div class="form-group">
                      <label class="control-label">Mobile</label>
                      <input type="text" name="mobile" id="mobile" value="<?php echo $user['mobile']; ?>" minlength="10" maxlength="10" class="form-control1" required="required">
                    </div>
                    <div class="form-group">
                      <label class="control-label">Place</label>
                      <input type="text" id="place" name="place" value="<?php echo $user['place']; ?>" class="form-control1" required="required">
                    </div>
                    <div class="form-group">
                      <label class="control-label">pincode assigned</label>
                      <input type="text" id="pincode" value="<?php echo $user['assigned_pincode']; ?>" name="pincode" minlength="6" maxlength="6" class="form-control1" required="required">
                    </div>
                  </fieldset>
                  </div>
                  
                    <div class="col-md-6">
                        <fieldset>
                            <div class="form-group">
                              <label class="control-label">Address Line 1</label>
                              <input type="text" name="address_line1" value="<?php echo $user['address_line1']; ?>" class="form-control1" required="required">
                            </div>
                            <div class="form-group">
                              <label class="control-label">Address Line 2</label>
                              <input type="text" name="address_line2" value="<?php echo $user['address_line2']; ?>" class="form-control1" required="required">
                            </div>
                            <div class="form-group">
                              <label class="control-label">Address Line 3</label>
                              <input type="text" name="address_line3" value="<?php echo $user['address_line3']; ?>" class="form-control1" required="required">
                            </div>
                            <div class="form-group filled">
                              <label class="control-label">Assigned Shop</label>
                              <select id="shop_id" name="shop_id" class="form-control1" required="required">
                                  <?php
            					    $servername = "localhost";
                                    $username = "finstech_sales";
                                    $password = "SalesApp@123";
                                    $dbname = "finstech_salesapp";
                                    
                                    $arr = [];
                                    try {
                                        $pdo = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
                                        $rows = $pdo->query("SELECT shop_id, shop_name FROM master_shop");
                                        $rows->setFetchMode(PDO::FETCH_ASSOC);
                                    }catch(PDOException $e) {
                                        echo $sql . "<br>" . $e->getMessage();
                                    }
                                    $stmt = null;
                                    $pdo = null;
            					
                                    while ($row = $rows->fetch()):
								?>
                                <option value="<?php echo htmlspecialchars($row['shop_id']) ?>"><?php echo htmlspecialchars($row['shop_name']) ?></option>
                                <?php  
								    endwhile; 
								?>
                              </select>
                            </div>
                            <div class="form-group" style="float: right;">
                              <button type="submit" id="btn_submit" class="btn btn-primary">Submit</button>
                            </div>
                        </fieldset>
                    </div>
                </form>
                </div>
              </div>
			</div>
			</div>
			</div>
			</div>
			<div class="clearfix"> </div>
		   </div>
		</div>					
       </div>
      </div>
      <!-- /#page-wrapper -->
   </div>
    <!-- /#wrapper -->
    <!-- Nav CSS -->
<link href="css/custom.css" rel="stylesheet">
<!-- Metis Menu Plugin JavaScript -->
<script src="js/metisMenu.min.js"></script>
<script src="js/custom.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>

</body>
</html>
