Your IP : 216.73.216.26


Current Path : /home2/wtmwscom/public_html/admin/report/
Upload File :
Current File : /home2/wtmwscom/public_html/admin/report/bank_report_JSON.php

<?php
session_start();
include "../../connection.php";
include '../../function_lib.php';
if (!isset($_SESSION['adminid']))
    die('Unauthorized');

$debit_ac_number = '188405000371';
$data = array();
$date =  date('d-M-Y');

$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 ";
$query = " FROM `income` t1 INNER JOIN user t2 on t1.uid =t2.uid WHERE t1.status=1 AND t1.payment_status=0 AND TRIM(t2.account_holder_name)!='' AND TRIM(t2.account_number)!='' AND TRIM(t2.ifsc)!='' ";
$query .=!empty($_GET['login_id']) ? " AND t2.login_id='" . $_GET['login_id'] . "'" : '';
if (!empty($_GET['downline_login_id'])) {
    $downline_uid = mysqli_fetch_object(mysqli_query($connection, "SELECT uid FROM user WHERE login_id = '" . $_GET['downline_login_id'] . "'"))->uid;
    $child_id_array = get_child_levels(get_child_ids($downline_uid));
    $query .= " AND t1.uid IN ( " . implode(", ", $child_id_array) . " ) ";
}
$query .=!empty($_REQUEST['from_date']) && !empty($_REQUEST['to_date']) ? " AND (t2.reg_date BETWEEN '" . $_REQUEST['from_date'] . "' AND '" . $_REQUEST['to_date'] . "') " : '';

//$query .=!empty($_GET['from_date']) && !empty($_GET['to_date']) ? " AND (date(t1.datetime) BETWEEN '" . $_GET['from_date'] . "' AND '" . $_GET['to_date'] . "')" : '';
$query .=!empty($_GET['income_type']) ? " AND t1.income_type='" . $_GET['income_type'] . "'" : '';
$query .= isset($_GET['hold_payment']) && $_GET['hold_payment'] != '' ? " AND t2.hold_payment='" . $_GET['hold_payment'] . "'" : '';
$query .= isset($_GET['status']) && $_GET['status'] != '' ? " AND t2.status='" . $_GET['status'] . "'" : '';
$query .= " GROUP BY (t1.uid) ORDER BY t2.name";

$totalRecordCount = mysqli_num_rows(mysqli_query($connection, "SELECT ".$query_select.$query));
$query_limit = $_GET['length'] == -1 ? '': " LIMIT ".$_GET['start'].", ".$_GET['length'];
$query_final = "SELECT ".$query_select.$query.$query_limit;
//echo $query_final;
$result = mysqli_query($connection, $query_final);
$total = 0;
$net_total = 0;
while ($row = mysqli_fetch_object($result)) {
    $wallet = $row->wallet;
    if($wallet >= 100) {
    //$tds = 0;
     $tds = ($wallet * $master_tds_rate)/100;
     $service = ($wallet * $master_service_rate)/100;
    //$service =0;
    $net_amount = $wallet - ($tds + $service);
    $total += $wallet;
    $net_total += $net_amount;

    if(substr($row->ifsc, 0, 4 )=="ICIC"){
       $pay_mod = "I"; 
       $ifsc = "";
    } else{
       $pay_mod = "N";
       $ifsc = strtoupper($row->ifsc);
    }
    $row_array = array(
        'debit_ac_number' => $debit_ac_number,
        'beneficiary_ac_no' => "$row->account_number",
        'beneficiary_name' => strtoupper($row->account_holder_name),
        'amt' => $net_amount,
        'pay_mod' => $pay_mod,
        'date' => $date,
        'ifsc' => $ifsc,
        'mobile'=>$row->mobile,
        'email'=>$row->email,
        'remarks'=>"global",
        'uid'=>$row->uid,
        'login_id'=>$row->login_id,
    );
    $data[] = $row_array;
    }
}

$json_array = array('data' => $data,'total'=>$total,'net_total'=>$net_total, 'recordsFiltered'=>$totalRecordCount, 'recordsTotal'=>$totalRecordCount);
echo json_encode($json_array);
?>