<?php 
include "includes/header.php"; 
include "includes/Mdme-functions.php";
$mdme = getMdmePurchaseEntry($db,'');
include_once "includes/pagepermission.php";
//check permission - START
if(!($res_modm_prm)){
	header("Location:".admin_public_url."error.php");
}
else if(trim($res_modm_prm['ViewPrm'])=="0") {
	header("Location:".admin_public_url."error.php");
}
//check permission - END
?> 


<div class="wrapper">
    <div class="container">
        <!-- Page-Title - START -->
        <div class="row">
            <div class="col-sm-12">   
				<div class="btn-group pull-right m-t-15">									
					<?php if(trim($res_modm_prm['AddPrm'])=="1") { ?>
						<a href="purchase_form.php" class="btn btn-custom waves-effect waves-light"> Add Purchase <span class="m-l-5"><i class="fa fa-plus"></i></span> </a>
					<?php } ?>
                </div>
						
                <h4 class="page-title">Manage Purchase</h4>
				<input type="hidden" name="disptblname" id="disptblname" value="<?php echo "purchase"; ?>" />
				<input type="hidden" name="rmv_sort_clm" id="rmv_sort_clm" value="<?php echo "0"; ?>" />
            </div>
        </div>
		<!-- Page-Title - END -->	
			
		
		<div class="row">
            <div class="col-sm-12">
                <div class="card-box table-responsive">                         
                    <table id="tblresult" class="table table-striped table-bordered">
                        <thead>
                            <tr>
								<th>S.No</th>
								<th>Invoice No</th>
								<th>Invoice Date</th>
								<th>Company Name</th>
								<th>Supplier</th>								
								<th>Final Purchase Amt</th>	
								<th>Product Cnt</th>		
								<th>Status</th>
								<th>Actions</th>
                            </tr>
                        </thead>                       
                    </table>
                </div>
            </div>
        </div> <!-- end row -->		

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

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


<script>
$(function () {   		
	datatblCal();		
});
$(document).ready(function(){
  $(document).ajaxComplete(function() {                 
               
		$(".hoverToolTip").popover({ trigger: "manual" , html: true, animation:false, placement: "bottom",title: purchaseDetails})
			    .on("click", function () {
			        var _this = this;
			        $(this).popover("show");
			        $(".popover").on("mouseleave", function () {
			            $(_this).popover('hide');
			        });
			    }).on("mouseleave", function () {
			        var _this = this;
			        setTimeout(function () {
			            if (!$(".popover:hover").length) {
			                $(_this).popover("hide");
			            }
			        }, 300);
			});				  
   }); // Add tooltip
  
});

function purchaseDetails(){	
  var id = this.id;
  
  var tooltipText = "";
  $.ajax({
   url: 'ajax_actions.php',
   type: 'post',
   async: false,
   data: {product_sku:id},
   data: 'action=get_product_det_by_purchase&pdt_inv_no='+id,
   success: function(response){
     tooltipText = response;
   }
  });
  return tooltipText;
}
</script>	
<style type="text/css">
.popover{
    max-width:500px;
    height:250px;    
    overflow-y:auto;
}
</style>
</body>
</html>
