0){ $set_sta = mysqli_fetch_array($get_sta, MYSQLI_ASSOC); $state = $set_sta['state']; }else{ $state=''; } if($set_bill['cust_country']!=99){ $get_sta = mysqli_query($conn, "select * from shop_country where country_id='".$set_bill['cust_country']."'"); $check_sta_rows = mysqli_num_rows($get_sta); if($check_sta_rows > 0){ $set_sta = mysqli_fetch_array($get_sta, MYSQLI_ASSOC); $state = $set_sta['name']; }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, '.', ''); } $url=''.sprintf("%03d",$set_bill['bill_id']).''; $data[] = array('bill_id'=>$url, 'name'=>$set_bill['cust_name'],'state'=>$state, 'phone'=>$set_bill['cust_phone'], 'amount'=>$amount, 'order_date'=>date('d-m-Y', strtotime($set_bill['created_at'])), 'id'=>$set_bill['id']); } if(!empty($data)) { echo json_encode(array( "aaData"=>$data)); } else { echo json_encode(array('aaData'=>[])); } ?>