<?php 
	include "../db_connection/db_connection.php";
	include "../config/config.php";
$LP_CNT1=0;
$qty=0;
	/*$SLCT_CNT1 = "SELECT * FROM design_sel_det WHERE ord_status='no' GROUP BY party_det_id,sel_date";
	$QURY_CNT1 = mysqli_query($connect,$SLCT_CNT1);
	$LP_CNT1 = mysqli_num_rows($QURY_CNT1);*/
	
	$SLCT_CNT1 = "SELECT party_det_id FROM design_sel_det GROUP BY party_det_id ORDER BY design_sel_det_id DESC";
	$QURY_CNT1 = mysqli_query($connect,$SLCT_CNT1);

	if(mysqli_num_rows($QURY_CNT1)>0)
	{
		while($FTCH_CNT1 = mysqli_fetch_object($QURY_CNT1))
		{
			$SLCT_CNT2 = "SELECT COUNT(design_sel_det_id) AS sel_cnt FROM design_sel_det WHERE  party_det_id = '$FTCH_CNT1->party_det_id' GROUP BY DATE(sel_date)";
			$QURY_CNT2 = mysqli_query($connect,$SLCT_CNT2);
			$FTCH_CNT2 = mysqli_fetch_object($QURY_CNT2);

			$SLCT_CNT3 = "SELECT COUNT(design_sel_det_id) AS des_cnt FROM design_sel_det WHERE party_det_id = '$FTCH_CNT1->party_det_id' AND ord_status = 'yes'";
			$QURY_CNT3 = mysqli_query($connect,$SLCT_CNT3);
			if(mysqli_num_rows($QURY_CNT3)>0)
			{
				$FTCH_CNT3 = mysqli_fetch_object($QURY_CNT3);
				if($FTCH_CNT3->des_cnt != $FTCH_CNT2->sel_cnt)
				{
					$LP_CNT1 = $LP_CNT1 +1;
				}
			}
			}
	}
	
	
	$SLCT_prt = "SELECT * FROM design_sel_det WHERE ord_status='no' GROUP BY party_det_id,sel_date ORDER BY design_sel_det_id DESC";
	$QURY_prt = mysqli_query($connect,$SLCT_prt);	
	while($FTCH_prt = mysqli_fetch_object($QURY_prt))
	{
	   $SLCT_dd = "SELECT COUNT(design_sel_det_id) AS sel_cnt FROM design_sel_det WHERE ord_status='no' AND party_det_id = '$FTCH_prt->party_det_id' and `sel_date` ='$FTCH_prt->sel_date' GROUP BY sel_date";
	   $QURY_dd = mysqli_query($connect,$SLCT_dd);
	   $FTCH_dd = mysqli_fetch_object($QURY_dd);
	   $qty = $qty+$FTCH_dd->sel_cnt;
	}
$clean_temp = mysqli_query($connect,"TRUNCATE temp_statistics");

$insert_stat = mysqli_query($connect,"insert into temp_statistics(req_value1,req_value2) values('".$LP_CNT1."','".$qty."')");

echo $LP_CNT1." - ".$qty;
?>