<?php
require_once 'config.php';
$sql="select count(*) as count from invoice_details where credit_date!='0000-00-00' and credit_date<=DATE_ADD(now() , INTERVAL 5 DAY) and status='pending'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}
if($result=mysqli_fetch_array($query)){
    $count=$result['count'];
}

$sql="select count(*) as count from vendor_invoice_details where credit_date!='0000-00-00' and  credit_date<=DATE_ADD(now() , INTERVAL 5 DAY) and status='pending'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}
if($result=mysqli_fetch_array($query)){
    $count1=$result['count'];
}
$sql="select count(*) as count from pdc_details where bar_date!='0000-00-00' and bar_date<=DATE_ADD(now() , INTERVAL 5 DAY) and status='pending'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}
if($result=mysqli_fetch_array($query)){
    $count2=$result['count'];
}


$sql="select count(*) as count from production_details where due_date!='0000-00-00' and due_date<=DATE_ADD(now() , INTERVAL 5 DAY) and status='pending'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}
if($result=mysqli_fetch_array($query)){
    $count3=$result['count'];
}
echo json_encode(array(
        "count"=>$count,
      "count1"=>$count1,
          "count2"=>$count2,
     "count3"=>$count3
        ));
?>