<?php
@session_start();
@ob_start();

include "header.php"; 
$objIms->supplier_alter();
?>
<script type="text/javascript">
	$(document).ready(function() {                
				$("#FORMNAME1").validate({
                    rules: {
					contact_no:"required number",
                   address:"required",
				  
					},
		messages: {
			
					 supplier_name: "",
					 address: "",
					 contact_no:"",
					 contact_person: "",
					
								
				},
		  });                
            });
//---auto search-----
</script>
<script type="text/javascript"> 
 
		jQuery(document).ready(function(){
			$('#emp_name').autocomplete({source:'../ProgramFile/auto/TMS_suggest_EmpName.php', minLength:1,
			select: function (event, ui) {
        	$("#trn_atndnt_mas_id").val(ui.item.trn_atndnt_mas_id);
			$("#emp_name").val(ui.item.value); // display the selected text.
						
    }
			});
			
			
		}); 
	</script> 
<!-- Page wrapper  -->
        <div class="page-wrapper">
           
            <!-- Container fluid  -->
             <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row justify-content-center">
                    <div class="col-lg-6">
                        <div class="card">
						<h4 style="text-align: center;">Owner Details <span style="float:right"><button onclick="goBack()" class="btn btn-info btn-sm">Go Back</button></span></h4><br  /><br />
            <script>
function goBack() {
    window.history.back();
}
</script>
		
<?php
if(isset($_REQUEST["Save"])){
$owner_name2 = $_REQUEST["owner_name"];
  $address2 = $_REQUEST["address"];
  $contact_no2 = $_REQUEST["contact_no"];
  $state2 = $_REQUEST["state"];
  $gstin2 = $_REQUEST["gstin"];


 $sql_ins = "INSERT INTO tbl_owner_address (name, address, contact_no, state, gstin, session_login_id) VALUES ('$owner_name2', '$address2', '$contact_no2', '$state2', '$gstin2', '".$_SESSION['login_id']."')";
$res_ins = mysql_query($sql_ins);
}
?>		
						
                                    <form class="form-valide" method="post">
									<?php  echo $objIms->error;?>
                                        <div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">Owner Name <span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                <input type="text" class="form-control"  name="owner_name" id="owner_name" maxlength="30" value="<?php echo $owner_name; ?>" required="required" <?php echo $objIms->disableit;?>>
                                            </div>
                                        </div>
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">Address <span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                 <textarea name="address" id="address" maxlength="50"  class="form-control" <?php echo $address; ?> ><?php echo $objIms->address;?></textarea>
                                            </div>
                                        </div>
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">State<span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                 <input name="state" type ="text" value="<?php echo $state; ?>" id="state" class="form-control" required <?php echo $objIms->disableit;?>/>
                                            </div>
                                        </div>
										
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">Contact No <span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                 <input name="contact_no" type ="number" value="<?php echo $contact_no; ?>" id="contact_no" onkeypress="return validate(event)"  class="form-control" required <?php echo $objIms->disableit;?>/>
                                            </div>
                                        </div>
										
										<div class="form-group row">
                                            <label class="col-lg-4 col-form-label" for="val-username">GSTIN<span class="text-danger">*</span></label>
                                            <div class="col-lg-6">
                                                 <input name="gstin" type ="text" id="gstin" class="form-control" value="<?php echo $gstin; ?>" required="required" <?php echo $objIms->disableit;?>/>
                                            </div>
                                        </div>
                                        
                                        <div class="form-group row">
                                            <div class="col-lg-8 ml-auto">
                                                <input type ="submit" name="Save" value="Save" class="btn btn-primary"/>
                                                
                                            </div>
                                        </div>
                                    </form>
						
						
						
	
  </div>

                            </div>
						
                            
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
            <!-- End Container fluid  -->
<?php include 'footer.php' ?>

<script type="text/javascript">
    function validate(key)
{
//getting key code of pressed key
var keycode = (key.which) ? key.which : key.keyCode;
var phn = document.getElementById('contact_no');
//comparing pressed keycodes
if ((keycode < 48 || keycode > 57))
{
    alert("no only allow")
return false;

}
else
{
//Condition to check textbox contains ten numbers or not
if (phn.value.length <10)
{
return true;
}
else
{
    alert("not greater than 10")
return false;

}
}
}
</script>
<script type="text/javascript">
    
    $(function() {

  $('#contact_person').keydown(function (e) {
  
    if (e.ctrlKey || e.altKey) {
    alert("only character allow");
      e.preventDefault();
      
    } else {
    
      var key = e.keyCode;
      
      if (!((key == 8) || (key == 32) || (key == 46) || (key >= 35 && key <= 40) || (key >= 65 && key <= 90))) {
        alert("only character allow");
        e.preventDefault();
        
      }

    }
    
  });
  
});
</script>