<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="datatable/data.css">
<script src="datatable/data.js" type="text/javascript"></script>
<script src="datatable/table.js" type="text/javascript"></script>
<script src="datatable/datatable.js"></script>
<link rel="stylesheet" href="datatable/data-boot.css">
<link href="javascript/select2.css" rel="stylesheet" >
<script src="javascript/selectt2.js"></script>
<style>
    
    #navbar
    {
        flex:15%;
      
        flex-direction:row;
        overflow:auto;
        
    }
    #content
    {
        flex:90%;
        overflow:auto;
        padding-left:10px;
        padding-right:10px;
    }
    #fullbody
    {
        display:flex;
        
         height:100%;         
    }
    label
    {
      font-size:20px;
    }
    .edit
    {
        font-size:18px;
        color:green;
        cursor:pointer;
    }
    .dele
    {
        font-size:18px;
        color:red;
        cursor:pointer;
    }
    .edit:hover
    {
        font-size:20px;
        
    }
    .dele:hover
    {
        font-size:20px;
        color:red;
        cursor:pointer;
        
    }
    td
    {
      text-align:center;
    }
    th
    {
      text-align:center;
    }
    li a 
    {
      color:black;
    }
    .page-item.active .page-link {
    
    background-color:yellow;
    border-color: #007bff;
}
input[type="date"],input[type="text"]
{
    width:100%;
}
input[type="checkbox"]{
      width:20px;height:20px;
    }
    @media (max-width: 800px) {
        #fullbody
    {
        display:flex;
        flex-wrap: wrap;
    }
        #navbar,#content {
    flex: 100%;
  }
}
</style>
<script>
$(document).ready( function () {
    $('#protable').DataTable();
} );
</script>

</head>
<body>
    <div ><?php include "navbar.php"?></div>
    <div id="fullbody"> 

<div id="content">
<br>
<h3>Edit Customer</h3>
<br>
<!-- entry for edit  -->
<?php 
$code = $_GET['code'];
$crcedit=mysqli_query($connect,"select * from customerdetails where code='$code'&& status!='deleted'");
while($crc_dis = mysqli_fetch_array($crcedit))
{
?>
<form action="update_customer.php" method="post">
            <!--  -->
    <!-- entry for edit  -->    
    <div class="row">
              <div class="col-sm-2"><label> Name</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" name="customername" placeholder="Name" value="<?php echo $crc_dis['name'] ?>"></div>
                    <input type="hidden" class="required" autocomplete="off" name="code" placeholder="Name" value="<?php echo $code ?>">
              <div class="col-sm-3"><label>Mobile</label></div>:
              <div class="col-sm-3"><input type="text" class="required " id="mobile" onKeyUp="mob()" autocomplete="off" name="mobile" placeholder="mobile" value="<?php echo $crc_dis['mobile'] ?>"></div>
              
            </div><br>
            
            <!--  -->
            
            <script>
function mob() 
{
  var a = document.getElementById("mobile").value;
  var n = a.length;
  //alert(n);
  if(n != 10)
  {
  //alert("Mobile Number Should Be 10 Digit");
  //document.getElementById("email").disabled=true;
  document.getElementById("mobile").style.color= "red";
  }
  else
  {
    //document.getElementById("email").disabled=false;
    document.getElementById("mobile").style.color = "black";
  }
}
</script>  
            
            <!--  -->
            
            <div class="row">
              
              <div class="col-sm-2"><label>Credit limit:</label></div>:
              <div class="col-sm-3"><input type="text" class="required creditdisplay" autocomplete="off" name="credit" placeholder="Limit"value="<?php echo $crc_dis['creditlimit'] ?>"></div>
              <div class="col-sm-3"><label>Sales Opening</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" name="salesopening" placeholder="opening"value="<?php echo $crc_dis['salesopening'] ?>"></div>
            </div>
            <br>
           
            
            
            <!--  -->

            <!--  -->
            <div class="row">
            <div class="col-sm-2" style="color:red"><label>Purchase Opening</label></div>:
              <div class="col-sm-3" ><input type="text" class="required" autocomplete="off" name="purchaseopening" placeholder="Purchase-Opening" style="color:red" value="<?php echo $crc_dis['purchaseopening'] ?>"></div>
              
              <div class="col-sm-3"><label>Pincode</label></div>:
              <div class="col-sm-3"><input type="number" class="required" autocomplete="off" id="pincode" name="pincode" placeholder="Pincode" value="<?php echo $crc_dis['pincode'] ?>"></div>
            </div><br>
            <!--  -->
            
            <!--  -->
            <div class="row">
              <div class="col-sm-2"><label>Address</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" name="address" placeholder="Address" value="<?php echo $crc_dis['address'] ?>"></div>
              <div class="col-sm-3"><label>District</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" id="district" name="district" placeholder="district" value="<?php echo $crc_dis['district'] ?>"></div><div class="spinner-border text-info spinner-grow-sm districtspin"></div>
            </div><br>
            <!--  -->
           
            <!--  -->
            <div class="row">
              <div class="col-sm-2"><label>State</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" id="state" name="state" placeholder="state" value="<?php echo $crc_dis['state'] ?>"></div><div class="spinner-border text-info spinner-grow-sm statespin"></div>
              <div class="col-sm-3"><label>Gst</label></div>:
              <div class="col-sm-3"><input type="text" class="required" autocomplete="off" id="state" name="gst" placeholder="Gst" value="<?php echo $crc_dis['gst'] ?>">
              <input type="hidden" class="" autocomplete="off" id="state" name="date" placeholder="Gst" value="<?php echo $crc_dis['date'] ?>"></div>
              <input type="hidden" class="" autocomplete="off" id="state" name="time" placeholder="Gst" value="<?php echo $crc_dis['time'] ?>">
            </div>
            
            <!--  -->
        
        <script>
          $(document).ready(function(){
           $(".statespin").hide();
           $(".districtspin").hide();
           $("#pincode").keyup(function(){
            $(".statespin").show();
           $(".districtspin").show();
             var pincode= $(this).val();
             var pinlen= pincode.length;

            //  alert(pinlen);
            if(pinlen == 6 )
            {
              // alert(pincode);
              $.ajax({
                      type:'POST',
                      url:'districtajax.php',
                      data:{pincode:pincode},
                      success:function(a){
                      //  alert(a);
                       // $("#showquantity-with-color").css("display","block");
                        $("#district").val(a);
                        //alert(a);

                     }
                                  });
                                  $.ajax({
                      type:'POST',
                      url:'stateajax.php',
                      data:{pincode:pincode},
                      success:function(a){
                      //  alert(a);
                       // $("#showquantity-with-color").css("display","block");
                        $("#state").val(a);
                       // alert(a);

                     }
                                  });
              $(".statespin").hide();
           $(".districtspin").hide();
            }
else
{
  $(".statespin").show();
           $(".districtspin").show();
           $("#state").val("");
           $("#district").val("");
}
           });
          });
        </script><br>
        <div class="row">
              <div class="col-sm-2"><label>Block Date</label></div>:
              <div class="col-sm-3"><input type="date" class="" autocomplete="off"  name="blockdate" placeholder="Block Date" value="<?php echo $crc_dis['blockdate'] ?>"></div>
              <div class="col-sm-4"><input type="checkbox" <?php echo $crc_dis['single_entry'] == 1?"checked":""?>  value="1"  name="forsingleentry">&nbsp;<label>To Show In Single Entry</label></div>
        </div>
            <br>
            <!--  -->
               <!-- Modal footer -->
        <div class="modal-footer">
        <input type="button"  class="btn btn-success" id="validationButton" value="Submit">
          <input type="hidden"  class="btn btn-success" data-toggle="modal" data-target="#addpro" value="Add" id="submitButton" >
        </div>
    <!-- entry for edit -->
        </div>
        
        <!-- Modal footer -->
      
         
       
        
<div class="modal fade" id="addpro">
    <div class="modal-dialog modal-sm">
      <div class="modal-content" style="background-color:rgba(77, 219, 106,0.9)">
      
        <!-- Modal Header -->
        
        
        <!-- Modal body -->
        <div class="modal-body">
          <span style="color:white"><i class="fas fa-check" style="font-size:24px"></i> Customer Have Been Updated Successfully</span>
        </div>
        
        <!-- Modal footer -->
        <div class="modal-footer">
          <button type="submit" type="button" class="btn btn-warning editsubmit" ><span class="spinner-border spinner-border-sm subspin2" data-dismiss="modal"></span>Ok</button>
        </div>
        
      </div>
    </div>
  </div>
  
<!-- modal for add -->
                  </form>
  <?php 
}
?>
<!-- modal for edit -->
</div>
  <!-- alert -->

<button type="button" class="btn btn-primary" id="alertPending" data-toggle="modal" data-target="#pendingLimit" style="display:none">
      </button>

  <!-- The Modal -->
  <div class="modal fade" id="pendingLimit">
    <div class="modal-dialog modal-lg">
     <div class="alert alert-danger alert-dismissible fade show">
    <button type="button" class="close"  data-dismiss="alert">&times;</button>
    <strong>Amount Exceeds</strong>
  </div>
  </div>
  </div>
        
<!-- alert -->

<script>
    $('.selectpro').select2({ width: '100%',height:'420px;' });
    
</script>
<script>
  $(document).ready(function(){
    //$("#showcredit").hide();
    $(".subspin").hide();
    $(".subspin2").hide();
$(".addsubmit").click(function(){
$(".subspin").show();
});
$(".editsubmit").click(function(){
$(".subspin2").show();
//$(".subspin2").hide();
});
  });
</script>


<script src="restriction/customer.js"></script>
</body>
</html>