<?php
if(isset($_POST['type'])){
      require_once('../../assets/config/config.php');
      $obj=new Database();
      $id1=date("d-M-Y",strtotime($_POST['date1']));
      $id2=date("d-M-Y",strtotime($_POST['date2']));
      $id='';
      if($_POST['type']=='Credit')
      {
         $id="debit='' and date BETWEEN '".$id1."' AND '".$id2."'";
      }
      elseif($_POST['type']=='Debit'){
      
            $id="credit='' and date BETWEEN '".$id1."' AND '".$id2."'";
      }
      elseif($_POST['type']=='')
      {
         $id="date BETWEEN '".$id1."' AND '".$id2."'";
      
      }

         $obj->select('txn_details','*',null,$id,'id DESC',null);
         $result=$obj->getResult();
         $b=[];                                
                  foreach($result as $row)
                  {
                     array_push($b,$row);                
                  }
         header('Content-type:application/json');
         echo json_encode($b);
}
?>