<?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">Follow Up</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>

								Follow Up

							</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>



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



          $('.contactrow').show();



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



		  var dataString = 'customer='+ customer;



		  //alert(dataString);



		  $.ajax



		  ({



		  type: "GET",



		  url: "getcontact.php",



		  data: dataString,



		  cache: false,



		  success: function(html)



		  {

		  

		  //alert(html);	



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

			

			$('.contact').html(html);



		  }



		  });



});





$(document).ready(function(){



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



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

		

		//alert(rem);



		if(rem=='Others')

		{

			

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

			

		}

		else

		{

			

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



		}



});



});





</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;

			};

		});

		

		return valid;

	});

	

});	



</script>                                







<?php        



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



$id = $_POST['id'];



$date = $_POST['date'];



$customer=$_POST['customer'];



$executive=$_POST['executive'];



$remarks = $_POST['remarks'];



$otherremarks = $_POST['otherremarks'];



$time=$_POST['time'];





if($remarks=='Others')

{

$remarks=$otherremarks;

}

else

{

$remarks=$remarks;

}





// now we insert it into the database



if($date)

{



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


$sel=mysql_query("select * from followup where ID='$id'");
$sel1=mysql_fetch_array($sel);


$ins=mysql_query("insert into followup(date,customer,executive,remarks,time,lastfollowup,lastremarks) values('$date','$customer','$executive','$remarks','$time','$sel1[date]','$sel1[remarks]')");



$in = "update followup set status='Updated' where ID='$id'";



$in1 = mysql_query($in) or die(mysql_error());



if($in1)

{



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



}



}



else

{



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



}



}





else 

{	



$id=$_GET['id'];



$follow=mysql_query("select * from followup where ID='$id'");

$follow1=mysql_fetch_array($follow);

 

 $customer=mysql_query("select * from crm_customer where ID='$follow1[customer]'");

 $customer1=mysql_fetch_array($customer);

 

?>



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



<input type="hidden" name="id" value="<?php echo $id; ?>" />



<input type="hidden" name="executive" value="<?php echo $follow1['executive']; ?>" />



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



<tr><td style="width:32%;">Date </td><td>:</td><td><input type="text" name="date" class="datepicker" id="required" title="*" /></td></tr>



<tr><td>Customer </td><td>:</td><td><input type="hidden" name="customer" value="<?php echo $follow1['customer']; ?>" /><input type="text" readonly="true" value="<?php echo $customer1['name']; ?>" /></td></tr>



<tr><td>Mobile </td><td>:</td><td><input type="text" readonly="true" value="<?php echo $customer1['mobile']; ?>" /></td></tr>



<tr style="display:none;" class="contactrow"><td>Contact No.</td><td>:</td><td><div class="contact"></div></td></tr>



<tr><td>Time</td><td>:</td><td><input type="text" name="time" value="<?php echo $follow1['time']; ?>" readonly="true" /></td></tr>



<tr><td>Reason </td><td>:</td><td><?php echo $follow1['remarks']; ?></td></tr>



<tr><td>Time</td><td>:</td><td><select name="time" class="select2"><option value="">-- Select --</option>



<?php



$st=mysql_query("select * from time_vl order by ID asc");

while($st1=mysql_fetch_array($st))

{

	echo"<option value='".$st1['time']."'>".$st1['time']."</option>";

}



?>



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



<tr><td>Remarks <span class="red">*</span></td><td>:</td><td><select name="remarks" class="select2 remarks" id="required" title="*">



<option value="">-- Select --</option>



<option value="No Rain">No Rain</option>



<option value="They Called">They Called</option>



<option value="Need na call pandra">Need na call pandra</option>



<option value="Driving">Driving</option>



<option value="Heavy Rain">Heavy Rain</option>



<option value="Call Later">Call Later</option>



<option value="No Need">No Need</option>



<option value="Manavari Payir">Manavari Payir</option>



<option value="Field ku vanga">Field ku vanga</option>



<option value="Not interested in organic">Not interested in organic</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%;">Remarks</td><td>:</td><td><textarea name="otherremarks" style="width:220px;"></textarea></td></tr>



</table>



</div>



</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();

?>