| Current Path : /home2/wtmwscom/public_html/admin/report/ |
| Current File : /home2/wtmwscom/public_html/admin/report/payout_json.php |
<?php
session_start();
include "../../connection.php";
include '../../function_lib.php';
$data = array();
$query_select = " SUM(t1.amount) as wallet, t1.uid as uid, t2.recid as recid, t2.login_id as login_id, t2.name as name, t2.email as email, t2.mobile as mobile, t2.account_holder_name as account_holder_name, t2.bank_name as bank_name, t2.branch_name as branch_name, t2.account_number as account_number, t2.ifsc as ifsc, t2.status AS status, t2.hold_payment AS hold_payment, "
. " CONCAT(t2.name,' (',t2.login_id,')') AS user_name";
$query = " FROM `income` t1 INNER JOIN user t2 on t1.uid =t2.uid WHERE t1.status=1 AND t1.payment_status=0 AND t2.is_paid=1";
//$query .=!empty($_REQUEST['income_type']) ? " AND i.income_type='" . $_REQUEST['income_type'] . "'" : '';
$query .=!empty($_REQUEST['from_date']) && !empty($_REQUEST['to_date']) ? " AND (t1.datetime BETWEEN '" . $_REQUEST['from_date'] . "' AND '" . $_REQUEST['to_date'] . "') " : '';
$query .= !empty($_REQUEST['hold_payment']) ? " AND t2.hold_payment='" . $_REQUEST['hold_payment'] . "'" : '';
$query .= !empty($_REQUEST['status']) ? " AND t2.status='" . $_REQUEST['status'] . "'" : '';
$query .=!empty($_REQUEST['login_id']) ? " AND t2.login_id='" . $_REQUEST['login_id'] . "'" : '';
//$query .= " ";
//echo "SELECT COUNT(t1.uid) as count " . $query;
//$result_total = mysqli_query($connection, "SELECT COUNT(t1.uid) as count " . $query);
//$totalRecordCount = $result_total ? mysqli_fetch_object($result_total)->count :0;
$totalRecordCount = mysqli_fetch_object(mysqli_query($connection, "SELECT COUNT(t1.uid) as count " . $query))->count;
$query .= " GROUP BY (t1.uid) ORDER BY t2.name ";
$query .= $_REQUEST['length'] == -1 ? '' : " LIMIT " . $_REQUEST['start'] . ", " . $_REQUEST['length'];
$query_final = "SELECT " . $query_select . $query;
//echo $query_final;
$result = mysqli_query($connection, $query_final);
$sno = $_REQUEST['start'] + 1;
while ($row = mysqli_fetch_assoc($result)) {
$row['sno'] = $sno;
$wallet = $row['wallet'];
$tds = 0;
$service = 0;
$tdstotal = 0;
$servicetotal = 0;
$tds = ($wallet * $master_tds_rate) / 100;
$service = ($wallet * $master_service_rate) / 100;
//$service =0;
$net_amount = $wallet - ($tds + $service);
// $tdstotal += $tds;
// $servicetotal += $service;
// $total += $wallet;
// $net_total += $net_amount;
$row['tds'] = $tds;
$row['service'] = $service;
$row['net_amount'] = $net_amount;
// $row['income_type'] = $master_income_type_array[$row['income_type']];
// $row['datetime'] = date("d/m/Y", strtotime($row['datetime']));
// $row['payment_status'] = $row['payment_status'] == 1 ? "Paid" : "Unpaid";
// $row['payment_date'] = !empty($row['payment_date']) ? date("d/m/Y h:i A", strtotime($row['payment_date'])) : '';
// $row['status'] = $row['status'] == 1 ? "Closed" : "Unclosed";
// $row['closing_date'] = !empty($row['closing_date']) ? date("d/m/Y h:i A", strtotime($row['closing_date'])) : '';
$data[] = $row;
$sno++;
}
$json_array = array('data' => $data, 'recordsFiltered' => $totalRecordCount, 'recordsTotal' => $totalRecordCount);
echo json_encode($json_array);
?>