<?php
include("../db.php");
$s = $_POST['s'];
$e = $_POST['e'];
$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'];

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

$data['all'] = (($data['sales'] + $data['inp'] + $data['service'] + $data['paid']) - $data['exp']);

echo json_encode($data);
?>