<?PHP

ob_start();

session_start();

include 'connect.php';

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

{

$user=$_SESSION['adminemail'];



$gtp=mysqli_query($conn,"select * from admin where username='$user'");

$gtp1=mysqli_fetch_assoc($gtp);



include 'top.php';

?>






<div id="page-wrapper" >
          <div id="page-inner">
			<div >

				<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=mysqli_query($conn,"select * from financial where user='$user' order by ID desc");

$aca1=mysqli_fetch_assoc($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="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.js"></script>
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables-buttons/3.0.2/js/dataTables.buttons.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>
  <script>
    $(function() {
      // Initialize the datepicker
      $("#datepicker").datepicker({
        format: "mm/dd/yyyy",
        autoclose: true,
        todayHighlight: true
      });

      // Adjust the positioning of the datepicker dropdown
      $("#datepicker").on("show", function(e) {
        var inputOffset = $(this).offset();
        var inputHeight = $(this).outerHeight();
        var datepickerDropdown = $(".datepicker-dropdown");

        datepickerDropdown.css({
          top: inputOffset.top + inputHeight + 10,
          left: inputOffset.left
        });
      });
    });
  </script>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css">
 <style>
    /* Custom CSS for Chosen select */
    .chosen-container {
      width: 25ch;
    }

    .chosen-container-single .chosen-single {
      border-radius: 4px;
      border: 1px solid #f0f0f0; /* Change the border color here */
      height:34px;
	  margin-bottom:10px;
      background-color: #fff;
      background-image: none;
      box-shadow: 0 0 0 1px #c0c0c0;
    }

    .chosen-container-single .chosen-single span {
      padding: 5px;
      text-transform: uppercase;
    }

    .chosen-container-single .chosen-search input[type="text"] {
      border-radius: 4px;
      border: 1px solid #c0c0c0;
      height: 34px;
    }

    .chosen-container-active .chosen-single {
      border-color: #7f7f7f;
      box-shadow: 0 0 0 1px #7f7f7f;
    }

    .chosen-container-active .chosen-single:hover {
      border-color: #7f7f7f;
      box-shadow: 0 0 0 1px #7f7f7f;
    }

    .chosen-container-active .chosen-search input[type="text"] {
      border-color: #7f7f7f;
    }
  </style>

<script>
$(function() {
  // Initialize the Chosen select element
  $(".chosen-select").chosen({
    width: '32ch',
    disable_search_threshold: 10
  });
});
</script>

<script>

$(".customer").on('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;
		$('button:submit').prop('disabled', true);
	});
});	
</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));



$ins=mysqli_query($conn,"insert into followup(date,customer,executive,remarks,time) values('$date','$customer','$executive','$remarks','$time')");



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



$in1 = mysqli_query($conn,$in) or die(mysqli_error($conn));



if($in1)

{



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



}



}



else

{



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



}



}





else 

{	



$id=$_GET['id'];



$follow=mysqli_query($conn,"select * from followup where ID='$id'");

$follow1=mysqli_fetch_assoc($follow);

 

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

 $customer1=mysqli_fetch_assoc($customer);

 

?>



<form id="course" action="status1.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 class="form-control" style="width: 30ch; margin-bottom:10px" type="text" name="date" class="datepicker" id="datepicker" title="*" /required></td></tr>



<tr><td>Customer </td><td></td><td><input  type="hidden" name="customer" value="<?php echo $follow1['customer']; ?>" /><input class="form-control" style="width: 30ch; margin-bottom:10px"type="text" readonly="true" value="<?php echo $customer1['name']; ?>" /></td></tr>



<tr><td>Mobile </td><td></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" 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="form-control" style="width: 30ch; margin-bottom:10px" class="contact"></div></td></tr>



<tr><td>Time</td><td></td><td><input class="form-control" style="width: 30ch; margin-bottom:10px" 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="chosen-select"><option value="">-- Select --</option>



<?php



$st=mysqli_query($conn,"select * from time_vl order by ID asc");

while($st1=mysqli_fetch_assoc($st))

{

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

}



?>



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





<tr><td>Remarks <span class="red"></span></td><td></td><td><select class="form-control" style="width: 30ch; margin-bottom:10px" name="remarks" class="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 -->
					</div><!-- /.main-content -->
					</div><!-- /.main-content -->





<?php



include 'bottom.php';



}

else

{



 header("location:login.php");

 

}



ob_flush();



?>