<?php
include("includes/useAVclass.php");
require_once "includes/connection.php";
require_once("includes/config.inc.php");
require_once "includes/functions.inc.php";
require_once "includes/functions-data.php";
//require_once "design.php";

  $useAVclass = new useAVclass();
   $useAVclass->connection(); 
  

 // $_GET['editid'];


@extract($_GET);
@extract($_POST);
@extract($_SESSION);

if(isset($_POST['mydata']))
{

  if ($_POST['mydata'] == 'thisdata') {
   

   	$data = array('success' => false, 'messages' => array());  

	$salt =rand(19999, 29999);
	$salt1 =rand(31999, 59999);
	$doctor_name 	= content_desc(check_input($_POST['doctor_name']));

	$user_name 		= content_desc(check_input($_POST['user_name']));
	$market_name 	= content_desc(check_input($_POST['market_name']));
	$indentity_type 	= content_desc(check_input($_POST['indentity_type']));
	$aadhar_no 		= content_desc(check_input($_POST['aadhar_no']));
	//txtuplode1
	//txtuplode2
	//txtuplode3
	$type 					= content_desc(check_input($_POST['type']));
	$timing 				= content_desc(check_input($_POST['timing']));
	$txttotal 				= content_desc(check_input($_POST['txttotal']));
	$isregistered 		= content_desc(check_input($_POST['isregistered']));
	$state 					= content_desc(check_input($_POST['state']));
	$district 				= content_desc(check_input($_POST['district']));
	$gender 				= content_desc(check_input($_POST['gender']));
	$user_phone 		= content_desc(check_input($_POST['user_phone']));
	$address 			= content_desc(check_input($_POST['address']));
	$pincode 			= content_desc(check_input($_POST['pincode']));
	$latitude 				= content_desc(check_input($_POST['latitude']));
	$lognitude 			= content_desc(check_input($_POST['lognitude']));
	
	$errormsg="";
	
	if($user_name == ''){
		$errormsg .= "user_name,";
	}
	/*if($market_name == ''){
		$errormsg .= "market_name,";
	} */
	/*if($type == ''){
		$errormsg .= "type,";
	}*/
/*	if($timing == ''){
		$errormsg .= "timing,";
	}*/
	if($state == ''){
		$errormsg .= "state,";
	}
	if($district == ''){
		$errormsg .= "district,";
	}
	if($gender == ''){
		$errormsg .= "gender,";
	}
	if($user_phone == ''){
		$errormsg .= "user_phone";
	}
	
	

if($errormsg == '')
{
 		
 	if ($_FILES["txtuplode1"]["tmp_name"]!="")
	{
		$tempfile=($_FILES["txtuplode1"]["tmp_name"]);
		$imageinfo = ($_FILES["txtuplode1"]["type"]);
		$section = strtoupper(base64_encode(file_get_contents($tempfile)));
		 $nsection=substr($section,0,8);
	
		$imageinfo = getimagesize($_FILES["txtuplode1"]["tmp_name"]);

		if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg' && $imageinfo['mime'] != 'image/jpg' && $imageinfo['mime'] != 'image/png' && isset($imageinfo))
		{
				$data = array('img' => 'image' );
				echo json_encode($data);
	   				exit();
		}

		if(($nsection=="/9J/4AAQ")  OR ($nsection=="IVBORW0K") OR ($nsection=="R0LGODLH"))
		{

		}
		else
		{
					$data = array('img' => 'image' );
					echo json_encode($data);
	   				 exit();
		}


	}


	if ($_FILES["txtuplode2"]["tmp_name"]!="")
	{
		$tempfile=($_FILES["txtuplode2"]["tmp_name"]);
		$imageinfo = ($_FILES["txtuplode2"]["type"]);
		$section = strtoupper(base64_encode(file_get_contents($tempfile)));
		 $nsection=substr($section,0,8);

		$imageinfo = getimagesize($_FILES["txtuplode2"]["tmp_name"]);

		if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg' && $imageinfo['mime'] != 'image/jpg' && $imageinfo['mime'] != 'image/png' && isset($imageinfo))
		{
				$data = array('img' => 'image');
				echo json_encode($data);
	   				 exit();
		}

		if(($nsection=="/9J/4AAQ")  OR ($nsection=="IVBORW0K") OR ($nsection=="R0LGODLH"))
		{

		}
		else
		{
					$data = array('img' => 'image');
					echo json_encode($data);

	   				 exit();
		}


	}

	if ($_FILES["txtuplode3"]["tmp_name"]!="")
	{
		$tempfile=($_FILES["txtuplode3"]["tmp_name"]);
		$imageinfo = ($_FILES["txtuplode3"]["type"]);
		$section = strtoupper(base64_encode(file_get_contents($tempfile)));
		 $nsection=substr($section,0,8);
	
		$imageinfo = getimagesize($_FILES["txtuplode3"]["tmp_name"]);

		if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg' && $imageinfo['mime'] != 'image/jpg' && $imageinfo['mime'] != 'image/png' && isset($imageinfo))
		{
				$data = array('img' => 'image');
				echo json_encode($data);
	   				 exit();
		}

		if(($nsection=="/9J/4AAQ")  OR ($nsection=="IVBORW0K") OR ($nsection=="R0LGODLH"))
		{}
		else
		{
					$data = array('img' => 'image');
					echo json_encode($data);
	   				 exit();
		}


	}


		if ($_FILES["txtuplode1"]["name"]!="")
		{
				$txtuplode1=$_FILES['txtuplode1']['name'];
				$txtuplode1 = preg_replace("/[^a-zA-Z0-9.]/", "", $txtuplode1);
				$uniq = uniqid("");
				$txtuplode1=$uniq.$txtuplode1;		
				$PATH="upload/vendor";					
				$PATH=$PATH."/"; 
				$val=move_uploaded_file($_FILES["txtuplode1"]["tmp_name"],$PATH.$txtuplode1);
				$size=filesize($PATH.$txtuplode1);
				$size=ceil($size/1024);
				$found="false";
		
		}	
		if ($_FILES["txtuplode2"]["name"]!="")
		{
				$txtuplode2=$_FILES['txtuplode2']['name'];
				$txtuplode2 = preg_replace("/[^a-zA-Z0-9.]/", "", $txtuplode2);
				$uniq = uniqid("");
				$txtuplode2=$uniq.$txtuplode2;		
				$PATH="upload/vendor";					
				$PATH=$PATH."/"; 
				$val=move_uploaded_file($_FILES["txtuplode2"]["tmp_name"],$PATH.$txtuplode2);
				$size=filesize($PATH.$txtuplode2);
				$size=ceil($size/1024);
				$found="false";
		}
		if ($_FILES["txtuplode3"]["name"]!="")
		{
				$txtuplode3=$_FILES['txtuplode3']['name'];
				$txtuplode3 = preg_replace("/[^a-zA-Z0-9.]/", "", $txtuplode3);
				$uniq = uniqid("");
				$txtuplode3=$uniq.$txtuplode3;		
				$PATH="upload/vendor";					
				$PATH=$PATH."/"; 
				$val=move_uploaded_file($_FILES["txtuplode3"]["tmp_name"],$PATH.$txtuplode3);
				$size=filesize($PATH.$txtuplode3);
				$size=ceil($size/1024);
				$found="false";
		
		}	

		$timing = implode(",",$timing);

	 $date=date('Y-m-d'); 	
		$tableName_send="vendor_login";
	$tableFieldsName_send=array("user_name","isregistered","registration_no","meal_type","gender","address","user_phone","aadhar_no","aadhar_front","aadhar_back","img_uplode","state","district","pincode","latitude","lognitude","user_type","indentity_type","no_of_meal","timing");
	$tableFieldsValues_send=array("$user_name","$isregistered","$registration_no","$type","$gender","$address","$user_phone","$aadhar_no","$txtuplode1","$txtuplode2","$txtuplode3","$state","$district","$pincode","$latitude","$lognitude","1","$indentity_type","$txttotal","$timing");
		$useAVclass->insertQuery($tableName_send,$tableFieldsName_send,$tableFieldsValues_send,$pdo);
		$id = $pdo->lastInsertId();
		

	 $date = date("Y-m-d h:i:s");
			$tableName_send="tbl_meal_donation";
			$tableFieldsName_old=array("no_of_meal","volunteer","description","donation_date","timing","mealtype","user_id");
			$tableFieldsValues_send=array("$txttotal","$partner","$description","$date","$timing","$type","$id");
					$value=$useAVclass->insertQuery($tableName_send,$tableFieldsName_old,$tableFieldsValues_send,$pdo);
	
					$data = array('success' => true, 'messages' => $id);
					 echo json_encode($data);
	    exit();
	/*	header("location:thanks.php");
		exit;*/
		
}
else
{
	   $error = explode(',', $errormsg);

	  //  $data['messages'] =  $error;
     foreach ( $error  as $key => $value)
     {
                $data['messages'][$key] = $value;
     } 
}

 echo json_encode($data);
       exit();

	 }

}




if(isset($cmdsubmit) && $_GET['editid']!='')
{
	
	$user_name = check_input($_POST['user_name']);
	$father_name =check_input($_POST['father_name']);
	$gender =check_input($_POST['gender']);
	$address =check_input($_POST['address']);
	$user_phone =check_input($_POST['user_phone']);
	$aadhar_no =check_input($_POST['aadhar_no']);
	$state =check_input($_POST['state']);
	$district =check_input($_POST['district']);
	$pincode =check_input($_POST['pincode']);
	$latitude =check_input($_POST['latitude']);
	$lognitude =check_input($_POST['lognitude']);
	
	$date=date('Y-m-d'); 
	 
	$tableName_send="vendor_login_new";
	$whereclause = "id = ?";
	$whereclausevalue=array($_GET['editid']);

	$old=array("user_name","father_name","gender","address","user_phone","aadhar_no","state","district","pincode","latitude","lognitude","user_type");
	$new=array("$user_name","$father_name","$gender","$address","$user_phone","$aadhar_no","$state","$district","$pincode","$latitude","$lognitude","1");
	$useAVclass->UpdateQuery($tableName_send,$whereclause,$whereclausevalue,$old,$new,$pdo);

	$id = $pdo->lastInsertId();
		
		header("location:vendor_registration.php");
		
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Donor Registration :: Indian Food Sharing Alliance</title>
<!-- Bootstrap Core CSS -->
  <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet"> 
        <!-- Bootstrap -->
        <link href="assets/css/bootstrap.min.css" rel="stylesheet">
        <!-- Icon CSS -->
        <link href="assets/css/font-awesome.min.css" rel="stylesheet">
        <link href="assets/css/icofont.css" rel="stylesheet">
        
        <!-- Owl Carousel CSS -->
        <link rel="stylesheet" href="assets/css/owl.carousel.css">
        <!-- Main Style -->
        <link href="assets/css/style.css" rel="stylesheet">
        <!-- Responsive CSS -->
        <link href="assets/css/responsive.css" rel="stylesheet">

        
        <style type="text/css">
          select {
            font-size: 12px !important;
          }
        </style>
        <!-- Favicon -->
        <link rel="shortcut icon" type="image/png" href="assets/image/favicon.png">
<script src="assets/js/jquery-1.12.4.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
<!-- Menu Access for Tab Key -->
<script src="js/jquery.js" type="text/javascript"> </script>
<script src="js/jquery.meanmenu.js"></script>
<script type="text/javascript">
jQuery(document).ready(function () {
   jQuery('#main-nav nav').meanmenu();
});

</script>

<script>
var x = document.getElementById("demo");
getLocation();
function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else { 
        //x.innerHTML = "Geolocation is not supported by this browser.";
    }
}

function showPosition(position) {

var lat=position.coords.latitude;
var long=position.coords.longitude;

$("#latitude").val(lat);
$("#lognitude").val(long);

$.ajax({
        url: "auth/webservices/test.php",  
        type: "POST", 
        data: {"lat":lat , "long":long},     
        cache: false,
       dataType: "json",
        success: function (msg) { 
       // alert("hello"); 
         $("#address").val(msg.results[0].formatted_address);
         length=msg.results[0].address_components.length-1;
$("#pincode").val(msg.results[0].address_components[length].long_name);
        }       
    });
}

</script>


<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript">
   jQuery.validator.addMethod("alphanumeric", function(value, element) {
    return this.optional(element) || /^\w+$/i.test(value);
}, "Letters, numbers, and underscores only please");

 jQuery.validator.addMethod("alpha", function(value, element) {
    return this.optional(element) || value == value.match(/^[a-zA-Z]+$/);
 });
/*

(function($,W,D)
{
	//alert("fffff");
    var JQUERY4U = {};

    JQUERY4U.UTIL =
    {
        setupFormValidation: function()
        {
            //form validation rules
            $("#contact_form").validate({
				
                rules: {
                  
					txtphone: {
								required: true,
								number: true,
								minlength: 10
						},
					user_name: "required",
				
					state: "required",	
					district: "required",
					gender: "required",
					
					user_phone: "required",
                },
               
				messages: {
				 
				  user_name: "Please Enter Name",
				  
				   state: "Please Select State",
                  district: "Please Enter District",
				  gender: "Please Select Gender",
					//pincode: "Please  Enter Pincode",
					user_phone: "Please Enter Contact Number that should be 10 to 12 digits",
			
                },
                submitHandler: function(form) {
                    form.submit();
                }
            });
        }
    }

    //when the dom has loaded setup form validation rules
    $(D).ready(function($) {
	
        JQUERY4U.UTIL.setupFormValidation();
    });

})(jQuery, window, document);*/
</script>
<script language="javascript" type="text/javascript">
	function getregistrtion(id) {
	if(id=='1')
		{ 	document.getElementById('isreg').style.display = 'block';
			document.getElementById('noreg').style.display = 'none';
			
		}
		else if(id=='2')
		{	document.getElementById('isreg').style.display = 'none';
			document.getElementById('noreg').style.display = 'block';
			
		}
		
	}
  	

</script>
<script type="text/javascript">
$(document).ready(function(){
 //  alert("fffff");
    $('#user_phone').keyup(function(){
        var user_phone = $(this).val(); // Get txtename textbox using $(this)
		// alert($('#user_phone').attr('id'));
		
        var Result = $('#result'); // Get ID of the result DIV where we display the results
        if(user_phone.length > 9) { // if greater than 2 (minimum 3)
            Result.html('Loading...'); // you can use loading animation here
            var dataPass = 'user_phone='+user_phone;
			//alert(dataPass);
            $.ajax({ // Send the txtename val to available.php
            type : 'POST',
            data : dataPass,
            url  : 'available.php',
            success: function(responseText){ // Get the result
				//alert(responseText);
              	if(responseText > 0){
                    Result.html('<span class="error">Phone no. already exist</span>');
                }
                else{
                	//alert('Problem with sql query');
                	Result.html('');
                }
            }
            });
        };
     
    });
	
	

});
</script>

<style type="text/css">
  .col-md-6 {
    width: 50%;
    padding: 10px;
}
</style>
</head>
<body class="single-service">
        <!-- start #main-site-wrapper -->
        <main id="main-site-wrapper">
            <!-- start .header-area -->
            
            <script src="w3.js"></script>
            <div w3-include-html="menus.html" corssorigin="false"></div>
            <script>
                 w3.includeHTML();
            </script>
            
            <!-- start section .page-header -->
            <!-- start section .page-header -->
            <section class="page-header valigncenter text-center">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12" style="    margin-bottom: -100px;">
                            <h1>Donor Registration</h1>
                           
                        </div> <!-- end .col-** -->
                    </div> <!-- end .row -->
                </div> <!-- end .container -->
            </section> <!-- end .page-header -->
            
            <!-- start section -->
            <section class="section-padding">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12">
                             <!-- start .page-inner -->
                            <div class="page-inner">
                                <div class="row">
                                    <div class="col-md-12">
                                       <section class="pb30 pt30">


<!--Carousel End -->
<div class="container content-area about-us-home-margin">

	<div class="col-md-12">
		<?php 
			if($errormsg != ''):
				echo '<div style="color: red;">'.$errormsg.'</div>';
			endif;
		?>
	</div>
  <div class="col-md-12">
    <h2>Donor Registration</h2>
    <hr>
	
    </div>
    <div class="col-md-12 form-style about-us-content-home">
	<div class="reg_form">
      <form id="contact_form" method="post"  name='form1' enctype="multipart/form-data">
        <?php	
if($_GET['editid']!='')
{

$edit = $pdo->prepare('select * from vendor_login where id= ? ');
//echo 'select * from vendor_login where id= 1';
		$edit->execute(array($_GET['editid']));
		$rr = $edit->fetch();
}
?>
        <fieldset>
          <legend>Donor Details (दानकर्त्ता विवरण)</legend>
          <!-- Text input-->
          <div class="col-md-6">
		  <div class="form-group">
            <label for="user_name" class="control-label">Name (नाम): <span class="star">*</span></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                <input type="text" id="user_name" class="form-control" placeholder="Name" name="user_name" value="<?php if($_POST['user_name']!=""){ echo $_POST['user_name'];} else { echo $rr['user_name'];} ?>">
                <br/>
              </div>
          </div>
		  </div>
		  <div class="col-md-6" style="display:none;">
		    <div class="form-group">
            <label for="market_name" class="control-label">Market Name (मार्केट का नाम): <span class="star">*</span></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                <input type="text" id="market_name" class="form-control" placeholder="Market Name" name="market_name" value="<?php if($_POST['market_name']!=""){ echo $_POST['market_name'];} else { echo $rr['market_name'];} ?>" onKeyPress="return LettersWithSpaceOnly(event);">
                <br/>
              </div>
          </div>
		  </div>
		   <div class="col-md-6">
          <div class="form-group">
            <label for="indentity_type" class="control-label">Identity Type (पहचान प्रकार) : </label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                <select name="indentity_type" id="indentity_type" autocomplete="off" class="form-control">
                
                  <option value="1"<?php if ($indentity_type=='1') { echo 'selected="selected"'; } elseif ($rr['indentity_type']=='1') { echo 'selected="selected"'; } ?>>Adhar Card</option>
                  <option value="2"<?php if ($indentity_type=='2') { echo 'selected="selected"'; } elseif ($rr['indentity_type']=='2') { echo 'selected="selected"'; } ?>>Pan Card</option>
				  <option value="3"<?php if ($indentity_type=='3') { echo 'selected="selected"'; } elseif ($rr['indentity_type']=='3') { echo 'selected="selected"'; } ?>>Voter Id</option>
                  <option value="4"<?php if ($indentity_type=='4') { echo 'selected="selected"'; } elseif ($rr['indentity_type']=='4') { echo 'selected="selected"'; } ?>>Other</option>
                </select>
              </div>
            </div>
          </div>
		 <!-- Text input-->
		  <div class="col-md-6">
          <div class="form-group">
            <label for="aadhar_no" class="control-label">Identity No. (पहचान संख्या): </label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
                <input type="text" id="aadhar_no" class="form-control" placeholder="Identity No." maxlength="12" name="aadhar_no" value="<?php if($aadhar_no!='') { echo $aadhar_no; } { echo $rr['aadhar_no'];} ?>"   onkeypress="return isNumberDecimal(event);">
              </div>
            </div>
          </div>
          <!-- Text input-->

		   <!-- Text input-->
		  <div class="col-md-6">
          <div class="form-group">
            <label for="txtuplode1" class="control-label">Identity Proof Image1 (पहचान प्रमाण इमेज 1): </label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-upload"></i></span>
                <input type="file" id="txtuplode1" class="form-control" placeholder="Identity Proof Image1" name="txtuplode1">
              </div>
            </div>
          </div>
          <!-- Text input-->

 <!-- Text input-->
		  <div class="col-md-6">
          <div class="form-group">
            <label for="txtuplode2" class="control-label">Identity Proof Image2 (पहचान प्रमाण इमेज 2)</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-upload"></i></span>
                <input type="file" id="txtuplode2" class="form-control" placeholder="Identity Proof Image2" name="txtuplode2">
              </div>
            </div>
          </div>
          <!-- Text input-->

 <!-- Text input-->
		  <div class="col-md-6">
          <div class="form-group">
            <label for="txtuplode3" class="control-label">Donor Photo (दानकर्त्ता फोटो)</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-upload"></i></span>
                <input type="file" id="txtuplode3" class="form-control" placeholder="Vendor Photo" name="txtuplode3">
              </div>
            </div>
          </div>

		   <div class="col-md-6">
          <div class="form-group">
            <label for="type" class="control-label">Type of Food (भोजन के प्रकार): </label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                <select name="type" id="type" autocomplete="off" class="form-control">
                  
                  <option value="Packed"<?php if ($type=='Packed') { echo 'selected="selected"'; } elseif ($rr['type']=='Packed') { echo 'selected="selected"'; } ?>>Packed</option>
                  <option value="Cooked"<?php if ($type=='Cooked') { echo 'selected="selected"'; } elseif ($rr['type']=='Cooked') { echo 'selected="selected"'; } ?>>Cooked</option>
                </select>
              </div>
            </div>
          </div>
		  	 <div class="col-md-6">
		 	   <div class="form-group">
            <label for="type" class="control-label">Timing (समय): </label>
              <div class="input-group">
              <?php 
	$data = $pdo->query("SELECT * FROM meal_timing where status=1");
while($AllData = $data->fetch())
{
		
		?>
		<input type="checkbox" name="timing[]" id="timing" placeholder="timing"   value="<?php echo $AllData['id'];?>" <?php if ($AllData['id']==$timing) echo 'checked="checked"';?>><?php echo $AllData['timing']; ?>
		<?php }
	?> 
              </div>
            </div>
          </div> 
		  
		  
		  <div class="col-md-6">
          <div class="form-group">
            <label for="txttotal" class="control-label">No.of meals (भोजन संख्या)</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-upload"></i></span>
                <input type="text" id="txttotal" class="form-control" placeholder="No.of meals" name="txttotal">
              </div>
            </div>
          </div>

		<div class="col-md-6">
          <div class="form-group">
            <label for="isregistered" class="control-label">Registered with FSSAI (एफएसएसएआई के साथ पंजीकृत): </label>
              <div class="input-group">
                
                  <input type="radio" name="isregistered" value="1"<?php if ($isregistered=='1') { echo 'checked="checked"'; } elseif ($rr['isregistered']=='1') { echo 'checked="checked"'; } ?> onClick="getregistrtion(this.value);">Yes</option>
                    <input type="radio" name="isregistered" value="2"<?php if ($isregistered=='2') { echo 'checked="checked"'; } elseif ($rr['isregistered']=='2') { echo 'checked="checked"'; } ?> onClick="getregistrtion(this.value);">No</option>
             
              </div>
            </div>
          </div>
<div id="isreg" <?php if($isregistered=='1') {?> style="display:block" <?php } else {?>style="display:none" <?php } ?>>

		  <div class="col-md-6">
          <div class="form-group">
            <label for="registration_no" class="control-label">Registration No.(पंजीकरण क्रमांक)</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-envelope"></i></span>
                <input type="text" id="registration_no" class="form-control" placeholder="Registration Number" maxlength="14" name="registration_no" value="<?php if($registration_no!='') { echo $registration_no; } { echo $rr['registration_no'];} ?>" onKeyPress="return isNumberDecimal(event);">
              </div>
            </div>
          </div>
</div>
<div id="noreg" <?php if($isregistered=='2') {?> style="display:block" <?php } else {?>style="display:none" <?php } ?>>

		  <div class="col-md-6">
          <div class="form-group">
            <label for="registration_no" class="control-label"></label>
              <div class="input-group"> 
               <a href="https://foodlicensing.fssai.gov.in/index.aspx" target="_blank">Click here for registration(पंजीकरण के लिए यहां क्लिक करें)</a>
              </div>
            </div>
          </div>
</div>

          <!-- Text input-->
		 <div class="col-md-6">
          <div class="form-group">
            <label for="state" class="control-label">State (राज्य): <span class="star">*</span></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-map-marker"></i></span> 
                <!-- <input type="text" id="state" class="form-control" placeholder="State" name="state" required value="<?php if($state!='') { echo $state; } else {};?>"> -->
                 <select name="state" id="state" class="form-control" autocomplete="off" onChange="getdistrict(this.value);">
				<option value=""> Select </option>
				<?php 
				$data = $pdo->query("SELECT * from state where c_status='1' order by c_name");
				while($role_module = $data->fetch())
				{

				?>
				<option value="<?php echo $role_module['c_id'];?>" <?php if ($role_module['c_id']==$state) { echo 'selected="selected"';}?>><?php echo $role_module['c_name']; ?></option>
				<?php }
				?>
				</select>
              </div>
            </div>
          </div>
		 
		  <div class="col-md-6" id="dis">
          <div class="form-group">
            <label for="district" class="control-label">District (जिला): <span class="star">*</span></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-map-marker"></i></span>
                <select name="district" placeholder="District (जिला):" class="form-control" id="district">
                  <option value=""> Select </option>
				<!--<?php 
				$data = $pdo->query("SELECT * from district where c_status='1'");
				while($role_module = $data->fetch())
				{

				?>
				<option value="<?php echo $role_module['c_name'];?>" <?php if ($c_name['c_id']==$district) { echo 'selected="selected"';} elseif($rr['state_id']==$role_module['c_id']) { echo "selected='selected'";}?>><?php echo $role_module['c_name']; ?></option>
				<?php }
				?>-->
                </select>
              </div>
            </div>
          </div>
		 
		  <div class="col-md-6">
          <div class="form-group">
            <label for="Gender" class="control-label">Gender (लिंग) : <span class="star">*</span></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
                <select name="gender" id="gender" placeholder="Gender" autocomplete="off" class="form-control">
				<option value="">Select</option>
                  <?php 
					//foreach($gender as $key=>$value1)
					//{
					//	?>
                  <!-- <option value="<?php echo $value1; ?>" <?php if($value1 == '1') { echo 'selected="selected"'; }  else { }?>><?php echo $value1; ?></option>
					<?php// }
					 ?>
					</select>   -->
                  <option value="Male"<?php if ($gender=='Male') { echo 'selected="selected"'; } elseif ($rr['gender']=='Male') { echo 'selected="selected"'; } ?>>Male</option>
                  <option value="Female"<?php if ($gender=='Female') { echo 'selected="selected"'; } elseif ($rr['gender']=='Male') { echo 'selected="selected"'; } ?>>Female</option>
                </select>
              </div>
            </div>
          </div>
         
		  <div class="col-md-6">
          <div class="form-group">
            <label for="user_phone" class="control-label">Mobile (मोबाइल):<span class="star">*</span></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-earphone"></i></span>
                <input autocomplete="off" type="text" id="user_phone" class="form-control" placeholder="`10 Digits Number`"	 maxlength="10"  name="user_phone" value="<?php if($user_phone!='') { echo $user_phone; } else { echo $rr['user_phone'];}?>"  ><div class="result" id="result" align="center"></div>
              </div>
            </div>
          </div>
          <!-- Text area -->
		   <div class="col-md-6">
          <div class="form-group">
            <label for="name" class="control-label">Address (exact street name, area and landmark) (पता):</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-map-marker"></i></span>
                <input autocomplete="off" type='text'  id="address" class="form-control" placeholder="Address" name="address" value="<?php if($address!='') { echo $address; } else { echo $rr['address']; }?>"  />
                <!-- onBlur="return getlocation2(this.value)" -->
                <?php //echo $rr['address'];?>
              </div>
            </div>
          </div>
		   <div class="col-md-6">
          <div class="form-group">
            <label for="pincode" class="control-label">Pincode (पिन कोड):<!-- <span class="star">*</span> --></label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-map-marker"></i></span>
                <input type="text" id="pincode" class="form-control" placeholder="Pincode" name="pincode"  maxlength="6" value="<?php if($rr['pincode']!='') { echo $rr['pincode']; } else {};?>" onKeyPress="return isNumberDecimal(event);">
              </div>
            </div>
          </div>
		  <div class="col-md-6">
          <div class="form-group">
            <label for="latitude" class="control-label">Latitude (अक्षांश):</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-map-marker"></i></span>
                <input type="text" readonly id="latitude" class="form-control" placeholder="Latitude" name="latitude" value="<?php if($rr['latitude']!='') { echo $rr['latitude']; } else {};?>" >
              </div>
            </div>
          </div>
		  <div class="col-md-6">
          <div class="form-group">
            <label for="lognitude" class="control-label">Longitude (देशान्तर):</label>
              <div class="input-group"> <span class="input-group-addon"><i class="glyphicon glyphicon-map-marker"></i></span>
                <input type="text" id="lognitude" readonly class="form-control" placeholder="Longitude"  name="lognitude" value="<?php if($rr['lognitude']!='') { echo $rr['lognitude']; } else {};?>" >
              </div>
            </div>
          </div>
          <div class="clearfix"></div>
          <!-- Button -->
          <div class="col-md-12">
          <div class="form-group text-center">
              <input type="submit" name="cmdsubmit" id="cmdsubmit" value="Submit" title="Submit" class="btn btn-warning" />
              &nbsp;&nbsp;
              <input type="reset" class="btn btn-warning"  name="cmdreset" title="Reset" value="Reset">
            </div>
          </div>
        </fieldset>
      </form>
    </div>
	</div>
  
</div>


   </div> <!-- end .row -->
                            </div> <!-- end .page-inner -->
                        </div> <!-- end .col-** -->
                    </div> <!-- end .row -->
                </div> <!-- end .container -->
            </section> <!-- end section -->

             <!-- start section -->
            <section class="section-padding">
                <div class="container">
                    
                </div> <!-- end .container -->
            </section> <!-- end section -->
<!-- Footer part --> 

<!-- Footer part -->

 <!-- start .footer-area -->
            <footer class="footer-area bg-gray">
              <script src="w3.js"></script>
<div corssorigin="false" w3-include-html="footer.html">    <br/><br/></div>
<script>
	 w3.includeHTML();
</script>
            </footer> <!-- end footer -->
        </main> <!-- end #main-site-wrapper -->
      
        <!-- Include all compiled plugins (below), or include individual files as needed -->
        <!-- Bootstrap JS -->
        <script src="assets/js/bootstrap.min.js"></script>
        <!-- Owl JS -->
        <script src="assets/js/owl.carousel.min.js"></script>
        <!-- Theme Scripts JS -->
        <script src="assets/js/scripts.js"></script>  


<script>
$(document).ready(function(){
    $(".nav-tabs a").click(function(){
        $(this).tab('show');
    });
});
</script> 


<script>
$(document).ready(function(){
    $(".nav-tabs a").click(function(){
        $(this).tab('show');
    });
});
</script> 


<script type="text/javascript">
function getPage(id) {
alert(id);
    //generate the parameter for the php script
    var data = 'cat=' + id;
	//alert(data);
    $.ajax({
        url: "category.php",  
        type: "POST", 
        data: data,     
        cache: false,
        success: function (html) {  
         
            //hide the progress bar
            $('#loading').hide();   
             
            //add the content retrieved from ajax and put it in the #content div
            $('#cat').html(html);
             
            //display the body with fadeIn transition
            $('#content2').fadeIn('slow');       
        }       
    });
}

function getdistrict(id) {
//alert(id);
    //generate the parameter for the php script
    var data = 'dis=' + id;
   
	//alert(data);
    $.ajax({
        url: "getcitynew.php",  
        type: "POST", 
        data: data,     
        cache: false,
        success: function (html) {  
         
            //hide the progress bar
            $('#loading').hide();   
             
            //add the content retrieved from ajax and put it in the #content div
            $('#dis').html(html);
             
            //display the body with fadeIn transition
            $('#content2').fadeIn('slow');       
        }       
    });
}

function getlocation(val) {
 var address = val;
// alert(data);
    $.ajax({
        url: "getcordinate.php",  
        type: "POST", 
        data: {"address":address},     
        cache: false,
        dataType: "json",
        success: function (msg) {  
         $("#latitude").val(msg.results[0].geometry.location.lat);
$("#lognitude").val(msg.results[0].geometry.location.lng);
length=msg.results[0].address_components.length-1;
$("#pincode").val(msg.results[0].address_components[length].long_name);
        }       
    });
}



$("#contact_form").submit(function(event) {     	
    event.preventDefault();
	 mydata =  $(this).serialize();

	 console.log(mydata);
	$.ajax({

		type:'post',
		url:'donor_registration.php',
		data:'mydata=thisdata&'+mydata,
    	 dataType:'json',
		success:function(htm){

	console.log(htm);

       if(htm.success == true )
       {

         
         window.location="thanks.php";

       }
       else if(htm.img == 'image' )
       {

         
          alert('please upload valid image');

       }
       else
       {
           $.each(htm.messages,function(key,value){



                    var element = $('#'+value);
                     var data_name = $('#'+value).attr('placeholder');

                    element.closest('div.input-group')
                    .removeClass('has-error')
                    .addClass(value ? 'has-error':'has-success')
                     .parent('div').find('.text-danger').remove();

                    element.parent('div.input-group').after('<span style="color:red;z-index: 9999999;position: absolute;width: 100%;" class="text-danger">Please fill valid  details for '+data_name+'</span>');

              });

       }		
	},
		error:function()
		{

		}

	});
});

</script> 
<script type="text/javascript">
$(".closestatus").click(function() {
$("#msgerror").addClass("hide").hide();
});
$(".closestatus").click(function() {
$("#msgclose").addClass("hide").hide();
});

</script>
</body>
</html>