<?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=iso-8859-1"/>
      <title>Customer Entry</title>
      <link href="style.css" rel="stylesheet" type="text/css"/>
      <?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>
      <table width="98%" 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 align="left" class="link2">&nbsp;
</td>
                  </tr>
                  
                  <tr>
                     <td align="center">&nbsp;
</td>
                  </tr>
                  <tr>
                     <td>
                        <form action="customer_profile.php" method="post" enctype="multipart/form-data" name="form1" class="round_box" id="form1" onsubmit="return validate()">
                           <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
                              <tr>
                                 <td height="40" colspan="3" align="center" bgcolor="#466c74">Customer Profile</td>
                              </tr>
                              <?php if($_GET[info]!=""){?>
                              <tr>
                                 <td height="40" colspan="3" align="center" bgcolor="#80E8F4"><?php echo $_GET[info];
 ?>   </td>
                              </tr>
                              <?php }?>
                              <tr>
                                <td width="14%" height="30">Customer Nid/Phone/Name :</td>
                                <td width="14%" class="input200"><input name="refr" type="text" required="required" id="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>
                                <td width="72%" class="input200"><input type="submit" name="Submit23" value="Search"/></td>
                              </tr>
                           </table>
                        </form>
                     </td>
                  </tr>
                  <tr>
                     <td>&nbsp;
</td>
                  </tr>
                  <tr>
                     <td align="center" class="round_box">
     <?php 
$refr_id=$_POST[refr_id];
																					  
if($_GET[refr_id]!=""){$refr_id=$_GET[refr_id];}		
if($_POST[refr_id]!=""){$refr_id=$_POST[refr_id];}																				 
																					  
$result=mysql_query("select * from customer where id='$refr_id' limit 1");
$row=mysql_fetch_array($result);
if($row!=""){
							
					?> 
                        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0" class="list_table">
                           <tr>
                              <th height="30">Customer / Company Name </th>
                              <th height="30" align="center">Contact Person</th>
                              <th height="30" align="left">Mobile</th>
                              <th height="30" align="left">Nid</th>
                              <th height="30" align="left">Email  </th>
                              <th height="30" align="center">Address</th>
                              
                           </tr>
                        
                           <tr>
						      <td width="284" align="center" valign="top" class="link"><?php    echo $row[customer_name];
            ?>   </td>
                              <td width="220" align="center" valign="top" class="link "><?php echo $row[contact_person];
   ?></td>
                              <td width="185" align="left" valign="top" class="link "><?php echo $row[personal_phn];
?></td>
                              <td width="175" align="left" valign="top" class="link "><?php echo $row[nid];
 ?></td>
                              <td width="213" align="left" valign="top" class="link "><?php echo $row[personal_email];
?></td>
                              <td width="372" align="center" valign="top" class="link "><?php echo $row[address];
 ?></td>
                          
                           </tr>
                           <tr>
                             <td align="center" valign="top" class="link">Nid / Passport :</td>
                             <td align="center" valign="top" class="link "><?php if($row[file1]!=""){?><img src="uploads/<?php echo $row[file1];?>" width="164" height="163" alt=""/><?php }?></td>
                             <td align="left" valign="top" class="link ">Other : </td>
                             <td align="left" valign="top" class="link "><?php if($row[file2]!=""){?><img src="uploads/<?php echo $row[file2];?>" width="164" height="163" alt=""/><?php }?></td>
                             <td align="left" valign="top" class="link ">&nbsp;</td>
                             <td align="center" valign="top" class="link ">&nbsp;</td>
                           </tr>
     
                        </table>
						 
	<?php }else{echo 'No Info Found';}?>					 
						 
                    <td width="25" align="center" class="paiging">&nbsp;
</td>
                  </tr>
               </table>
            </td>
         </tr>
         <tr>
           <td height="28" align="center">&nbsp;</td>
         </tr>
         <tr>
           <td height="28" align="center"><table width="100%" border="0" cellspacing="2" cellpadding="2">
             <tbody>
               <tr>
                 <td width="50%" valign="top" class="round_box">Booking
                   
  <?php 







		    


		  if($ds!=""){



		  $ds=dtformat($ds);


		  $de=dtformat($de);

		  $d="and cdate>='$ds' and cdate<='$de' ";}else{$d="";}




		  $dresult=mysql_query("select * from bill WHERE customer_id!='0' and customer_id='$refr_id'  $d order by id desc");
 
          $drow=mysql_fetch_array($dresult);

if($drow!=""){ 

					 ?>
  <table width="100%" border="0" cellpadding="3" cellspacing="1" class="list_table">
                <tr>
                       <th align="center" >Reservations No</th>
                       <th align="center" >Room No</th>
                       <th align="center" >Date</th>
                       <th align="center" >Total Payeble</th>
                       <th align="center" >Payment</th>
                       <th align="center" >Due</th>
                       <th align="center" >P.Method </th>
                       <th align="center" >User</th>
                       <th align="center" >Pay Due</th>
                     </tr>
                     <?php 





		  $total=0;







		  do{







		  ?>
                     <tr>
                       <td width="11%" align="center" class="link"><a href="javascript:void(0);" onclick="popUp('show_bill.php?id=<?php echo $drow[bill_id]; ?>')"><?php echo $drow[bill_id]; ?></a></td>
                       <td width="12%" align="center" class="link"><?php 	

	 

		$eresult=mysql_query("SELECT  room_no FROM bookings WHERE bill_id = '$drow[bill_id]' group by room_no  ORDER BY room_no ASC");

$erow=mysql_fetch_array($eresult);

	   do{

		  ?>
                         <?php echo $erow[room_no];?>,
                         <?php 

		    

		   

	   }while($erow=mysql_fetch_array($eresult));

		?></td>
                       <td width="12%" align="center" class="link"><?php 







			 echo dtformat($drow[cdate]);







			?></td>
                       <td width="10%" align="center" class="link"><?php 



 



			 echo $drow[total_payeble];







			 $total=$total+$drow[total_payeble];







			?></td>
                       <td width="10%" align="center" class="link"><?php 







			 echo number_format($drow[all_payment_total]);







			?></td>
                       <td width="11%" align="center" class="link"><?php 







			 echo number_format($drow[last_due]);





$due=$due+$drow[last_due];

			?></td>
                       <td width="22%" align="center" class="link"><?php  echo $drow[pay_methode];?></td>
                       <td width="6%" align="center" class="link"><?php  
			  
$eresult=mysql_query("SELECT  userid FROM user WHERE id = '$drow[suser]'  limit 1");
$erow=mysql_fetch_array($eresult);
				
			  echo $erow[userid];
				?></td>
                       <td width="6%" align="center" class="link"><?php if($drow[last_due]>'0'){?>
                         <a href="hotel_new_due_payment.php?id=<?php  echo $drow[bill_id];?>">Pay Due</a>
                         <?php }?></td>
                     </tr>
                     <?php 







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







		 







		  ?>
                     <tr>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link"><strong>Total :</strong></td>
                       <td align="center"  class="link"><strong><?php echo $total; ?></strong></td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link"><strong><?php echo $due; ?></strong></td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link">&nbsp;</td>
                     </tr>
                   </table>
                   
                   <?php }?>
                   
                 </td>
                 <td width="50%" valign="top" class="round_box">Reference<?php 







		    


		  if($ds!=""){



		  $ds=dtformat($ds);


		  $de=dtformat($de);

		  $d="and cdate>='$ds' and cdate<='$de' ";}else{$d="";}




		  $dresult=mysql_query("select * from bill WHERE refr_id!='0' and refr_id='$refr_id'  $d order by id desc");
 
          $drow=mysql_fetch_array($dresult);

if($drow!=""){ 

					 ?>
                   
                   <table width="100%" border="0" cellpadding="3" cellspacing="1" class="list_table">
                     <tr>
                       <th align="center" >Reservations No</th>
                       <th align="center" >Room No</th>
                       <th align="center" >Date</th>
                       <th align="center" >Total Payeble</th>
                       <th align="center" >Payment</th>
                       <th align="center" >Due</th>
                       <th align="center" >P.Method </th>
                       <th align="center" >User</th>
                       <th align="center" >Pay Due</th>
                     </tr>
                     <?php 





		  $total=0;







		  do{







		  ?>
                     <tr>
                       <td width="11%" align="center" class="link"><a href="javascript:void(0);" onclick="popUp('show_bill.php?id=<?php echo $drow[bill_id]; ?>')"><?php echo $drow[bill_id]; ?></a></td>
                       <td width="12%" align="center" class="link"><?php 	

	 

		$eresult=mysql_query("SELECT  room_no FROM bookings WHERE bill_id = '$drow[bill_id]' group by room_no  ORDER BY room_no ASC");

$erow=mysql_fetch_array($eresult);

	   do{

		  ?>
                         <?php echo $erow[room_no];?>,
                         <?php 

		    

		   

	   }while($erow=mysql_fetch_array($eresult));

		?></td>
                       <td width="12%" align="center" class="link"><?php 







			 echo dtformat($drow[cdate]);







			?></td>
                       <td width="10%" align="center" class="link"><?php 



 



			 echo $drow[total_payeble];







			 $total=$total+$drow[total_payeble];







			?></td>
                       <td width="10%" align="center" class="link"><?php 







			 echo number_format($drow[all_payment_total]);







			?></td>
                       <td width="11%" align="center" class="link"><?php 







			 echo number_format($drow[last_due]);





$due=$due+$drow[last_due];

			?></td>
                       <td width="22%" align="center" class="link"><?php  echo $drow[pay_methode];?></td>
                       <td width="6%" align="center" class="link"><?php  
			  
$eresult=mysql_query("SELECT  userid FROM user WHERE id = '$drow[suser]'  limit 1");
$erow=mysql_fetch_array($eresult);
				
			  echo $erow[userid];
				?></td>
                       <td width="6%" align="center" class="link"><?php if($drow[last_due]>'0'){?>
                         <a href="hotel_new_due_payment.php?id=<?php  echo $drow[bill_id];?>">Pay Due</a>
                         <?php }?></td>
                     </tr>
                     <?php 







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







		 







		  ?>
                     <tr>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link"><strong>Total :</strong></td>
                       <td align="center"  class="link"><strong><?php echo $total; ?></strong></td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link"><strong><?php echo $due; ?></strong></td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link">&nbsp;</td>
                       <td align="center"  class="link">&nbsp;</td>
                     </tr>
                   </table>
                 <?php }?></td>
                 <td width="1%">&nbsp;</td>
               </tr>
             </tbody>
           </table></td>
         </tr>
         <tr>
            <td height="28" align="center">&nbsp;</td>
         </tr>
         <tr>
            <td height="28"><?php include("bot.php");
?></td>
         </tr>
      </table>
   </body>
</html>
<?php }?>