<?php 
include "includes/header.php"; 
include "includes/Mdme-functions.php";
$mdme = getMdme_Rpt_Purchase_Payment_Pending($db,'');
include_once "includes/pagepermission.php";

include_once "common/dpselect-functions.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">  
				<h4 class="page-title">Payment Pending List</h4>
							
            </div>
        </div>
		<!-- Page-Title - END -->	
			
		<form class="form-horizontal" id="jvalidate" action="#" method="post" >
		<input type="hidden" name="action" id="action" value="<?php echo "rpt_pur_payment_pending"; ?>" />	
		<div class="row">
            <div class="col-sm-12">
                <div class="card-box">                         
                    <div class="row">
						
						<div class="col-md-3">
							<?php 
							echo getSelectBox_companylist($db, 'srch_sup_company', 'jsrequired');
							?>							
						</div>
						
						<div class="col-md-3">
							<?php 
							echo getSelectBox_supplierlist($db, 'srch_sup_supplier', 'jsrequired');
							?>							
						</div>
						
						<div class="col-md-1">
							<button onclick="fn_pu_payment_pending();" type="button" class="btn btn-warning pull-right">Search</button>
						</div>
						
					</div>
                </div>
            </div>
        </div>
		</form>
		
		
		<div class="row">
            <div class="col-sm-12">
                <div class="card-box table-responsive" id="dv_rpt_results">                         
                    
                </div>
            </div>
        </div> <!-- end row -->		

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

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


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


function search_result(){
	$("#dv_rpt_results").html('');	
	
	$.ajax({
		url        : 'bind_reports_html.php',
		method     : 'POST',
		dataType   : 'json',
		data       : $("#jvalidate").serialize(),
		beforeSend: function() { loading(); },
		success: function(response){ 	
			if(response.rslt == "1"){
				$("#dv_rpt_results").html(response.reports_rslt);
				
				//$("#dv_rpt_results_foot").html(response.rslt_html_data_foot);	
				re_intialize_data_tbl();
			}					
			else{
				swal("Failure!", "Some data are missing please login once after that try this operation", "warning");
			}
			unloading();
		}
	});	
	
}


function re_intialize_data_tbl(){
	$('#rslt_tbl').DataTable({
		initComplete: function () 
			{	
				unloading(); 
				
			},
		"lengthMenu": [[-1], ["All"]],
		"bFilter": false,
		"bPaginate": false,	
		"ordering": false,		        
		"scrollX":  true,
        "scrollCollapse":true,       
       // "columnDefs": [ { width: 250, targets: 14 } ],	
		"footerCallback": function (row, data, start, end, display) {
            var api = this.api(), data;
            var colNumber = [2,3,4];
            for (i = 0; i < colNumber.length; i++) {
                var colNo = colNumber[i];
                var total2 = api
                        .column(colNo,{ page: 'current'})
                        .data()
                        .reduce(function (a, b) {
                            return parseFloat(a) + parseFloat(b);
                        }, 0);
												
						//alert('Total:  ' + total2.toFixed(2));
						$(api.column(colNo).footer()).html("<b>"+total2.toFixed(2)+"</b>");
            }
        },
			
		dom: 'Bfrtip',
        buttons: [
			{
			extend: 'excel', 
			text: 'Export to Excel',
			footer: true,
			filename: function(){
					var d = new Date();
					var n = d.getTime();
					return 'accounting_report_'+n;
				}
			}
		]
	});
	

} 


function fn_pu_payment_pending(){	
	search_result();
}

</script>	

</body>
</html>
