<?PHP


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











echo"<br /><center><table style='width:90%;'><tr>


<td style='width:25%;'></td>


<td style='width:50%; text-align:center;'><b>Today Order Confirmed - ".date('d-m-Y')."</b></td>


<td style='width:25%;'></td></tr></table></center><br />";





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





echo"<table style='width:90%; margin:auto;'>


<tr><td><table border='1' style='width:100%; border-collapse:collapse; font-size:12px;'>


<thead><tr><th>Customer</th><th>Mobile</th><th>Village</th><th>Taluk</th><th>District</th>


<th>Product</th><th>Qty</th><th>Executive</th><th>Rate</th><th>Order Value</th></tr></thead>";





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


$nmrw=mysqli_num_rows($sel);


$sel1=mysqli_fetch_assoc($sel);





if($nmrw>0)


{


$getr=mysqli_query($conn,"select * from followup where date='$date' and status='Confirmed'");


}


else


{





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


$empd1=mysqli_fetch_assoc($empd);





$usr=$empd1['ID'];





$getr=mysqli_query($conn,"select * from followup where date='$date' and executive='$usr' and status='Confirmed'");


}





while($getr1=mysqli_fetch_assoc($getr))


{


	


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


	$cust1=mysqli_fetch_assoc($cust);


	


	$exec=mysqli_query($conn,"select * from employee where ID='$getr1[executive]'");


	$exec1=mysqli_fetch_assoc($exec);


	


	$sl=mysqli_query($conn,"select *,sum(total) as total from sales_order where orderno='$getr1[salesorderno]'");


	$sl1=mysqli_fetch_assoc($sl);


	


	$prd=mysqli_query($conn,"select * from product where ID='$sl1[product]'");


	$prd1=mysqli_fetch_assoc($prd);


	


	$vil=mysqli_query($conn,"select * from villages where ID='$cust1[village]'");


	$vil1=mysqli_fetch_assoc($vil);


	


	$tal=mysqli_query($conn,"select * from taluk where ID='$cust1[taluk]'");


	$tal1=mysqli_fetch_assoc($tal);
	
	
	
	$dis=mysqli_query($conn,"select * from districts where ID='$cust1[district]'");

	$dis1=mysqli_fetch_assoc($dis);


	


	echo"<tr><td>".$cust1['name']."</td>


	


	<td>".$cust1['mobile']."</td>


	


	<td>".$vil1['village']."</td>


	


	<td>".$tal1['taluk']."</td>


	


	<td>".$dis1['district']."</td>


	


	<td>".$prd1['product']."</td>


	


	<td>".$sl1['qty']."</td>





	<td>".$exec1['name']."</td>
	


	
	<td style='text-align:right;'>".$sl1['rate']."</td>
	

	
	
	<td style='text-align:right;'>".$sl1['total']."</td></tr>";



	


}





echo"</table></td></tr></table>";






}


else


{





 header("location:login.php");


 


}










?>