<?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 Holidays Accounting Software</title>



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

 


<SCRIPT LANGUAGE="JavaScript">







<!-- Begin



function popUp(URL) {

day = new Date();
id = day.getTime();



eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=yes,width=950,height=650,left = 100,top = 100');");



}



// End -->



</script>



<?php 		
	$dresult=mysql_query("select * from chalan WHERE id='$_GET[cid]'");
	$drow=mysql_fetch_array($dresult);

 
 	  
	
		  $eresult=mysql_query("select * from customer WHERE id='$drow[client_id]' limit 1");
          $erow=mysql_fetch_array($eresult);
	
	   $watermark_font="12";
		$watermark="Paid";
	if($drow[last_due] == "0"){$watermark="PAID"; $watermark_font="14";}
	if($drow[last_due]>"0"){$watermark="UNPAID";}
	if($drow[total_payeble] == "0"){$watermark="CANCELLED"; $watermark_font="9";}
	
	
			?>
<style type="text/css">

<!--

.style2 {color: #DC147B;

	font-weight: bold;

}

.style3 {color: #000000}

-->
    body {
        font-family: 'Segoe UI', Arial, sans-serif;
        
    }

    .invoice-container {
        width: 820px;
        margin: 40px auto;
        background: #ffffff;
        padding: 40px 45px;
        border: 2px solid #000;
        box-shadow: 0 0 12px rgba(0,0,0,0.15);
    }
.invoice-container::before {
    content: "<?php echo $watermark;?>";
    position: absolute;
    left: 50%;
    top: 80%;
    transform: translate(-50%, -50%) rotate(-28deg);
    font-size: <?php echo $watermark_font;?>.5rem;       /* very large */
    font-weight: 800;
    color: rgba(0, 0, 0, 0.06);
    letter-spacing: 8px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 0;
  }
	
    .logo {
        text-align: center;
        margin-bottom: 10px;
    }

    .logo img {
        
        height: auto;
    }

    .heading {
        text-align: center;
        font-size: 20px;
        font-weight: 700;
        letter-spacing: 2px;
        margin-bottom: 25px;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }

    .section-title {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 8px;
        color: #333;
        text-transform: uppercase;
    }

    .section {
        margin-bottom: 25px;
        padding-bottom: 10px;
        border-bottom: 1px dashed #aaa;
    }

    .section table {
        width: 100%;
        border-collapse: collapse;
        margin-top: 12px;
        font-size: 15px;
    }



    .invoice-container  th {
        padding: 12px;
        text-align: center;
        background: #f0f0f0;
        font-weight: 600;
        letter-spacing: 0.5px;
    }

    .invoice-container  td {
        padding: 12px;
    }
.bill td {
        padding: 8px;
    }
    .right {
        text-align: right;
        font-weight: 600;
    }

    .summary-table td:first-child {
        text-align: right;
        width: 70%;
    }

    .grand-total {
        background: #f6f6f6;
        font-size: 17px;
        font-weight: 700;
    }

    .footer {
        margin-top: 35px;
        text-align: center;
        font-size: 14px;
        padding-top: 15px;
        border-top: 1px solid #aaa;
    }

  .bangla td {
        border: 1px solid #000;
    }
  .bangla th {
        border: 1px solid #000;
    }	
	 .bill td {
        border: 1px solid #000;
    }
    .print-btn {
        background-color: #007bff;
        color: white;
        padding: 10px 18px;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        font-size: 16px;
        transition: 0.3s;
    }

    .print-btn:hover {
        background-color: #0056b3;
    }
</style>
</head>







<body>



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



  <tr>



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



  </tr>



  <tr>



    <td>&nbsp;</td>



  </tr>



  <tr>



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


<tr>







        <td valign="top"><br />







          <form id="form1" name="form1" method="get" action="">







            <table width="100%" border="0" cellpadding="3" cellspacing="1"  class="round_box">







              <tr>







                <td width="44%">&nbsp;</td>







                <td width="21%" align="center"><strong>Search Bill </strong></td>







                <td width="35%">&nbsp;</td>
              </tr>



<?php 



if($_POST[ds]!=""){$ds=$_POST[ds];}



if($_POST[de]!=""){$de=$_POST[de];}







if($_GET[ds]!=""){$ds=$_GET[ds];}



if($_GET[de]!=""){$de=$_GET[de];}







if($ds == ""){







$dddez = strtotime("-60 day");



$ds=date('d-m-Y', $dddez);







}



if($de == ""){$de=date("d-m-Y");}







 ?>



              <tr>







                <td colspan="3"><table width="1130" border="0" cellspacing="1" cellpadding="2">

                  <tbody>

                    <tr>

                      <td width="821" align="right">Enter Invoice No</td>

                      <td width="9">:</td>

                      <td width="184"><input type="text" name="cid" id="cid" /></td>

                      <td width="95"><input type="submit" name="Submit" value="Search" /></td>
                    </tr>
                  </tbody>

                </table></td>
                </tr>



              <tr>

                

                

                

                <td>&nbsp;</td>

                

                

                

                <td colspan="2">&nbsp;</td>
              </tr>
            </table>







            </form>







          </td>







      </tr>



      <tr>



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



      </tr>



      <tr>



        <td class="round_box">
		
		<?php if($drow!=""){?>
		
			<div align="center"> 
			
			<button class="print-btn" onclick="popUp('chalan_print.php?cid=<?php echo $_GET[cid]; ?>');">🖨 Print</button>
			</div>
			
			

			<div class="invoice-container">

<div class="section" style="display:flex; justify-content:space-between; align-items:flex-start;">
    <div class="logo"><img src="images/wlogo.png" alt="Hotel Logo" /></div>
<?php 


	$xbresult=mysql_query("select * from company WHERE id='$drow[com_id]'");
	$xbrow=mysql_fetch_array($xbresult);

 
	?> 
   <div><strong>--------</strong>|<strong> <?php echo $xbrow[company];?></strong> |<strong>-------<br>
      Address :</strong> <?php echo $xbrow[address];?><br>
      <strong>Phone :</strong> <?php echo $xbrow[mobile];?><br>
      <strong>E-mail : </strong><?php echo $xbrow[email];?>, <strong>Web:</strong> <?php echo $xbrow[web];?><br>
	  <strong>FB : </strong> <?php echo $xbrow[phone];?></div>
</div>
	
   
 	 
    <div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:15px; border-bottom:2px solid #000; padding-bottom:10px;">
    <div class="heading" style="margin:0; border:none; padding:0;">RESTAURANT INVOICE</div>
  </div>

    <div class="section" style="display:flex; justify-content:space-between; align-items:flex-start;">
    <div> <strong>Customer Information:</strong><br>
        Name: <?php echo $erow[customer_name];?>- <?php echo $erow[contact_person];?><br>
        Phone: <?php echo $erow[personal_phn];?><br>
        Email: <?php echo $erow[personal_email];?></div>

    <div style="text-align:right; font-size:15px; line-height:1.5;">
        <strong>Invoice No:</strong> <?php echo $drow[id];?><br>
        <strong>Date:</strong> <?php echo mydate2($drow[cdate]);?>
    </div>
</div>
     

    <div class="section">
        <strong>Booking Details:</strong>
        <table class="bangla">
            <tr>
                <th width="8%">SL</th>
                <th width="49%">Item</th>
                <th width="14%">Price</th>
                <th width="12%">Qty</th>
                <th width="17%">Total</th>
            </tr>

<?php 

	
	
$fresult=mysql_query("SELECT cp . * , pd . *
FROM chalan_product cp
JOIN product_details pd ON pd.id = cp.product_type
WHERE cp.cid = '$_GET[cid]'");
	
$frow=mysql_fetch_array($fresult);	
	if($frow!=""){
	do{
	$sr1=$sr1+1;
	
?>

<tr>
    <td><?php echo $sr1;?></td>
    <td bgcolor="#FFFFFF" ><?php echo $frow[pname];?></td>
              <td bgcolor="#FFFFFF" ><?php echo $frow[unit_price];?></td>
              <td bgcolor="#FFFFFF" ><?php echo $frow[qty];?></td>
              <td align="right" bgcolor="#FFFFFF" ><?php echo number_format($frow[total_prize]); 
							$total=$total+$frow[total_prize];    ?></td>
</tr>
<?php }while($frow=mysql_fetch_array($fresult)); }?>
   </table>
    </div>

    <div class="section">
      <table class="bill">
        <tr>
          <td class="right">Subtotal:</td>
          <td class="right"><?php echo number_format($total); ?> BDT</td>
        </tr>
        <?php if($drow[discount]>'0'){?>
        <tr>
          <td class="right">Discount:</td>
          <td class="right"><?php echo number_format($drow[discount]); ?> BDT</td>
        </tr>
        <?php }?>
        <?php if($drow[vat_amount]>'0'){?>
        <tr>
          <td class="right">VAT (<?php echo number_format($drow[vat]); ?>%):</td>
          <td class="right"><?php echo number_format($drow[vat_amount]); ?> BDT</td>
        </tr>
        <?php }?>
        <tr>
          <td class="right"><strong>Grand Total:</strong></td>
          <td class="right"><strong>
            <?php $gtotal=($total-$drow[discount])+$drow[vat_amount]; echo number_format($gtotal);?>
            BDT</strong></td>
        </tr>
<?php 
$due=$gtotal-$drow[payment];
if($drow[payment]>"0"){ 
		  ?>
        <tr>
          <td class="right"><?php echo mydate2($drow[cdate]);?> Payment (<?php echo $drow[pay_methode];?>):</td>
          <td class="right"><?php $due=$gtotal-$drow[payment]; echo number_format($drow[payment]);?>
            BDT</td>
        </tr>
        <?php 
		}
				   
$xresult=mysql_query("SELECT  * FROM chalan_payment WHERE bill_id = '$drow[id]' ORDER BY cdate ASC");
$xrow=mysql_fetch_array($xresult);
if($xrow!=""){
do{
			?>
        <tr>
          <td class="right"><?php echo mydate2($xrow[cdate]);?> Payment (<?php echo $xrow[pay_methode];?>  )</td>
          <td class="right"><?php echo number_format($xrow[payment_amount]); $due=$due-$xrow[payment_amount];?> BDT</td>
        </tr>
        <?php
}while($xrow=mysql_fetch_array($xresult));
}?>
       
		
<?php if($due>'0'){?>

			<tr>

                <td bgcolor="#E0ECED" class="right">Due</td>

                <td bgcolor="#E0ECED" class="right"><strong><?php echo number_format($due);?> BDT</strong></td>

            </tr>

			<tr>

			  <td colspan="2" class="right">

				  

				<form action="resturent_payment_insert.php" method="post" enctype="multipart/form-data" name="enquiryform" id="enquiryform" >

						  

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

			    <tbody>

			      <tr>

			        <td width="31%">Payment Date</td>

			        <td width="26%">Pay Methode</td>

			        <td width="30%">Payment Amount</td>

			        <td width="13%">&nbsp;</td>

			        </tr>

			      <tr>

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

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

			        <td><select name="pay_methode" id="pay_methode">
					<option value="" selected="selected">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>         <input name="bill_id" type="hidden" id="bill_id" value="<?php echo $drow[id];?>" />			        </td>

			        <td><span class="input200">

			      
					  <input name="payment_amount"  id="payment_amount" 
  type="number" min="1" max="<?php echo $due; ?>" value="0" oninput="if(this.value < 0) this.value =0; if(this.value > <?php echo $due; ?>) this.value = <?php echo $due; ?>;"  onfocus="javascript:if(this.value=='0')this.value=''" onblur="javascript:if(this.value=='')this.value='1'"/>


			        </span></td>

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

			        </tr>

			      </tbody>

			    </table></form></td>

			  </tr>

			<?php }?>
      </table>
    </div>

    
		 <div class="section" style="display:flex; justify-content:space-between; align-items:flex-start;">
    <div style="margin-top:20px; text-align:left;">
        <strong>Guest Signature:</strong><br><br>
        <div style="width:250px; height:60px; border:1px solid #000;"></div>
    </div>
			 
			 <div style="margin-top:20px; text-align:right;">
        <span style="display:inline-block; padding:10px 25px; border:2px solid #000; font-size:20px; font-weight:700; letter-spacing:2px;">
			<?php echo $watermark;?></span>
    </div>
</div>
 <?php if($drow[unote]!=""){echo 'Note: ';}echo $drow[unote];?>
<div class="footer">
        Thank you for choosing ARNIM Resort Restaurant.</div>

</div>
<?php }else{?>

		   

		   <div align="center">No Bill Found</div><?php }?>
</td>



      </tr>



    </table></td>



  </tr>



  <tr>



    <td><?php include("bot.php")?></td>



  </tr>



</table>



</body>



</html>



<?php }?>