<?php  include_once('../../config/db.php');  //include_once('../config/check.php'); 






$query = "   SELECT a.*,b.transtype,b.memo bmemo,b.notes bnotes, b.date bdate ,b.memo,b.notes,
            c.name cname,d.code dcode,e.name ename    FROM  acctransactionsdetails a 
            LEFT JOIN  acctransactions b ON  a.transid=b.id 
            LEFT JOIN bppartner c ON a.partner=c.id 
            LEFT JOIN  acccurrency d ON a.currency=d.id
            LEFT JOIN coa e ON a.coa=e.id
            WHERE b.transtype=13   AND transmove=2    ";




$statement = $conn->prepare($query);

$statement->execute();

$number_filter_row = $statement->rowCount();

$statement = $conn->prepare($query );

$statement->execute();

$result = $statement->fetchAll();

$data = array();



foreach($result as $row)
{
  
    $actionButton = '<input type="radio" name="myradio" class="myradio" value="' . $row["id"] . '" /> </i></a>';

    $sub_array = array();
    $sub_array[] =  $actionButton  ;
    $sub_array[] = $row['bdate'];
    $sub_array[] = $row['cname'];
    $sub_array[] = $row['dcode'];
    $sub_array[] = $row['bmemo']; 
    $sub_array[] = $row['itemtotal'];
    $sub_array[] = $row['ename'];
     
    $data[] = $sub_array;

}

function count_all_data($conn,$query)
{
 $statement = $conn->prepare($query);
 $statement->execute();
 return $statement->rowCount();
}

$output = array(
                       "draw"       =>  $number_filter_row ,
                        "recordsTotal"   =>  count_all_data($conn,$query),
                        "recordsFiltered"  =>  $number_filter_row,
                        "data"       =>  $data
);

echo json_encode($output);

?>
