<?php 
include "includes/header.php"; 

if(isset($_REQUEST['p_invoice_id']) && !empty($_REQUEST['p_invoice_id']) ){
	$p_invoice_id = base64_decode($_REQUEST['p_invoice_id']);
	//$p_invoice_id = $_REQUEST['p_invoice_id'];
	
	$rslt_main_det = $db->get_a_line(" select t1.*,DATE_FORMAT(t1.p_invoice_date,'%d-%b-%Y') AS disp_inv_date, t2.company_name, t2.c_address, t2.c_city, t2.c_state, t2.c_country, t2.c_landline, t2.c_mobile, t3.sup_name, t3.sup_address, t3.sup_city, t3.sup_state, t3.sup_country from t_purchase_entry_main t1 inner join m_company t2 on t1.company_id=t2.company_id inner join m_supplier t3 on t1.sup_id = t3.sup_id  where 1=1 and t1.IsActive=1 and t1.p_invoice_no='".$p_invoice_id."' ");
	
	$rslt_pdt_det =$db->get_rsltset("select * from t_purchase_entry_details where 1=1 and IsActive=1 and p_invoice_no='".$p_invoice_id."'  ");
	
	
}
?> 

<div class="wrapper">
    <div class="container">
        <!-- Page-Title - START -->
        <div class="row">
            <div class="col-sm-12">  						
                <h4 class="page-title">Invoice </h4>
            </div>
        </div>
		<!-- Page-Title - END -->	
			
		
		
        <div class="row">
            <div class="col-xs-12">
                <div class="card-box">                           
					<div class="panel-body">
                        <div class="clearfix">
                            <div class="pull-left">
                                <h2 class="logo" style="color: #2b3d51 !important;">Logo</h2>
                            </div>
                            <div class="pull-right">
                                <h5>Invoice #<?php echo $rslt_main_det['p_invoice_no']; ?> <br>
                                    <small><?php echo $rslt_main_det['disp_inv_date']; ?></small>
                                </h5>
                            </div>
                        </div>
                        <hr>
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="pull-xs-left m-t-5">
                                    <address>
                                        <strong><?php echo $rslt_main_det['sup_name']; ?></strong><br>
                                            <?php echo $rslt_main_det['sup_address']; ?><br>
                                            <?php echo $rslt_main_det['sup_city']; ?><br>
											<?php echo $rslt_main_det['sup_state'].' '.$rslt_main_det['sup_country']; ?><br>
                                        <!--<abbr title="Phone">P:</abbr> (123) 456-7890-->
                                    </address>
                                </div>
                                <div class="pull-xs-right m-t-5">
                                    <address>
                                        <strong><?php echo $rslt_main_det['company_name']; ?></strong><br>
                                            <?php echo $rslt_main_det['c_address']; ?><br>
                                            <?php echo $rslt_main_det['c_city']; ?><br>
											<?php echo $rslt_main_det['c_state'].' '.$rslt_main_det['c_country']; ?><br>
											<abbr title="Phone">P:</abbr> <?php echo $rslt_main_det['c_landline'].','.$rslt_main_det['c_mobile']; ?>
                                    </address>
                                </div>
                            </div><!-- end col -->
                        </div>
                        <!-- end row -->

                        <div class="m-h-50"></div>

                        <div class="row">
                            <div class="col-xs-12">
                                <div class="table-responsive">
                                    <table class="table m-t-30">
                                        <thead class="bg-faded">
                                            <tr>
												<th>#</th>
                                                <th>Item</th>
                                                <th>Rate</th>
                                                <th>CGST (%)</th>
                                                <th>SGST (%)</th>
                                                <th>IGST (%)</th>
												<th>Tax Amount (Rs.)</th>
												<th>Total Amount (Rs.)</th>
                                            </tr>
										</thead>
                                        <tbody>
											<?php 
											$sn_no=1;
											foreach($rslt_pdt_det as $r){
											?>
											
											<tr>
                                                <td><?php echo $sn_no; ?></td>
                                                <td><?php echo $r['pdt_sku']; ?></td>
                                                <td><?php echo $r['rate']; ?></td>
                                                <td><?php echo $r['cgst_tax']; ?></td>
                                                <td><?php echo $r['sgst_tax']; ?></td>
                                                <td><?php echo $r['igst_tax']; ?></td>
												<td><?php echo $r['tax_amount']; ?></td>
                                                <td><?php echo $r['tot_amount']; ?></td>
                                            </tr>

											<?php	
											$sn_no= $sn_no+1;
											}
											?>                                           
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
						
                        <div class="row">
                            <div class="col-md-6 col-sm-6 col-xs-6">
                                <div class="clearfix m-t-30">
                                    <h5 class="small text-inverse font-600"><b>PAYMENT TERMS AND POLICIES</b></h5>

                                    <small>
                                        All accounts are to be paid within 7 days from receipt of
                                        invoice. To be paid by cheque or credit card or direct payment
                                        online. If account is not paid within 7 days the credits details
                                        supplied as confirmation of work undertaken will be charged the
                                        agreed quoted fee noted above.
                                    </small>
                                </div>
                            </div>
                            <div class="col-md-3 col-sm-6 col-xs-6 col-md-offset-3">
                                <p class="text-xs-right"><b>Sub-total:</b> <?php echo $rslt_main_det['total_amount']; ?></p>
                               <!-- <p class="text-xs-right">Discout: 12.9%</p>
                                <p class="text-xs-right">VAT: 12.9%</p>-->
                                <hr>
                                <h3 class="text-xs-right">Rs. <?php echo $rslt_main_det['total_amount']; ?></h3>
                            </div>
                        </div>
                        <hr>
                        <div class="hidden-print">
                            <div class="pull-xs-right">
                                <a href="javascript:window.print()" class="btn btn-dark waves-effect waves-light"><i class="fa fa-print"></i></a>
                                <!--<a href="#" class="btn btn-primary waves-effect waves-light">Submit</a>-->
                            </div>
                            <div class="clearfix"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!-- end row -->
				
			

<?php include "includes/footer.php";  ?> 
	</div> <!-- container -->
</div> <!-- End wrapper -->

<?php include "includes/footer_script.php";  ?> 


<script>
$(function () {   		
	//datatblCal();		
});
</script>	

</body>
</html>
