<!DOCTYPE html>

<html lang="en">
<head>
  <title>Customer Payment Formate</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/bootstrap.min.css">

		   <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

		 <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script src="js/bootstrap.min.js"></script>
    <script>
         $( function() {
    $( "#search" ).autocomplete({
      minLength: 3,
      source: "resources/search_name.php?vc=",
      focus: function( event, ui ) {
        $( "#search" ).val( ui.item.name);
		//alert(ui.item.name);
        return false;
      },
      select: function( event, ui ) {
        $( "#c_id" ).val( ui.item.code );
        $( "#search" ).val( ui.item.name );
        $( "#cfname" ).val( ui.item.desc );
		$( "#cnic" ).val( ui.item.cnic );
        $( "#address" ).val( ui.item.address );
        $( "#phone1" ).val( ui.item.phone1 );
        $( "#pkg" ).val( ui.item.pkg );
		
									showHin(ui.item.code);

			
			//showHin(ui.item.code);

       // $( "#project-icon" ).attr( "src", "images/" + ui.item.desc );
         //var ccod= ui.item.code; 
        return false;
      }
    })
    .autocomplete( "instance" )._renderItem = function( ul, item ) {
	return $( "<li>" )
        .append( "<div><b>" + item.name + "</b><br>" + item.address + "</div>" )
        .appendTo( ul );
    };
  
		
  } );
  
   function showHin(str) {

    if (str.length == 0) { 
        document.getElementById("demo").innerHTML = "";
        return;
    } else {
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
				var data = this.responseText;
				var data=JSON.parse(data);
        $("#inv").val(data[0].inv);
        $("#pkgid").val(data[0].pkg);
        $("#arear").val(data[0].arear);
        $("#current").val(data[0].bill);
        $("#total").val(data[0].total);
        $("#date").val(data[0].date);
        $("#month").val(data[0].month);
        $("#payment").val(data[0].paid);



		//    $("#project-description").val(data[0].pre_address);


				}
        };
        xmlhttp.open("GET", "resources/count.php?q=" + str, true);
        xmlhttp.send();
    }
}

  </script>
</head>
<body>