<?php
include('connect.php');

error_reporting(0);

if(isset($_POST["subservice"]) && !empty($_POST["subservice"])){
    //Get all state data
    
	$subservicemid = $_POST['subservice'];
	$branchmid = $_POST['inqbranch'];
	$inquirydate = date("Y-m-d",strtotime($_POST['inquirydate']));
	 
	
	 $eve="SELECT * FROM res_offer_master WHERE offermid in (select offermid from res_offersubservice_detail where subservicemid= ".$subservicemid.") and  offermid in (select offermid from res_offerbranch_detail where branchmid= ".$branchmid.") and offervalidtill > '$inquirydate' and offerstartdate <= '$inquirydate'";
	
    $re = mysqli_query($conn, $eve);
	//echo '<option value="'.$eve.'">'.$eve.'</option>';
    //Count total number of rows
    if(mysqli_num_rows($re) > 0)
	{
		echo '<option value="0">Select Offer</option>';
        while($rt = mysqli_fetch_assoc($re)){ 
            echo '<option value="'.$rt['offermid'].'">'.$rt['offername'].'('.$rt['offerdiscount'].'%)</option>';
			
        }
    }else{
        echo '<option value="0">No Data Found</option>'; 
    }
}
?>