0){ $set_sta = mysqli_fetch_array($get_sta, MYSQLI_ASSOC); $state = $set_sta['state']; }else{ $state=''; } $get_amou = mysqli_query($conn, "select sum(price * qty) as amount from tbl_dealer_sales where bill_id = '".$set_bill['bill_id']."' and dealer_id = '".$_SESSION['dealer_id']."'"); $set_amou = mysqli_fetch_array($get_amou, MYSQLI_ASSOC); if($set_bill['cust_discount']!=0){ $disc_price = ($set_amou['amount'] * $set_bill['cust_discount']) / 100; $flat_amount = $set_amou['amount'] - $disc_price; $amount = number_format((float)$flat_amount, 2, '.', ''); }else{ $amount = number_format((float)$set_amou['amount'], 2, '.', ''); } $data[] = array('bill_id'=>''.sprintf("%04d",$set_bill['bill_id']).'', 'name'=>$set_bill['cust_name'],'state'=>$state, 'phone'=>$set_bill['cust_phone'], 'amount'=>$amount, 'order_date'=>date('d-m-Y H:i:s', strtotime($set_bill['created_at'])), 'id'=>$set_bill['id']); } if(!empty($data)) { echo json_encode(array( "aaData"=>$data)); } else { echo json_encode(array('aaData'=>[])); } ?>