include_once('/data/php/includes.php');
$cash = R::getAssoc('SELECT * FROM cash');
$terminal = R::getAssoc('SELECT * FROM terminal');
$online = R::getAssoc('SELECT * FROM online');
for ($i=30; $i>0; $i--) {
$date = date("Y-m-d", mktime(0, 0, 0, date('m'), date('d') - $i, date('Y')));
foreach ($cash as $cas) {
if ( $date == $cas['date'] ) {
$sum1 = $cas['money'];
$j = 1;
};
};
foreach ($terminal as $term) {
if ( $date == $term['date'] ) {
$sum2 = $term['money'];
$j = 1;
};
};
foreach ($online as $onli) {
if ( $date == $onli['date'] ) {
$sum3 = $onli['money'];
$j = 1;
};
};
$sum = $sum1 + $sum2 + $sum3;
if ( $j == 1 ) {
echo $sum. ", ";
$j = 0;
} else {
echo "0,";
};
$sum1 = 0;
$sum2 = 0;
$sum3 = 0;
};