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






$query = " SELECT a.*,b.transtype,b.transmode,c.name,c.code,c.description,d.name dname,e.name ename 
            FROM acctransactionsdetails a
            LEFT JOIN acctransactions b ON a.transid=b.id
            LEFT JOIN item c ON a.item=c.id
            LEFT JOIN admbranch d ON a.branch= d.id 
            LEFT JOIN admbranch e ON a.warehouse= e.id
            WHERE b.transtype=1 and b.transmode=1 OR b.transmode=2
 ";




$statement = $conn->prepare($query);
$statement->execute();
$number_filter_row = $statement->rowCount();

$result = $statement->fetchAll();

$data = array();



foreach($result as $row)
{
  

    $actionButton = '<input type="radio" name="myradio" class="myradio" value="' . $row["id"] . '" /> </i></a>';
    //$edit = ' <form method="post" action="invcategorye" >  <button type="submit" style="background:none;border:none;padding:0px; outline:none; " name="edit" value="' . $row["id"] . '"   "> <i class="fa fa-edit"></i>  </button></form> ' ; 
    $edit = ' <form method="post" action="#" >  <button type="submit" style="background:none;border:none;padding:0px; outline:none; " name="edit" value="' . $row["id"] . '"   "> <i class="fa fa-edit"></i>  </button></form> ' ; 
    
    
     $sub_array = array();
     $sub_array[] =  $actionButton  ;
     $sub_array[] =  $edit  ;
     $sub_array[] = $row['dname'];
     $sub_array[] = $row['ename'];
     $sub_array[] = $row['name'];
     $sub_array[] = $row['code'];
     $sub_array[] = $row['itemunittotal'];
     
     $sub_array[] = $row['description'];
     $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);

?>

