<?php
include("../db.php");
$s = $_POST['s'];
$e = $_POST['e'];
$query = mysqli_query($db,"select * from `cus` where `date_cus` between '$s' and '$e'");
$data['num_cus_new'] = mysqli_num_rows($query);

$query = mysqli_query($db,"select * from `return_cus` where `date` between '$s' and '$e'");
$data['num_cus_old'] = mysqli_num_rows($query);

$query = mysqli_query($db,"select sum(paid) as `t` from `stock_mony` where `date` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['total_paid'] = $row['t'];

$query = mysqli_query($db,"select sum(mony_cus) as `t` from `cus` where `date_cus` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['total_stay'] = $row['t'];

$query = mysqli_query($db,"select COUNT(DISTINCT(id_cus)) as `t` from `table_day` where `date_table` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['total_active'] = $row['t'];

$query = mysqli_query($db,"select sum(paid) as `t` from `stock_mony` where `date` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['paid'] = $row['t'];

$query = mysqli_query($db,"select sum(x) as `t` from `mony` where `date` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['service'] = $row['t'];

$query = mysqli_query($db,"select sum(value_inp) as `t` from `inp_mony` where `date_inp` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['inp'] = $row['t'];

$query = mysqli_query($db,"select sum(value_exp) as `t` from `exp_mony` where `date_exp` between '$s' and '$e'");
$row = mysqli_fetch_assoc($query);
$data['exp'] = $row['t'];


echo json_encode($data);
?>