<?php 
session_start();
ob_start(); 
include "header.php";
//$objIms->Semifinisheditem_alter();
?>



<?php

if(isset($_GET["uid"]))
{
$uid=$_GET["uid"];
$rs=$objIms->getRows("view_purchase_supplier","md5(id)='$uid' and session_login_id = '".$_SESSION['login_id']."'");
$pur_id=$rs["id"];
$order_no=$rs["order_no"];
$purchase_date=$objIms->IntToDate($rs["purchase_date"]);
$supplier_name=$rs["supplier_name"];

}


	
?>

<!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>Untitled Document</title>

		
	
		 <style>
			select.error { background-color:#ffa8a8; border: 1px dotted red;  }
			input.error{ background-color:#ffa8a8;   }
			textarea.error{ background-color:#ffa8a8; border: 1px dotted red;  }
         </style>
		 
        


<style type="text/css">
<!--
.table_bg{ border:#CCCCCC solid 1px; border-radius:5px; height:auto; width:auto; padding:20px; margin-bottom:10px;}
.style2 {
	color: #00CC00;
	font-style: italic;
}
.style3 {color: #00CC00}


-->
</style>
</head>
<script type="text/javascript">
 
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>
<!-- Page wrapper  -->
        <div class="page-wrapper">
            <!-- Bread crumb -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-primary"></h3> </div>
                <div class="col-md-7 align-self-center">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                        <li class="breadcrumb-item active">Purchase Complete Report</li>
                    </ol>
                </div>
            </div>
            <!-- End Bread crumb -->
            <!-- Container fluid  -->
            <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
						<h4>Purchase Complete Report <span style="float:right"><button onclick="goBack()" class="btn btn-info btn-sm">Go Back</button><script>
function goBack() {
  window.history.back();
}
</script></span></h4>
							<hr />
<div id="printableArea">


     
            
		
            <?php 
				  $sql_viewtmp="SELECT * FROM `tbl_purchase_master` where session_login_id = '".$_SESSION['login_id']."'";
				$res_viewtmp=mysql_query($sql_viewtmp);
				if(mysql_num_rows($res_viewtmp)>0)
				{ 
					$i=1;
					$sums=0;
					?>
					<div class="panel">
					
					<p>&nbsp;</p>
                     <table width="100%" class="table table-bordered">
                     <tr height="32" align="left">
            <th nowrap="nowrap" width="6%">Si No</th>
            <th nowrap="nowrap" width="24%">Purchase Date </th>
            <th nowrap="nowrap" width="35%">Supplier Name</th>
           
            <th nowrap="nowrap" width="17%">Order No </th>
			<th nowrap="nowrap" width="17%"> Amount </th>
			
            <th nowrap="nowrap" width="18%">View</th>
            </tr>
            <?php
			$tot_amount=0;
				while($rows=mysql_fetch_assoc($res_viewtmp))
					{
						
						
						
						
							
							
			?>
           
            <tr height="32">
            <td nowrap="nowrap" width="6%"><?php echo $i++;?></td>
           
		    <td nowrap="nowrap" width="24%"><?php echo $objIms->IntToDate($rows["purchase_date"]);?></td>
		    <td nowrap="nowrap" width="35%"><?php $sql_viewtmp22="select * from tbl_supplier where id = '".$rows["supplier_id"]."' and session_login_id = '".$_SESSION['login_id']."'";
			$res_viewtmp22=mysql_query($sql_viewtmp22);
			$rows22=mysql_fetch_assoc($res_viewtmp22);
			
			 echo $rows22['supplier_name'];?></td>
            
            <td nowrap="nowrap" width="17%"><?php echo $rows["order_no"];?></td>
			
			<td>
			<?php
			$sql_cr="select Cr_Amt as total_cr from tbl_account where session_login_id = '".$_SESSION['login_id']."' and mas_id = '".$rows["id"]."' and sales_type = 'Purchase' order by id limit 1";
			$res_cr=mysql_query($sql_cr);
			$rows_cr=mysql_fetch_assoc($res_cr);
			if($rows_cr['total_cr']=='0'){
			$sql_cr="select Dr_Amt as total_cr from tbl_account where session_login_id = '".$_SESSION['login_id']."' and mas_id = '".$rows["id"]."' and sales_type = 'Purchase' order by id limit 1";
			$res_cr=mysql_query($sql_cr);
			$rows_cr=mysql_fetch_assoc($res_cr);
			}
			
			
			 echo $t_cr = round($rows_cr['total_cr'],2);
			 
			$tot_amount+=$t_cr;
			?>
			</td>
            <td nowrap="nowrap" width="18%"><a onclick="PopupCenter('purchasepopup_view.php?uid=<?php echo md5($rows["id"]);?>','xtf','1000','700');" style="cursor:pointer; text-decoration:none">View</a></td>
            </tr>   <?php }?>
			<tr>
			<?php
			
			?>
			<td colspan="4" align="right"><b>Total Amount</b></td><td><?php echo $total=$tot_amount;?></td>
			</tr>
			
			
			
           </table>
		   </div>
    <?php }
	?>
	
		

   


<div align="center"><span class="btn btn-info" onClick="printDiv('printableArea')">Print</span></div>
 </div>
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
            <!-- End Container fluid  -->
<?php include 'footer.php' ?>
 <script src="../js/lib/datatables/datatables.min.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/buttons.flash.min.js"></script>
    <script src="../js/lib/datatables/cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
    <script src="../js/lib/datatables/cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
    <script src="../js/lib/datatables/cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>
    <script src="../js/lib/datatables/datatables-init.js"></script>