<?php session_start();





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




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




}else{




include("config.php");





$dresult=mysql_query("select * from restaurant_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);

 
	
$adresult=mysql_query("select bill_id from bill WHERE customer_id='$drow[client_id]' order by cdate desc limit 1");
	$adrow=mysql_fetch_array($adresult);

	

	    $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";}



	



?>



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



<html lang="en">



<head>



<meta charset="UTF-8">



<title>Invoice - ARNIM RESORT</title>



<style>



    body {



        font-family: 'Segoe UI', Arial, sans-serif;



        margin: 0;



        padding: 0;



        background: #e9eef3;



    }







	



.invoice-container::before {



    content: "<?php echo $watermark;?>";



    position: absolute;



    left: 50%;



    top: 50%;



    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;



  }



	



	



    .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);



    }







    .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;



    }







    table {



        width: 100%;



        border-collapse: collapse;



        margin-top: 12px;



        font-size: 15px;



    }







    table, th, td {



        border: 1px solid #000;



    }







    th {



        padding: 5px;



        text-align: center;



        background: #f0f0f0;



        font-weight: 600;



        letter-spacing: 0.5px;



    }







    td {



        padding: 5px;



    }



.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;



    }







    



	



	



	@media print {



  body {



    background: #fff !important;



  }







  .invoice-container {



    border: 2px solid #000 !important;



    box-shadow: none !important;



    -webkit-print-color-adjust: exact;



    print-color-adjust: exact;



  }







  table, th, td, .section, .heading, .footer, div {



    border-color: #000 !important;



  }







  * {



    color-adjust: exact !important;



  }



}

.style2 {text-align: right}

</style>



</head>



<body>







<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>
        </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 mydate1($drow[cdate]);?><br />
RSV No : <?php echo $drow[hbill_id];?>
    </div>
</div>
     

    <div class="section">
        <strong>Item Details:</strong>
        <table class="bangla">
            <tr>
                <th width="6%">SL</th>
                <th width="67%">Item</th>
                <th width="10%">Price</th>
                <th width="7%">Qty</th>
                <th width="10%">Total</th>
            </tr>

<?php 

	
	
$fresult=mysql_query("SELECT cp . * , pd . *
FROM restaurant_chalan_product cp
JOIN restaurant_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[product_item];?></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 width="74%" class="right">Subtotal:</td>
          <td width="26%" 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 restaurant_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>
        <?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><strong>
 <?php if($drow[remarks]!=""){echo 'Note: ';}echo $drow[remarks];?></strong>
<div class="footer">
        Thank you for choosing Arnim Resort Restaurant.</div>

</div>







</body>



</html>



<?php }?>



