<?php

// Created by Ibrohimjon Ahmadjonov Ilhomjon o'g'li on 08.02.2020
header('Content-type: text/html; charset=UTF-8');
require "connect.php";
 
$user_id = $_GET['id'];  

date_default_timezone_set('Tashkent');

$timestamp = time();
$date_time = date("Y-m-d", $timestamp);
 


$jami_zakaz = 0;
$jami_tolov = 0;

$sql = "SELECT SUM(soni * narxi) AS jami_zakaz FROM zakazlar WHERE user_id = '$user_id' AND time LIKE '$date_time%'";

mysqli_set_charset($conn,"utf8");
$result = mysqli_query($conn,"SET NAMES utf8");

$result = mysqli_query($conn, $sql); 


if ($result !== false && $result->num_rows > 0) {
	while($row=mysqli_fetch_array($result)){

		$jami_zakaz=$row['jami_zakaz']; 
	}
}
$sql2 = "SELECT SUM(summa) AS jami_tolov FROM tolovlar WHERE user_id = '$user_id' AND time LIKE '$date_time%'";

mysqli_set_charset($conn,"utf8");
$result2 = mysqli_query($conn,"SET NAMES utf8");

$result2 = mysqli_query($conn, $sql2); 


if ($result2 !== false && $result2->num_rows > 0) {
	while($row2=mysqli_fetch_array($result2)){

		$jami_tolov=$row2['jami_tolov']; 
	}
}

$timestamp = time();
$date_time = date("H:i:s d.m.Y", $timestamp);
echo ''.$jami_tolov.'^'.$jami_zakaz.'^'.$date_time.'~';
$conn->close();
?>