<?php session_start();
if(empty($_SESSION['id'])):
header('Location:../index.php');
endif;
if(empty($_SESSION['branch'])):
header('Location:../index.php');
endif;
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Receipt | <?php include('../dist/includes/title.php');?></title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../plugins/datatables/dataTables.bootstrap.css">
    <link rel="stylesheet" href="../dist/css/AdminLTE.min.css">
    <link rel="stylesheet" href="../plugins/select2/select2.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="../dist/css/skins/_all-skins.min.css">
    
    <style type="text/css">
      tr td{
        padding-top:-10px!important;
        border: 1px solid #000;
      }
      @media print {
          .btn-print {
            display:none !important;
          }
      }
    </style>
 </head>
  <!-- ADD THE CLASS layout-top-nav TO REMOVE THE SIDEBAR. -->
  <body class="hold-transition skin-blue layout-top-nav">
    <div class="wrapper" style="margin-left:-200px;">
      
      <!-- Full Width Column -->
      <div class="content-wrapper">
        <div class="container">

          <section class="content">
            <div class="row" >
	      <div class="col-md-12">
             
                
                <div class="box-body">

                  <!-- Date range -->
                  <form method="post" action="">
<?php
include('../dist/includes/dbcon.php');
$id=$_SESSION['id'];        
?>			              
<?php

    $branch=$_SESSION['branch'];
	$sales_id=$_REQUEST['sales_id'];
    $query=mysqli_query($con,"select * from sales where sales_id='$sales_id'")or die(mysqli_error($con));
        $row=mysqli_fetch_array($query);
        $branch=$row['branch_id'];
        $sales_id=$row['sales_id'];
		$cust_id=$row['cust_id'];
		$delivery=$row['delivery'];
		  $queryb=mysqli_query($con,"select * from branch where branch_id='$branch'")or die(mysqli_error());
  
        $rowb=mysqli_fetch_array($queryb);
		
		 $queryk=mysqli_query($con,"select * from customer where cust_id='$cust_id'")or die(mysqli_error($con));
        $rowk=mysqli_fetch_array($queryk);
		
		
        $last=$rowk['cust_last'];
        $first=$rowk['cust_first'];
        $address=$rowk['cust_address'];
        $contact=$rowk['cust_contact'];
        $sid=$row['sales_id'];
        $due=$row['amount_due'];
       $discount=$row['discko'];
		$discounttotal=$row['discount'];
        $grandtotal=$due-$discount;
        $tendered=$row['cash_tendered'];
        $change=$row['cash_change'];

        $query1=mysqli_query($con,"select * from payment where sales_id='$sales_id'")or die(mysqli_error($con));
      
        $row1=mysqli_fetch_array($query1);

?>    
         
		 
		 
		 

                   <table class="table">
                    <thead>
					
					 <tr>
            
				  <th colspan="5"><p style="font-size:24px;">CITIBUILDERS AND SUPPLY </p>
				  <p>0168 PUROK 1 DIVERSION RD. BRGY KINAMALIGAN MASBATE CITY </p>
				   <p>TM: 0967-937-2550 / SMART 0919-839-4967 </p>
				    <p>Email Address: citibuilders42@yahoo.com </p>
				   </th>
				   <th></th>
				     <th></th>
					  
				    <th colspan="2"> <img src="logo.jpg" alt="logo" style="min-width:300px;height:130px;border-radius:90%;"/>
                            
				  </th>
                      </tr>
					
                      <tr>
                        <th colspan="4"><h3><b><?php echo $rowb['branch_name'];?></b></h3></th>
						<th></th>
				       <th></th>
					     <th></th>
					   <th></th>
					
                        <th style="min-width:400px;"><h2><u>QUOTATION SLIP</u></h2></th>
                      </tr>
                      <tr>
                        <th colspan="4"><h5>Delivery/Payment Type:<?php echo $delivery ?? null; ?> &nbsp <?php echo $cashnote ?? null; ?></h5></th>
					   <th></th>
					   <th></th>
					   <th></th>
					    <th></th>
                        <th><span style="font-size: 25px;color: red">Receipt#. SN00<?php echo $sales_id;?></span></th>
                      </tr>
                      <tr>
                        <th colspan="3"><h5>Contact #: <?php echo $rowb['branch_contact'];?></h5></th>
                        <th></th>
						 <th></th>
						  <th></th>
						   <th></th>
						    <th></th>
						  <th></th>
						   <th></th>
                      </tr>
                      
                    </thead>
                    <thead>

                      <tr>
                        <th>CUSTOMER:</th>
                        <th colspan="4" style="font-weight: bold;width:600px;font-family: Arial, Helvetica, sans-serif;font-size:16px;margin:0;padding:0;" ><u><?php echo $last.", ".$first;?></u></th>
						
                        <th colspan="3" >Trans Date:</th>
                        <th style="font-weight: bold;font-family: Arial, Helvetica, sans-serif;font-size:14px;margin:0;padding:0;"><u><?php echo date("M d, Y");?> Time <?php echo date("h:i A");?></u></th>
                      </tr>
                      <tr>
                        <th>Address</th>
                        <th colspan="4"><u><?php echo $address;?></u></th>
						
                        <th colspan="3"style="width:300px;" >Pickup Date:</th>
                        <th>________________________</th>
                      </tr>
                      <tr>
                        <th>Contact #:</th>
                        <th colspan="4">________________________</th>
						
                        <th colspan="3" >Delivery Date:</th>
                        <th>________________________</th>
                      </tr>
                    </thead>
                  </table>
                  <table class="table">
                    <thead>
                        
                      <tr >
                        <th style="border: solid 2px #000">QTY</th>
                        <th style="border: solid 2px #000">UNIT</th>
                        <th style="border: solid 2px #000">DESCRIPTION</th>
						<th style="border: solid 2px #000"><?php if($branch == 1){ ?> H PIC <?php }else{ ?> M PIC /LENGTH<?php } ?></th>
            						<th style="border: solid 2px #000"><?php if($branch == 1){ ?> W PRICE <?php }else{ ?> THICK/UNIT PRICE <?php } ?></th>
									
									<th style="border: solid 2px #000"><?php if($branch == 1){ ?> VARIATION/GLASS COLOR <?php }else{ ?> COLOR <?php } ?></th>
            						<th style="border: solid 2px #000" class="text-right">AMOUNT</th>
                      </tr>
                    </thead>
                    <tbody>
<?php
		$query=mysqli_query($con,"select * from sales_details natural join product where sales_id='$sid'")or die(mysqli_error($con));
			$grand=0;
		while($row=mysqli_fetch_array($query)){
				//$id=$row['temp_trans_id'];
				$total= $row['qty']*$row['price'];
				$grand=$due;
        
?>
                      <tr>
            			<td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:center;font-weight:bold;" ><?php echo $row['qty'];?></td>
                        <td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:center;font-weight:bold;" > <?php if($row['branch'] == 1){ ?> PCS <?php }else if($row['branch'] == 2){ ?> SHEETS <?php }else{ ?>STEEL <?php } ?></td>
                        <td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:center;font-weight:bold;"  class="record"><?php echo $row['prod_name'];?></td>
						<td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:center;font-weight:bold;" ><img style="width:50px;height:30px" src="../dist/uploads/<?php echo $row['prod_pic'];?>"><?php if($row['hh'] == 1 ){ } else { echo $row['hh'];?> M <?php } ?></td>
						
            						
									<td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:center;font-weight:bold;" >     <?php if($branch == 1){ ?> <?php echo number_format($row['ww'],2);?> <?php }else{ ?>  <?php echo $row['thick'];?>/<?php echo number_format($row['ww'],2);?>  <?php } ?>    </td>
									<td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:center;font-weight:bold;" >   <?php if($branch == 1){ ?> <?php echo $row['variation'];?>/<?php echo $row['color'];?> <?php }else{ ?> <?php echo $row['color'];?> <?php } ?>       </td>
            						<td style="border: solid 2px #000;font-size:20px;padding:0;margin:0;text-align:right;font-weight:bold;" ><?php echo number_format($total,2);?></td>
                                    
                      </tr>
					  

<?php }?>	

</tbody>
</table>

 <table style="margin-top:-20px;">

<?php
    $query=mysqli_query($con,"select * from user where user_id='$id'")or die(mysqli_error($con));
    $row=mysqli_fetch_array($query);
	
	
	
	$dodo=$discount/100;
	$dodokoko=$dodo * $grand;
	
	
	
	
	$cashchange=$grand-$dodokoko;
	
	$changenew=$cashchange - $tendered;
	
	
 
?>     
  <?php 
						 $query1=mysqli_query($con,"SELECT * FROM customer where cust_id=''")or die(mysqli_error($con));
			$row1=mysqli_fetch_array($query1);
						 ?>
<tr>
                        <th colspan="5" ><div style="margin-top:-10px;width:80%;text-align:justify;font-size:16px;">PAYMENT: <?php echo number_format($tendered,2);?> &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp BALANCE: <?php echo $rowk['balance'];?>   </th>
                      
                      
                        <td  style="font-size:16px;padding:0;width:150px;text-align:right;font-weight:bold;"  class="text-right">SUBTOTAL</td>
                        <td   style="border: solid 2px #000;font-size:18px;padding:0;width:87px;margin:0;text-align:right;font-weight:bold;"><?php echo number_format($due,2);?></td>
                      </tr>
				<h4 style="marggin-top:-20px;"></h4>
                      <tr>
                        <th colspan="5" ><div style="margin-top:1px;width:90%;text-align:justify;"> <p>In case of any revision such as hold, changes in size/color or other special instructions after confirmation of this quotation, JO revisions form has to be signed and acknowledge to confirm the validity. It is important that the</p> </div>
			            </th>
                     <td style="font-size:16px;padding:0;margin:0;text-align:right;font-weight:bold;" class="text-right">DISCOUNT <?php echo $discount;?>%</td>
                        <td  style="border: solid 2px #000;font-size:18px;padding:0;margin:0;text-align:right;font-weight:bold;" ><?php echo $discounttotal; ?></td>
                      </tr>
                      <tr>
                       <th colspan="5"> <p> customer keep copy of the JO revision form which is sign by our company representative and your office. </p></th>
                          <td style="font-size:16px;padding:0;margin:0;text-align:right;font-weight:bold;" class="text-right"><b>AMOUNT DUE</b></td>
                        <td style="border: solid 2px #000;font-size:18px;padding:0;margin:0;text-align:right;font-weight:bold;"><b><?php echo number_format($grand-$dodokoko,2);?></b></td>
                      </tr>
                      <tr>
                      <th>Prepared By: <br><?php echo $row['name'];?></th>
                      <th> </th>
					  <th> </th>
					  <th></th>
                      <th>______________________________</th>
                      <td style="font-size:16px;padding:0;margin:0;text-align:right;font-weight:bold;"class="text-right">DOWNPAYMENT</td>
                      <td style="border: solid 2px #000;font-size:18px;padding:0;margin:0;text-align:right;font-weight:bold;"><?php echo number_format($tendered,2);?></td>
                      </tr>
                      <tr>
                       <th><p>Important:</p></th>
                       <th></th>
                      <th></th>
					  <th></th>
                        <th>Check By:</th>
                           <td style="font-size:16px;padding:0;margin:0;text-align:right;font-weight:bold;"class="text-right"><b>BALANCE</b></td>
                        <td style="border: solid 2px #000;font-size:18px;padding:0;margin:0;text-align:right;font-weight:bold;"><b><?php echo number_format($changenew,2);?></b></td>
                      </tr>
                      <tr>
					  <th>
						 
					  <div style="margin-top:-5px;width:400px;text-align:justify;">
						  
						  <p>Items orders shall be claimed 30 days by the dated of down payment has been made otherwise roof ordered will be authomatically for disposal without need further notice due to quality and stoarge concerned. Further, PAYMENT made will be authomatically forpeted </p>
						 </div>   </th>
                      <th></th>
					  <th></th>
					  <th></th>
					 <th> <p>______________________________</p>Delivered by:</th>

                      </tr> 
					
	 <div style="margin-left:800px;margin-top:220px;width:300px;position:fixed">
						  
						  
				
						<center>  <p>_____________________________________</p>
						  <p style="font-weight:bold;">Customer Signature over printed name</p>  </center>
						  </div>
						  
				

						  
                    </tbody>
                    
                  </table>
				  
				
						  <h5 style="font-weight:bold;color:#DAA520	">BANK NAME: METROBANK  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp     &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp   &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp GCASH</h5>
						  <h5 style="font-weight:bold; color:#DAA520	">ACCOUNT # 369-7369-010-766  &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp     &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ACCOUNT NAME: ERROL JOHNSON SIA</h5>
						   <h5 style="font-weight:bold; color:#DAA520	">ACCOUNT NAME:  CITIBUILDERS AND SUPPLY  &nbsp &nbsp &nbsp &nbsp  &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp     &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp ACCOUNT NO: 0947-243-9867</h5>
			  	




				<h6 style="font-weight:bold; color:#DAA520	">Note: Items Delivery are subject for availability of transport delivery vehicle, if delivery transport are not available clients must aggree to pick their purchased items.</h6>
			  	
                </div><!-- /.box-body -->
				</div>  
				</form>	
                </div><!-- /.box-body -->
                <a class = "btn btn-success btn-print" href = "" onclick = "window.print()"><i class ="glyphicon glyphicon-print"></i> Print</a>
                <a class = "btn btn-primary btn-print" href = "home.php"><i class ="glyphicon glyphicon-arrow-left"></i> Back to Homepage</a>
              </div><!-- /.box -->
            </div><!-- /.col (right) -->
           
          </div><!-- /.row -->
	  
             
          </section><!-- /.content -->
        </div><!-- /.container -->
      </div><!-- /.content-wrapper -->
     
    </div><!-- ./wrapper -->
	
	
	<script type="text/javascript" src="autosum.js"></script>
    <!-- jQuery 2.1.4 -->
    <script src="../plugins/jQuery/jQuery-2.1.4.min.js"></script>
	<script src="../dist/js/jquery.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="../bootstrap/js/bootstrap.min.js"></script>
    <script src="../plugins/select2/select2.full.min.js"></script>
    <!-- SlimScroll -->
    <script src="../plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="../plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="../dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../dist/js/demo.js"></script>
    <script src="../plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../plugins/datatables/dataTables.bootstrap.min.js"></script>
   
  </body>
</html>
