<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))
{

$user=$_SESSION['adminemail'];


$gtp=mysql_query("select * from admin where username='$user'");
$gtp1=mysql_fetch_array($gtp);

include 'top.php';

?>



			<div class="main-content">



				<div class="main-content-inner">



					<div class="breadcrumbs ace-save-state" id="breadcrumbs">



						<ul class="breadcrumb">



							<li>



								<i class="ace-icon fa fa-home home-icon"></i>



								<a href="#">Home</a>



							</li>



							<li class="active">Coconut Project</li>



						</ul><!-- /.breadcrumb -->



					</div>







					<div class="page-content">



			







						<div class="page-header">



                        



<?php







$aca=mysql_query("select * from financial where user='$user' order by ID desc");



$aca1=mysql_fetch_array($aca);







$financial=$aca1['financial'];







?>



                        



                        <table style="width:100%;">



                        



                        <tr><td style="width:50%;">



                        



							<h1>



								Coconut Project



							</h1>



                            



                            </td>



                            



                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">



                            



                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>



                            



                            </td></tr></table>



                            



						</div><!-- /.page-header -->







						<div class="row">



							<div class="col-xs-12">



                            



								<!-- PAGE CONTENT BEGINS -->







<script src="assets/js/jquery.js"></script>







<script>







$(".state").live('change',function() {







		  var state=$(this).val();







		  var dataString = 'state='+ state;







		  //alert(dataString);







		  $.ajax







		  ({







		  type: "GET",







		  url: "getdistrict.php",







		  data: dataString,







		  cache: false,







		  success: function(resp)







		  {



		  



		  $('.district').html($('#district',resp).html());







		  }







		  });







});











$(".district").live('change',function() {







		  var district=$(this).val();







		  var dataString = 'district='+ district;







		  //alert(dataString);







		  $.ajax







		  ({







		  type: "GET",







		  url: "gettaluk.php",







		  data: dataString,







		  cache: false,







		  success: function(resp)







		  {



		  



		  $('.taluk').html($('#taluk',resp).html());







		  }







		  });







});











$(".taluk").live('change',function() {







		  var taluk=$(this).val();







		  var dataString = 'taluk='+ taluk;







		  //alert(dataString);







		  $.ajax







		  ({







		  type: "GET",







		  url: "getvillage.php",







		  data: dataString,







		  cache: false,







		  success: function(resp)







		  {



		  



		  $('.village').html($('#village',resp).html());







		  }







		  });







});















$(document).ready(function(){



$(".variety").change(function() {



		var vvt=$(this).val();



		//alert(vvt);



		if(vvt=='Others')

		{



			$('.others').show();



		}

		else

		{



			$('.others').hide();



		}



});



});



</script>







<script type="text/javascript">

$(document).ready(function(){

$('.mobile').blur(function(){

		  var mobile=$('.mobile').val();
		  var dataString = 'mobile='+ mobile;
		  //alert(dataString);
		  $.ajax
		  ({
		  type: "GET",
		  url: "getmob1.php",
		  data: dataString,
		  cache: false,
		  success: function(html)
		  {

			//alert(html);
			var warn=$(html).filter('#warn').text();

			if(warn>0)
			{
				alert("Mobile no already exist.");
				$('.warn').val(1);
			}
			else
			{				
				$('.warn').val('');				
			}

		  }

		  });

});

});

</script>



<script>

jQuery(function($){

	// simple jQuery validation script

	$('#course').submit(function(){

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		$('.' + errorcn, this).remove();

		$('#required', this).each(function(){

			var parent = $(this).parent();
			
			if( $(this).val() == '' ){
				
				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		var mob=$('.mobile').val().length;

		var warn=$('.warn').val();	

		//alert(mob);

		if(mob<10)
		{

			alert("Enter Valid Mobile No.");

			valid = false;

		}
		else if(warn==1)
		{
			
			alert("Mobile No already exist.");

			valid = false;
			
		}


		return valid;	


		$('button:submit').prop('disabled', true);

	});

});	

</script>



<?php        


if(isset($_POST['submit'])) 
{


$name=$_POST['name'];



$mobile=$_POST['mobile'];



$state=$_POST['state'];



$district=$_POST['district'];



$taluk=$_POST['taluk'];



$village=$_POST['village'];



$agricultureexperience=$_POST['agricultureexperience'];



$farming=$_POST['farming'];



$variety=$_POST['variety'];



$intercrops=$_POST['intercrops'];



$whichtypeoffertilizer=$_POST['whichtypeoffertilizer'];



$irrigationsystem=$_POST['irrigationsystem'];



$typeofsoil=$_POST['typeofsoil'];



$averageyieldpertree=$_POST['averageyieldpertree'];



$whichtypeofproblem=$_POST['whichtypeofproblem'];



$totalagriland=$_POST['totalagriland'];



$spacingdistance=$_POST['spacingdistance'];



$cropstage=$_POST['cropstage'];



$variety1=$_POST['variety1'];



$executive=$_POST['executive'];




/*
if($variety=='Others')
{

	$variety=$variety1;

}

else
{

	$variety=$variety;

}
*/


$date=date('Y-m-d');


$ins=mysql_query("insert into coconutproject(name,mobile,state,district,taluk,village,agricultureexperience,farming,variety,variety1,intercrops,whichtypeoffertilizer,irrigationsystem,typesofsoil,averageyieldpertree,whichtypeofproblem,totalagriland,spacingdistance,cropstage,executive,date) values('$name','$mobile','$state','$district','$taluk','$village','$agricultureexperience','$farming','$variety','$variety1','$intercrops','$whichtypeoffertilizer','$irrigationsystem','$typeofsoil','$averageyieldpertree','$whichtypeofproblem','$totalagriland','$spacingdistance','$cropstage','$executive','$date')") or die(mysql_error());


if($ins)
{

	header("location:viewcoconutproject.php?s=1");

}

else
{

	header("location:viewcoconutproject.php?s=2");

}


}


else
{

?>

<form id="course" action="coconutproject.php" method="post">

<?php

$sel=mysql_query("select * from admin where username='$user'");

$nmrw=mysql_num_rows($sel);

$sel1=mysql_fetch_array($sel);


if($nmrw>0)
{

}


else
{

$empd=mysql_query("select * from employee where username='$user'");
$empd1=mysql_fetch_array($empd);

$usr=$empd1['ID'];

echo"<input type='hidden' name='executive' value='".$usr."' />";

}

?>


<input type="hidden" class="warn" />


<table width="70%" style="margin:auto; line-height:35px;">


<tr><td>Name <span class="red">*</span></td><td>:</td><td><input type="text" name="name" required autocomplete="off" /></td></tr>


<tr><td>Mobile <span class="red">*</span></td><td>:</td><td><input type="text" name="mobile" class="mobile" required maxlength="10" autocomplete="off" /></td></tr>


<tr><td>State</td><td>:</td><td><select name="state" class="state" style="width:220px;"><option value="">-- Select --</option>


<?php



$ste=mysql_query("select * from statecode order by ID asc");

while($ste1=mysql_fetch_array($ste))

{



	echo"<option value='".$ste1['ID']."'>".$ste1['state']."</option>";



}



?>


</select></td></tr>


<tr><td>District</td><td>:</td><td><select name="district" class="district" style="width:220px;"><option value="" selected="selected">-- Select --</option></select></td></tr>


<tr><td>Taluk</td><td>:</td><td><select name="taluk" class="taluk" style="width:220px;"><option value="" selected="selected">-- Select --</option></select></td></tr>


<tr><td>Village</td><td>:</td><td><select name="village" class="village" style="width:220px;"><option value="" selected="selected">-- Select --</option></select></td></tr>


<tr><td>Agriculture Experience</td><td>:</td><td><input type="text" name="agricultureexperience" /></td></tr>


<tr><td>Farming</td><td>:</td><td><select name="farming"><option value="">-- Select --</option>

<option value="Organic Farming">Organic Farming</option>

<option value="Chemical Farming">Chemical Farming</option>

</select></td></tr>


<tr><td style="width:32%;">Variety</td><td>:</td><td><select name="variety" class="variety"><option value="">-- Select --</option>

<option value="T x T (நெட்டை)">T x T (நெட்டை)</option>

<option value="d x d (குட்டை)">d x d (குட்டை)</option>

<option value="T x d (நெட்டை குட்டை)">T x d (நெட்டை குட்டை)</option>

<option value="d x T (குட்டை)">d x T (குட்டை)</option>

<option value="Others">Others</option>

</select></td></tr>


<tr><td colspan="3" style="padding-top:15px;">


<div class="others" style="width:100%; display:none;">


<table style="width:100%;">


<tr><td style="width:32%;">Variety</td><td>:</td><td><input type="text" name="variety1" style="width:220px;" /></td></tr>


</table>


</div>


</td></tr>


<tr><td>Inter Crops</td><td>:</td><td><input type="text" name="intercrops" style="width:220px;" /></td></tr>


<tr><td>Which type of fertilizer used</td><td>:</td><td><input type="text" name="whichtypeoffertilizer" /></td></tr>


<tr><td>Irrigation System</td><td>:</td><td><input type="text" name="irrigationsystem" autocomplete="off" /></td></tr>


<tr><td>Types of soil</td><td>:</td><td><input type="text" name="typeofsoil" autocomplete="off" /></td></tr>


<tr><td>Average yield per tree</td><td>:</td><td><input type="text" name="averageyieldpertree" autocomplete="off" /></td></tr>


<tr><td>Which type of problem</td><td>:</td><td><input type="text" name="whichtypeofproblem" autocomplete="off" /></td></tr>


<tr><td>Total Agriland</td><td>:</td><td><input type="text" name="totalagriland" autocomplete="off" /></td></tr>


<tr><td>Spacing Distance</td><td>:</td><td><input type="text" name="spacingdistance" autocomplete="off" /></td></tr>


<tr><td>Crop Stage</td><td>:</td><td><input type="text" name="cropstage" autocomplete="off" /></td></tr>


<tr><td colspan="3" style="text-align:center; padding-top:7px;"><button type="submit" name="submit" class="btn btn-sm btn-primary">Submit</button></td></tr>


</table>


</form>


<?php


}


?>



										<!-- PAGE CONTENT ENDS -->


									</div><!-- /.col -->


								</div><!-- /.row -->


							</div><!-- /.page-content -->


						</div>


					</div><!-- /.main-content -->




<?php

include 'bottom.php';

}

else
{

 header("location:login.php");

}

ob_flush();

?>