<?php session_start();







if($_SESSION[invcox] == ""){







header("location:login.php?action=need");







}else{







include("config.php");?>







<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">







<html xmlns="http://www.w3.org/1999/xhtml">



<head>



<meta http-equiv="Content-Type" content="text/html; charset=utf-8">



<title>Arnim Resort Reservation System</title>



<link href="style.css" rel="stylesheet" type="text/css" />



<?php include("calendar.php");?>



<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

	<!-- Select2 CSS -->

<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />



<!-- Select2 JS -->

<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>



<style type="text/css">







<!--



	.select2-selection--single{

		background: #769fa4;

		border: 1px solid #518289;

	}



        #suggestions {

            border: 1px solid #ccc;

            background: #fff;

            position: absolute;

            width: 400px;

            max-height: 200px;

            overflow-y: auto;

            display: none;

            z-index: 999;

        }

        #suggestions div {

            padding: 8px;

            cursor: pointer;

        }

        #suggestions div:hover {

            background: #f0f0f0;

        }

	
        #suggestions_ref {

            border: 1px solid #ccc;

            background: #fff;

            position: absolute;

            width: 400px;

            max-height: 200px;

            overflow-y: auto;

            display: none;

            z-index: 999;

        }

        #suggestions_ref div {

            padding: 8px;

            cursor: pointer;

        }

        #suggestions_ref div:hover {

            background: #f0f0f0;

        }

        #suggestions_room_no {

            border: 1px solid #ccc;

            background: #fff;

            position: absolute;

            width: 300px;

            max-height: 200px;

            overflow-y: auto;

            display: none;

            z-index: 999;

        }

        #suggestions_room_no div {

            padding: 8px;

            cursor: pointer;

        }

        #suggestions_room_no div:hover {

            background: #f0f0f0;

        }	

 

	

        .date-box {

            display: inline-block;

            padding: 10px 15px;

            background: #23D57A;

            border-radius: 6px;

            margin: 5px;

            cursor: pointer;

            user-select: none;

        }

	

	.date-boxBooked {

            display: inline-block;

            padding: 10px 15px;

            background: #F91115;

            border-radius: 6px;

            margin: 5px;

            cursor: pointer;

            user-select: none;

        }

.date-boxHold {

            display: inline-block;

            padding: 10px 15px;

            background: #7AA5C0;

            border-radius: 6px;

            margin: 5px;

            cursor: pointer;

            user-select: none;

        }

.date-boxCheck-in {

            display: inline-block;

            padding: 10px 15px;

            background: #13DC56;

            border-radius: 6px;

            margin: 5px;

            cursor: pointer;

            user-select: none;

        }

.date-boxCheck-out {

            display: inline-block;

            padding: 10px 15px;

            background: #4E4B4B;

            border-radius: 6px;

            margin: 5px;

            cursor: pointer;

            user-select: none;

        }	

        .date-box.selected {

            background: #4CAF50;

            color: white;

        }



        #result {

            margin-top: 20px;

            padding: 10px;

            background: #e9ffe6;

            border: 1px solid #a7ddb2;

            border-radius: 5px;

            min-height: 20px;

        }

-->







</style>



</head>







<body>

<script language="javascript">

	

function total_price_cak(){



 

//var rprice = parseFloat(document.getElementById('rprice').value);

var stotal_taka = parseFloat(document.getElementById('stotal_taka').value);

//var total_prix = Math.round(rprice*number_of_days); // totol price  

document.getElementById('total_price').value =stotal_taka;

	

var total_price = stotal_taka;



var discount = parseFloat(document.getElementById('discount').value); 



var total_price2 = Math.round(total_price-discount); // totol price after discount





if(discount>'0'){

document.getElementById("afd").style.display='block';

document.getElementById('afd').innerHTML =total_price2;



}else{

document.getElementById("afd").style.display='none';

}







var vat2 = parseFloat(document.getElementById('vat').value); 

var vat =  Math.round((total_price2/100)*vat2); 







if(vat>'0'){

document.getElementById("tvat").style.display='block';

document.getElementById('tvat').innerHTML =vat;

document.getElementById('vat_amount').value =vat;

}else{

document.getElementById("tvat").style.display='none';

document.getElementById('vat_amount').value =0;

}





var total_price3 = Math.round(total_price2+vat); // totol price after vat tax

document.getElementById('total_payeble').value =total_price3; // set the fiinal payeble

var payment_amount = parseFloat(document.getElementById('payment_amount').value);

var due = Math.round(total_price3-payment_amount); // due

document.getElementById('due').value =due;

}





function checkForm() {

    let total = document.getElementById("total_price").value.trim();



    // Convert to number

    let num = parseFloat(total);



    if (num > 0) {

        return true;  // allow submit

    } else {

        alert("Total Amount must be greater than 0");

        return false; // stop submit

    }

}



	

	

window.onload = function () {

    total_price_cak();

};



	</script>

<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" class="box-wrap">



  <tr>



    <td><?php include("top.php");?></td>



  </tr>



  <tr>



    <td><table width="100%" border="0" cellspacing="1" cellpadding="0">



        <tr>



          <td height="15" align="left" class="link2">&nbsp;</td>



        </tr>



        <tr>



          <td height="30" align="left" background="images/place_bg.jpg" class="location"><strong>&nbsp;Home &gt; </strong><strong>Arnim Resort</strong></td>



        </tr>



        <tr>



          <td align="center">&nbsp;</td>



        </tr>



        <tr>



          <td align="center"><?php if($_GET[info]!=""){echo '<span class="red"><strong>'.$_GET[info].'</strong></span>';}?></td>



        </tr>



        <?php if($_GET[action] == 'edit'){ 

}else{?>



        <tr>



          <td><form action="insert_hotel_new.php" method="post" enctype="multipart/form-data" name="enquiryform" class="round_box" id="enquiryform" onsubmit="return checkForm();">



              <table width="100%" border="0" cellpadding="2" cellspacing="1">



                <tr>



                  <td colspan="2" class="location"><strong>Add New Reservation</strong></td>

                </tr>



                <tr>



                  <td width="9%" height="30">Invoice Date :</td>



                  <td width="91%" class="input200"><table width="250" border="0" cellspacing="0" cellpadding="0">



                      <tr>



                        <td width="70%"><input name="cdate" type="text" id="cdate" size="15"  value="<?php echo date("d-m-Y");?>" required="required"/></td>



                        <td width="30%" align="center"><a title="Calendar" onclick="displayDatePicker('cdate', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>

                      </tr>



                    </table></td>

                </tr>



                <tr>



                  <td colspan="2" align="left" valign="middle" bgcolor="#FFFFFF" class="round_box">

                    <a href="add_client.php" target="_blank"></a> 



                    

                    <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">

                      

                   

                      <tr>

                        <td>NID/PP/Phone:</td>

                        <td class="input200">

							

						 

 <input type="text" id="nid" autocomplete="off">

    <div id="suggestions"></div>



							

<script>

$(document).ready(function() {

    // Live Search

    $("#nid").keyup(function () {

        let query = $(this).val();


        if (query.length === 0) {

            $("#suggestions").hide();

            return;

        }



        $.ajax({

            url: "search.php",

            method: "POST",

            data: { search: query },

            success: function (data) {

                $("#suggestions").html(data).show();

            }

        });

    });



    // On click suggestion

    $(document).on("click", ".suggest-item", function () {

        let customer = $(this).data("customer");


        $("#nid").val(customer.nid);

		$("#nid2").val(customer.nid);

        $("#customer_name").val(customer.customer_name);

        $("#contact_person").val(customer.contact_person);

        $("#personal_phn").val(customer.personal_phn);

        $("#personal_email").val(customer.personal_email);

        $("#address").val(customer.address);



        $("#suggestions").hide();

    });

});

</script>



						  Search</td>

                        <td width="15%" height="30"> Customer / Company Name: <span class="red">*</span></td>

                        <td width="35%" class="input200"><input name="customer_name" type="text" required="required" id="customer_name" /></td>

                      </tr>

                      <tr>

                        <td>Room No :<span class="red">*</span></td>

                        <td class="input200"> 

	<input type="text" id="room_no" autocomplete="off">

    <div id="suggestions_room_no"></div>



<script>

$(document).ready(function() {



    // Live Search

    $("#room_no").keyup(function () {

        let query = $(this).val();



        if (query.length === 0) {

            $("#suggestions_room_no").hide();

            return;

        }



        $.ajax({

            url: "search_room.php",

            method: "POST",

            data: { search: query },

            success: function (data) {

                $("#suggestions_room_no").html(data).show();

            }

        });

    });



    // On click suggestion

    $(document).on("click", ".suggest-item2", function () {

        let hotel_room = $(this).data("hotel_room");



        $("#room_no").val(hotel_room.room_no);

        $("#rtype").val(hotel_room.rtype);

        $("#rprice").val(hotel_room.rprice);

       

        //document.getElementById('srt_description_div').innerHTML = hotel_room.srt_description;



        $("#suggestions_room_no").hide();

    });

});

</script>

						  </td>

                        <td bordercolor="#CCCCCC"> Contact Person:</td>

                        <td bordercolor="#CCCCCC" class="input200"><label>

                          <input name="contact_person" type="text" id="contact_person"  value="" />

                        </label></td>

                      </tr>

                      <tr>

                        <td>&nbsp;</td>

                        <td class="input200">&nbsp;</td>

                        <td>NID / Passport :<span class="red">*</span></td>

                        <td class="input200"><input name="nid2" type="text" required="required" id="nid2" /></td>

                      </tr>

                      <tr>

                        <td>Room Type :</td>

                        <td class="input200"><input type="text" name="rtype" id="rtype" /></td>

                        <td>Mobile:<span class="red">*</span></td>

                        <td class="input200"><input name="personal_phn" type="text" required="required" id="personal_phn" /></td>

                      </tr>

                      <tr>

                        <td width="10%">Price :</td>

                        <td width="40%" class="input200"><input type="text" name="rprice" id="rprice" autocomplete="off"/>

                        <strong>৳</strong></td>

                        <td>Email :<span class="input200">

                          <input name="url" type="hidden" id="url" value="add_client.php"/>

                        </span></td>

                        <td class="input200"><input name="personal_email" type="text" id="personal_email" /></td>

                      </tr>

                      <tr>

                        <td height="50" align="left"><span class="style81"><strong>Check-in <span class="red">* </span></strong></span></td>

                        <td height="50" align="left"><table width="100" border="0" cellspacing="0" cellpadding="2">

                          <tr>

                            <td width="20%" valign="top"><input name="check_in_date" type="text" id="check_in_date" size="15"  value="" />

							  

							  

<script>

 

$(document).ready(function() {

    // Live Search

	 $("#check_in_date, #room_no").focus(function () {

    //$("#check_in_date").focus(function () {

      

    let date = $("#check_in_date").val();

    let room = $("#room_no").val();

		

if (date.length === 0 && room.length === 0) {

        $("#result").html("");

        return;

    }



    $.ajax({

        url: "search_room_available.php",

        method: "POST",

        data: { date: date, room: room },

        success: function (data) {

            $("#search_room_available").html(data).show();

            }

 

        });

    });



    // On click suggestion

    $(document).on("click", ".suggest-item2", function () {

        let hotel_room = $(this).data("hotel_room");



        $("#room_no").val(hotel_room.room_no);

        $("#rtype").val(hotel_room.rtype);

        $("#rprice").val(hotel_room.rprice);

       

        //document.getElementById('srt_description_div').innerHTML = hotel_room.srt_description;



        $("#suggestions_room_no").hide();

		 

    });

});

</script>

							  </td>

                            <td width="3%" align="center" valign="middle"><a title="Calendar" onclick="displayDatePicker('check_in_date', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" id="datep" /></a></td>

                            </tr>

                        </table>

                       </td>

                        <td>Address :</td>

                        <td class="input200"><textarea name="address" rows="5" id="address"></textarea></td>

                      </tr>

                      <tr>

                        <td height="50" align="left" valign="bottom">Numer of Days<br />                          <br /></td>

                        <td height="50" align="left" class="input200"><div id="dates-container">
                          
                          <div id="search_room_available">
                            
                            
                            
                            
                            
                            </div>
                          
                          </div>
                          
                          
                          
                          <div id="result1"></div>
                          
                          <input name="result2" type="hidden" required="required" id="result2" readonly="readonly">
                          
                          <input name="number_of_days" type="text" required="required" id="number_of_days" readonly="readonly">
                          
  <script>

let selected = [];

let firstDate = null;



// Convert "DD-MM-YYYY" to Date object

function parseDate(d){

    let [day, month, year] = d.split("-").map(Number);

    return new Date(year, month - 1, day);

}



document.getElementById("dates-container").addEventListener("click", function(e) {

    let box = e.target.closest(".date-box");

    if (!box) return;



    let clickedDate = box.textContent.trim();



    // -------- FIRST CLICK --------

    if (!firstDate) {

        firstDate = clickedDate;

        selected = [clickedDate];



        // Clear all selections visually

        document.querySelectorAll(".date-box").forEach(b => b.classList.remove("selected"));

        box.classList.add("selected");



        // Update result fields

        document.getElementById("result2").value = selected.join(",");

        document.getElementById("number_of_days").value = selected.length;



        return;

    }



    // -------- SECOND CLICK (SELECT RANGE) --------

    let start = parseDate(firstDate);

    let end = parseDate(clickedDate);



    if (end < start) [start, end] = [end, start]; // swap



    selected = [];



    document.querySelectorAll(".date-box").forEach(b => {

        let d = b.textContent.trim();

        let current = parseDate(d);



        if (current >= start && current <= end) {

            b.classList.add("selected");

            selected.push(d);

        } else {

            b.classList.remove("selected");

        }

    });



    // Update result fields

    document.getElementById("result2").value = selected.join(",");

    document.getElementById("number_of_days").value = selected.length;



    // Reset for new selection cycle

    firstDate = null;

});

</script>
                          
                          
                          
</td>
                        <td height="50" align="left">Nid / Passport :</td>
                        <td height="50" align="left"><input type="file" name="file1" /></td>

                      </tr>

                      <tr>

                        <td height="50" align="left">&nbsp;</td>

                        <td height="50" align="left" class="input200">&nbsp;</td>
                        <td height="50" align="left">Other :</td>
                        <td height="50" align="left"><input type="file" name="file2" /></td>

                      </tr>

                      <tr>
                        <td height="50" align="center">&nbsp;</td>
                        <td height="50" align="left">&nbsp;</td>
                        <td height="50" align="left" valign="middle">Additional Service</td>
                        <td height="50" align="left" valign="middle" class="input200"><select name="addition_service" id="addition_service" style="width: 220px;">
                          <?php     

																					  

			$dresult=mysql_query("select * from hotel_service  order by sprice asc ");

            $drow=mysql_fetch_array($dresult);

				  do{

            ?>
                          <option value="<?php echo $drow[service_name];?>"><?php echo $drow[service_name];?></option>
                          <?php 

}while($drow=mysql_fetch_array($dresult));

 ?>
                        </select>
                          <script>

$(document).ready(function() {

    $('#addition_service').select2({

        placeholder: "Select a Service",

        allowClear: true

    });

});

                          </script></td>
                      </tr>
                      <tr>

                        <td height="50" align="center">&nbsp;</td>

                        <td height="50" align="left"><button id="myBtn" type="button">Add Room</button>
                          
                          
                          
                          
                          
  <script>

							$(document).ready(function() {



    $('#myBtn').on('click', function() {



        let number_of_days = $('#number_of_days').val();

		let nid2 = $('#nid2').val();

		let customer_name = $('#customer_name').val();

		let contact_person = $('#contact_person').val();

		let personal_phn = $('#personal_phn').val();

		let personal_email = $('#personal_email').val();

		let address = $('#address').val();

		let result2 = $('#result2').val();

		

		let room_no = $('#room_no').val();

		let rprice = $('#rprice').val();

		let tboking = $('#tboking').val();

		let addition_service = $('#addition_service').val();

		let pax = $('#pax').val();

	 

        

		

		

		



        $.ajax({

            url: "add_single_room.php",

            type: "POST",

            data: {

                number_of_days: number_of_days,

                nid2: nid2,

				customer_name: customer_name,

				contact_person: contact_person,

				personal_phn: personal_phn,

				personal_email: personal_email,

				address: address,

				result2: result2,

				

				room_no: room_no,

				rprice:  rprice,

				tboking: tboking,

				addition_service: addition_service,

				pax: pax

				

            },

            success: function(response) {

                $('#responseBox').html(response);

				

				//$("#room_no").val('');

				//$("#number_of_days").val('');

				//$("#dates-container").html('');

				total_price_cak();

				

            },

            error: function() {

                $('#responseBox').html("Something went wrong");

            }

        });



    });



});



	

 

 



function delete_hotel(id,room_no) {

    //console.log("Received:", v);

	



        $.ajax({

            url: "delete_single_room.php",

            type: "POST",

            data: {

                id: id,

                room_no: room_no 

				

            },

            success: function(response) {

                $('#responseBox').html(response);

				

				//$("#room_no").val('');

				//$("#number_of_days").val('');

				//$("#dates-container").html('');

				total_price_cak();

				

            },

            error: function() {

                $('#responseBox').html("Something went wrong");

            }

        });

}

						

							</script>
                          
</td>
                        <td height="50" align="left" valign="middle">Adult and Chield  (Qty/Person) <span class="red">*</span></td>
                        <td height="50" align="left" valign="middle"><span class="input200">
                          <input name="pax" type="text" required="required" id="pax" />
                        </span></td>

                      </tr>

                    </table></td>

                </tr>



                <tr>

                  <td height="7" colspan="2">&nbsp;</td>

                </tr>

                <tr>

                  <td height="7" colspan="2" class="round_box">



					 <div id="responseBox" style="margin-top:10px; color:#333;">

					   

						 <?php 

						 

$bresult=mysql_query("select * from bookings WHERE customer_id='$cid' and ostatus='0' group by room_no asc");

$brow=mysql_fetch_array($bresult);

if($brow!=""){

?>

<table width="100%" border="0" cellspacing="0" cellpadding="2" class="list_table">

  <tbody>

    <tr>

      <th width="10%">Room No</th>

      <th width="39%">Booked/Hold Date</th>

	  <th width="12%">Price</th>

	  <th width="11%">Days</th>

      <th width="11%">Addition Service</th>

      <th width="11%">Addition Service for Person</th>

    <th width="6%">Total</th>

    <th width="6%">Delete</th>

    </tr>

<?php 

do{

	  ?>

    <tr>

      <td><?php echo $brow[room_no]; ?></td>

      <td><?php 

$cresult=mysql_query("select check_in,rprice from bookings WHERE customer_id='$cid' and ostatus='0' and room_no='$brow[room_no]'");

$crow=mysql_fetch_array($cresult);

	$sr=0;

do{

$sr=$sr+1;

echo $crow[check_in].", ";

$rprice=$crow[rprice];

}while($crow=mysql_fetch_array($cresult));

	

		  

		  ?></td>

      <td><?php echo $brow[rprice]; ?></td>

		<td><?php echo $sr; ?></td>

      <td><?php echo $brow[additional_ser]; ?></td>

      <td><?php echo $brow[addi_pax]; ?></td>

     <td><?php $total=$sr*$rprice; echo $total; $gtotal=$gtotal+$total; ?></td>

     <td align="center"><a href="javascript:void(0);" onClick="delete_hotel('<?php echo $brow[id]; ?>','<?php echo $brow[room_no]; ?>');">Delete</a>

</td>

    </tr>

	 <?php 

	  

	  }while($brow=mysql_fetch_array($bresult));

	  ?>

	  <tr>

      <td colspan="5">&nbsp;</td>

      <td>Total </td>

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

      <td align="center">&nbsp;</td>

    </tr>

  </tbody>

</table>

 

<?php

}else{?><input name="stotal_taka" type="hidden" id="stotal_taka" value="0" /><?php }?>

					 </div>



					

					</td>

                </tr>

                <tr>



                  <td height="7" colspan="2"><br /></td>

                </tr>



                <tr>



                  <td height="30" colspan="2" class="round_box"><table width="100%" border="0" cellspacing="1" cellpadding="2">

                    <tbody>

                      <tr>

                        <td height="50" align="left">Type of Booking</td>

                        <td height="50" align="left" class="input200"><select name="tboking" id="tboking">

                          <option value="Booked">Booked</option>

                          <option value="Hold">Hold</option>
							<option value="Check-in">Check-in</option>
							
							

                        </select></td>

                      </tr>

                      <tr>

                        <td height="30">Total Amount :</td>

                        <td class="input200"><input name="total_price" type="text" id="total_price"  value="0" onkeyup="total_price_cak();" autocomplete="off"/></td>

                      </tr>

                      <tr>

                        <td width="9%" height="30">Discount : </td>

                        <td width="91%" class="input200"><input name="discount" type="text" id="discount"  value="0" onkeyup="total_price_cak();" onfocus="javascript:if(this.value=='0')this.value=''" onblur="javascript:if(this.value=='')this.value='0'" autocomplete="off"/>

                          <div id="afd" class="show_info"></div></td>

                      </tr>

                      <tr>

                        <td height="30">VAT %:</td>

                        <td class="input200"><input name="vat" type="text" id="vat" onkeyup="total_price_cak();" value="0" onfocus="javascript:if(this.value=='0')this.value=''" onblur="javascript:if(this.value=='')this.value='0'" autocomplete="off"/>

                          <div id="tvat" class="show_info"></div>

						  <input name="vat_amount" type="hidden" id="vat_amount" value="0" />

						  

						  </td>

                      </tr>

                      <tr>

                        <td height="30">Total Payeble :</td>

                        <td class="input200"><input name="total_payeble" type="text" id="total_payeble" value="0"  readonly="readonly" /></td>

                      </tr>

                      <tr>

                        <td height="30">Paid Amount :</td>

                        <td class="input200"><input name="payment_amount" type="text" id="payment_amount"  onkeyup="total_price_cak();" value="0" onfocus="javascript:if(this.value=='0')this.value=''" onblur="javascript:if(this.value=='')this.value='0'" autocomplete="off"/></td>

                      </tr>

                      <tr>

                        <td height="30">Pay Methode :</td>

                        <td class="input200">

<select name="pay_methode" required="required" id="pay_methode">
<option value="">Select Pay Methode</option>
<?php 

$rresult=mysql_query("select * from bank_acc order by bank asc");

$rrow=mysql_fetch_array($rresult);

do{

	?>

<option value="<?php echo $rrow[bank];?> - <?php echo $rrow[accname];?> - <?php echo $rrow[accno];?>"><?php echo $rrow[bank];?> - <?php echo $rrow[accname];?> - <?php echo $rrow[accno];?></option>

<?php }while($rrow=mysql_fetch_array($rresult));?>

                           

                        </select></td>

                      </tr>

                      <tr>

                        <td height="30">&nbsp;</td>

                        <td><div id="Bank" style="display: none ">

                          <table width="100%" border="0" cellpadding="2" cellspacing="1">

                            <tr>

                              <td align="left" >Bank Name :</td>

                              <td ><input name="bankname" type="text" id="bankname" size="20" /></td>

                            </tr>

                            <tr>

                              <td align="left" >Account Name :</td>

                              <td ><input name="acname" type="text" id="acname" size="20" /></td>

                            </tr>

                            <tr>

                              <td width="20%" align="left" > Account Number :</td>

                              <td width="80%" ><input name="acc_no" type="text" id="acc_no" size="20" /></td>

                            </tr>

                            <tr>

                              <td align="left" >Cheque  no : </td>

                              <td ><input name="chackno" type="text" id="chackno" size="20" /></td>

                            </tr>

                            <tr>

                              <td align="left" >Date of Cheque Maturity: </td>

                              <td ><table width="175" border="0" cellspacing="0" cellpadding="0">

                                <tr>

                                  <td width="76%"><input name="chdate" type="text" id="chdate" value="<?php echo date("d-m-Y"); ?>" size="20" /></td>

                                  <td width="24%" align="center"><a title="Calendar" onclick="displayDatePicker('chdate', this);" href="javascript:;"><img src="images/calendar.gif" width="20" height="20" border="0" /></a></td>

                                </tr>

                              </table></td>

                            </tr>

                          </table>

                        </div></td>

                      </tr>

                      <tr>

                        <td height="30">Due / Advance : </td>

                        <td><span class="input200">

                          <input name="due" type="text" id="due" value="0"  readonly="readonly"/>

                        </span></td>

                      </tr>

                      <tr>

                        <td height="30">Refarence :</td>

                        <td class="input200">
	<input type="text" id="refr" name="refr" autocomplete="off">
	<span class="input200">
	<input type="hidden" id="refr_id" name="refr_id" autocomplete="off" />
	</span>

    <div id="suggestions_ref"></div>



							


						  
<script>

$(document).ready(function() {



    // Live Search

    $("#refr").keyup(function () {

        let query = $(this).val();



        if (query.length === 0) {

            $("#suggestions_ref").hide();

            return;

        }



        $.ajax({

            url: "search2.php",

            method: "POST",

            data: { search: query },

            success: function (data) {

                $("#suggestions_ref").html(data).show();

            }

        });

    });



    // On click suggestion
$(document).on("click", ".suggest-item3", function () {

    let customer2 = JSON.parse($(this).attr("data-customer3"));

    $("#refr").val(customer2.customer_name);  // fill visible box
    $("#refr_id").val(customer2.id);         // hidden value

    $("#suggestions_ref").hide();
});
	
	
   
});

</script>
						  
						  </td>

                      </tr>

                      <tr>
                        <td height="30">R Commision :</td>
                        <td class="input200"><input name="rcom" type="number" id="rcom" value="0" onfocus="javascript:if(this.value=='0')this.value=''" onblur="javascript:if(this.value=='')this.value='0'" autocomplete="off"/></td>
                      </tr>
                      <tr>
                        <td height="30">Note : </td>
                        <td><textarea name="unote" id="unote" cols="45" rows="5"></textarea></td>
                      </tr>
                      <tr>

                        <td height="30">&nbsp;</td>

                        <td><input type="submit" name="Submit2" value="Submit" /></td>

                      </tr>

                      </tbody>

                  </table></td>

                </tr>



                <tr>



                  <td height="6" colspan="2">&nbsp;</td>

                </tr>

                <tr>

                  <td height="6" colspan="2">&nbsp;</td>

                </tr>

              </table>



              <br />



          </form></td>



        </tr>



        <?php }?>



        <tr>



          <td height="10"><p><br />



              <br />



            </p></td>



        </tr>



      </table></td>



  </tr>



  <tr>



    <td height="25"><?php include("bot.php");?></td>



  </tr>



</table>



</body>



</html>



<?php }?>